progs: Port vp-tris to glew.
authorJosé Fonseca <jfonseca@vmware.com>
Fri, 23 Jan 2009 16:24:43 +0000 (16:24 +0000)
committerJosé Fonseca <jfonseca@vmware.com>
Fri, 23 Jan 2009 17:09:51 +0000 (17:09 +0000)
There was some wglGetProcAddress calls to setup extensions already, but
including glext caused many compilation errors in MinGW.

progs/SConscript
progs/vp/Makefile
progs/vp/SConscript [new file with mode: 0644]
progs/vp/vp-tris.c

index 245fc267257c588c9772b86a1303ef1bedd452d5..ffb6de4f16c6e1c2783bb4155d0679e15dc67df6 100644 (file)
@@ -1,4 +1,5 @@
 SConscript([
     'demos/SConscript',
     'trivial/SConscript',
+    'vp/SConscript',
 ])
index 41d025c574625586d5ee9d4f3b76c76f18381f6e..58a0dacb22ec9c4629f4d9efb7a7887ed6cd9833 100644 (file)
@@ -8,7 +8,7 @@ TOP = ../..
 include $(TOP)/configs/current
 
 
-LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
+LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
 
 SOURCES = \
        vp-tris.c
diff --git a/progs/vp/SConscript b/progs/vp/SConscript
new file mode 100644 (file)
index 0000000..640c5dd
--- /dev/null
@@ -0,0 +1,13 @@
+Import('env')
+
+if not env['GLUT']:
+    Return()
+
+env = env.Clone()
+
+env.Prepend(LIBS = ['$GLUT_LIB'])
+
+env.Program(
+        target = 'vp-tris',
+        source = ['vp-tris.c'],
+    )
index e1ddb2e14d23d75d7ee3ef83bef73939cc7c919c..87cb12b98466f3d93d79d8054e084fde8113b3fd 100644 (file)
@@ -9,25 +9,11 @@
 #ifndef WIN32
 #include <unistd.h>
 #include <signal.h>
-#define GL_GLEXT_PROTOTYPES
-#else
-#include <GL/glext.h>
 #endif
 
+#include <GL/glew.h>
 #include <GL/glut.h>
 
-#ifdef WIN32
-static PFNGLBINDPROGRAMARBPROC glBindProgramARB = NULL;
-static PFNGLGENPROGRAMSARBPROC glGenProgramsARB = NULL;
-static PFNGLPROGRAMSTRINGARBPROC glProgramStringARB = NULL;
-static PFNGLISPROGRAMARBPROC glIsProgramARB = NULL;
-
-static PFNGLBINDPROGRAMNVPROC glBindProgramNV = NULL;
-static PFNGLGENPROGRAMSNVPROC glGenProgramsNV = NULL;
-static PFNGLLOADPROGRAMNVPROC glLoadProgramNV = NULL;
-static PFNGLISPROGRAMNVPROC glIsProgramNV = NULL;
-#endif
-
 static const char *filename = NULL;
 static GLuint nr_steps = 4;
 
@@ -115,13 +101,6 @@ static void Init( void )
    fprintf(stderr, "%.*s\n", sz, buf);
 
    if (strncmp( buf, "!!VP", 4 ) == 0) {
-#ifdef WIN32
-      glBindProgramNV = (PFNGLBINDPROGRAMNVPROC) wglGetProcAddress( "glBindProgramNV" );
-      glGenProgramsNV = (PFNGLGENPROGRAMSNVPROC) wglGetProcAddress( "glGenProgramsNV" );
-      glLoadProgramNV = (PFNGLLOADPROGRAMNVPROC) wglGetProcAddress( "glLoadProgramNV" );
-      glIsProgramNV = (PFNGLISPROGRAMNVPROC) wglGetProcAddress( "glIsProgramNV" );
-#endif
-
       glEnable( GL_VERTEX_PROGRAM_NV );
       glGenProgramsNV( 1, &prognum );
       glBindProgramNV( GL_VERTEX_PROGRAM_NV, prognum );
@@ -129,13 +108,6 @@ static void Init( void )
       assert( glIsProgramNV( prognum ) );
    }
    else {
-#ifdef WIN32
-      glBindProgramARB = (PFNGLBINDPROGRAMARBPROC) wglGetProcAddress( "glBindProgramARB" );
-      glGenProgramsARB = (PFNGLGENPROGRAMSARBPROC) wglGetProcAddress( "glGenProgramsARB" );
-      glProgramStringARB = (PFNGLPROGRAMSTRINGARBPROC) wglGetProcAddress( "glProgramStringARB" );
-      glIsProgramARB = (PFNGLISPROGRAMARBPROC) wglGetProcAddress( "glIsProgramARB" );
-#endif
-
       glEnable(GL_VERTEX_PROGRAM_ARB);
 
       glGenProgramsARB(1, &prognum);
@@ -288,6 +260,7 @@ int main( int argc, char *argv[] )
    glutInitWindowSize( 250, 250 );
    glutInitDisplayMode( GLUT_RGB | GLUT_SINGLE | GLUT_DEPTH );
    glutCreateWindow(argv[argc-1]);
+   glewInit();
    glutReshapeFunc( Reshape );
    glutKeyboardFunc( Key );
    glutDisplayFunc( Display );