OpenGL: use simple shader for texture drawing in a few places.
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Sat, 28 Nov 2015 00:20:28 +0000 (01:20 +0100)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Sun, 6 Dec 2015 18:35:15 +0000 (19:35 +0100)
Differential Revision: https://developer.blender.org/D1645

source/blender/blenfont/intern/blf.c
source/blender/editors/interface/interface_icons.c
source/blender/editors/screen/glutil.c
source/blender/editors/sculpt_paint/paint_cursor.c
source/blender/editors/space_clip/clip_draw.c
source/blender/editors/space_sequencer/sequencer_draw.c
source/blender/windowmanager/intern/wm_operators.c

index 3369e1c08b6e760a5f82d089d74616f0ac09968a..8b654d25bcffd48b6b5b7a4fe4388ae8559e03b7 100644 (file)
@@ -55,6 +55,8 @@
 
 #include "IMB_colormanagement.h"
 
+#include "GPU_simple_shader.h"
+
 #include "blf_internal_types.h"
 #include "blf_internal.h"
 
@@ -494,9 +496,10 @@ static void blf_draw_gl__start(FontBLF *font, GLint *mode)
         */
 
        glEnable(GL_BLEND);
-       glEnable(GL_TEXTURE_2D);
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 
+       GPU_simple_shader_bind(GPU_SHADER_TEXTURE_2D | GPU_SHADER_USE_COLOR);
+
        /* Save the current matrix mode. */
        glGetIntegerv(GL_MATRIX_MODE, mode);
 
@@ -536,8 +539,8 @@ static void blf_draw_gl__end(GLint mode)
        if (mode != GL_MODELVIEW)
                glMatrixMode(mode);
 
+       GPU_simple_shader_bind(GPU_SHADER_USE_COLOR);
        glDisable(GL_BLEND);
-       glDisable(GL_TEXTURE_2D);
 }
 
 void BLF_draw_ex(
index 843b0d5f2dc43391b4c1a7952b3bb7a30b6bf627..e0128660e77a2fdff77f2406c6caa1ceaaf936b3 100644 (file)
@@ -34,6 +34,7 @@
 #include "MEM_guardedalloc.h"
 
 #include "GPU_extensions.h"
+#include "GPU_simple_shader.h"
 
 #include "BLI_blenlib.h"
 #include "BLI_utildefines.h"
@@ -1122,7 +1123,7 @@ static void icon_draw_texture(
        y1 = iy * icongltex.invh;
        y2 = (iy + ih) * icongltex.invh;
 
-       glEnable(GL_TEXTURE_2D);
+       GPU_simple_shader_bind(GPU_SHADER_TEXTURE_2D | GPU_SHADER_USE_COLOR);
        glBindTexture(GL_TEXTURE_2D, icongltex.id);
 
        /* sharper downscaling, has no effect when scale matches with a mip level */
@@ -1145,7 +1146,7 @@ static void icon_draw_texture(
        glTexEnvf(GL_TEXTURE_FILTER_CONTROL, GL_TEXTURE_LOD_BIAS, 0.0f);
 
        glBindTexture(GL_TEXTURE_2D, 0);
-       glDisable(GL_TEXTURE_2D);
+       GPU_simple_shader_bind(GPU_SHADER_USE_COLOR);
 }
 
 /* Drawing size for preview images */
index 337a959200af58f6a025f84104c4cc35eba1352c..a7f239ed04c6e50882d55428bb11b8ec117c0b3b 100644 (file)
 #include "BIF_gl.h"
 #include "BIF_glutil.h"
 
-
 #include "IMB_colormanagement.h"
 #include "IMB_imbuf_types.h"
 
+#include "GPU_simple_shader.h"
+
 #include "UI_interface.h"
 
 #ifndef GL_CLAMP_TO_EDGE
@@ -589,7 +590,7 @@ void glaDrawPixelsTexScaled(float x, float y, int img_w, int img_h, int format,
                                        glTexSubImage2D(GL_TEXTURE_2D, 0, subpart_w, subpart_h, 1, 1, format, GL_UNSIGNED_BYTE, &uc_rect[(((size_t)subpart_y) * offset_y + subpart_h - 1) * img_w * components + (subpart_x * offset_x + subpart_w - 1) * components]);
                        }
 
-                       glEnable(GL_TEXTURE_2D);
+                       GPU_simple_shader_bind(GPU_SHADER_TEXTURE_2D | GPU_SHADER_USE_COLOR);
                        glBegin(GL_QUADS);
                        glTexCoord2f((float)(0 + offset_left) / tex_w, (float)(0 + offset_bot) / tex_h);
                        glVertex2f(rast_x + (float)offset_left * xzoom, rast_y + (float)offset_bot * yzoom);
@@ -603,7 +604,7 @@ void glaDrawPixelsTexScaled(float x, float y, int img_w, int img_h, int format,
                        glTexCoord2f((float)(0 + offset_left) / tex_w, (float)(subpart_h - offset_top) / tex_h);
                        glVertex2f(rast_x + (float)offset_left * xzoom, rast_y + (float)(subpart_h - offset_top) * yzoom * scaleY);
                        glEnd();
-                       glDisable(GL_TEXTURE_2D);
+                       GPU_simple_shader_bind(GPU_SHADER_USE_COLOR);
                }
        }
 
index 9f5602efad05cb78d6d042f4ec4c46b01fd58706..079d08882070a1b74102c6e0652fec6c277cab68 100644 (file)
@@ -59,6 +59,8 @@
 
 #include "ED_view3d.h"
 
+#include "GPU_simple_shader.h"
+
 #include "UI_resources.h"
 
 #include "paint_intern.h"
@@ -334,7 +336,7 @@ static int load_tex(Brush *br, ViewContext *vc, float zoom, bool col, bool prima
                target->old_col = col;
        }
 
-       glEnable(GL_TEXTURE_2D);
+       GPU_simple_shader_bind(GPU_SHADER_TEXTURE_2D | GPU_SHADER_USE_COLOR);
 
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
@@ -457,7 +459,7 @@ static int load_tex_cursor(Brush *br, ViewContext *vc, float zoom)
                        MEM_freeN(buffer);
        }
 
-       glEnable(GL_TEXTURE_2D);
+       GPU_simple_shader_bind(GPU_SHADER_TEXTURE_2D | GPU_SHADER_USE_COLOR);
 
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
@@ -793,6 +795,7 @@ static void paint_draw_alpha_overlay(UnifiedPaintSettings *ups, Brush *brush,
        }
 
        glPopAttrib();
+       GPU_simple_shader_bind(GPU_SHADER_USE_COLOR);
 }
 
 
index 848883aacc160d6e5585571684f1a8588b8b40e2..2d7367885ca54ba3d8a01668030767dc02daf101 100644 (file)
@@ -58,6 +58,8 @@
 #include "BIF_gl.h"
 #include "BIF_glutil.h"
 
+#include "GPU_simple_shader.h"
+
 #include "WM_types.h"
 
 #include "UI_interface.h"
@@ -1085,7 +1087,7 @@ static void draw_plane_marker_image(Scene *scene,
 
                        glColor4f(1.0, 1.0, 1.0, plane_track->image_opacity);
 
-                       glEnable(GL_TEXTURE_2D);
+                       GPU_simple_shader_bind(GPU_SHADER_TEXTURE_2D | GPU_SHADER_USE_COLOR);
                        glGenTextures(1, (GLuint *)&texid);
 
                        glBindTexture(GL_TEXTURE_2D, texid);
@@ -1109,7 +1111,7 @@ static void draw_plane_marker_image(Scene *scene,
                        glPopMatrix();
 
                        glBindTexture(GL_TEXTURE_2D, 0);
-                       glDisable(GL_TEXTURE_2D);
+                       GPU_simple_shader_bind(GPU_SHADER_USE_COLOR);
 
                        if (transparent) {
                                glDisable(GL_BLEND);
index e9539bcc4c98803cde8a33584461743759c7b7af..925804b8bb4414aacc08d605d8ed3d66533972b1 100644 (file)
@@ -58,6 +58,8 @@
 #include "BIF_gl.h"
 #include "BIF_glutil.h"
 
+#include "GPU_simple_shader.h"
+
 #include "ED_anim_api.h"
 #include "ED_gpencil.h"
 #include "ED_markers.h"
@@ -1294,7 +1296,7 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
 
        glColor4f(1.0, 1.0, 1.0, 1.0);
 
-       glEnable(GL_TEXTURE_2D);
+       GPU_simple_shader_bind(GPU_SHADER_TEXTURE_2D | GPU_SHADER_USE_COLOR);
        glGenTextures(1, (GLuint *)&texid);
 
        glBindTexture(GL_TEXTURE_2D, texid);
@@ -1369,7 +1371,7 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
        glEnd();
 
        glBindTexture(GL_TEXTURE_2D, 0);
-       glDisable(GL_TEXTURE_2D);
+       GPU_simple_shader_bind(GPU_SHADER_USE_COLOR);
        if (sseq->mainb == SEQ_DRAW_IMG_IMBUF && sseq->flag & SEQ_USE_ALPHA)
                glDisable(GL_BLEND);
        glDeleteTextures(1, &texid);
index 3734b5ab53026dacfb5187c1aace0c2c69af794c..0ac26e7d8837ef493516edac8299155f4d068c32 100644 (file)
 #include "ED_util.h"
 #include "ED_view3d.h"
 
+#include "GPU_simple_shader.h"
 #include "GPU_material.h"
 
 #include "RNA_access.h"
@@ -4179,7 +4180,7 @@ static void radial_control_paint_tex(RadialControl *rc, float radius, float alph
                }
 
                /* draw textured quad */
-               glEnable(GL_TEXTURE_2D);
+               GPU_simple_shader_bind(GPU_SHADER_TEXTURE_2D | GPU_SHADER_USE_COLOR);
                glBegin(GL_QUADS);
                glTexCoord2f(0, 0);
                glVertex2f(-radius, -radius);
@@ -4190,7 +4191,7 @@ static void radial_control_paint_tex(RadialControl *rc, float radius, float alph
                glTexCoord2f(0, 1);
                glVertex2f(-radius, radius);
                glEnd();
-               glDisable(GL_TEXTURE_2D);
+               GPU_simple_shader_bind(GPU_SHADER_USE_COLOR);
 
                /* undo rotation */
                if (rc->rot_prop)