[Bf-blender-cvs] [e437841239] blender2.8: OpenGL immediate mode: modifying immDrawPixelsTex

Clément Foucault noreply at git.blender.org
Fri Feb 24 01:29:04 CET 2017


Commit: e4378412394caaf84215ae52af0a916b71804cd0
Author: Clément Foucault
Date:   Thu Feb 23 14:31:40 2017 +0100
Branches: blender2.8
https://developer.blender.org/rBe4378412394caaf84215ae52af0a916b71804cd0

OpenGL immediate mode: modifying immDrawPixelsTex

This way OCIO can be used with it.

===================================================================

M	source/blender/editors/interface/interface_draw.c
M	source/blender/editors/screen/glutil.c

===================================================================

diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index c96e5c7316..afb6422ec4 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -1735,6 +1735,7 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc
 				UI_draw_roundbox_gl_mode(GL_TRIANGLE_FAN, rect.xmin - 1, rect.ymin, rect.xmax + 1, rect.ymax + 1, 3.0f, color);
 			}
 
+			GPU_shader_unbind(); /* make sure there is no program bound */
 			immDrawPixelsTex(rect.xmin, rect.ymin + 1, drawibuf->x, drawibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_LINEAR, drawibuf->rect, 1.0f, 1.0f, img_col);
 
 			/* draw cross for pixel position */
diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c
index de24b8ec50..898fdb3bf9 100644
--- a/source/blender/editors/screen/glutil.c
+++ b/source/blender/editors/screen/glutil.c
@@ -618,8 +618,7 @@ void glaDrawPixelsAuto(float x, float y, int img_w, int img_h, int format, int t
 	                           0.0f, 0.0f, 0.0f, 0.0f);
 }
 
-/* TODO this is utterly slow and need some love
- * but in the meantime it's not using deprecated api */
+/* Use the currently bound shader if there is one */
 void immDrawPixelsTexScaled_clipping(float x, float y, int img_w, int img_h,
                                      int format, int type, int zoomfilter, void *rect,
                                      float scaleX, float scaleY,
@@ -687,9 +686,15 @@ void immDrawPixelsTexScaled_clipping(float x, float y, int img_w, int img_h,
 	unsigned int pos = add_attrib(vert_format, "pos", GL_FLOAT, 2, KEEP_FLOAT);
 	unsigned int texco = add_attrib(vert_format, "texCoord", GL_FLOAT, 2, KEEP_FLOAT);
 
-	immBindBuiltinProgram(GPU_SHADER_2D_IMAGE_COLOR);
-	immUniform4fv("color", color);
-	immUniform1i("image", 0);
+	unsigned int program = glaGetOneInt(GL_CURRENT_PROGRAM);
+
+	if (program)
+		immBindProgram(program);
+	else {
+		immBindBuiltinProgram(GPU_SHADER_2D_IMAGE_COLOR);
+		immUniform1i("image", 0);
+		immUniform4fv("color", color);
+	}
 
 	for (subpart_y = 0; subpart_y < nsubparts_y; subpart_y++) {
 		for (subpart_x = 0; subpart_x < nsubparts_x; subpart_x++) {




More information about the Bf-blender-cvs mailing list