implemented SUPER key/modifier support on windows
[freeglut] / src / fg_geometry.c
index 587501c..f5af166 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * freeglut_geometry.c
+ * fg_geometry.c
  *
  * Freeglut geometry rendering methods.
  *
 
 /* declare for drawing using the different OpenGL versions here so we can
    have a nice code order below */
-#ifndef GL_ES_VERSION_2_0
 static void fghDrawGeometryWire11(GLfloat *vertices, GLfloat *normals,
                                   GLushort *vertIdxs, GLsizei numParts, GLsizei numVertPerPart, GLenum vertexMode,
                                   GLushort *vertIdxs2, GLsizei numParts2, GLsizei numVertPerPart2
     );
 static void fghDrawGeometrySolid11(GLfloat *vertices, GLfloat *normals, GLfloat *textcs, GLsizei numVertices,
                                    GLushort *vertIdxs, GLsizei numParts, GLsizei numVertIdxsPerPart);
-#endif
 static void fghDrawGeometryWire20(GLfloat *vertices, GLfloat *normals, GLsizei numVertices,
                                   GLushort *vertIdxs, GLsizei numParts, GLsizei numVertPerPart, GLenum vertexMode,
                                   GLushort *vertIdxs2, GLsizei numParts2, GLsizei numVertPerPart2,
@@ -62,9 +60,7 @@ static void fghDrawGeometrySolid20(GLfloat *vertices, GLfloat *normals, GLfloat
                                    GLint attribute_v_coord, GLint attribute_v_normal, GLint attribute_v_texture);
 /* declare function for generating visualization of normals */
 static void fghGenerateNormalVisualization(GLfloat *vertices, GLfloat *normals, GLsizei numVertices);
-#ifndef GL_ES_VERSION_2_0
 static void fghDrawNormalVisualization11();
-#endif
 static void fghDrawNormalVisualization20(GLint attribute_v_coord);
 
 /* Drawing geometry:
@@ -138,8 +134,10 @@ void fghDrawGeometryWire(GLfloat *vertices, GLfloat *normals, GLsizei numVertice
                                 GLushort *vertIdxs2, GLsizei numParts2, GLsizei numVertPerPart2
     )
 {
-    GLint attribute_v_coord  = fgStructure.CurrentWindow->Window.attribute_v_coord;
-    GLint attribute_v_normal = fgStructure.CurrentWindow->Window.attribute_v_normal;
+    SFG_Window *win = fgStructure.CurrentWindow;
+
+    GLint attribute_v_coord  = win ? win->Window.attribute_v_coord : -1;
+    GLint attribute_v_normal = win ? win->Window.attribute_v_normal : -1;
 
     if (fgState.HasOpenGL20 && (attribute_v_coord != -1 || attribute_v_normal != -1))
         /* User requested a 2.0 draw */
@@ -147,12 +145,10 @@ void fghDrawGeometryWire(GLfloat *vertices, GLfloat *normals, GLsizei numVertice
                               vertIdxs, numParts, numVertPerPart, vertexMode,
                               vertIdxs2, numParts2, numVertPerPart2,
                               attribute_v_coord, attribute_v_normal);
-#ifndef GL_ES_VERSION_2_0
     else
         fghDrawGeometryWire11(vertices, normals,
                               vertIdxs, numParts, numVertPerPart, vertexMode,
                               vertIdxs2, numParts2, numVertPerPart2);
-#endif
 }
 
 /* Draw the geometric shape with filled triangles
@@ -184,11 +180,17 @@ void fghDrawGeometryWire(GLfloat *vertices, GLfloat *normals, GLsizei numVertice
 void fghDrawGeometrySolid(GLfloat *vertices, GLfloat *normals, GLfloat *textcs, GLsizei numVertices,
                           GLushort *vertIdxs, GLsizei numParts, GLsizei numVertIdxsPerPart)
 {
-    GLint attribute_v_coord   = fgStructure.CurrentWindow->Window.attribute_v_coord;
-    GLint attribute_v_normal  = fgStructure.CurrentWindow->Window.attribute_v_normal;
-    GLint attribute_v_texture = fgStructure.CurrentWindow->Window.attribute_v_texture;
+    GLint attribute_v_coord, attribute_v_normal, attribute_v_texture;
+    SFG_Window *win = fgStructure.CurrentWindow;
+    if(win) {
+        attribute_v_coord   = win->Window.attribute_v_coord;
+        attribute_v_normal  = win->Window.attribute_v_normal;
+        attribute_v_texture = win->Window.attribute_v_texture;
+    } else {
+        attribute_v_coord = attribute_v_normal = attribute_v_texture = -1;
+    }
 
-    if (fgStructure.CurrentWindow->State.VisualizeNormals)
+    if (win && win->State.VisualizeNormals)
         /* generate normals for each vertex to be drawn as well */
         fghGenerateNormalVisualization(vertices, normals, numVertices);
 
@@ -199,27 +201,24 @@ void fghDrawGeometrySolid(GLfloat *vertices, GLfloat *normals, GLfloat *textcs,
                                vertIdxs, numParts, numVertIdxsPerPart,
                                attribute_v_coord, attribute_v_normal, attribute_v_texture);
 
-        if (fgStructure.CurrentWindow->State.VisualizeNormals)
+        if (win && win->State.VisualizeNormals)
             /* draw normals for each vertex as well */
             fghDrawNormalVisualization20(attribute_v_coord);
     }
-#ifndef GL_ES_VERSION_2_0
     else
     {
         fghDrawGeometrySolid11(vertices, normals, textcs, numVertices,
                                vertIdxs, numParts, numVertIdxsPerPart);
 
-        if (fgStructure.CurrentWindow->State.VisualizeNormals)
+        if (win && win->State.VisualizeNormals)
             /* draw normals for each vertex as well */
             fghDrawNormalVisualization11();
     }
-#endif
 }
 
 
 
 /* Version for OpenGL (ES) 1.1 */
-#ifndef GL_ES_VERSION_2_0
 static void fghDrawGeometryWire11(GLfloat *vertices, GLfloat *normals,
                                   GLushort *vertIdxs, GLsizei numParts, GLsizei numVertPerPart, GLenum vertexMode,
                                   GLushort *vertIdxs2, GLsizei numParts2, GLsizei numVertPerPart2
@@ -282,7 +281,6 @@ static void fghDrawGeometrySolid11(GLfloat *vertices, GLfloat *normals, GLfloat
     if (textcs)
         glDisableClientState(GL_TEXTURE_COORD_ARRAY);
 }
-#endif
 
 /* Version for OpenGL (ES) >= 2.0 */
 static void fghDrawGeometryWire20(GLfloat *vertices, GLfloat *normals, GLsizei numVertices,
@@ -540,7 +538,6 @@ static void fghGenerateNormalVisualization(GLfloat *vertices, GLfloat *normals,
 }
 
 /* Version for OpenGL (ES) 1.1 */
-#ifndef GL_ES_VERSION_2_0
 static void fghDrawNormalVisualization11()
 {
     GLfloat currentColor[4];
@@ -559,7 +556,6 @@ static void fghDrawNormalVisualization11()
     free(verticesForNormalVisualization);
     glColor4f(currentColor[0],currentColor[1],currentColor[2],currentColor[3]);
 }
-#endif
 
 /* Version for OpenGL (ES) >= 2.0 */
 static void fghDrawNormalVisualization20(GLint attribute_v_coord)