[Bf-blender-cvs] [6ce1d71914e] blender2.8: OpenGL: Convert drawobject.c (cont)

Clément Foucault noreply at git.blender.org
Thu Mar 9 22:28:25 CET 2017


Commit: 6ce1d71914e919ea3bcb9d9529193d8f247e0a9d
Author: Clément Foucault
Date:   Thu Mar 9 19:12:13 2017 +0100
Branches: blender2.8
https://developer.blender.org/rB6ce1d71914e919ea3bcb9d9529193d8f247e0a9d

OpenGL: Convert drawobject.c (cont)

Remove drawcircball
Convert texturespace, editfont, metaball (except for displist usage)

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

M	source/blender/editors/include/ED_view3d.h
M	source/blender/editors/space_view3d/drawobject.c

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

diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h
index b1b78a9876f..319d5afe0f3 100644
--- a/source/blender/editors/include/ED_view3d.h
+++ b/source/blender/editors/include/ED_view3d.h
@@ -281,7 +281,6 @@ float ED_view3d_radius_to_dist(
         const char persp, const bool use_aspect,
         const float radius);
 
-void drawcircball(int mode, const float cent[3], float rad, const float tmat[4][4]);
 void imm_drawcircball(const float cent[3], float rad, const float tmat[4][4], unsigned pos);
 
 /* backbuffer select and draw support */
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index 6852e171f56..973055a7d97 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -780,19 +780,6 @@ static void circball_array_fill(float verts[CIRCLE_RESOL][3], const float cent[3
 	}
 }
 
-/* DEPRECATED use imm_drawcircball instead */
-void drawcircball(int mode, const float cent[3], float rad, const float tmat[4][4])
-{
-	float verts[CIRCLE_RESOL][3];
-
-	circball_array_fill(verts, cent, rad, tmat);
-
-	glEnableClientState(GL_VERTEX_ARRAY);
-	glVertexPointer(3, GL_FLOAT, 0, verts);
-	glDrawArrays(mode, 0, CIRCLE_RESOL);
-	glDisableClientState(GL_VERTEX_ARRAY);
-}
-
 void imm_drawcircball(const float cent[3], float rad, const float tmat[4][4], unsigned pos)
 {
 	float verts[CIRCLE_RESOL][3];
@@ -5599,7 +5586,8 @@ static void draw_particle_arrays(int draw_as, int totpoint, int ob_dt, int selec
 	}
 }
 static void draw_particle(ParticleKey *state, int draw_as, short draw, float pixsize,
-                          float imat[4][4], const float draw_line[2], ParticleBillboardData *bb, ParticleDrawData *pdd)
+                          float imat[4][4], const float draw_line[2], ParticleBillboardData *bb, ParticleDrawData *pdd,
+                          unsigned int pos)
 {
 	float vec[3], vec2[3];
 	float *vd = NULL;
@@ -5709,7 +5697,7 @@ static void draw_particle(ParticleKey *state, int draw_as, short draw, float pix
 		}
 		case PART_DRAW_CIRC:
 		{
-			drawcircball(GL_LINE_LOOP, state->co, pixsize, imat);
+			imm_drawcircball(state->co, pixsize, imat, pos);
 			break;
 		}
 		case PART_DRAW_BB:
@@ -5750,7 +5738,8 @@ static void draw_particle(ParticleKey *state, int draw_as, short draw, float pix
 static void draw_particle_data(ParticleSystem *psys, RegionView3D *rv3d,
                                ParticleKey *state, int draw_as,
                                float imat[4][4], ParticleBillboardData *bb, ParticleDrawData *pdd,
-                               const float ct, const float pa_size, const float r_tilt, const float pixsize_scale)
+                               const float ct, const float pa_size, const float r_tilt, const float pixsize_scale,
+                               unsigned int pos)
 {
 	ParticleSettings *part = psys->part;
 	float pixsize;
@@ -5781,7 +5770,7 @@ static void draw_particle_data(ParticleSystem *psys, RegionView3D *rv3d,
 
 	pixsize = ED_view3d_pixel_size(rv3d, state->co) * pixsize_scale;
 
-	draw_particle(state, draw_as, part->draw, pixsize, imat, part->draw_line, bb, pdd);
+	draw_particle(state, draw_as, part->draw, pixsize, imat, part->draw_line, bb, pdd, pos);
 }
 /* unified drawing of all new particle systems draw types except dupli ob & group
  * mostly tries to use vertex arrays for speed
@@ -5818,6 +5807,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
 	GLint polygonmode[2];
 	char numstr[32];
 	unsigned char tcol[4] = {0, 0, 0, 255};
+	unsigned int pos;
 
 /* 1. */
 	if (part == NULL || !psys_check_enabled(ob, psys, G.is_rendering))
@@ -6062,6 +6052,11 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
 			totpoint = pdd->totpoint; /* draw data is up to date */
 		}
 		else {
+			if ((draw_as == PART_DRAW_CIRC) || (part->draw & PART_DRAW_SIZE)) {
+				pos = add_attrib(immVertexFormat(), "pos", GL_FLOAT, 3, KEEP_FLOAT);
+				immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
+				imm_cpack(0xFFFFFF);
+			}
 			for (a = 0, pa = pars; a < totpart + totchild; a++, pa++) {
 				/* setup per particle individual stuff */
 				if (a < totpart) {
@@ -6132,7 +6127,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
 
 						draw_particle_data(psys, rv3d,
 						                   &state, draw_as, imat, &bb, psys->pdd,
-						                   ct, pa_size, r_tilt, pixsize_scale);
+						                   ct, pa_size, r_tilt, pixsize_scale, pos);
 
 						totpoint++;
 						drawn = 1;
@@ -6144,7 +6139,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
 
 						draw_particle_data(psys, rv3d,
 						                   &state, draw_as, imat, &bb, psys->pdd,
-						                   pa_time, pa_size, r_tilt, pixsize_scale);
+						                   pa_time, pa_size, r_tilt, pixsize_scale, pos);
 
 						totpoint++;
 						drawn = 1;
@@ -6166,7 +6161,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
 
 					if (part->draw & PART_DRAW_SIZE) {
 						setlinestyle(3);
-						drawcircball(GL_LINE_LOOP, state.co, pa_size, imat);
+						imm_drawcircball(state.co, pa_size, imat, pos);
 						setlinestyle(0);
 					}
 
@@ -6203,6 +6198,9 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
 					}
 				}
 			}
+			if ((draw_as == PART_DRAW_CIRC) || (part->draw & PART_DRAW_SIZE)) {
+				immUnbindProgram();
+			}
 		}
 	}
 /* 6. */
@@ -7273,17 +7271,20 @@ static void draw_editnurb(
 
 static void draw_editfont_textcurs(RegionView3D *rv3d, float textcurs[4][2])
 {
-	cpack(0);
+	unsigned int pos = add_attrib(immVertexFormat(), "pos", GL_FLOAT, 2, KEEP_FLOAT);
 	ED_view3d_polygon_offset(rv3d, -1.0);
 	set_inverted_drawing(1);
-	glBegin(GL_QUADS);
-	glVertex2fv(textcurs[0]);
-	glVertex2fv(textcurs[1]);
-	glVertex2fv(textcurs[2]);
-	glVertex2fv(textcurs[3]);
-	glEnd();
+	immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+	imm_cpack(0);
+	immBegin(GL_TRIANGLE_FAN, 4);
+	immVertex2fv(pos, textcurs[0]);
+	immVertex2fv(pos, textcurs[1]);
+	immVertex2fv(pos, textcurs[2]);
+	immVertex2fv(pos, textcurs[3]);
+	immEnd();
 	set_inverted_drawing(0);
 	ED_view3d_polygon_offset(rv3d, 0.0);
+	immUnbindProgram();
 }
 
 static void draw_editfont(Scene *scene, SceneLayer *sl, View3D *v3d, RegionView3D *rv3d, Base *base,
@@ -7308,7 +7309,9 @@ static void draw_editfont(Scene *scene, SceneLayer *sl, View3D *v3d, RegionView3
 	}
 
 	if (cu->linewidth != 0.0f) {
-		UI_ThemeColor(TH_WIRE_EDIT);
+		unsigned int pos = add_attrib(immVertexFormat(), "pos", GL_FLOAT, 2, KEEP_FLOAT);
+		immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+		immUniformThemeColor(TH_WIRE_EDIT);
 		copy_v3_v3(vec1, ob->orig);
 		copy_v3_v3(vec2, ob->orig);
 		vec1[0] += cu->linewidth;
@@ -7316,31 +7319,35 @@ static void draw_editfont(Scene *scene, SceneLayer *sl, View3D *v3d, RegionView3
 		vec1[1] += cu->linedist * cu->fsize;
 		vec2[1] -= cu->lines * cu->linedist * cu->fsize;
 		setlinestyle(3);
-		glBegin(GL_LINES);
-		glVertex2fv(vec1);
-		glVertex2fv(vec2);
-		glEnd();
+		immBegin(GL_LINES, 2);
+		immVertex2fv(pos, vec1);
+		immVertex2fv(pos, vec2);
+		immEnd();
 		setlinestyle(0);
+		immUnbindProgram();
 	}
 
 	setlinestyle(3);
 	for (int i = 0; i < cu->totbox; i++) {
 		if (cu->tb[i].w != 0.0f) {
-			UI_ThemeColor(i == (cu->actbox - 1) ? TH_ACTIVE : TH_WIRE);
+			unsigned int pos = add_attrib(immVertexFormat(), "pos", GL_FLOAT, 3, KEEP_FLOAT);
+			immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
+			immUniformThemeColor(i == (cu->actbox - 1) ? TH_ACTIVE : TH_WIRE);
 			vec1[0] = cu->xof + cu->tb[i].x;
 			vec1[1] = cu->yof + cu->tb[i].y + cu->fsize;
 			vec1[2] = 0.001;
-			glBegin(GL_LINE_STRIP);
-			glVertex3fv(vec1);
+			immBegin(GL_LINE_STRIP, 5);
+			immVertex3fv(pos, vec1);
 			vec1[0] += cu->tb[i].w;
-			glVertex3fv(vec1);
+			immVertex3fv(pos, vec1);
 			vec1[1] -= cu->tb[i].h;
-			glVertex3fv(vec1);
+			immVertex3fv(pos, vec1);
 			vec1[0] -= cu->tb[i].w;
-			glVertex3fv(vec1);
+			immVertex3fv(pos, vec1);
 			vec1[1] += cu->tb[i].h;
-			glVertex3fv(vec1);
-			glEnd();
+			immVertex3fv(pos, vec1);
+			immEnd();
+			immUnbindProgram();
 		}
 	}
 	setlinestyle(0);
@@ -7350,7 +7357,9 @@ static void draw_editfont(Scene *scene, SceneLayer *sl, View3D *v3d, RegionView3
 		const int seltot = selend - selstart;
 		float selboxw;
 
-		cpack(0xffffff);
+		unsigned int pos = add_attrib(immVertexFormat(), "pos", GL_FLOAT, 3, KEEP_FLOAT);
+		immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
+		imm_cpack(0xffffff);
 		set_inverted_drawing(1);
 		for (int i = 0; i <= seltot; i++) {
 			EditFontSelBox *sb = &ef->selboxes[i];
@@ -7369,20 +7378,20 @@ static void draw_editfont(Scene *scene, SceneLayer *sl, View3D *v3d, RegionView3
 			/* fill in xy below */
 			tvec[2] = 0.001;
 
-			glBegin(GL_QUADS);
+			immBegin(GL_TRIANGLE_FAN, 4);
 
 			if (sb->rot == 0.0f) {
 				copy_v2_fl2(tvec, sb->x, sb->y);
-				glVertex3fv(tvec);
+				immVertex3fv(pos, tvec);
 
 				copy_v2_fl2(tvec, sb->x + selboxw, sb->y);
-				glVertex3fv(tvec);
+				immVertex3fv(pos, tvec);
 
 				copy_v2_fl2(tvec, sb->x + selboxw, sb->y + sb->h);
-				glVertex3fv(tvec);
+				immVertex3fv(pos, tvec);
 
 				copy_v2_fl2(tvec, sb->x, sb->y + sb->h);
-				glVertex3fv(tvec);
+				immVertex3fv(pos, tvec);
 			}
 			else {
 				float mat[2][2];
@@ -7390,27 +7399,28 @@ static void draw_editfont(Scene *scene, SceneLayer *sl, View3D *v3d, RegionView3
 				angle_to_mat2(mat, sb->rot);
 
 				copy_v2_fl2(tvec, sb->x, sb->y);
-				glVertex3fv(tvec);
+				immVertex3fv(pos, tvec);
 
 				copy_v2_fl2(tvec, selboxw, 0.0f);
 				mul_m2v2(mat, tvec);
 				add_v2_v2(tvec, &sb->x);
-				glVertex3fv(tvec);
+				immVertex3fv(pos, tvec);
 
 				copy_v2_fl2(tvec, selboxw, sb->h);
 				mul_m2v2(mat, tvec);
 				add_v2_v2(tvec, &sb->x);
-				glVertex3fv(tvec);
+				immVertex3fv(pos, tvec);
 
 				copy_v2_fl2(tvec, 0.0f, sb->h);
 				mul_m2v2(mat, tvec);
 				add_v2_v2(tvec, &sb->x);
-				glVertex3fv(tvec);
+				immVertex3fv(pos, tvec);
 			}
 
-			glEnd();
+			imm

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list