From cf921934b1a6a30461779e26d67d02d0b66bdafc Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sat, 28 Nov 2015 01:20:28 +0100 Subject: OpenGL: use simple shader for texture drawing in a few places. Differential Revision: https://developer.blender.org/D1645 --- source/blender/blenfont/intern/blf.c | 7 +++++-- source/blender/editors/interface/interface_icons.c | 5 +++-- source/blender/editors/screen/glutil.c | 7 ++++--- source/blender/editors/sculpt_paint/paint_cursor.c | 7 +++++-- source/blender/editors/space_clip/clip_draw.c | 6 ++++-- source/blender/editors/space_sequencer/sequencer_draw.c | 6 ++++-- source/blender/windowmanager/intern/wm_operators.c | 5 +++-- 7 files changed, 28 insertions(+), 15 deletions(-) (limited to 'source') diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c index 3369e1c08b6..8b654d25bcf 100644 --- a/source/blender/blenfont/intern/blf.c +++ b/source/blender/blenfont/intern/blf.c @@ -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( diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index 843b0d5f2dc..e0128660e77 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -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 */ diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c index 337a959200a..a7f239ed04c 100644 --- a/source/blender/editors/screen/glutil.c +++ b/source/blender/editors/screen/glutil.c @@ -45,10 +45,11 @@ #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); } } diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index 9f5602efad0..079d0888207 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -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); } diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c index 848883aacc1..2d7367885ca 100644 --- a/source/blender/editors/space_clip/clip_draw.c +++ b/source/blender/editors/space_clip/clip_draw.c @@ -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); diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index e9539bcc4c9..925804b8bb4 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -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); diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 3734b5ab530..0ac26e7d883 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -105,6 +105,7 @@ #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) -- cgit v1.2.3