[Bf-blender-cvs] [169fc3b173] temp-blender2.8-stable: OpenGL immediate mode: interface_draw.c (end)

Clément Foucault noreply at git.blender.org
Fri Feb 10 18:04:26 CET 2017


Commit: 169fc3b173887f2c2cefacd18087734569cd9ff4
Author: Clément Foucault
Date:   Fri Feb 10 17:58:24 2017 +0100
Branches: temp-blender2.8-stable
https://developer.blender.org/rB169fc3b173887f2c2cefacd18087734569cd9ff4

OpenGL immediate mode: interface_draw.c (end)

Eradicate leftover legacy functions.
Fix a crash with histogram resolution.

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

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

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

diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index aedb55ea03..7b17c3d644 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -571,6 +571,10 @@ static void histogram_draw_one(
 {
 	float color[4] = {r, g, b, alpha};
 
+	/* that can happen */
+	if (res == 0)
+		return;
+
 	glEnable(GL_LINE_SMOOTH);
 	glBlendFunc(GL_SRC_ALPHA, GL_ONE);
 
@@ -1015,9 +1019,9 @@ void ui_draw_but_VECTORSCOPE(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wco
 		immEnd();
 	}
 	/* skin tone line */
-	glColor4f(1.0f, 0.4f, 0.0f, 0.2f);
-	fdrawline(polar_to_x(centerx, diam, 0.5f, skin_rad), polar_to_y(centery, diam, 0.5f, skin_rad),
-	          polar_to_x(centerx, diam, 0.1f, skin_rad), polar_to_y(centery, diam, 0.1f, skin_rad));
+	immUniformColor4f(1.0f, 0.4f, 0.0f, 0.2f);
+	imm_draw_line(pos, polar_to_x(centerx, diam, 0.5f, skin_rad), polar_to_y(centery, diam, 0.5f, skin_rad),
+	                   polar_to_x(centerx, diam, 0.1f, skin_rad), polar_to_y(centery, diam, 0.1f, skin_rad));
 	/* saturation points */
 	for (int i = 0; i < 6; i++)
 		vectorscope_draw_target(pos, centerx, centery, diam, colors[i]);
@@ -1473,11 +1477,11 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti
 	/* XXX 2.48 */
 #if 0
 	if (cumap->flag & CUMA_DRAW_CFRA) {
-		glColor3ub(0x60, 0xc0, 0x40);
-		glBegin(GL_LINES);
-		glVertex2f(rect->xmin + zoomx * (cumap->sample[0] - offsx), rect->ymin);
-		glVertex2f(rect->xmin + zoomx * (cumap->sample[0] - offsx), rect->ymax);
-		glEnd();
+		immUniformColor3ub(0x60, 0xc0, 0x40);
+		immBegin(GL_LINES, 2);
+		immVertex2f(pos, rect->xmin + zoomx * (cumap->sample[0] - offsx), rect->ymin);
+		immVertex2f(pos, rect->xmin + zoomx * (cumap->sample[0] - offsx), rect->ymax);
+		immEnd();
 	}
 #endif
 	/* sample option */
@@ -1760,26 +1764,31 @@ void ui_draw_but_NODESOCKET(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol
 	          BLI_rcti_size_x(&scissor_new),
 	          BLI_rcti_size_y(&scissor_new));
 	
-	glColor4ubv(but->col);
-	
 	float x = 0.5f * (recti->xmin + recti->xmax);
 	float y = 0.5f * (recti->ymin + recti->ymax);
-	
+
+	VertexFormat *format = immVertexFormat();
+	unsigned int pos = add_attrib(format, "pos", GL_FLOAT, 2, KEEP_FLOAT);
+	immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+	immUniformColor4ubv(but->col);
+
 	glEnable(GL_BLEND);
-	glBegin(GL_TRIANGLE_FAN);
+	immBegin(GL_TRIANGLE_FAN, 16);
 	for (int a = 0; a < 16; a++)
-		glVertex2f(x + size * si[a], y + size * co[a]);
-	glEnd();
+		immVertex2f(pos, x + size * si[a], y + size * co[a]);
+	immEnd();
 	
-	glColor4ub(0, 0, 0, 150);
+	immUniformColor4ub(0, 0, 0, 150);
 	glLineWidth(1);
 	glEnable(GL_LINE_SMOOTH);
-	glBegin(GL_LINE_LOOP);
+	immBegin(GL_LINE_LOOP, 16);
 	for (int a = 0; a < 16; a++)
-		glVertex2f(x + size * si[a], y + size * co[a]);
-	glEnd();
+		immVertex2f(pos, x + size * si[a], y + size * co[a]);
+	immEnd();
 	glDisable(GL_LINE_SMOOTH);
 	glDisable(GL_BLEND);
+
+	immUnbindProgram();
 	
 	/* restore scissortest */
 	glScissor(scissor[0], scissor[1], scissor[2], scissor[3]);




More information about the Bf-blender-cvs mailing list