[Bf-blender-cvs] [d1b21d1] blender2.8: OpenGL: add support for programmable point size

Mike Erwin noreply at git.blender.org
Sat Oct 1 01:51:22 CEST 2016


Commit: d1b21d1278b3f91643fb52ed67320c064e28a0d4
Author: Mike Erwin
Date:   Fri Sep 30 19:51:04 2016 -0400
Branches: blender2.8
https://developer.blender.org/rBd1b21d1278b3f91643fb52ed67320c064e28a0d4

OpenGL: add support for programmable point size

And enable point sprites always. Fragment shaders can use gl_PointCoord now.

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

M	source/blender/gpu/GPU_draw.h
M	source/blender/gpu/intern/gpu_draw.c

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

diff --git a/source/blender/gpu/GPU_draw.h b/source/blender/gpu/GPU_draw.h
index 90b65af..91d4365 100644
--- a/source/blender/gpu/GPU_draw.h
+++ b/source/blender/gpu/GPU_draw.h
@@ -59,6 +59,13 @@ struct DupliObject;
 
 void GPU_state_init(void);
 
+/* Programmable point size
+ * - shaders set their own point size when enabled
+ * - use glPointSize when disabled */
+
+void GPU_enable_program_point_size(void);
+void GPU_disable_program_point_size(void);
+
 /* Material drawing
  * - first the state is initialized by a particular object and
  *   it's materials
diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c
index 25b28b1..96a35f0 100644
--- a/source/blender/gpu/intern/gpu_draw.c
+++ b/source/blender/gpu/intern/gpu_draw.c
@@ -2247,7 +2247,13 @@ void GPU_state_init(void)
 	glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
 
 	GPU_default_lights();
-	
+
+	GPU_disable_program_point_size();
+#ifdef __APPLE__
+	/* TODO: remove this when we switch to core profile */
+	glEnable(GL_POINT_SPRITE);
+#endif
+
 	glDepthFunc(GL_LEQUAL);
 	/* scaling matrices */
 	glEnable(GL_NORMALIZE);
@@ -2269,7 +2275,7 @@ void GPU_state_init(void)
 	glDisableClientState(GL_NORMAL_ARRAY);
 	glDisableClientState(GL_COLOR_ARRAY);
 	glDisableClientState(GL_TEXTURE_COORD_ARRAY);
-	
+
 	glPixelTransferi(GL_MAP_COLOR, GL_FALSE);
 	glPixelTransferi(GL_RED_SCALE, 1);
 	glPixelTransferi(GL_RED_BIAS, 0);
@@ -2279,7 +2285,7 @@ void GPU_state_init(void)
 	glPixelTransferi(GL_BLUE_BIAS, 0);
 	glPixelTransferi(GL_ALPHA_SCALE, 1);
 	glPixelTransferi(GL_ALPHA_BIAS, 0);
-	
+
 	glPixelTransferi(GL_DEPTH_BIAS, 0);
 	glPixelTransferi(GL_DEPTH_SCALE, 1);
 	glDepthRange(0.0, 1.0);
@@ -2297,6 +2303,26 @@ void GPU_state_init(void)
 	GPU_basic_shader_bind(GPU_SHADER_USE_COLOR);
 }
 
+void GPU_enable_program_point_size()
+{
+#ifdef __APPLE__
+	/* TODO: remove this when we switch to core profile */
+	glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
+#else
+	glEnable(GL_PROGRAM_POINT_SIZE);
+#endif
+}
+
+void GPU_disable_program_point_size()
+{
+#ifdef __APPLE__
+	/* TODO: remove this when we switch to core profile */
+	glDisable(GL_VERTEX_PROGRAM_POINT_SIZE);
+#else
+	glDisable(GL_PROGRAM_POINT_SIZE);
+#endif
+}
+
 #ifdef WITH_OPENSUBDIV
 /* Update face-varying variables offset which might be
  * different from mesh to mesh sharing the same material.




More information about the Bf-blender-cvs mailing list