implement setter for texture coord 2 (u,v) vertex attribute so it can be used by...
authorDiederick Niehorster <dcnieho@gmail.com>
Mon, 1 Apr 2013 12:01:17 +0000 (12:01 +0000)
committerDiederick Niehorster <dcnieho@gmail.com>
Mon, 1 Apr 2013 12:01:17 +0000 (12:01 +0000)
git-svn-id: svn+ssh://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@1570 7f0cb862-5218-0410-a997-914c9d46530a

include/GL/freeglut_ext.h
src/fg_ext.c
src/fg_geometry.c
src/fg_gl2.c
src/fg_internal.h
src/fg_window.c
src/freeglutdll.def.in

index 35e857c..1e0f444 100644 (file)
@@ -239,6 +239,7 @@ FGAPI void    FGAPIENTRY glutInitWarningFunc( void (* callback)( const char *fmt
 /* OpenGL >= 2.0 support */
 FGAPI void    FGAPIENTRY glutSetVertexAttribCoord3(GLint attrib);
 FGAPI void    FGAPIENTRY glutSetVertexAttribNormal(GLint attrib);
+FGAPI void    FGAPIENTRY glutSetVertexAttribTexCoord2(GLint attrib);
 
 /* Mobile platforms lifecycle */
 FGAPI void    FGAPIENTRY glutInitContextFunc(void (* callback)());
index 5107dfe..5e61e36 100644 (file)
@@ -205,6 +205,9 @@ static GLUTproc fghGetGLUTProcAddress( const char* procName )
     CHECK_NAME(glutInitContextFunc)
     CHECK_NAME(glutPauseFunc)
     CHECK_NAME(glutResumeFunc)
+    CHECK_NAME(glutSetVertexAttribCoord3)
+    CHECK_NAME(glutSetVertexAttribNormal)
+    CHECK_NAME(glutSetVertexAttribTexCoord2)
 #undef CHECK_NAME
 
     return NULL;
index 11bde1c..96f171e 100644 (file)
@@ -186,7 +186,7 @@ void fghDrawGeometrySolid(GLfloat *vertices, GLfloat *normals, GLfloat *textcs,
 {
     GLint attribute_v_coord   = fgStructure.CurrentWindow->Window.attribute_v_coord;
     GLint attribute_v_normal  = fgStructure.CurrentWindow->Window.attribute_v_normal;
-    GLint attribute_v_texture = -1;   // TODO!!!
+    GLint attribute_v_texture = fgStructure.CurrentWindow->Window.attribute_v_texture;
 
     if (fgStructure.CurrentWindow->State.VisualizeNormals)
         /* generate normals for each vertex to be drawn as well */
index deb4bb2..4ef87be 100644 (file)
@@ -37,6 +37,11 @@ void FGAPIENTRY glutSetVertexAttribNormal(GLint attrib) {
     fgStructure.CurrentWindow->Window.attribute_v_normal = attrib;
 }
 
+void FGAPIENTRY glutSetVertexAttribTexCoord2(GLint attrib) {
+    if (fgStructure.CurrentWindow != NULL)
+        fgStructure.CurrentWindow->Window.attribute_v_texture = attrib;
+}
+
 void fgInitGL2() {
 #ifndef GL_ES_VERSION_2_0
     fgState.HasOpenGL20 = 0;
index 25de1db..2de99b1 100644 (file)
@@ -371,8 +371,14 @@ struct tagSFG_Context
        SFG_PlatformContext pContext;    /* The window's FBConfig (X11) or device context (Windows) */
 
     int             DoubleBuffered;  /* Treat the window as double-buffered */
+
+    /* When drawing geometry to vertex attribute buffers, user specifies 
+     * the attribute indices for vertices, normals and/or texture coords
+     * to freeglut. Those are stored here
+     */
     GLint           attribute_v_coord;
     GLint           attribute_v_normal;
+    GLint           attribute_v_texture;
 };
 
 
index ad151cf..711defb 100644 (file)
@@ -148,6 +148,7 @@ void fgOpenWindow( SFG_Window* window, const char* title,
 #endif
     window->Window.attribute_v_coord = -1;
     window->Window.attribute_v_normal = -1;
+    window->Window.attribute_v_texture = -1;
 
     fgInitGL2();
 
index ca2fd31..d0c50c3 100644 (file)
@@ -157,6 +157,9 @@ EXPORTS
        glutMultiEntryFunc
        glutMultiMotionFunc
        glutMultiPassiveFunc
-        glutInitContextFunc
-        glutPauseFunc
-        glutResumeFunc
+    glutInitContextFunc
+    glutPauseFunc
+    glutResumeFunc
+    glutSetVertexAttribCoord3
+    glutSetVertexAttribNormal
+    glutSetVertexAttribTexCoord2