From b180b2a7d0d012ff8dc6a8c823dc358c378c4509 Mon Sep 17 00:00:00 2001 From: Diederick Niehorster Date: Mon, 1 Apr 2013 12:01:17 +0000 Subject: [PATCH] implement setter for texture coord 2 (u,v) vertex attribute so it can be used by FreeGLUT 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 | 1 + src/fg_ext.c | 3 +++ src/fg_geometry.c | 2 +- src/fg_gl2.c | 5 +++++ src/fg_internal.h | 6 ++++++ src/fg_window.c | 1 + src/freeglutdll.def.in | 9 ++++++--- 7 files changed, 23 insertions(+), 4 deletions(-) diff --git a/include/GL/freeglut_ext.h b/include/GL/freeglut_ext.h index 35e857c..1e0f444 100644 --- a/include/GL/freeglut_ext.h +++ b/include/GL/freeglut_ext.h @@ -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)()); diff --git a/src/fg_ext.c b/src/fg_ext.c index 5107dfe..5e61e36 100644 --- a/src/fg_ext.c +++ b/src/fg_ext.c @@ -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; diff --git a/src/fg_geometry.c b/src/fg_geometry.c index 11bde1c..96f171e 100644 --- a/src/fg_geometry.c +++ b/src/fg_geometry.c @@ -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 */ diff --git a/src/fg_gl2.c b/src/fg_gl2.c index deb4bb2..4ef87be 100644 --- a/src/fg_gl2.c +++ b/src/fg_gl2.c @@ -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; diff --git a/src/fg_internal.h b/src/fg_internal.h index 25de1db..2de99b1 100644 --- a/src/fg_internal.h +++ b/src/fg_internal.h @@ -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; }; diff --git a/src/fg_window.c b/src/fg_window.c index ad151cf..711defb 100644 --- a/src/fg_window.c +++ b/src/fg_window.c @@ -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(); diff --git a/src/freeglutdll.def.in b/src/freeglutdll.def.in index ca2fd31..d0c50c3 100644 --- a/src/freeglutdll.def.in +++ b/src/freeglutdll.def.in @@ -157,6 +157,9 @@ EXPORTS glutMultiEntryFunc glutMultiMotionFunc glutMultiPassiveFunc - glutInitContextFunc - glutPauseFunc - glutResumeFunc + glutInitContextFunc + glutPauseFunc + glutResumeFunc + glutSetVertexAttribCoord3 + glutSetVertexAttribNormal + glutSetVertexAttribTexCoord2 -- 1.7.10.4