OpenGL: use simple shader for texture drawing in a few places.

Differential Revision: https://developer.blender.org/D1645
This commit is contained in:
Brecht Van Lommel 2015-11-28 01:20:28 +01:00
parent 147f7a1e86
commit cf921934b1
7 changed files with 28 additions and 15 deletions

@ -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(

@ -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 */

@ -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);
}
}

@ -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);
}

@ -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);

@ -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);

@ -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)