- fixed: glProgramUniform is only present from GL 4.1 or a specific extension so it may not be used on systems not supporting it.

This commit is contained in:
Christoph Oelckers 2014-07-15 02:48:59 +02:00
parent fc0cf4f998
commit fb6b4238ed
4 changed files with 30 additions and 8 deletions

View file

@ -298,9 +298,9 @@ void GLFlat::DrawSubsectors(int pass, bool istrans)
if (gl_drawinfo->ss_renderflags[sub-subsectors]&renderflags || istrans)
{
if (pass == GLPASS_ALL) lightsapplied = SetupSubsectorLights(lightsapplied, sub);
//drawcalls.Clock();
drawcalls.Clock();
glDrawArrays(GL_TRIANGLE_FAN, index, sub->numlines);
//drawcalls.Unclock();
drawcalls.Unclock();
flatvertices += sub->numlines;
flatprimitives++;
}

View file

@ -293,8 +293,18 @@ FShader *FShaderManager::Compile (const char *ShaderName, const char *ShaderPath
void FShader::ApplyMatrices(VSMatrix *proj, VSMatrix *view)
{
glProgramUniformMatrix4fv(hShader, projectionmatrix_index, 1, false, proj->get());
glProgramUniformMatrix4fv(hShader, viewmatrix_index, 1, false, view->get());
if (gl.flags & RFL_SEPARATE_SHADER_OBJECTS)
{
glProgramUniformMatrix4fv(hShader, projectionmatrix_index, 1, false, proj->get());
glProgramUniformMatrix4fv(hShader, viewmatrix_index, 1, false, view->get());
}
else
{
Bind();
glUniformMatrix4fv(projectionmatrix_index, 1, false, proj->get());
glUniformMatrix4fv(viewmatrix_index, 1, false, view->get());
}
}
@ -486,7 +496,16 @@ void FShaderManager::SetWarpSpeed(unsigned int eff, float speed)
FShader *sh = mTextureEffects[eff];
float warpphase = gl_frameMS * speed / 1000.f;
glProgramUniform1f(sh->GetHandle(), sh->timer_index, warpphase);
if (gl.flags & RFL_SEPARATE_SHADER_OBJECTS)
{
glProgramUniform1f(sh->GetHandle(), sh->timer_index, warpphase);
}
else
{
// not so pretty...
sh->Bind();
glUniform1f(sh->timer_index, warpphase);
}
}
}

View file

@ -133,6 +133,8 @@ void gl_LoadExtensions()
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 (CheckExtension("GL_ARB_buffer_storage")) gl.flags |= RFL_BUFFER_STORAGE;
if (CheckExtension("GL_ARB_separate_shader_objects")) gl.flags |= RFL_SEPARATE_SHADER_OBJECTS;
glGetIntegerv(GL_MAX_TEXTURE_SIZE,&gl.max_texturesize);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

View file

@ -9,9 +9,10 @@ enum RenderFlags
RFL_TEXTURE_COMPRESSION=1,
RFL_TEXTURE_COMPRESSION_S3TC=2,
RFL_BUFFER_STORAGE = 8,
RFL_SHADER_STORAGE_BUFFER = 16,
RFL_BASEINDEX = 32,
RFL_SEPARATE_SHADER_OBJECTS = 4, // we need this extension for glProgramUniform. On hardware not supporting it we need some rather clumsy workarounds
RFL_BUFFER_STORAGE = 8, // allows persistently mapped buffers, which are the only efficient way to actually use a dynamic vertex buffer. If this isn't present, a workaround with uniform arrays is used.
RFL_SHADER_STORAGE_BUFFER = 16, // to be used later for a parameter buffer
RFL_BASEINDEX = 32, // currently unused
};
enum TexMode