diff options
Diffstat (limited to 'progs/vp/vp-tris.c')
-rw-r--r-- | progs/vp/vp-tris.c | 63 |
1 files changed, 55 insertions, 8 deletions
diff --git a/progs/vp/vp-tris.c b/progs/vp/vp-tris.c index eb450cb5981..3fe35f7e3e6 100644 --- a/progs/vp/vp-tris.c +++ b/progs/vp/vp-tris.c @@ -5,10 +5,27 @@ #include <stdio.h> #include <stdlib.h> #include <math.h> -#define GL_GLEXT_PROTOTYPES #include <GL/glut.h> + +#ifndef WIN32 #include <unistd.h> #include <signal.h> +#define GL_GLEXT_PROTOTYPES +#else +#include <GL/glext.h> +#endif + +#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; @@ -25,6 +42,9 @@ static void usage( char *name ) unsigned show_fps = 0; unsigned int frame_cnt = 0; + +#ifndef WIN32 + void alarmhandler(int); void alarmhandler (int sig) @@ -39,6 +59,8 @@ void alarmhandler (int sig) alarm(5); } +#endif + static void args(int argc, char *argv[]) { GLint i; @@ -83,7 +105,7 @@ static void Init( void ) exit(1); } - sz = fread(buf, 1, sizeof(buf), f); + sz = (GLuint) fread(buf, 1, sizeof(buf), f); if (!feof(f)) { fprintf(stderr, "file too long\n"); exit(1); @@ -91,13 +113,37 @@ static void Init( void ) fprintf(stderr, "%.*s\n", sz, buf); - glEnable(GL_VERTEX_PROGRAM_NV); + 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 ); + glLoadProgramNV( GL_VERTEX_PROGRAM_NV, prognum, sz, (const GLubyte *) buf ); + assert( glIsProgramNV( prognum ) ); + } + else { +#ifdef WIN32 + glBindProgramARB = (PFNGLBINDPROGRAMARBPROC) wglGetProcAddress( "glBindProgramARB" ); + glGenProgramsARB = (PFNGLGENPROGRAMSARBPROC) wglGetProcAddress( "glGenProgramsARB" ); + glProgramStringARB = (PFNGLPROGRAMSTRINGARBPROC) wglGetProcAddress( "glProgramStringARB" ); + glIsProgramARB = (PFNGLISPROGRAMARBPROC) wglGetProcAddress( "glIsProgramARB" ); +#endif - glGenProgramsARB(1, &prognum); + glEnable(GL_VERTEX_PROGRAM_ARB); - glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prognum); - glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, - sz, (const GLubyte *) buf); + glGenProgramsARB(1, &prognum); + + glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prognum); + glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + sz, (const GLubyte *) buf); + assert(glIsProgramARB(prognum)); + } errno = glGetError(); printf("glGetError = %d\n", errno); @@ -109,7 +155,6 @@ static void Init( void ) printf("errorpos: %d\n", errorpos); printf("%s\n", (char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB)); } - assert(glIsProgramARB(prognum)); } @@ -236,10 +281,12 @@ int main( int argc, char *argv[] ) glutDisplayFunc( Display ); args( argc, argv ); Init(); +#ifndef WIN32 if (show_fps) { signal(SIGALRM, alarmhandler); alarm(5); } +#endif glutMainLoop(); return 0; } |