summaryrefslogtreecommitdiffstats
path: root/progs
diff options
context:
space:
mode:
authorJosé Fonseca <[email protected]>2009-02-01 12:00:07 +0000
committerJosé Fonseca <[email protected]>2009-02-01 12:00:17 +0000
commit9aa73cfae84c7710df97ce182d32bea8d3423ab7 (patch)
tree07c1e2cf4938aff49ae73950eb4c197e6bd38bb8 /progs
parent7062b7c7cb32c3c96bb87b296d9df0ecae7e7c83 (diff)
progs: Get more samples building on windows.
Diffstat (limited to 'progs')
-rw-r--r--progs/SConscript1
-rw-r--r--progs/demos/SConscript26
-rw-r--r--progs/demos/fogcoord.c28
-rw-r--r--progs/demos/gloss.c2
-rw-r--r--progs/demos/multiarb.c2
-rw-r--r--progs/demos/rain.cxx2
-rw-r--r--progs/demos/stex3d.c4
-rw-r--r--progs/demos/winpos.c18
-rw-r--r--progs/trivial/fs-tri.c39
-rw-r--r--progs/util/SConscript15
10 files changed, 82 insertions, 55 deletions
diff --git a/progs/SConscript b/progs/SConscript
index ffb6de4f16c..631923a38ff 100644
--- a/progs/SConscript
+++ b/progs/SConscript
@@ -1,4 +1,5 @@
SConscript([
+ 'util/SConscript',
'demos/SConscript',
'trivial/SConscript',
'vp/SConscript',
diff --git a/progs/demos/SConscript b/progs/demos/SConscript
index 112da7bedb1..bc166dd7895 100644
--- a/progs/demos/SConscript
+++ b/progs/demos/SConscript
@@ -1,11 +1,22 @@
-Import('env')
+Import('*')
if not env['GLUT']:
Return()
env = env.Clone()
-env.Prepend(LIBS = ['$GLUT_LIB'])
+env.Prepend(CPPPATH = [
+ '../util',
+])
+
+env.Prepend(LIBS = [
+ util,
+ '$GLUT_LIB'
+])
+
+if env['platform'] == 'windows':
+ env.Append(CPPDEFINES = ['NOMINMAX'])
+ env.Prepend(LIBS = ['winmm'])
progs = [
'arbfplight',
@@ -38,7 +49,6 @@ progs = [
'multiarb',
'paltex',
'pointblast',
- 'rain',
'ray',
'readpix',
'reflect',
@@ -65,7 +75,15 @@ progs = [
]
for prog in progs:
- prog = env.Program(
+ env.Program(
target = prog,
source = prog + '.c',
)
+
+env.Program(
+ target = 'rain',
+ source = [
+ 'rain.cxx',
+ 'particles.cxx',
+ ]
+)
diff --git a/progs/demos/fogcoord.c b/progs/demos/fogcoord.c
index 00c73c6f048..6f50993c98f 100644
--- a/progs/demos/fogcoord.c
+++ b/progs/demos/fogcoord.c
@@ -7,19 +7,16 @@
* Daniel Borca
*/
-#define GL_GLEXT_PROTOTYPES
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
+#include <GL/glew.h>
#include <GL/glut.h>
#define DEPTH 5.0f
-static PFNGLFOGCOORDFEXTPROC glFogCoordf_ext;
static PFNGLFOGCOORDPOINTEREXTPROC glFogCoordPointer_ext;
-static GLboolean have_fog_coord;
-
static GLfloat camz;
static GLint fogMode;
@@ -45,10 +42,11 @@ Reset(void)
}
-static void APIENTRY
-glFogCoordf_nop (GLfloat f)
+static void
+glFogCoordf_ext (GLfloat f)
{
- (void)f;
+ if (fogCoord)
+ glFogCoordfEXT(f);
}
@@ -120,14 +118,11 @@ SetFogMode(GLint fogMode)
static GLboolean
SetFogCoord(GLboolean fogCoord)
{
- glFogCoordf_ext = glFogCoordf_nop;
-
- if (!have_fog_coord) {
+ if (!GLEW_EXT_fog_coord) {
return GL_FALSE;
}
if (fogCoord) {
- glFogCoordf_ext = (PFNGLFOGCOORDFEXTPROC)glutGetProcAddress("glFogCoordfEXT");
glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FOG_COORDINATE_EXT);
}
else {
@@ -340,7 +335,7 @@ Key( unsigned char key, int x, int y )
SetFogMode(fogMode);
break;
case 'c':
- fogCoord = SetFogCoord(fogCoord ^ GL_TRUE);
+ fogCoord = SetFogCoord(fogCoord ^ GL_TRUE);
break;
case 't':
Texture = !Texture;
@@ -372,8 +367,7 @@ Init(void)
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
- have_fog_coord = glutExtensionSupported("GL_EXT_fog_coord");
- if (!have_fog_coord) {
+ if (!GLEW_EXT_fog_coord) {
printf("GL_EXT_fog_coord not supported!\n");
}
@@ -400,10 +394,9 @@ Init(void)
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(2, GL_FLOAT, 0, texcoord_pointer);
- if (have_fog_coord) {
- glFogCoordPointer_ext = (PFNGLFOGCOORDPOINTEREXTPROC)glutGetProcAddress("glFogCoordPointerEXT");
+ if (GLEW_EXT_fog_coord) {
glEnableClientState(GL_FOG_COORDINATE_ARRAY_EXT);
- glFogCoordPointer_ext(GL_FLOAT, 0, fogcoord_pointer);
+ glFogCoordPointerEXT(GL_FLOAT, 0, fogcoord_pointer);
}
Reset();
@@ -417,6 +410,7 @@ main( int argc, char *argv[] )
glutInitWindowSize( 600, 600 );
glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
glutCreateWindow(argv[0]);
+ glewInit();
glutReshapeFunc( Reshape );
glutKeyboardFunc( Key );
glutDisplayFunc( Display );
diff --git a/progs/demos/gloss.c b/progs/demos/gloss.c
index 9974f0dab2e..b2126e32678 100644
--- a/progs/demos/gloss.c
+++ b/progs/demos/gloss.c
@@ -22,6 +22,7 @@
#include <stdlib.h>
#include <math.h>
#include <string.h>
+#include <GL/glew.h>
#include <GL/glut.h>
#include "readtex.h"
@@ -438,6 +439,7 @@ int main( int argc, char *argv[] )
glutInitWindowSize(WinWidth, WinHeight);
glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
glutCreateWindow(argv[0] );
+ glewInit();
glutReshapeFunc( Reshape );
glutKeyboardFunc( Key );
glutDisplayFunc( Display );
diff --git a/progs/demos/multiarb.c b/progs/demos/multiarb.c
index 451fd11efe1..85c4e3a266c 100644
--- a/progs/demos/multiarb.c
+++ b/progs/demos/multiarb.c
@@ -14,6 +14,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <GL/glew.h>
#include <GL/glut.h>
#include "readtex.h"
@@ -326,6 +327,7 @@ int main( int argc, char *argv[] )
glutInitWindowPosition( 0, 0 );
glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
glutCreateWindow(argv[0] );
+ glewInit();
Init( argc, argv );
diff --git a/progs/demos/rain.cxx b/progs/demos/rain.cxx
index 59b6471ef8f..265d90cd95f 100644
--- a/progs/demos/rain.cxx
+++ b/progs/demos/rain.cxx
@@ -24,8 +24,6 @@ extern "C" {
#ifdef _WIN32
#include <windows.h>
#include <mmsystem.h>
-#include "particles.cxx"
-#include "readtex.c"
#endif
#ifdef XMESA
diff --git a/progs/demos/stex3d.c b/progs/demos/stex3d.c
index 83ae3684ae2..c0bbea0960f 100644
--- a/progs/demos/stex3d.c
+++ b/progs/demos/stex3d.c
@@ -18,7 +18,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
-#include <GL/gl.h>
+#include <GL/glew.h>
#include <GL/glut.h>
@@ -662,6 +662,8 @@ main(int argc, char **argv)
exit(0);
}
+ glewInit();
+
init();
printHelp();
diff --git a/progs/demos/winpos.c b/progs/demos/winpos.c
index b58e3308643..13a9c7e9a8f 100644
--- a/progs/demos/winpos.c
+++ b/progs/demos/winpos.c
@@ -11,7 +11,7 @@
#ifdef _WIN32
#include <windows.h>
#endif
-#define GL_GLEXT_PROTOTYPES
+#include "GL/glew.h"
#include "GL/glut.h"
#include "readtex.h"
@@ -29,8 +29,7 @@ static GLubyte *Image;
static int ImgWidth, ImgHeight;
static GLenum ImgFormat;
-typedef void (APIENTRY * PFNWINDOWPOSFUNC)(GLfloat x, GLfloat y);
-static PFNWINDOWPOSFUNC WindowPosFunc;
+static PFNGLWINDOWPOS2FPROC WindowPosFunc;
static void draw( void )
{
@@ -71,19 +70,16 @@ static void reshape( int width, int height )
static void init( void )
{
-#ifdef GL_ARB_window_pos
- if (glutExtensionSupported("GL_ARB_window_pos")) {
+ if (GLEW_ARB_window_pos) {
printf("Using GL_ARB_window_pos\n");
- WindowPosFunc = &glWindowPos2fARB;
+ WindowPosFunc = glWindowPos2fARB;
}
else
-#elif defined(GL_MESA_window_pos)
- if (glutExtensionSupported("GL_MESA_window_pos")) {
+ if (GLEW_MESA_window_pos) {
printf("Using GL_MESA_window_pos\n");
- WindowPosFunc = &glWindowPos2fMESA;
+ WindowPosFunc = glWindowPos2fMESA;
}
else
-#endif
{
printf("Sorry, GL_ARB/MESA_window_pos extension not available.\n");
exit(1);
@@ -109,6 +105,8 @@ int main( int argc, char *argv[] )
exit(0);
}
+ glewInit();
+
init();
glutReshapeFunc( reshape );
diff --git a/progs/trivial/fs-tri.c b/progs/trivial/fs-tri.c
index 3be4d42e54c..6e86df1dcfa 100644
--- a/progs/trivial/fs-tri.c
+++ b/progs/trivial/fs-tri.c
@@ -5,10 +5,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
-#include <GL/gl.h>
+#include <GL/glew.h>
#include <GL/glut.h>
-#include <GL/glext.h>
-#include "extfuncs.h"
static GLuint fragShader;
@@ -56,9 +54,9 @@ Reshape(int width, int height)
static void
CleanUp(void)
{
- glDeleteShader_func(fragShader);
- glDeleteShader_func(vertShader);
- glDeleteProgram_func(program);
+ glDeleteShader(fragShader);
+ glDeleteShader(vertShader);
+ glDeleteProgram(program);
glutDestroyWindow(win);
}
@@ -110,15 +108,15 @@ LoadAndCompileShader(GLuint shader, const char *text)
{
GLint stat;
- glShaderSource_func(shader, 1, (const GLchar **) &text, NULL);
+ glShaderSource(shader, 1, (const GLchar **) &text, NULL);
- glCompileShader_func(shader);
+ glCompileShader(shader);
- glGetShaderiv_func(shader, GL_COMPILE_STATUS, &stat);
+ glGetShaderiv(shader, GL_COMPILE_STATUS, &stat);
if (!stat) {
GLchar log[1000];
GLsizei len;
- glGetShaderInfoLog_func(shader, 1000, &len, log);
+ glGetShaderInfoLog(shader, 1000, &len, log);
fprintf(stderr, "fslight: problem compiling shader:\n%s\n", log);
exit(1);
}
@@ -129,11 +127,11 @@ static void
CheckLink(GLuint prog)
{
GLint stat;
- glGetProgramiv_func(prog, GL_LINK_STATUS, &stat);
+ glGetProgramiv(prog, GL_LINK_STATUS, &stat);
if (!stat) {
GLchar log[1000];
GLsizei len;
- glGetProgramInfoLog_func(prog, 1000, &len, log);
+ glGetProgramInfoLog(prog, 1000, &len, log);
fprintf(stderr, "Linker error:\n%s\n", log);
}
}
@@ -165,24 +163,22 @@ Init(void)
exit(1);
}
- GetExtensionFuncs();
-
- fragShader = glCreateShader_func(GL_FRAGMENT_SHADER);
+ fragShader = glCreateShader(GL_FRAGMENT_SHADER);
LoadAndCompileShader(fragShader, fragShaderText);
#if 0
- vertShader = glCreateShader_func(GL_VERTEX_SHADER);
+ vertShader = glCreateShader(GL_VERTEX_SHADER);
LoadAndCompileShader(vertShader, vertShaderText);
#endif
- program = glCreateProgram_func();
- glAttachShader_func(program, fragShader);
+ program = glCreateProgram();
+ glAttachShader(program, fragShader);
#if 0
- glAttachShader_func(program, vertShader);
+ glAttachShader(program, vertShader);
#endif
- glLinkProgram_func(program);
+ glLinkProgram(program);
CheckLink(program);
- glUseProgram_func(program);
+ glUseProgram(program);
assert(glGetError() == 0);
@@ -200,6 +196,7 @@ main(int argc, char *argv[])
glutInitWindowSize(200, 200);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
win = glutCreateWindow(argv[0]);
+ glewInit();
glutReshapeFunc(Reshape);
glutKeyboardFunc(Key);
glutSpecialFunc(SpecialKey);
diff --git a/progs/util/SConscript b/progs/util/SConscript
new file mode 100644
index 00000000000..8ad2466291d
--- /dev/null
+++ b/progs/util/SConscript
@@ -0,0 +1,15 @@
+Import('env')
+
+env = env.Clone()
+
+util = env.StaticLibrary(
+ target = ['util'],
+ source = [
+ 'readtex.c',
+ 'trackball.c',
+ 'showbuffer.c',
+ 'shaderutil.c',
+ ],
+)
+
+Export('util')