diff options
author | Mike Erwin <significant.bit@gmail.com> | 2016-10-18 07:08:34 +0300 |
---|---|---|
committer | Mike Erwin <significant.bit@gmail.com> | 2016-10-18 07:08:34 +0300 |
commit | 70ff63e63fc3a63dccc6a6c567bbc347c64d6c7d (patch) | |
tree | 76934061ddae6dc4091541f5ee227bedc0346ad6 /source/blender/windowmanager/intern/wm_draw.c | |
parent | 0c6939f5f597e4e7fe5777de7a49b49ff53fa987 (diff) |
OpenGL: tweak image shaders & code that uses them
- rename image shaders to describe exactly what they do
- rename inputs to match other built-in shaders
- set & use active texture unit
- no need to enable/disable textures with GLSL
- pull vertex format setup out of loops
Diffstat (limited to 'source/blender/windowmanager/intern/wm_draw.c')
-rw-r--r-- | source/blender/windowmanager/intern/wm_draw.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c index e9eaa5677e4..f38f1eee7ec 100644 --- a/source/blender/windowmanager/intern/wm_draw.c +++ b/source/blender/windowmanager/intern/wm_draw.c @@ -447,16 +447,16 @@ void wm_triple_draw_textures(wmWindow *win, wmDrawTriple *triple, float alpha) } VertexFormat *format = immVertexFormat(); - unsigned texcoord = add_attrib(format, "texcoord", GL_FLOAT, 2, KEEP_FLOAT); - unsigned pos = add_attrib(format, "position", GL_FLOAT, 2, KEEP_FLOAT); - - glEnable(triple->target); - immBindBuiltinProgram((triple->target == GL_TEXTURE_2D) ? GPU_SHADER_2D_TEXTURE_2D : GPU_SHADER_2D_TEXTURE_RECT); + unsigned texcoord = add_attrib(format, "texCoord", GL_FLOAT, 2, KEEP_FLOAT); + unsigned pos = add_attrib(format, "pos", GL_FLOAT, 2, KEEP_FLOAT); + const int activeTex = GL_TEXTURE0; + glActiveTexture(activeTex); glBindTexture(triple->target, triple->bind); + immBindBuiltinProgram((triple->target == GL_TEXTURE_2D) ? GPU_SHADER_3D_IMAGE_MODULATE_ALPHA : GPU_SHADER_3D_IMAGE_RECT_MODULATE_ALPHA); immUniform1f("alpha", alpha); - immUniform1i("texture_map", 0); + immUniform1i("image", activeTex); immBegin(GL_QUADS, 4); @@ -476,7 +476,6 @@ void wm_triple_draw_textures(wmWindow *win, wmDrawTriple *triple, float alpha) immUnbindProgram(); glBindTexture(triple->target, 0); - glDisable(triple->target); } static void wm_triple_copy_textures(wmWindow *win, wmDrawTriple *triple) |