mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-24 13:11:33 +00:00
- removed most of the specific options for legacy hardware and consolidated them in one variable (does not work yet.)
This commit is contained in:
parent
4a0e082836
commit
3389a5a74e
27 changed files with 182 additions and 360 deletions
|
@ -66,7 +66,7 @@
|
|||
|
||||
void gl_PatchMenu()
|
||||
{
|
||||
if (gl.glslversion == 0)
|
||||
if (gl.legacyMode)
|
||||
{
|
||||
// Radial fog and Doom lighting are not available without full shader support.
|
||||
|
||||
|
@ -99,6 +99,8 @@ void gl_PatchMenu()
|
|||
// disable features that don't work without shaders.
|
||||
if (gl_lightmode == 2 || gl_lightmode == 8) gl_lightmode = 3;
|
||||
if (gl_fogmode == 2) gl_fogmode = 1;
|
||||
|
||||
// todo: remove more unsupported stuff like postprocessing options.
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -378,7 +380,7 @@ void FRenderState::DrawColormapOverlay()
|
|||
//==========================================================================
|
||||
|
||||
bool gl_SetupLight(int group, Plane & p, ADynamicLight * light, Vector & nearPt, Vector & up, Vector & right,
|
||||
float & scale, int desaturation, bool checkside, bool additive)
|
||||
float & scale, bool checkside, bool additive)
|
||||
{
|
||||
Vector fn, pos;
|
||||
|
||||
|
@ -434,14 +436,6 @@ bool gl_SetupLight(int group, Plane & p, ADynamicLight * light, Vector & nearPt,
|
|||
{
|
||||
gl_RenderState.BlendEquation(GL_FUNC_ADD);
|
||||
}
|
||||
if (desaturation > 0 && gl.glslversion > 0) // no-shader excluded because no desaturated textures.
|
||||
{
|
||||
float gray = (r * 77 + g * 143 + b * 37) / 257;
|
||||
|
||||
r = (r*(32 - desaturation) + gray*desaturation) / 32;
|
||||
g = (g*(32 - desaturation) + gray*desaturation) / 32;
|
||||
b = (b*(32 - desaturation) + gray*desaturation) / 32;
|
||||
}
|
||||
gl_RenderState.SetColor(r, g, b);
|
||||
return true;
|
||||
}
|
||||
|
@ -491,11 +485,6 @@ bool GLWall::PutWallCompat(int passflag)
|
|||
bool masked = passflag == 2 && gltexture->isMasked();
|
||||
|
||||
int list = list_indices[masked][foggy];
|
||||
if (list == GLLDL_WALLS_PLAIN)
|
||||
{
|
||||
if (gltexture->tex->gl_info.Brightmap && gl.glslversion >= 0.f) list = GLLDL_WALLS_BRIGHT;
|
||||
//if (flags & GLWF_GLOW) list = GLLDL_WALLS_BRIGHT;
|
||||
}
|
||||
gl_drawinfo->dldrawlists[list].AddWall(this);
|
||||
return true;
|
||||
|
||||
|
@ -520,10 +509,6 @@ bool GLFlat::PutFlatCompat(bool fog)
|
|||
|
||||
|
||||
int list = list_indices[masked][foggy];
|
||||
if (list == GLLDL_FLATS_PLAIN)
|
||||
{
|
||||
if (gltexture->tex->gl_info.Brightmap && gl.glslversion >= 0.f) list = GLLDL_FLATS_BRIGHT;
|
||||
}
|
||||
gl_drawinfo->dldrawlists[list].AddFlat(this);
|
||||
return true;
|
||||
}
|
||||
|
@ -612,7 +597,7 @@ void GLFlat::DrawSubsectorLights(subsector_t * sub, int pass)
|
|||
}
|
||||
|
||||
p.Set(plane.plane);
|
||||
if (!gl_SetupLight(sub->sector->PortalGroup, p, light, nearPt, up, right, scale, CM_DEFAULT, false, pass != GLPASS_LIGHTTEX))
|
||||
if (!gl_SetupLight(sub->sector->PortalGroup, p, light, nearPt, up, right, scale, false, pass != GLPASS_LIGHTTEX))
|
||||
{
|
||||
node = node->nextLight;
|
||||
continue;
|
||||
|
@ -692,7 +677,7 @@ bool GLWall::PrepareLight(ADynamicLight * light, int pass)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!gl_SetupLight(seg->frontsector->PortalGroup, p, light, nearPt, up, right, scale, CM_DEFAULT, true, pass != GLPASS_LIGHTTEX))
|
||||
if (!gl_SetupLight(seg->frontsector->PortalGroup, p, light, nearPt, up, right, scale, true, pass != GLPASS_LIGHTTEX))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -798,9 +783,7 @@ void FGLRenderer::RenderMultipassStuff()
|
|||
gl_RenderState.SetTextureMode(TM_MASK);
|
||||
gl_RenderState.EnableBrightmap(true);
|
||||
gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_threshold);
|
||||
gl_drawinfo->dldrawlists[GLLDL_WALLS_BRIGHT].DrawWalls(GLPASS_PLAIN);
|
||||
gl_drawinfo->dldrawlists[GLLDL_WALLS_MASKED].DrawWalls(GLPASS_PLAIN);
|
||||
gl_drawinfo->dldrawlists[GLLDL_FLATS_BRIGHT].DrawFlats(GLPASS_PLAIN);
|
||||
gl_drawinfo->dldrawlists[GLLDL_FLATS_MASKED].DrawFlats(GLPASS_PLAIN);
|
||||
|
||||
// Part 3: The base of fogged surfaces, including the texture
|
||||
|
@ -823,10 +806,8 @@ void FGLRenderer::RenderMultipassStuff()
|
|||
glDepthFunc(GL_EQUAL);
|
||||
if (glset.lightmode == 8) gl_RenderState.SetSoftLightLevel(255);
|
||||
gl_drawinfo->dldrawlists[GLLDL_WALLS_PLAIN].DrawWalls(GLPASS_LIGHTTEX);
|
||||
gl_drawinfo->dldrawlists[GLLDL_WALLS_BRIGHT].DrawWalls(GLPASS_LIGHTTEX);
|
||||
gl_drawinfo->dldrawlists[GLLDL_WALLS_MASKED].DrawWalls(GLPASS_LIGHTTEX);
|
||||
gl_drawinfo->dldrawlists[GLLDL_FLATS_PLAIN].DrawFlats(GLPASS_LIGHTTEX);
|
||||
gl_drawinfo->dldrawlists[GLLDL_FLATS_BRIGHT].DrawFlats(GLPASS_LIGHTTEX);
|
||||
gl_drawinfo->dldrawlists[GLLDL_FLATS_MASKED].DrawFlats(GLPASS_LIGHTTEX);
|
||||
gl_RenderState.BlendEquation(GL_FUNC_ADD);
|
||||
}
|
||||
|
@ -841,8 +822,6 @@ void FGLRenderer::RenderMultipassStuff()
|
|||
glDepthFunc(GL_LEQUAL);
|
||||
gl_drawinfo->dldrawlists[GLLDL_WALLS_PLAIN].DrawWalls(GLPASS_TEXONLY);
|
||||
gl_drawinfo->dldrawlists[GLLDL_FLATS_PLAIN].DrawFlats(GLPASS_TEXONLY);
|
||||
gl_drawinfo->dldrawlists[GLLDL_WALLS_BRIGHT].DrawWalls(GLPASS_TEXONLY);
|
||||
gl_drawinfo->dldrawlists[GLLDL_FLATS_BRIGHT].DrawFlats(GLPASS_TEXONLY);
|
||||
gl_RenderState.AlphaFunc(GL_GREATER, gl_mask_threshold);
|
||||
gl_drawinfo->dldrawlists[GLLDL_WALLS_MASKED].DrawWalls(GLPASS_TEXONLY);
|
||||
gl_drawinfo->dldrawlists[GLLDL_FLATS_MASKED].DrawFlats(GLPASS_TEXONLY);
|
||||
|
@ -854,10 +833,8 @@ void FGLRenderer::RenderMultipassStuff()
|
|||
if (gl_SetupLightTexture())
|
||||
{
|
||||
gl_drawinfo->dldrawlists[GLLDL_WALLS_PLAIN].DrawWalls(GLPASS_LIGHTTEX_ADDITIVE);
|
||||
gl_drawinfo->dldrawlists[GLLDL_WALLS_BRIGHT].DrawWalls(GLPASS_LIGHTTEX_ADDITIVE);
|
||||
gl_drawinfo->dldrawlists[GLLDL_WALLS_MASKED].DrawWalls(GLPASS_LIGHTTEX_ADDITIVE);
|
||||
gl_drawinfo->dldrawlists[GLLDL_FLATS_PLAIN].DrawFlats(GLPASS_LIGHTTEX_ADDITIVE);
|
||||
gl_drawinfo->dldrawlists[GLLDL_FLATS_BRIGHT].DrawFlats(GLPASS_LIGHTTEX_ADDITIVE);
|
||||
gl_drawinfo->dldrawlists[GLLDL_FLATS_MASKED].DrawFlats(GLPASS_LIGHTTEX_ADDITIVE);
|
||||
gl_drawinfo->dldrawlists[GLLDL_WALLS_FOG].DrawWalls(GLPASS_LIGHTTEX_FOGGY);
|
||||
gl_drawinfo->dldrawlists[GLLDL_WALLS_FOGMASKED].DrawWalls(GLPASS_LIGHTTEX_FOGGY);
|
||||
|
|
|
@ -75,7 +75,7 @@ FVertexBuffer::~FVertexBuffer()
|
|||
void FSimpleVertexBuffer::BindVBO()
|
||||
{
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vbo_id);
|
||||
if (gl.glslversion > 0)
|
||||
if (!gl.legacyMode)
|
||||
{
|
||||
glVertexAttribPointer(VATTR_VERTEX, 3, GL_FLOAT, false, sizeof(FSimpleVertex), &VSiO->x);
|
||||
glVertexAttribPointer(VATTR_TEXCOORD, 2, GL_FLOAT, false, sizeof(FSimpleVertex), &VSiO->u);
|
||||
|
@ -100,7 +100,7 @@ void FSimpleVertexBuffer::EnableColorArray(bool on)
|
|||
{
|
||||
if (on)
|
||||
{
|
||||
if (gl.glslversion > 0)
|
||||
if (!gl.legacyMode)
|
||||
{
|
||||
glEnableVertexAttribArray(VATTR_COLOR);
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ void FSimpleVertexBuffer::EnableColorArray(bool on)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (gl.glslversion > 0)
|
||||
if (!gl.legacyMode)
|
||||
{
|
||||
glDisableVertexAttribArray(VATTR_COLOR);
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ void FSimpleVertexBuffer::set(FSimpleVertex *verts, int count)
|
|||
//==========================================================================
|
||||
|
||||
FFlatVertexBuffer::FFlatVertexBuffer(int width, int height)
|
||||
: FVertexBuffer(gl.buffermethod != BM_CLIENTARRAY)
|
||||
: FVertexBuffer(!gl.legacyMode)
|
||||
{
|
||||
switch (gl.buffermethod)
|
||||
{
|
||||
|
@ -162,7 +162,7 @@ FFlatVertexBuffer::FFlatVertexBuffer(int width, int height)
|
|||
break;
|
||||
}
|
||||
|
||||
case BM_CLIENTARRAY:
|
||||
default:
|
||||
{
|
||||
map = new FFlatVertex[BUFFER_SIZE];
|
||||
DPrintf(DMSG_NOTIFY, "Using client array buffer\n");
|
||||
|
@ -219,7 +219,7 @@ FFlatVertexBuffer::~FFlatVertexBuffer()
|
|||
glUnmapBuffer(GL_ARRAY_BUFFER);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
}
|
||||
if (gl.buffermethod == BM_CLIENTARRAY)
|
||||
if (gl.legacyMode)
|
||||
{
|
||||
delete[] map;
|
||||
}
|
||||
|
@ -230,19 +230,10 @@ FFlatVertexBuffer::~FFlatVertexBuffer()
|
|||
void FFlatVertexBuffer::BindVBO()
|
||||
{
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vbo_id);
|
||||
if (gl.glslversion > 0)
|
||||
if (!gl.legacyMode)
|
||||
{
|
||||
if (gl.buffermethod != BM_CLIENTARRAY)
|
||||
{
|
||||
glVertexAttribPointer(VATTR_VERTEX, 3, GL_FLOAT, false, sizeof(FFlatVertex), &VTO->x);
|
||||
glVertexAttribPointer(VATTR_TEXCOORD, 2, GL_FLOAT, false, sizeof(FFlatVertex), &VTO->u);
|
||||
}
|
||||
else
|
||||
{
|
||||
// If we cannot use a hardware buffer, use an old-style client array.
|
||||
glVertexAttribPointer(VATTR_VERTEX, 3, GL_FLOAT, false, sizeof(FFlatVertex), &map->x);
|
||||
glVertexAttribPointer(VATTR_TEXCOORD, 2, GL_FLOAT, false, sizeof(FFlatVertex), &map->u);
|
||||
}
|
||||
glVertexAttribPointer(VATTR_VERTEX, 3, GL_FLOAT, false, sizeof(FFlatVertex), &VTO->x);
|
||||
glVertexAttribPointer(VATTR_TEXCOORD, 2, GL_FLOAT, false, sizeof(FFlatVertex), &VTO->u);
|
||||
glEnableVertexAttribArray(VATTR_VERTEX);
|
||||
glEnableVertexAttribArray(VATTR_TEXCOORD);
|
||||
glDisableVertexAttribArray(VATTR_COLOR);
|
||||
|
|
|
@ -105,7 +105,7 @@ void gl_FlushModels()
|
|||
//===========================================================================
|
||||
|
||||
FModelVertexBuffer::FModelVertexBuffer(bool needindex, bool singleframe)
|
||||
: FVertexBuffer(singleframe || gl.glslversion > 0)
|
||||
: FVertexBuffer(singleframe || !gl.legacyMode)
|
||||
{
|
||||
vbo_ptr = nullptr;
|
||||
ibo_id = 0;
|
||||
|
@ -125,7 +125,7 @@ void FModelVertexBuffer::BindVBO()
|
|||
{
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo_id);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vbo_id);
|
||||
if (gl.glslversion > 0)
|
||||
if (!gl.legacyMode)
|
||||
{
|
||||
glEnableVertexAttribArray(VATTR_VERTEX);
|
||||
glEnableVertexAttribArray(VATTR_TEXCOORD);
|
||||
|
@ -170,7 +170,7 @@ FModelVertex *FModelVertexBuffer::LockVertexBuffer(unsigned int size)
|
|||
{
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vbo_id);
|
||||
glBufferData(GL_ARRAY_BUFFER, size * sizeof(FModelVertex), nullptr, GL_STATIC_DRAW);
|
||||
if (gl.version >= 3.0)
|
||||
if (!gl.legacyMode)
|
||||
return (FModelVertex*)glMapBufferRange(GL_ARRAY_BUFFER, 0, size * sizeof(FModelVertex), GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
|
||||
else
|
||||
return (FModelVertex*)glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
|
||||
|
@ -211,7 +211,7 @@ unsigned int *FModelVertexBuffer::LockIndexBuffer(unsigned int size)
|
|||
{
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo_id);
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, size * sizeof(unsigned int), NULL, GL_STATIC_DRAW);
|
||||
if (gl.version >= 3.0)
|
||||
if (!gl.legacyMode)
|
||||
return (unsigned int*)glMapBufferRange(GL_ELEMENT_ARRAY_BUFFER, 0, size * sizeof(unsigned int), GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
|
||||
else
|
||||
return (unsigned int*)glMapBuffer(GL_ELEMENT_ARRAY_BUFFER, GL_WRITE_ONLY);
|
||||
|
@ -251,7 +251,7 @@ unsigned int FModelVertexBuffer::SetupFrame(unsigned int frame1, unsigned int fr
|
|||
glBindBuffer(GL_ARRAY_BUFFER, vbo_id);
|
||||
if (vbo_id > 0)
|
||||
{
|
||||
if (gl.glslversion > 0)
|
||||
if (!gl.legacyMode)
|
||||
{
|
||||
glVertexAttribPointer(VATTR_VERTEX, 3, GL_FLOAT, false, sizeof(FModelVertex), &VMO[frame1].x);
|
||||
glVertexAttribPointer(VATTR_TEXCOORD, 2, GL_FLOAT, false, sizeof(FModelVertex), &VMO[frame1].u);
|
||||
|
|
|
@ -126,7 +126,7 @@ void FGLRenderer::RenderScreenQuad()
|
|||
void FGLRenderer::BloomScene()
|
||||
{
|
||||
// Only bloom things if enabled and no special fixed light mode is active
|
||||
if (!gl_bloom || !FGLRenderBuffers::IsEnabled() || gl_fixedcolormap != CM_DEFAULT)
|
||||
if (!gl_bloom || gl_fixedcolormap != CM_DEFAULT)
|
||||
return;
|
||||
|
||||
FGLDebug::PushGroup("BloomScene");
|
||||
|
@ -212,7 +212,7 @@ void FGLRenderer::BloomScene()
|
|||
|
||||
void FGLRenderer::TonemapScene()
|
||||
{
|
||||
if (gl_tonemap == 0 || !FGLRenderBuffers::IsEnabled())
|
||||
if (gl_tonemap == 0)
|
||||
return;
|
||||
|
||||
FGLDebug::PushGroup("TonemapScene");
|
||||
|
@ -292,7 +292,7 @@ void FGLRenderer::ClearTonemapPalette()
|
|||
|
||||
void FGLRenderer::LensDistortScene()
|
||||
{
|
||||
if (gl_lens == 0 || !FGLRenderBuffers::IsEnabled())
|
||||
if (gl_lens == 0)
|
||||
return;
|
||||
|
||||
FGLDebug::PushGroup("LensDistortScene");
|
||||
|
|
|
@ -218,17 +218,8 @@ void FGLRenderBuffers::CreateScene(int width, int height, int samples)
|
|||
if (samples > 1)
|
||||
mSceneMultisample = CreateRenderBuffer("SceneMultisample", GetHdrFormat(), samples, width, height);
|
||||
|
||||
if ((gl.flags & RFL_NO_DEPTHSTENCIL) != 0)
|
||||
{
|
||||
mSceneDepth = CreateRenderBuffer("SceneDepth", GL_DEPTH_COMPONENT24, samples, width, height);
|
||||
mSceneStencil = CreateRenderBuffer("SceneStencil", GL_STENCIL_INDEX8, samples, width, height);
|
||||
mSceneFB = CreateFrameBuffer("SceneFB", samples > 1 ? mSceneMultisample : mPipelineTexture[0], mSceneDepth, mSceneStencil, samples > 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
mSceneDepthStencil = CreateRenderBuffer("SceneDepthStencil", GL_DEPTH24_STENCIL8, samples, width, height);
|
||||
mSceneFB = CreateFrameBuffer("SceneFB", samples > 1 ? mSceneMultisample : mPipelineTexture[0], mSceneDepthStencil, samples > 1);
|
||||
}
|
||||
mSceneDepthStencil = CreateRenderBuffer("SceneDepthStencil", GL_DEPTH24_STENCIL8, samples, width, height);
|
||||
mSceneFB = CreateFrameBuffer("SceneFB", samples > 1 ? mSceneMultisample : mPipelineTexture[0], mSceneDepthStencil, samples > 1);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
@ -288,7 +279,7 @@ void FGLRenderBuffers::CreateBloom(int width, int height)
|
|||
|
||||
GLuint FGLRenderBuffers::GetHdrFormat()
|
||||
{
|
||||
return ((gl.flags & RFL_NO_RGBA16F) != 0) ? GL_RGBA8 : GL_RGBA16F;
|
||||
return GL_RGBA16F;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
@ -559,7 +550,7 @@ void FGLRenderBuffers::BindOutputFB()
|
|||
|
||||
bool FGLRenderBuffers::IsEnabled()
|
||||
{
|
||||
return gl_renderbuffers && gl.glslversion != 0 && !FailedCreate;
|
||||
return gl_renderbuffers && !gl.legacyMode && !FailedCreate;
|
||||
}
|
||||
|
||||
bool FGLRenderBuffers::FailedCreate = false;
|
||||
|
|
|
@ -129,8 +129,8 @@ void FGLRenderer::Initialize(int width, int height)
|
|||
mPresentShader = new FPresentShader();
|
||||
m2DDrawer = new F2DDrawer;
|
||||
|
||||
// Only needed for the core profile, because someone decided it was a good idea to remove the default VAO.
|
||||
if (gl.buffermethod != BM_CLIENTARRAY)
|
||||
// needed for the core profile, because someone decided it was a good idea to remove the default VAO.
|
||||
if (!gl.legacyMode)
|
||||
{
|
||||
glGenVertexArrays(1, &mVAOID);
|
||||
glBindVertexArray(mVAOID);
|
||||
|
@ -145,7 +145,7 @@ void FGLRenderer::Initialize(int width, int height)
|
|||
|
||||
mVBO = new FFlatVertexBuffer(width, height);
|
||||
mSkyVBO = new FSkyVertexBuffer;
|
||||
if (gl.lightmethod != LM_SOFTWARE) mLights = new FLightBuffer();
|
||||
if (!gl.legacyMode) mLights = new FLightBuffer();
|
||||
else mLights = NULL;
|
||||
gl_RenderState.SetVertexBuffer(mVBO);
|
||||
mFBID = 0;
|
||||
|
|
|
@ -314,7 +314,7 @@ void FRenderState::Apply()
|
|||
else mVertexBuffer->BindVBO();
|
||||
mCurrentVertexBuffer = mVertexBuffer;
|
||||
}
|
||||
if (gl.glslversion > 0)
|
||||
if (!gl.legacyMode)
|
||||
{
|
||||
ApplyShader();
|
||||
}
|
||||
|
@ -351,7 +351,7 @@ void FRenderState::ApplyMatrices()
|
|||
|
||||
void FRenderState::ApplyLightIndex(int index)
|
||||
{
|
||||
if (gl.lightmethod != LM_SOFTWARE)
|
||||
if (!gl.legacyMode)
|
||||
{
|
||||
if (index > -1 && GLRenderer->mLights->GetBufferType() == GL_UNIFORM_BUFFER)
|
||||
{
|
||||
|
|
|
@ -113,7 +113,7 @@ public:
|
|||
// Without shaders this translation must be applied to any texture.
|
||||
if (alphatexture)
|
||||
{
|
||||
if (mat->tex->UseBasePalette() || gl.glslversion == 0) translation = TRANSLATION(TRANSLATION_Standard, 8);
|
||||
if (mat->tex->UseBasePalette() || gl.legacyMode) translation = TRANSLATION(TRANSLATION_Standard, 8);
|
||||
}
|
||||
mEffectState = overrideshader >= 0? overrideshader : mat->mShaderIndex;
|
||||
mShaderTimer = mat->tex->gl_info.shaderspeed;
|
||||
|
|
|
@ -322,7 +322,7 @@ void GLDrawList::SortWallIntoPlane(SortNode * head,SortNode * sort)
|
|||
AddWall(&w);
|
||||
|
||||
// Splitting is done in the shader with clip planes, if available
|
||||
if (gl.glslversion < 1.3f)
|
||||
if (gl.flags & RFL_NO_CLIP_PLANES)
|
||||
{
|
||||
GLWall * ws1;
|
||||
ws->vertcount = 0; // invalidate current vertices.
|
||||
|
@ -382,7 +382,7 @@ void GLDrawList::SortSpriteIntoPlane(SortNode * head,SortNode * sort)
|
|||
AddSprite(&s); // add a copy to avoid reallocation issues.
|
||||
|
||||
// Splitting is done in the shader with clip planes, if available
|
||||
if (gl.glslversion < 1.3f)
|
||||
if (gl.flags & RFL_NO_CLIP_PLANES)
|
||||
{
|
||||
GLSprite * ss1;
|
||||
ss1=&sprites[sprites.Size()-1];
|
||||
|
@ -480,6 +480,11 @@ void GLDrawList::SortWallIntoWall(SortNode * head,SortNode * sort)
|
|||
ws1->ztop[0]=ws->ztop[1]=izt;
|
||||
ws1->zbottom[0]=ws->zbottom[1]=izb;
|
||||
ws1->tcs[GLWall::LOLFT].u = ws1->tcs[GLWall::UPLFT].u = ws->tcs[GLWall::LORGT].u = ws->tcs[GLWall::UPRGT].u = iu;
|
||||
if (gl.buffermethod == BM_DEFERRED)
|
||||
{
|
||||
ws->MakeVertices(false);
|
||||
ws1->MakeVertices(false);
|
||||
}
|
||||
|
||||
SortNode * sort2=SortNodes.GetNew();
|
||||
memset(sort2,0,sizeof(SortNode));
|
||||
|
@ -806,17 +811,19 @@ void GLDrawList::DrawSorted()
|
|||
|
||||
if (!sorted)
|
||||
{
|
||||
GLRenderer->mVBO->Map();
|
||||
MakeSortList();
|
||||
sorted=DoSort(SortNodes[SortNodeStart]);
|
||||
GLRenderer->mVBO->Unmap();
|
||||
}
|
||||
gl_RenderState.ClearClipSplit();
|
||||
if (gl.glslversion >= 1.3f)
|
||||
if (!(gl.flags & RFL_NO_CLIP_PLANES))
|
||||
{
|
||||
glEnable(GL_CLIP_DISTANCE1);
|
||||
glEnable(GL_CLIP_DISTANCE2);
|
||||
}
|
||||
DoDrawSorted(sorted);
|
||||
if (gl.glslversion >= 1.3f)
|
||||
if (!(gl.flags & RFL_NO_CLIP_PLANES))
|
||||
{
|
||||
glDisable(GL_CLIP_DISTANCE1);
|
||||
glDisable(GL_CLIP_DISTANCE2);
|
||||
|
@ -995,7 +1002,7 @@ static FDrawInfoList di_list;
|
|||
FDrawInfo::FDrawInfo()
|
||||
{
|
||||
next = NULL;
|
||||
if (gl.lightmethod == LM_SOFTWARE)
|
||||
if (gl.legacyMode)
|
||||
{
|
||||
dldrawlists = new GLDrawList[GLLDL_TYPES];
|
||||
}
|
||||
|
|
|
@ -30,11 +30,9 @@ enum DLDrawListType
|
|||
{
|
||||
// These are organized so that the various multipass rendering modes have to be set as few times as possible
|
||||
GLLDL_WALLS_PLAIN, // dynamic lights on normal walls
|
||||
GLLDL_WALLS_BRIGHT, // dynamic lights on brightmapped walls
|
||||
GLLDL_WALLS_MASKED, // dynamic lights on masked midtextures
|
||||
|
||||
GLLDL_FLATS_PLAIN, // dynamic lights on normal flats
|
||||
GLLDL_FLATS_BRIGHT, // dynamic lights on brightmapped flats
|
||||
GLLDL_FLATS_MASKED, // dynamic lights on masked flats
|
||||
|
||||
GLLDL_WALLS_FOG, // lights on fogged walls
|
||||
|
|
|
@ -430,7 +430,7 @@ void GLFlat::Draw(int pass, bool trans) // trans only has meaning for GLPASS_LIG
|
|||
{
|
||||
gl_RenderState.SetMaterial(gltexture, CLAMP_NONE, 0, -1, false);
|
||||
gl_SetPlaneTextureRotation(&plane, gltexture);
|
||||
DrawSubsectors(pass, gl.lightmethod != LM_SOFTWARE, true);
|
||||
DrawSubsectors(pass, !gl.legacyMode, true);
|
||||
gl_RenderState.EnableTextureMatrix(false);
|
||||
}
|
||||
if (renderstyle==STYLE_Add) gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
@ -468,7 +468,7 @@ inline void GLFlat::PutFlat(bool fog)
|
|||
{
|
||||
Colormap.Clear();
|
||||
}
|
||||
if (gl.lightmethod == LM_SOFTWARE)
|
||||
if (gl.legacyMode)
|
||||
{
|
||||
if (PutFlatCompat(fog)) return;
|
||||
}
|
||||
|
|
|
@ -409,7 +409,7 @@ void FGLRenderer::RenderScene(int recursion)
|
|||
|
||||
// this is the only geometry type on which decals can possibly appear
|
||||
gl_drawinfo->drawlists[GLDL_PLAINWALLS].DrawDecals();
|
||||
if (gl.lightmethod == LM_SOFTWARE)
|
||||
if (gl.legacyMode)
|
||||
{
|
||||
// also process the render lists with walls and dynamic lights
|
||||
gl_drawinfo->dldrawlists[GLLDL_WALLS_PLAIN].DrawDecals();
|
||||
|
@ -681,7 +681,7 @@ void FGLRenderer::EndDrawScene(sector_t * viewsector)
|
|||
gl_RenderState.SetSoftLightLevel(-1);
|
||||
DrawTargeterSprites();
|
||||
DrawBlend(viewsector);
|
||||
if (gl.glslversion == 0.0)
|
||||
if (gl.legacyMode)
|
||||
{
|
||||
gl_RenderState.SetFixedColormap(cm);
|
||||
gl_RenderState.DrawColormapOverlay();
|
||||
|
@ -846,9 +846,9 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo
|
|||
|
||||
ProcessScene(toscreen);
|
||||
if (mainview && toscreen) EndDrawScene(retval); // do not call this for camera textures.
|
||||
if (mainview)
|
||||
if (mainview && FGLRenderBuffers::IsEnabled())
|
||||
{
|
||||
if (FGLRenderBuffers::IsEnabled()) mBuffers->BlitSceneToTexture();
|
||||
mBuffers->BlitSceneToTexture();
|
||||
BloomScene();
|
||||
TonemapScene();
|
||||
LensDistortScene();
|
||||
|
@ -896,7 +896,7 @@ void FGLRenderer::RenderView (player_t* player)
|
|||
|
||||
P_FindParticleSubsectors ();
|
||||
|
||||
if (gl.lightmethod != LM_SOFTWARE) GLRenderer->mLights->Clear();
|
||||
if (!gl.legacyMode) GLRenderer->mLights->Clear();
|
||||
|
||||
// NoInterpolateView should have no bearing on camera textures, but needs to be preserved for the main view below.
|
||||
bool saved_niv = NoInterpolateView;
|
||||
|
@ -951,7 +951,7 @@ void FGLRenderer::WriteSavePic (player_t *player, FILE *file, int width, int hei
|
|||
SetFixedColormap(player);
|
||||
gl_RenderState.SetVertexBuffer(mVBO);
|
||||
GLRenderer->mVBO->Reset();
|
||||
if (gl.lightmethod != LM_SOFTWARE) GLRenderer->mLights->Clear();
|
||||
if (!gl.legacyMode) GLRenderer->mLights->Clear();
|
||||
|
||||
// Check if there's some lights. If not some code can be skipped.
|
||||
TThinkerIterator<ADynamicLight> it(STAT_DLIGHT);
|
||||
|
|
|
@ -87,7 +87,7 @@ FSkyVertexBuffer::~FSkyVertexBuffer()
|
|||
void FSkyVertexBuffer::BindVBO()
|
||||
{
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vbo_id);
|
||||
if (gl.glslversion > 0)
|
||||
if (!gl.legacyMode)
|
||||
{
|
||||
glVertexAttribPointer(VATTR_VERTEX, 3, GL_FLOAT, false, sizeof(FSkyVertex), &VSO->x);
|
||||
glVertexAttribPointer(VATTR_TEXCOORD, 2, GL_FLOAT, false, sizeof(FSkyVertex), &VSO->u);
|
||||
|
@ -321,7 +321,7 @@ void FSkyVertexBuffer::RenderDome(FMaterial *tex, int mode)
|
|||
RenderRow(GL_TRIANGLE_FAN, rc);
|
||||
gl_RenderState.EnableTexture(true);
|
||||
// The color array can only be activated now if this is drawn without shader
|
||||
if (gl.glslversion == 0)
|
||||
if (gl.legacyMode)
|
||||
{
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
}
|
||||
|
|
|
@ -870,7 +870,7 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal)
|
|||
RenderStyle.CheckFuzz();
|
||||
if (RenderStyle.BlendOp == STYLEOP_Fuzz)
|
||||
{
|
||||
if (gl_fuzztype != 0 && gl.glslversion > 0)
|
||||
if (gl_fuzztype != 0 && !gl.legacyMode)
|
||||
{
|
||||
// Todo: implement shader selection here
|
||||
RenderStyle = LegacyRenderStyles[STYLE_Translucent];
|
||||
|
|
|
@ -140,7 +140,7 @@ void GLWall::PutWall(bool translucent)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (gl.lightmethod == LM_SOFTWARE && !translucent)
|
||||
if (gl.legacyMode && !translucent)
|
||||
{
|
||||
if (PutWallCompat(passflag[type])) return;
|
||||
}
|
||||
|
|
|
@ -216,9 +216,8 @@ void GLWall::RenderWall(int textured)
|
|||
}
|
||||
else if (vertcount == 0)
|
||||
{
|
||||
// in case we get here without valid vertex data and no ability to create them now,
|
||||
// use the quad drawer as fallback (without edge splitting.)
|
||||
// This can only happen in one special situation, when a translucent line got split during sorting.
|
||||
// This should never happen but in case it actually does, use the quad drawer as fallback (without edge splitting.)
|
||||
// This way it at least gets drawn.
|
||||
FQuadDrawer qd;
|
||||
qd.Set(0, glseg.x1, zbottom[0], glseg.y1, tcs[LOLFT].u, tcs[LOLFT].v);
|
||||
qd.Set(1, glseg.x1, ztop[0], glseg.y1, tcs[UPLFT].u, tcs[UPLFT].v);
|
||||
|
@ -242,7 +241,7 @@ void GLWall::RenderFogBoundary()
|
|||
{
|
||||
if (gl_fogmode && gl_fixedcolormap == 0)
|
||||
{
|
||||
if (gl.glslversion > 0.f)
|
||||
if (!gl.legacyMode)
|
||||
{
|
||||
int rel = rellight + getExtraLight();
|
||||
gl_SetFog(lightlevel, rel, &Colormap, false);
|
||||
|
@ -276,7 +275,7 @@ void GLWall::RenderMirrorSurface()
|
|||
Vector v(glseg.y2-glseg.y1, 0 ,-glseg.x2+glseg.x1);
|
||||
v.Normalize();
|
||||
|
||||
if (gl.glslversion >= 0.f)
|
||||
if (!gl.legacyMode)
|
||||
{
|
||||
// we use texture coordinates and texture matrix to pass the normal stuff to the shader so that the default vertex buffer format can be used as is.
|
||||
tcs[LOLFT].u = tcs[LORGT].u = tcs[UPLFT].u = tcs[UPRGT].u = v.X();
|
||||
|
|
|
@ -87,20 +87,6 @@ void FBlurShader::Blur(FGLRenderer *renderer, float blurAmount, int sampleCount,
|
|||
else
|
||||
setup->HorizontalShader->Bind();
|
||||
|
||||
if (gl.glslversion < 1.3)
|
||||
{
|
||||
if (vertical)
|
||||
{
|
||||
setup->VerticalScaleX.Set(1.0f / width);
|
||||
setup->VerticalScaleY.Set(1.0f / height);
|
||||
}
|
||||
else
|
||||
{
|
||||
setup->HorizontalScaleX.Set(1.0f / width);
|
||||
setup->HorizontalScaleY.Set(1.0f / height);
|
||||
}
|
||||
}
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, inputTexture);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
|
@ -156,14 +142,6 @@ FBlurShader::BlurSetup *FBlurShader::GetSetup(float blurAmount, int sampleCount)
|
|||
blurSetup.HorizontalShader->Bind();
|
||||
glUniform1i(glGetUniformLocation(*blurSetup.HorizontalShader.get(), "SourceTexture"), 0);
|
||||
|
||||
if (gl.glslversion < 1.3)
|
||||
{
|
||||
blurSetup.VerticalScaleX.Init(*blurSetup.VerticalShader.get(), "ScaleX");
|
||||
blurSetup.VerticalScaleY.Init(*blurSetup.VerticalShader.get(), "ScaleY");
|
||||
blurSetup.HorizontalScaleX.Init(*blurSetup.HorizontalShader.get(), "ScaleX");
|
||||
blurSetup.HorizontalScaleY.Init(*blurSetup.HorizontalShader.get(), "ScaleY");
|
||||
}
|
||||
|
||||
mBlurSetups.Push(blurSetup);
|
||||
|
||||
return &mBlurSetups[mBlurSetups.Size() - 1];
|
||||
|
|
|
@ -91,40 +91,27 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char *
|
|||
//
|
||||
FString vp_comb;
|
||||
|
||||
if (gl.lightmethod == LM_SOFTWARE)
|
||||
assert(GLRenderer->mLights != NULL);
|
||||
// On the shader side there is no difference between LM_DEFERRED and LM_DIRECT, it only decides how the buffer is initialized.
|
||||
unsigned int lightbuffertype = GLRenderer->mLights->GetBufferType();
|
||||
unsigned int lightbuffersize = GLRenderer->mLights->GetBlockSize();
|
||||
if (lightbuffertype == GL_UNIFORM_BUFFER)
|
||||
{
|
||||
if (gl.glslversion >= 1.3)
|
||||
// This differentiation is for some Intel drivers which fail on #extension, so use of #version 140 is necessary
|
||||
if (gl.glslversion < 1.4f)
|
||||
{
|
||||
vp_comb = "#version 130\n";
|
||||
vp_comb.Format("#version 130\n#extension GL_ARB_uniform_buffer_object : require\n#define NUM_UBO_LIGHTS %d\n", lightbuffersize);
|
||||
}
|
||||
else
|
||||
{
|
||||
vp_comb = "#define GLSL12_COMPATIBLE\n";
|
||||
vp_comb.Format("#version 140\n#define NUM_UBO_LIGHTS %d\n", lightbuffersize);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(GLRenderer->mLights != NULL);
|
||||
// On the shader side there is no difference between LM_DEFERRED and LM_DIRECT, it only matters which buffer type is used by the light buffer.
|
||||
unsigned int lightbuffertype = GLRenderer->mLights->GetBufferType();
|
||||
unsigned int lightbuffersize = GLRenderer->mLights->GetBlockSize();
|
||||
if (lightbuffertype == GL_UNIFORM_BUFFER)
|
||||
{
|
||||
// This differentiation is for some Intel drivers which fail on #extension, so use of #version 140 is necessary
|
||||
if (gl.glslversion < 1.4f || gl.version < 3.1f)
|
||||
{
|
||||
vp_comb.Format("#version 130\n#extension GL_ARB_uniform_buffer_object : require\n#define NUM_UBO_LIGHTS %d\n", lightbuffersize);
|
||||
}
|
||||
else
|
||||
{
|
||||
vp_comb.Format("#version 140\n#define NUM_UBO_LIGHTS %d\n", lightbuffersize);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
vp_comb = "#version 400 core\n#extension GL_ARB_shader_storage_buffer_object : require\n#define SHADER_STORAGE_LIGHTS\n";
|
||||
}
|
||||
vp_comb = "#version 400 core\n#extension GL_ARB_shader_storage_buffer_object : require\n#define SHADER_STORAGE_LIGHTS\n";
|
||||
}
|
||||
|
||||
if (gl.buffermethod == BM_DEFERRED)
|
||||
{
|
||||
vp_comb << "#define USE_QUAD_DRAWER\n";
|
||||
|
@ -169,12 +156,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char *
|
|||
}
|
||||
}
|
||||
|
||||
if (gl.glslversion < 1.3)
|
||||
{
|
||||
FShaderProgram::PatchVertShader(vp_comb);
|
||||
FShaderProgram::PatchFragShader(fp_comb);
|
||||
}
|
||||
else if (gl.flags & RFL_NO_CLIP_PLANES)
|
||||
if (gl.flags & RFL_NO_CLIP_PLANES)
|
||||
{
|
||||
// On ATI's GL3 drivers we have to disable gl_ClipDistance because it's hopelessly broken.
|
||||
// This will cause some glitches and regressions but is the only way to avoid total display garbage.
|
||||
|
@ -273,7 +255,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char *
|
|||
texcoordmatrix_index = glGetUniformLocation(hShader, "uQuadTexCoords");
|
||||
quadmode_index = glGetUniformLocation(hShader, "uQuadMode");
|
||||
|
||||
if (LM_SOFTWARE != gl.lightmethod && !(gl.flags & RFL_SHADER_STORAGE_BUFFER))
|
||||
if (!gl.legacyMode && !(gl.flags & RFL_SHADER_STORAGE_BUFFER))
|
||||
{
|
||||
int tempindex = glGetUniformBlockIndex(hShader, "LightBufferUBO");
|
||||
if (tempindex != -1) glUniformBlockBinding(hShader, tempindex, LIGHTBUF_BINDINGPOINT);
|
||||
|
@ -424,7 +406,7 @@ static const FEffectShader effectshaders[]=
|
|||
|
||||
FShaderManager::FShaderManager()
|
||||
{
|
||||
if (gl.glslversion > 0) CompileShaders();
|
||||
if (!gl.legacyMode) CompileShaders();
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
@ -435,7 +417,7 @@ FShaderManager::FShaderManager()
|
|||
|
||||
FShaderManager::~FShaderManager()
|
||||
{
|
||||
if (gl.glslversion > 0) Clean();
|
||||
if (!gl.legacyMode) Clean();
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
@ -577,7 +559,7 @@ EXTERN_CVAR(Int, gl_fuzztype)
|
|||
|
||||
void FShaderManager::ApplyMatrices(VSMatrix *proj, VSMatrix *view)
|
||||
{
|
||||
if (gl.glslversion == 0)
|
||||
if (gl.legacyMode)
|
||||
{
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadMatrixf(proj->get());
|
||||
|
|
|
@ -240,24 +240,13 @@ FString FShaderProgram::PatchShader(ShaderType type, const FString &code, const
|
|||
if (defines)
|
||||
patchedCode << defines;
|
||||
|
||||
if (gl.glslversion >= 1.3)
|
||||
{
|
||||
// these settings are actually pointless but there seem to be some old ATI drivers that fail to compile the shader without setting the precision here.
|
||||
patchedCode << "precision highp int;\n";
|
||||
patchedCode << "precision highp float;\n";
|
||||
}
|
||||
// these settings are actually pointless but there seem to be some old ATI drivers that fail to compile the shader without setting the precision here.
|
||||
patchedCode << "precision highp int;\n";
|
||||
patchedCode << "precision highp float;\n";
|
||||
|
||||
patchedCode << "#line 1\n";
|
||||
patchedCode << code;
|
||||
|
||||
if (gl.glslversion < 1.3)
|
||||
{
|
||||
if (type == Vertex)
|
||||
PatchVertShader(patchedCode);
|
||||
else if (type == Fragment)
|
||||
PatchFragShader(patchedCode);
|
||||
}
|
||||
|
||||
return patchedCode;
|
||||
}
|
||||
|
||||
|
@ -268,36 +257,3 @@ FString FShaderProgram::PatchShader(ShaderType type, const FString &code, const
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void FShaderProgram::PatchCommon(FString &code)
|
||||
{
|
||||
code.Substitute("precision highp int;", "");
|
||||
code.Substitute("precision highp float;", "");
|
||||
}
|
||||
|
||||
void FShaderProgram::PatchVertShader(FString &code)
|
||||
{
|
||||
PatchCommon(code);
|
||||
code.Substitute("in vec", "attribute vec");
|
||||
code.Substitute("in float", "attribute float");
|
||||
code.Substitute("out vec", "varying vec");
|
||||
code.Substitute("out float", "varying float");
|
||||
code.Substitute("gl_ClipDistance", "//");
|
||||
}
|
||||
|
||||
void FShaderProgram::PatchFragShader(FString &code)
|
||||
{
|
||||
PatchCommon(code);
|
||||
code.Substitute("out vec4 FragColor;", "");
|
||||
code.Substitute("FragColor", "gl_FragColor");
|
||||
code.Substitute("in vec", "varying vec");
|
||||
// this patches the switch statement to if's.
|
||||
code.Substitute("break;", "");
|
||||
code.Substitute("switch (uFixedColormap)", "int i = uFixedColormap;");
|
||||
code.Substitute("case 0:", "if (i == 0)");
|
||||
code.Substitute("case 1:", "else if (i == 1)");
|
||||
code.Substitute("case 2:", "else if (i == 2)");
|
||||
code.Substitute("case 3:", "else if (i == 3)");
|
||||
code.Substitute("case 4:", "else if (i == 4)");
|
||||
code.Substitute("case 5:", "else if (i == 5)");
|
||||
code.Substitute("texture(", "texture2D(");
|
||||
}
|
||||
|
|
|
@ -26,16 +26,11 @@ public:
|
|||
operator GLuint() const { return mProgram; }
|
||||
explicit operator bool() const { return mProgram != 0; }
|
||||
|
||||
// Needed by FShader
|
||||
static void PatchVertShader(FString &code);
|
||||
static void PatchFragShader(FString &code);
|
||||
|
||||
private:
|
||||
FShaderProgram(const FShaderProgram &) = delete;
|
||||
FShaderProgram &operator=(const FShaderProgram &) = delete;
|
||||
|
||||
static FString PatchShader(ShaderType type, const FString &code, const char *defines, int maxGlslVersion);
|
||||
static void PatchCommon(FString &code);
|
||||
|
||||
void CreateShader(ShaderType type);
|
||||
FString GetShaderInfoLog(GLuint handle);
|
||||
|
|
|
@ -162,7 +162,7 @@ void OpenGLFrameBuffer::InitializeState()
|
|||
glEnable(GL_BLEND);
|
||||
glEnable(GL_DEPTH_CLAMP);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
if (gl.glslversion == 0) glEnable(GL_TEXTURE_2D);
|
||||
if (gl.legacyMode) glEnable(GL_TEXTURE_2D);
|
||||
glDisable(GL_LINE_SMOOTH);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
|
|
|
@ -154,10 +154,10 @@ void gl_LoadExtensions()
|
|||
else Printf("Emulating OpenGL v %s\n", version);
|
||||
}
|
||||
|
||||
gl.version = strtod(version, NULL) + 0.01f;
|
||||
float gl_version = (float)strtod(version, NULL) + 0.01f;
|
||||
|
||||
// Don't even start if it's lower than 2.0 or no framebuffers are available
|
||||
if ((gl.version < 2.0 || !CheckExtension("GL_EXT_framebuffer_object")) && gl.version < 3.0)
|
||||
// Don't even start if it's lower than 2.0 or no framebuffers are available (The framebuffer extension is needed for glGenerateMipmapsEXT!)
|
||||
if ((gl_version < 2.0f || !CheckExtension("GL_EXT_framebuffer_object")) && gl_version < 3.0f)
|
||||
{
|
||||
I_FatalError("Unsupported OpenGL version.\nAt least OpenGL 2.0 with framebuffer support is required to run " GAMENAME ".\n");
|
||||
}
|
||||
|
@ -166,105 +166,86 @@ void gl_LoadExtensions()
|
|||
gl.glslversion = strtod((char*)glGetString(GL_SHADING_LANGUAGE_VERSION), NULL) + 0.01f;
|
||||
|
||||
gl.vendorstring = (char*)glGetString(GL_VENDOR);
|
||||
gl.lightmethod = LM_SOFTWARE;
|
||||
gl.buffermethod = BM_CLIENTARRAY;
|
||||
|
||||
if ((gl.version >= 3.3f || CheckExtension("GL_ARB_sampler_objects")) && !Args->CheckParm("-nosampler"))
|
||||
// first test for optional features
|
||||
if (CheckExtension("GL_ARB_texture_compression")) gl.flags |= RFL_TEXTURE_COMPRESSION;
|
||||
if (CheckExtension("GL_EXT_texture_compression_s3tc")) gl.flags |= RFL_TEXTURE_COMPRESSION_S3TC;
|
||||
|
||||
if ((gl_version >= 3.3f || CheckExtension("GL_ARB_sampler_objects")) && !Args->CheckParm("-nosampler"))
|
||||
{
|
||||
gl.flags |= RFL_SAMPLER_OBJECTS;
|
||||
}
|
||||
|
||||
// Buffer lighting is only feasible with GLSL 1.3 and higher, even if 1.2 supports the extension.
|
||||
if (gl.version > 3.0f && (gl.version >= 3.3f || CheckExtension("GL_ARB_uniform_buffer_object")))
|
||||
// The minimum requirement for the modern render path are GL 3.0 + uniform buffers
|
||||
if (gl_version < 3.0f || (gl_version < 3.1f && !CheckExtension("GL_ARB_uniform_buffer_object")))
|
||||
{
|
||||
gl.lightmethod = LM_DEFERRED;
|
||||
gl.buffermethod = BM_DEFERRED;
|
||||
}
|
||||
|
||||
if (CheckExtension("GL_ARB_texture_compression")) gl.flags |= RFL_TEXTURE_COMPRESSION;
|
||||
if (CheckExtension("GL_EXT_texture_compression_s3tc")) gl.flags |= RFL_TEXTURE_COMPRESSION_S3TC;
|
||||
|
||||
if (Args->CheckParm("-noshader")/* || gl.glslversion < 1.2f*/)
|
||||
{
|
||||
gl.version = 2.11f;
|
||||
gl.legacyMode = true;
|
||||
gl.lightmethod = LM_LEGACY;
|
||||
gl.buffermethod = BM_LEGACY;
|
||||
gl.glslversion = 0;
|
||||
gl.lightmethod = LM_SOFTWARE;
|
||||
gl.flags |= RFL_NO_CLIP_PLANES;
|
||||
}
|
||||
else if (gl.version < 3.0f)
|
||||
{
|
||||
if (CheckExtension("GL_NV_GPU_shader4") || CheckExtension("GL_EXT_GPU_shader4")) gl.glslversion = 1.21f; // for pre-3.0 drivers that support capable hardware. Needed for Apple.
|
||||
else
|
||||
{
|
||||
gl.buffermethod = BM_CLIENTARRAY;
|
||||
gl.glslversion = 0;
|
||||
}
|
||||
|
||||
if (!CheckExtension("GL_EXT_packed_float")) gl.flags |= RFL_NO_RGBA16F;
|
||||
if (!CheckExtension("GL_EXT_packed_depth_stencil")) gl.flags |= RFL_NO_DEPTHSTENCIL;
|
||||
gl.flags |= RFL_NO_CLIP_PLANES;
|
||||
}
|
||||
else if (gl.version < 4.f)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if (strstr(gl.vendorstring, "ATI Tech"))
|
||||
{
|
||||
gl.flags |= RFL_NO_CLIP_PLANES; // gl_ClipDistance is horribly broken on ATI GL3 drivers for Windows.
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else if (gl.version < 4.5f)
|
||||
{
|
||||
// don't use GL 4.x features when running in GL 3 emulation mode.
|
||||
if (CheckExtension("GL_ARB_buffer_storage"))
|
||||
{
|
||||
// work around a problem with older AMD drivers: Their implementation of shader storage buffer objects is piss-poor and does not match uniform buffers even closely.
|
||||
// Recent drivers, GL 4.4 don't have this problem, these can easily be recognized by also supporting the GL_ARB_buffer_storage extension.
|
||||
if (CheckExtension("GL_ARB_shader_storage_buffer_object"))
|
||||
{
|
||||
// Shader storage buffer objects are broken on current Intel drivers.
|
||||
if (strstr(gl.vendorstring, "Intel") == NULL)
|
||||
{
|
||||
gl.flags |= RFL_SHADER_STORAGE_BUFFER;
|
||||
}
|
||||
}
|
||||
gl.flags |= RFL_BUFFER_STORAGE;
|
||||
gl.lightmethod = LM_DIRECT;
|
||||
gl.buffermethod = BM_PERSISTENT;
|
||||
}
|
||||
else
|
||||
{
|
||||
gl.version = 3.3f;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Assume that everything works without problems on GL 4.5 drivers where these things are core features.
|
||||
gl.flags |= RFL_SHADER_STORAGE_BUFFER | RFL_BUFFER_STORAGE;
|
||||
gl.lightmethod = LM_DIRECT;
|
||||
gl.buffermethod = BM_PERSISTENT;
|
||||
}
|
||||
gl.legacyMode = false;
|
||||
gl.lightmethod = LM_DEFERRED;
|
||||
gl.buffermethod = BM_DEFERRED;
|
||||
if (gl_version < 4.f)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if (strstr(gl.vendorstring, "ATI Tech"))
|
||||
{
|
||||
gl.flags |= RFL_NO_CLIP_PLANES; // gl_ClipDistance is horribly broken on ATI GL3 drivers for Windows.
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else if (gl_version < 4.5f)
|
||||
{
|
||||
// don't use GL 4.x features when running a GL 3.x context.
|
||||
if (CheckExtension("GL_ARB_buffer_storage"))
|
||||
{
|
||||
// work around a problem with older AMD drivers: Their implementation of shader storage buffer objects is piss-poor and does not match uniform buffers even closely.
|
||||
// Recent drivers, GL 4.4 don't have this problem, these can easily be recognized by also supporting the GL_ARB_buffer_storage extension.
|
||||
if (CheckExtension("GL_ARB_shader_storage_buffer_object"))
|
||||
{
|
||||
// Shader storage buffer objects are broken on current Intel drivers.
|
||||
if (strstr(gl.vendorstring, "Intel") == NULL)
|
||||
{
|
||||
gl.flags |= RFL_SHADER_STORAGE_BUFFER;
|
||||
}
|
||||
}
|
||||
gl.flags |= RFL_BUFFER_STORAGE;
|
||||
gl.lightmethod = LM_DIRECT;
|
||||
gl.buffermethod = BM_PERSISTENT;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Assume that everything works without problems on GL 4.5 drivers where these things are core features.
|
||||
gl.flags |= RFL_SHADER_STORAGE_BUFFER | RFL_BUFFER_STORAGE;
|
||||
gl.lightmethod = LM_DIRECT;
|
||||
gl.buffermethod = BM_PERSISTENT;
|
||||
}
|
||||
|
||||
if (gl.version >= 4.3f || CheckExtension("GL_ARB_invalidate_subdata")) gl.flags |= RFL_INVALIDATE_BUFFER;
|
||||
if (gl.version >= 4.3f || CheckExtension("GL_KHR_debug")) gl.flags |= RFL_DEBUG;
|
||||
if (gl_version >= 4.3f || CheckExtension("GL_ARB_invalidate_subdata")) gl.flags |= RFL_INVALIDATE_BUFFER;
|
||||
if (gl_version >= 4.3f || CheckExtension("GL_KHR_debug")) gl.flags |= RFL_DEBUG;
|
||||
|
||||
const char *lm = Args->CheckValue("-lightmethod");
|
||||
if (lm != NULL)
|
||||
{
|
||||
if (!stricmp(lm, "deferred") && gl.lightmethod == LM_DIRECT) gl.lightmethod = LM_DEFERRED;
|
||||
if (!stricmp(lm, "textured")) gl.lightmethod = LM_SOFTWARE;
|
||||
}
|
||||
const char *lm = Args->CheckValue("-lightmethod");
|
||||
if (lm != NULL)
|
||||
{
|
||||
if (!stricmp(lm, "deferred") && gl.lightmethod == LM_DIRECT) gl.lightmethod = LM_DEFERRED;
|
||||
}
|
||||
|
||||
lm = Args->CheckValue("-buffermethod");
|
||||
if (lm != NULL)
|
||||
{
|
||||
if (!stricmp(lm, "deferred") && gl.buffermethod == BM_PERSISTENT) gl.buffermethod = BM_DEFERRED;
|
||||
if (!stricmp(lm, "clientarray")) gl.buffermethod = BM_CLIENTARRAY;
|
||||
lm = Args->CheckValue("-buffermethod");
|
||||
if (lm != NULL)
|
||||
{
|
||||
if (!stricmp(lm, "deferred") && gl.buffermethod == BM_PERSISTENT) gl.buffermethod = BM_DEFERRED;
|
||||
}
|
||||
}
|
||||
|
||||
int v;
|
||||
|
||||
if (gl.lightmethod != LM_SOFTWARE && !(gl.flags & RFL_SHADER_STORAGE_BUFFER))
|
||||
if (!gl.legacyMode && !(gl.flags & RFL_SHADER_STORAGE_BUFFER))
|
||||
{
|
||||
glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, &v);
|
||||
gl.maxuniforms = v;
|
||||
|
@ -284,24 +265,27 @@ void gl_LoadExtensions()
|
|||
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &gl.max_texturesize);
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
|
||||
// fudge a bit with the framebuffer stuff to avoid redundancies in the main code. Some of the older cards do not have the ARB stuff but the calls are nearly identical.
|
||||
FUDGE_FUNC(glGenerateMipmap, EXT);
|
||||
FUDGE_FUNC(glGenFramebuffers, EXT);
|
||||
FUDGE_FUNC(glBindFramebuffer, EXT);
|
||||
FUDGE_FUNC(glDeleteFramebuffers, EXT);
|
||||
FUDGE_FUNC(glFramebufferTexture2D, EXT);
|
||||
FUDGE_FUNC(glGenerateMipmap, EXT);
|
||||
FUDGE_FUNC(glGenFramebuffers, EXT);
|
||||
FUDGE_FUNC(glBindFramebuffer, EXT);
|
||||
FUDGE_FUNC(glDeleteFramebuffers, EXT);
|
||||
FUDGE_FUNC(glFramebufferTexture2D, EXT);
|
||||
FUDGE_FUNC(glFramebufferRenderbuffer, EXT);
|
||||
FUDGE_FUNC(glGenRenderbuffers, EXT);
|
||||
FUDGE_FUNC(glDeleteRenderbuffers, EXT);
|
||||
FUDGE_FUNC(glRenderbufferStorage, EXT);
|
||||
FUDGE_FUNC(glBindRenderbuffer, EXT);
|
||||
FUDGE_FUNC(glCheckFramebufferStatus, EXT);
|
||||
gl_PatchMenu();
|
||||
if (gl.legacyMode)
|
||||
{
|
||||
// fudge a bit with the framebuffer stuff to avoid redundancies in the main code. Some of the older cards do not have the ARB stuff but the calls are nearly identical.
|
||||
FUDGE_FUNC(glGenerateMipmap, EXT);
|
||||
FUDGE_FUNC(glGenFramebuffers, EXT);
|
||||
FUDGE_FUNC(glBindFramebuffer, EXT);
|
||||
FUDGE_FUNC(glDeleteFramebuffers, EXT);
|
||||
FUDGE_FUNC(glFramebufferTexture2D, EXT);
|
||||
FUDGE_FUNC(glGenerateMipmap, EXT);
|
||||
FUDGE_FUNC(glGenFramebuffers, EXT);
|
||||
FUDGE_FUNC(glBindFramebuffer, EXT);
|
||||
FUDGE_FUNC(glDeleteFramebuffers, EXT);
|
||||
FUDGE_FUNC(glFramebufferTexture2D, EXT);
|
||||
FUDGE_FUNC(glFramebufferRenderbuffer, EXT);
|
||||
FUDGE_FUNC(glGenRenderbuffers, EXT);
|
||||
FUDGE_FUNC(glDeleteRenderbuffers, EXT);
|
||||
FUDGE_FUNC(glRenderbufferStorage, EXT);
|
||||
FUDGE_FUNC(glBindRenderbuffer, EXT);
|
||||
FUDGE_FUNC(glCheckFramebufferStatus, EXT);
|
||||
gl_PatchMenu();
|
||||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
@ -313,7 +297,7 @@ void gl_LoadExtensions()
|
|||
void gl_PrintStartupLog()
|
||||
{
|
||||
int v = 0;
|
||||
if (gl.version >= 3.2) glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &v);
|
||||
if (!gl.legacyMode) glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &v);
|
||||
|
||||
Printf ("GL_VENDOR: %s\n", glGetString(GL_VENDOR));
|
||||
Printf ("GL_RENDERER: %s\n", glGetString(GL_RENDERER));
|
||||
|
@ -332,7 +316,7 @@ void gl_PrintStartupLog()
|
|||
glGetIntegerv(GL_MAX_VARYING_FLOATS, &v);
|
||||
Printf ("Max. varying: %d\n", v);
|
||||
|
||||
if (gl.lightmethod != LM_SOFTWARE && !(gl.flags & RFL_SHADER_STORAGE_BUFFER))
|
||||
if (!gl.legacyMode && !(gl.flags & RFL_SHADER_STORAGE_BUFFER))
|
||||
{
|
||||
glGetIntegerv(GL_MAX_UNIFORM_BLOCK_SIZE, &v);
|
||||
Printf ("Max. uniform block size: %d\n", v);
|
||||
|
@ -349,7 +333,7 @@ void gl_PrintStartupLog()
|
|||
}
|
||||
|
||||
// For shader-less, the special alphatexture translation must be changed to actually set the alpha, because it won't get translated by a shader.
|
||||
if (gl.glslversion == 0)
|
||||
if (gl.legacyMode)
|
||||
{
|
||||
FRemapTable *remap = translationtables[TRANSLATION_Standard][8];
|
||||
for (int i = 0; i < 256; i++)
|
||||
|
|
|
@ -21,12 +21,10 @@ enum RenderFlags
|
|||
RFL_BUFFER_STORAGE = 8,
|
||||
RFL_SAMPLER_OBJECTS = 16,
|
||||
|
||||
RFL_NO_RGBA16F = 32,
|
||||
RFL_NO_DEPTHSTENCIL = 64,
|
||||
RFL_NO_CLIP_PLANES = 128,
|
||||
RFL_NO_CLIP_PLANES = 32,
|
||||
|
||||
RFL_INVALIDATE_BUFFER = 256,
|
||||
RFL_DEBUG = 512
|
||||
RFL_INVALIDATE_BUFFER = 64,
|
||||
RFL_DEBUG = 128
|
||||
};
|
||||
|
||||
enum TexMode
|
||||
|
@ -43,15 +41,15 @@ enum TexMode
|
|||
|
||||
enum ELightMethod
|
||||
{
|
||||
LM_SOFTWARE = 0, // multi-pass texturing
|
||||
LM_LEGACY = 0, // placeholder for legacy mode (textured lights), should not be checked anywhere in the code!
|
||||
LM_DEFERRED = 1, // calculate lights up front in a separate pass
|
||||
LM_DIRECT = 2, // calculate lights on the fly along with the render data
|
||||
};
|
||||
|
||||
enum EBufferMethod
|
||||
{
|
||||
BM_CLIENTARRAY = 0, // use a client array instead of a hardware buffer
|
||||
BM_DEFERRED = 1, // use a temporarily mapped buffer (only necessary on GL 3.x core profile, i.e. Apple)
|
||||
BM_LEGACY = 0, // placeholder for legacy mode (client arrays), should not be checked anywhere in the code!
|
||||
BM_DEFERRED = 1, // use a temporarily mapped buffer, for GL 3.x core profile
|
||||
BM_PERSISTENT = 2 // use a persistently mapped buffer
|
||||
};
|
||||
|
||||
|
@ -64,10 +62,10 @@ struct RenderContext
|
|||
unsigned int uniformblockalignment;
|
||||
int lightmethod;
|
||||
int buffermethod;
|
||||
float version;
|
||||
float glslversion;
|
||||
int max_texturesize;
|
||||
char * vendorstring;
|
||||
bool legacyMode;
|
||||
|
||||
int MaxLights() const
|
||||
{
|
||||
|
|
|
@ -264,7 +264,7 @@ unsigned char *gl_CreateUpsampledTextureBuffer ( const FTexture *inputTexture, u
|
|||
return inputBuffer;
|
||||
|
||||
// [BB] Don't upsample non-shader handled warped textures. Needs too much memory and time
|
||||
if (gl.glslversion == 0 && inputTexture->bWarped)
|
||||
if (gl.legacyMode && inputTexture->bWarped)
|
||||
return inputBuffer;
|
||||
|
||||
// already scaled?
|
||||
|
|
|
@ -296,7 +296,7 @@ const FHardwareTexture *FGLTexture::Bind(int texunit, int clampmode, int transla
|
|||
if (translation <= 0) translation = -translation;
|
||||
else
|
||||
{
|
||||
alphatrans = (gl.glslversion == 0 && translation == TRANSLATION(TRANSLATION_Standard, 8));
|
||||
alphatrans = (gl.legacyMode && translation == TRANSLATION(TRANSLATION_Standard, 8));
|
||||
translation = GLTranslationPalette::GetInternalTranslation(translation);
|
||||
}
|
||||
|
||||
|
@ -307,7 +307,7 @@ const FHardwareTexture *FGLTexture::Bind(int texunit, int clampmode, int transla
|
|||
if (hwtex)
|
||||
{
|
||||
// Texture has become invalid
|
||||
if ((!tex->bHasCanvas && (!tex->bWarped || gl.glslversion == 0)) && tex->CheckModified())
|
||||
if ((!tex->bHasCanvas && (!tex->bWarped || gl.legacyMode)) && tex->CheckModified())
|
||||
{
|
||||
Clean(true);
|
||||
hwtex = CreateHwTexture();
|
||||
|
@ -325,7 +325,7 @@ const FHardwareTexture *FGLTexture::Bind(int texunit, int clampmode, int transla
|
|||
if (!tex->bHasCanvas)
|
||||
{
|
||||
buffer = CreateTexBuffer(translation, w, h, hirescheck, true, alphatrans);
|
||||
if (tex->bWarped && gl.glslversion == 0 && w*h <= 256*256) // do not software-warp larger textures, especially on the old systems that still need this fallback.
|
||||
if (tex->bWarped && gl.legacyMode && w*h <= 256*256) // do not software-warp larger textures, especially on the old systems that still need this fallback.
|
||||
{
|
||||
// need to do software warping
|
||||
FWarpTexture *wt = static_cast<FWarpTexture*>(tex);
|
||||
|
@ -489,7 +489,7 @@ FMaterial::FMaterial(FTexture * tx, bool expanded)
|
|||
mSpriteU[0] = mSpriteV[0] = 0.f;
|
||||
mSpriteU[1] = mSpriteV[1] = 1.f;
|
||||
|
||||
FTexture *basetex = (tx->bWarped && gl.glslversion == 0)? tx : tx->GetRedirect(false);
|
||||
FTexture *basetex = (tx->bWarped && gl.legacyMode)? tx : tx->GetRedirect(false);
|
||||
// allow the redirect only if the textute is not expanded or the scale matches.
|
||||
if (!expanded || (tx->Scale.X == basetex->Scale.X && tx->Scale.Y == basetex->Scale.Y))
|
||||
{
|
||||
|
|
|
@ -51,32 +51,6 @@ vec4 desaturate(vec4 texel)
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
#ifdef GLSL12_COMPATIBLE
|
||||
vec4 getTexel(vec2 st)
|
||||
{
|
||||
vec4 texel = texture(tex, st);
|
||||
|
||||
//
|
||||
// Apply texture modes
|
||||
//
|
||||
if (uTextureMode != 0)
|
||||
{
|
||||
if (uTextureMode == 1) texel.rgb = vec3(1.0,1.0,1.0);
|
||||
else if (uTextureMode == 2) texel.a = 1.0;
|
||||
else if (uTextureMode == 3) texel = vec4(1.0-texel.r, 1.0-texel.b, 1.0-texel.g, texel.a);
|
||||
else if (uTextureMode == 4) texel = vec4(1.0, 1.0, 1.0, texel.r*texel.a);
|
||||
else if (uTextureMode == 5)
|
||||
{
|
||||
if (st.t < 0.0 || st.t > 1.0)
|
||||
{
|
||||
texel.a = 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
texel *= uObjectColor;
|
||||
return desaturate(texel);
|
||||
}
|
||||
#else
|
||||
vec4 getTexel(vec2 st)
|
||||
{
|
||||
vec4 texel = texture(tex, st);
|
||||
|
@ -113,7 +87,6 @@ vec4 getTexel(vec2 st)
|
|||
|
||||
return desaturate(texel);
|
||||
}
|
||||
#endif
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
|
|
|
@ -70,17 +70,10 @@ uniform sampler2D PaletteLUT;
|
|||
vec3 Tonemap(vec3 color)
|
||||
{
|
||||
ivec3 c = ivec3(clamp(color.rgb, vec3(0.0), vec3(1.0)) * 255.0 + 0.5);
|
||||
#if __VERSION__ < 130
|
||||
int index = (c.r / 4 * 64 + c.g / 4) * 64 + c.b / 4;
|
||||
float tx = mod(index, 512) / 512.0;
|
||||
float ty = float(index / 512) / 512.0;
|
||||
return texture2D(PaletteLUT, vec2(tx, ty)).rgb;
|
||||
#else
|
||||
int index = ((c.r >> 2) * 64 + (c.g >> 2)) * 64 + (c.b >> 2);
|
||||
int tx = index % 512;
|
||||
int ty = index / 512;
|
||||
return texelFetch(PaletteLUT, ivec2(tx, ty), 0).rgb;
|
||||
#endif
|
||||
}
|
||||
|
||||
#else
|
||||
|
|
Loading…
Reference in a new issue