From: Sylvain Beucler Date: Sat, 31 Mar 2012 20:52:48 +0000 (+0000) Subject: OpenGL 2.0: add 2 user-defined, per-context vertex attributes for coordinates and... X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=commitdiff_plain;h=39c957d9929f0aba775c4a07a70b6124bc4b50e6;p=freeglut OpenGL 2.0: add 2 user-defined, per-context vertex attributes for coordinates and normals (e.g. for use in fg_geometry) git-svn-id: svn+ssh://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@1221 7f0cb862-5218-0410-a997-914c9d46530a --- diff --git a/include/GL/freeglut_ext.h b/include/GL/freeglut_ext.h index 0fda0e2..911f224 100644 --- a/include/GL/freeglut_ext.h +++ b/include/GL/freeglut_ext.h @@ -226,6 +226,11 @@ FGAPI void FGAPIENTRY glutInitContextProfile( int profile ); FGAPI void FGAPIENTRY glutInitErrorFunc( void (* vError)( const char *fmt, va_list ap ) ); FGAPI void FGAPIENTRY glutInitWarningFunc( void (* vWarning)( const char *fmt, va_list ap ) ); +/* OpenGL >= 2.0 support */ +FGAPI void FGAPIENTRY glutSetVertexAttribCoord3(GLint attrib); +FGAPI void FGAPIENTRY glutSetVertexAttribNormal(GLint attrib); + + /* * GLUT API macro definitions -- the display mode definitions */ diff --git a/src/fg_gl2.c b/src/fg_gl2.c index 47913f4..e7dea50 100644 --- a/src/fg_gl2.c +++ b/src/fg_gl2.c @@ -27,6 +27,16 @@ #include "fg_internal.h" #include "fg_gl2.h" +void glutSetVertexAttribCoord3(GLint attrib) { + if (fgStructure.CurrentWindow != NULL) + fgStructure.CurrentWindow->Window.attribute_v_coord = attrib; +} + +void glutSetVertexAttribNormal(GLint attrib) { + if (fgStructure.CurrentWindow != NULL) + fgStructure.CurrentWindow->Window.attribute_v_normal = attrib; +} + typedef void (APIENTRY *PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers); typedef void (APIENTRY *PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); typedef void (APIENTRY *PFNGLBUFFERDATAPROC) (GLenum target, fghGLsizeiptr size, const GLvoid *data, GLenum usage); diff --git a/src/fg_gl2.h b/src/fg_gl2.h index 788db43..2450f8d 100644 --- a/src/fg_gl2.h +++ b/src/fg_gl2.h @@ -29,6 +29,7 @@ #ifndef APIENTRY # define APIENTRY #endif + typedef ptrdiff_t fghGLsizeiptr; typedef void (APIENTRY *PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers); typedef void (APIENTRY *PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); diff --git a/src/fg_internal.h b/src/fg_internal.h index c7dd53b..da0b44d 100644 --- a/src/fg_internal.h +++ b/src/fg_internal.h @@ -319,8 +319,8 @@ struct tagSFG_State int MajorVersion; /* Major OpenGL context version */ int MinorVersion; /* Minor OpenGL context version */ int ContextFlags; /* OpenGL context flags */ - int HasOpenGL20; /* fgInitGL2 could find all OpenGL 2.0 functions */ int ContextProfile; /* OpenGL context profile */ + int HasOpenGL20; /* fgInitGL2 could find all OpenGL 2.0 functions */ FGError ErrorFunc; /* User defined error handler */ FGWarning WarningFunc; /* User defined warning handler */ }; @@ -361,6 +361,8 @@ struct tagSFG_Context SFG_PlatformContext pContext; /* The window's FBConfig (X11) or device context (Windows) */ int DoubleBuffered; /* Treat the window as double-buffered */ + GLint attribute_v_coord; + GLint attribute_v_normal; }; diff --git a/src/fg_window.c b/src/fg_window.c index 06efa03..9a980f8 100644 --- a/src/fg_window.c +++ b/src/fg_window.c @@ -145,6 +145,8 @@ void fgOpenWindow( SFG_Window* window, const char* title, glReadBuffer ( GL_FRONT ); } #endif + window->Window.attribute_v_coord = -1; + window->Window.attribute_v_normal = -1; } /*