mojoshader_opengl.c
changeset 1197 4883fc7d3751
parent 1196 906becfc1042
child 1207 c4a393403859
--- a/mojoshader_opengl.c	Tue Apr 23 01:00:59 2019 -0400
+++ b/mojoshader_opengl.c	Tue Apr 23 01:42:58 2019 -0400
@@ -279,6 +279,7 @@
     void (*profilePushSampler)(GLint loc, GLuint sampler);
     int (*profileMustPushConstantArrays)(void);
     int (*profileMustPushSamplers)(void);
+    void (*profileToggleProgramPointSize)(int enable);
 };
 
 
@@ -919,6 +920,20 @@
 
 #endif  // SUPPORT_PROFILE_ARB1
 
+#if SUPPORT_PROFILE_GLSL || SUPPORT_PROFILE_ARB1
+
+static void impl_REAL_ToggleProgramPointSize(int enable)
+{
+    toggle_gl_state(GL_PROGRAM_POINT_SIZE, enable);
+} // impl_REAL_ToggleProgramPointSize
+
+static void impl_NOOP_ToggleProgramPointSize(int enable)
+{
+    // No-op, this profile's GL context forces this to always be on
+} // impl_NOOP_ToggleProgramPointSize
+
+#endif // SUPPORT_PROFILE_GLSL || SUPPORT_PROFILE_ARB1
+
 
 const char *MOJOSHADER_glGetError(void)
 {
@@ -1463,6 +1478,10 @@
         ctx->profilePushSampler = impl_GLSL_PushSampler;
         ctx->profileMustPushConstantArrays = impl_GLSL_MustPushConstantArrays;
         ctx->profileMustPushSamplers = impl_GLSL_MustPushSamplers;
+        if (strcmp(profile, MOJOSHADER_PROFILE_GLSLES) == 0)
+            ctx->profileToggleProgramPointSize = impl_NOOP_ToggleProgramPointSize;
+        else
+            ctx->profileToggleProgramPointSize = impl_REAL_ToggleProgramPointSize;
     } // if
 #endif
 
@@ -1488,6 +1507,7 @@
         ctx->profilePushSampler = impl_ARB1_PushSampler;
         ctx->profileMustPushConstantArrays = impl_ARB1_MustPushConstantArrays;
         ctx->profileMustPushSamplers = impl_ARB1_MustPushSamplers;
+        ctx->profileToggleProgramPointSize = impl_REAL_ToggleProgramPointSize;
     } // if
 #endif
 
@@ -1507,6 +1527,7 @@
     assert(ctx->profilePushSampler != NULL);
     assert(ctx->profileMustPushConstantArrays != NULL);
     assert(ctx->profileMustPushSamplers != NULL);
+    assert(ctx->profileToggleProgramPointSize != NULL);
 
     retval = ctx;
     ctx = current_ctx;
@@ -2402,10 +2423,7 @@
 
     if (program->uses_pointsize != ctx->pointsize_enabled)
     {
-        if (program->uses_pointsize)
-            ctx->glEnable(GL_PROGRAM_POINT_SIZE);
-        else
-            ctx->glDisable(GL_PROGRAM_POINT_SIZE);
+        ctx->profileToggleProgramPointSize(program->uses_pointsize);
         ctx->pointsize_enabled = program->uses_pointsize;
     } // if