diff options
author | Mike Erwin <significant.bit@gmail.com> | 2017-05-19 01:30:09 +0300 |
---|---|---|
committer | Mike Erwin <significant.bit@gmail.com> | 2017-05-19 01:30:24 +0300 |
commit | e03e977385c9285ec13695f93e43bb805c4dd0af (patch) | |
tree | 7b10708c15620b74bc7a838da28f30285266685a /source/blender/gpu/intern/gpu_shader.c | |
parent | 77f8d631b1f6479b6e5b3b99ecb3611fca519444 (diff) |
OpenGL: call glProgramUniform only if version >= 4.1
Otherwise crash! Called from OpenSubdiv setup code. Might start using this in more places...
Diffstat (limited to 'source/blender/gpu/intern/gpu_shader.c')
-rw-r--r-- | source/blender/gpu/intern/gpu_shader.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/source/blender/gpu/intern/gpu_shader.c b/source/blender/gpu/intern/gpu_shader.c index 58610ee7f4b..83e126bd39f 100644 --- a/source/blender/gpu/intern/gpu_shader.c +++ b/source/blender/gpu/intern/gpu_shader.c @@ -435,14 +435,22 @@ GPUShader *GPU_shader_create_ex(const char *vertexcode, #ifdef WITH_OPENSUBDIV /* TODO(sergey): Find a better place for this. */ - if (use_opensubdiv && GLEW_VERSION_4_1) { - glProgramUniform1i(shader->program, - ShaderInterface_uniform(shader->interface, "FVarDataOffsetBuffer")->location, - 30); /* GL_TEXTURE30 */ - - glProgramUniform1i(shader->program, - ShaderInterface_uniform(shader->interface, "FVarDataBuffer")->location, - 31); /* GL_TEXTURE31 */ + if (use_opensubdiv) { + if (GLEW_VERSION_4_1) { + glProgramUniform1i(shader->program, + ShaderInterface_uniform(shader->interface, "FVarDataOffsetBuffer")->location, + 30); /* GL_TEXTURE30 */ + + glProgramUniform1i(shader->program, + ShaderInterface_uniform(shader->interface, "FVarDataBuffer")->location, + 31); /* GL_TEXTURE31 */ + } + else { + glUseProgram(shader->program); + glUniform1i(ShaderInterface_uniform(shader->interface, "FVarDataOffsetBuffer")->location, 30); + glUniform1i(ShaderInterface_uniform(shader->interface, "FVarDataBuffer")->location, 31); + glUseProgram(0); + } } #endif |