summaryrefslogtreecommitdiff
path: root/progs/demos
diff options
context:
space:
mode:
Diffstat (limited to 'progs/demos')
-rw-r--r--progs/demos/Makefile.win23
-rw-r--r--progs/demos/arbfplight.c4
-rw-r--r--progs/demos/arbfslight.c2
-rw-r--r--progs/demos/fogcoord.c364
-rw-r--r--progs/demos/fplight.c6
-rw-r--r--progs/demos/fslight.c12
-rw-r--r--progs/demos/shadowtex.c17
-rw-r--r--progs/demos/tessdemo.c2
8 files changed, 233 insertions, 197 deletions
diff --git a/progs/demos/Makefile.win b/progs/demos/Makefile.win
index 4ac32361b2..0d0b19b9fe 100644
--- a/progs/demos/Makefile.win
+++ b/progs/demos/Makefile.win
@@ -22,9 +22,11 @@ LIBS = GLUT32.LIB OPENGL32.LIB
all: OPENGL32.DLL GLU32.DLL GLUT32.DLL \
readtex.h readtex.c showbuffer.h showbuffer.c \
+ extfuncs.h trackball.h trackball.c \
arbfplight.exe arbfslight.exe arbocclude.exe bounce.exe \
- clearspd.exe cubemap.exe drawpix.exe fire.exe fogcoord.exe \
- fplight.exe gamma.exe gearbox.exe \
+ clearspd.exe cubemap.exe drawpix.exe engine.exe \
+ fire.exe fogcoord.exe \
+ fplight.exe fslight.exe gamma.exe gearbox.exe \
gears.exe geartrain.exe gloss.exe \
glinfo.exe glslnoise.exe \
gltestperf.exe glutfx.exe ipers.exe isosurf.exe lodbias.exe \
@@ -42,14 +44,16 @@ bounce.exe: bounce.obj
clearspd.exe: clearspd.obj
cubemap.exe: cubemap.obj readtex.obj
drawpix.exe: drawpix.obj readtex.obj
+engine.exe: engine.obj readtex.obj trackball.obj
fire.exe: fire.obj readtex.obj
fogcoord.exe: fogcoord.obj readtex.obj
fplight.exe: fplight.obj
+fslight.exe: fslight.obj
gamma.exe: gamma.obj
gearbox.exe: gearbox.obj
gears.exe: gears.obj
geartrain.exe: geartrain.obj
-gloss.exe: gloss.obj readtex.obj
+gloss.exe: gloss.obj readtex.obj trackball.obj
glinfo.exe: glinfo.obj
glslnoise.exe: glslnoise.obj
gltestperf.exe: gltestperf.obj
@@ -105,14 +109,23 @@ showbuffer.c: $(TOP)\progs\util\showbuffer.c
showbuffer.h: $(TOP)\progs\util\showbuffer.h
copy $** .
+trackball.c: $(TOP)\progs\util\trackball.c
+ copy $** .
+
+trackball.h: $(TOP)\progs\util\trackball.h
+ copy $** .
+
+extfuncs.h: $(TOP)\progs\util\extfuncs.h
+ copy $** .
+
.obj.exe:
$(link) $(ldebug) -out:$@ $** /LIBPATH:$(LIBDIR) $(LIBS)
.c.obj:
- $(cc) $(cdebug) $(cflags) $(cvars) /I$(INCDIR) $*.c
+ $(cc) $(cdebug) $(cflags) $(cvars) -D_USE_MATH_DEFINES /I$(INCDIR) $*.c
clean::
- del *.obj *.exe readtex.* showbuffer.*
+ del *.obj *.exe readtex.* showbuffer.* trackball.*
clobber::
diff --git a/progs/demos/arbfplight.c b/progs/demos/arbfplight.c
index d9c564fbe5..bc2c7e312a 100644
--- a/progs/demos/arbfplight.c
+++ b/progs/demos/arbfplight.c
@@ -24,6 +24,7 @@ static GLuint VertProg;
static GLboolean Anim = GL_TRUE;
static GLboolean Wire = GL_FALSE;
static GLboolean PixelLight = GL_TRUE;
+static GLint Win;
static GLint T0 = 0;
static GLint Frames = 0;
@@ -148,6 +149,7 @@ static void Key( unsigned char key, int x, int y )
case 27:
glDeleteProgramsARB_func(1, &VertProg);
glDeleteProgramsARB_func(1, &FragProg);
+ glutDestroyWindow(Win);
exit(0);
break;
}
@@ -382,7 +384,7 @@ int main( int argc, char *argv[] )
glutInitWindowPosition( 0, 0 );
glutInitWindowSize( 200, 200 );
glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
- glutCreateWindow(argv[0]);
+ Win = glutCreateWindow(argv[0]);
glutReshapeFunc( Reshape );
glutKeyboardFunc( Key );
glutSpecialFunc( SpecialKey );
diff --git a/progs/demos/arbfslight.c b/progs/demos/arbfslight.c
index 374de56887..69575f0623 100644
--- a/progs/demos/arbfslight.c
+++ b/progs/demos/arbfslight.c
@@ -62,7 +62,7 @@ static PFNGLUNIFORM3FVARBPROC glUniform4fvARB = NULL;
static void normalize (GLfloat *dst, const GLfloat *src)
{
- GLfloat len = sqrtf (src[0] * src[0] + src[1] * src[1] + src[2] * src[2]);
+ GLfloat len = sqrt (src[0] * src[0] + src[1] * src[1] + src[2] * src[2]);
dst[0] = src[0] / len;
dst[1] = src[1] / len;
dst[2] = src[2] / len;
diff --git a/progs/demos/fogcoord.c b/progs/demos/fogcoord.c
index 19a15f05b8..00c73c6f04 100644
--- a/progs/demos/fogcoord.c
+++ b/progs/demos/fogcoord.c
@@ -7,151 +7,136 @@
* Daniel Borca
*/
-
+#define GL_GLEXT_PROTOTYPES
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <GL/glut.h>
-#include "readtex.h"
-
-#define TEXTURE_FILE "../images/bw.rgb"
-
-#define ARRAYS 0 /* use glDrawElements */
-
-#define VERBOSE 1 /* tell me what happens */
+#define DEPTH 5.0f
-#define DEPTH 15.0f
+static PFNGLFOGCOORDFEXTPROC glFogCoordf_ext;
+static PFNGLFOGCOORDPOINTEREXTPROC glFogCoordPointer_ext;
-#if !defined(GLAPIENTRYP)
-# define GLAPIENTRYP *
-#endif
-
-typedef void (GLAPIENTRYP GLFOGCOORDFEXTPROC) (GLfloat f);
-typedef void (GLAPIENTRYP GLFOGCOORDPOINTEREXTPROC) (GLenum, GLsizei, const GLvoid *);
-
-static GLFOGCOORDFEXTPROC glFogCoordf_ext;
-#if ARRAYS
-static GLFOGCOORDPOINTEREXTPROC glFogCoordPointer_ext;
-#endif
static GLboolean have_fog_coord;
static GLfloat camz;
-static GLuint texture[1];
static GLint fogMode;
static GLboolean fogCoord;
static GLfloat fogDensity = 0.75;
-static GLfloat fogStart = 1.0, fogEnd = 40.0;
+static GLfloat fogStart = 1.0, fogEnd = DEPTH;
static GLfloat fogColor[4] = {0.6f, 0.3f, 0.0f, 1.0f};
+static const char *ModeStr = NULL;
+static GLboolean Arrays = GL_FALSE;
+static GLboolean Texture = GL_TRUE;
-static void APIENTRY glFogCoordf_nop (GLfloat f)
+static void
+Reset(void)
{
- (void)f;
+ fogMode = 1;
+ fogCoord = 1;
+ fogDensity = 0.75;
+ fogStart = 1.0;
+ fogEnd = DEPTH;
+ Arrays = GL_FALSE;
+ Texture = GL_TRUE;
}
-static int BuildTexture (const char *filename, GLuint texid[])
+static void APIENTRY
+glFogCoordf_nop (GLfloat f)
{
- GLubyte *tex_data;
- GLenum tex_format;
- GLint tex_width, tex_height;
+ (void)f;
+}
- tex_data = LoadRGBImage(filename, &tex_width, &tex_height, &tex_format);
- if (tex_data == NULL) {
- return -1;
- }
- {
- GLint tex_max;
- glGetIntegerv(GL_MAX_TEXTURE_SIZE, &tex_max);
- if ((tex_width > tex_max) || (tex_height > tex_max)) {
- return -1;
- }
+static void
+PrintString(const char *s)
+{
+ while (*s) {
+ glutBitmapCharacter(GLUT_BITMAP_8_BY_13, (int) *s);
+ s++;
}
+}
- glGenTextures(1, texid);
-
- glBindTexture(GL_TEXTURE_2D, texid[0]);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-
- glTexImage2D(GL_TEXTURE_2D, 0, tex_format, tex_width, tex_height, 0,
- tex_format, GL_UNSIGNED_BYTE, tex_data);
- return 0;
+static void
+PrintInfo(void)
+{
+ char s[100];
+
+ glDisable(GL_FOG);
+ glColor3f(0, 1, 1);
+
+ sprintf(s, "Mode(m): %s Start(s/S): %g End(e/E): %g Density(d/D): %g",
+ ModeStr, fogStart, fogEnd, fogDensity);
+ glWindowPos2iARB(5, 20);
+ PrintString(s);
+
+ sprintf(s, "Arrays(a): %s glFogCoord(c): %s EyeZ(z/z): %g",
+ (Arrays ? "Yes" : "No"),
+ (fogCoord ? "Yes" : "No"),
+ camz);
+ glWindowPos2iARB(5, 5);
+ PrintString(s);
}
-static int SetFogMode (GLint fogMode)
+static int
+SetFogMode(GLint fogMode)
{
fogMode &= 3;
switch (fogMode) {
case 0:
+ ModeStr = "Off";
glDisable(GL_FOG);
-#if VERBOSE
- printf("fog(disable)\n");
-#endif
break;
case 1:
+ ModeStr = "GL_LINEAR";
glEnable(GL_FOG);
glFogi(GL_FOG_MODE, GL_LINEAR);
glFogf(GL_FOG_START, fogStart);
glFogf(GL_FOG_END, fogEnd);
-#if VERBOSE
- printf("fog(GL_LINEAR, %.2f, %.2f)\n", fogStart, fogEnd);
-#endif
break;
case 2:
+ ModeStr = "GL_EXP";
glEnable(GL_FOG);
glFogi(GL_FOG_MODE, GL_EXP);
glFogf(GL_FOG_DENSITY, fogDensity);
-#if VERBOSE
- printf("fog(GL_EXP, %.2f)\n", fogDensity);
-#endif
break;
case 3:
+ ModeStr = "GL_EXP2";
glEnable(GL_FOG);
glFogi(GL_FOG_MODE, GL_EXP2);
glFogf(GL_FOG_DENSITY, fogDensity);
-#if VERBOSE
- printf("fog(GL_EXP2, %.2f)\n", fogDensity);
-#endif
break;
}
return fogMode;
}
-static GLboolean SetFogCoord (GLboolean fogCoord)
+static GLboolean
+SetFogCoord(GLboolean fogCoord)
{
glFogCoordf_ext = glFogCoordf_nop;
if (!have_fog_coord) {
-#if VERBOSE
- printf("fog(GL_FRAGMENT_DEPTH_EXT)%s\n", fogCoord ? " EXT_fog_coord not available!" : "");
-#endif
return GL_FALSE;
}
if (fogCoord) {
- glFogCoordf_ext = (GLFOGCOORDFEXTPROC)glutGetProcAddress("glFogCoordfEXT");
+ glFogCoordf_ext = (PFNGLFOGCOORDFEXTPROC)glutGetProcAddress("glFogCoordfEXT");
glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FOG_COORDINATE_EXT);
-#if VERBOSE
- printf("fog(GL_FOG_COORDINATE_EXT)\n");
-#endif
- } else {
+ }
+ else {
glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FRAGMENT_DEPTH_EXT);
-#if VERBOSE
- printf("fog(GL_FRAGMENT_DEPTH_EXT)\n");
-#endif
}
return fogCoord;
}
-#if ARRAYS
/* could reuse vertices */
static GLuint vertex_index[] = {
/* Back */
@@ -172,19 +157,19 @@ static GLuint vertex_index[] = {
static GLfloat vertex_pointer[][3] = {
/* Back */
- {-2.5f,-2.5f,-DEPTH}, { 2.5f,-2.5f,-DEPTH}, { 2.5f, 2.5f,-DEPTH}, {-2.5f, 2.5f,-DEPTH},
+ {-1.0f,-1.0f,-DEPTH}, { 1.0f,-1.0f,-DEPTH}, { 1.0f, 1.0f,-DEPTH}, {-1.0f, 1.0f,-DEPTH},
/* Floor */
- {-2.5f,-2.5f,-DEPTH}, { 2.5f,-2.5f,-DEPTH}, { 2.5f,-2.5f, DEPTH}, {-2.5f,-2.5f, DEPTH},
+ {-1.0f,-1.0f,-DEPTH}, { 1.0f,-1.0f,-DEPTH}, { 1.0f,-1.0f, 0.0}, {-1.0f,-1.0f, 0.0},
/* Roof */
- {-2.5f, 2.5f,-DEPTH}, { 2.5f, 2.5f,-DEPTH}, { 2.5f, 2.5f, DEPTH}, {-2.5f, 2.5f, DEPTH},
+ {-1.0f, 1.0f,-DEPTH}, { 1.0f, 1.0f,-DEPTH}, { 1.0f, 1.0f, 0.0}, {-1.0f, 1.0f, 0.0},
/* Right */
- { 2.5f,-2.5f, DEPTH}, { 2.5f, 2.5f, DEPTH}, { 2.5f, 2.5f,-DEPTH}, { 2.5f,-2.5f,-DEPTH},
+ { 1.0f,-1.0f, 0.0}, { 1.0f, 1.0f, 0.0}, { 1.0f, 1.0f,-DEPTH}, { 1.0f,-1.0f,-DEPTH},
/* Left */
- {-2.5f,-2.5f, DEPTH}, {-2.5f, 2.5f, DEPTH}, {-2.5f, 2.5f,-DEPTH}, {-2.5f,-2.5f,-DEPTH}
+ {-1.0f,-1.0f, 0.0}, {-1.0f, 1.0f, 0.0}, {-1.0f, 1.0f,-DEPTH}, {-1.0f,-1.0f,-DEPTH}
};
static GLfloat texcoord_pointer[][2] = {
@@ -192,118 +177,139 @@ static GLfloat texcoord_pointer[][2] = {
{0.0f, 0.0f}, {1.0f, 0.0f}, {1.0f, 1.0f}, {0.0f, 1.0f},
/* Floor */
- {0.0f, 0.0f}, {1.0f, 0.0f}, {1.0f, 1.0f}, {0.0f, 1.0f},
+ {0.0f, 0.0f}, {1.0f, 0.0f}, {1.0f, DEPTH}, {0.0f, DEPTH},
/* Roof */
- {0.0f, 0.0f}, {1.0f, 0.0f}, {1.0f, 1.0f}, {0.0f, 1.0f},
+ {1.0f, 0.0f}, {0.0f, 0.0f}, {0.0f, DEPTH}, {1.0f, DEPTH},
/* Right */
- {0.0f, 0.0f}, {0.0f, 1.0f}, {1.0f, 1.0f}, {1.0f, 0.0f},
+ {0.0f, 1.0f}, {0.0f, 0.0f}, {DEPTH, 0.0f}, {DEPTH, 1.0f},
/* Left */
- {0.0f, 0.0f}, {0.0f, 1.0f}, {1.0f, 1.0f}, {1.0f, 0.0f}
+ {0.0f, 0.0f}, {0.0f, 1.0f}, {DEPTH, 1.0f}, {DEPTH, 0.0f}
};
-static GLfloat fogcoord_pointer[][1] = {
+static GLfloat fogcoord_pointer[] = {
/* Back */
- {1.0f}, {1.0f}, {1.0f}, {1.0f},
+ DEPTH, DEPTH, DEPTH, DEPTH,
/* Floor */
- {1.0f}, {1.0f}, {0.0f}, {0.0f},
+ DEPTH, DEPTH, 0.0, 0.0,
/* Roof */
- {1.0f}, {1.0f}, {0.0f}, {0.0f},
+ DEPTH, DEPTH, 0.0, 0.0,
/* Right */
- {0.0f}, {0.0f}, {1.0f}, {1.0f},
+ 0.0, 0.0, DEPTH, DEPTH,
/* Left */
- {0.0f}, {0.0f}, {1.0f}, {1.0f}
+ 0.0, 0.0, DEPTH, DEPTH
};
-#endif
-static void Display( void )
+static void
+Display( void )
{
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity ();
- glTranslatef(0.0f, 0.0f, camz);
+ glTranslatef(0.0f, 0.0f, -camz);
-#if ARRAYS
- glDrawElements(GL_QUADS, sizeof(vertex_index) / sizeof(vertex_index[0]), GL_UNSIGNED_INT, vertex_index);
-#else
- /* Back */
- glBegin(GL_QUADS);
- glFogCoordf_ext(1.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(-2.5f,-2.5f,-DEPTH);
- glFogCoordf_ext(1.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f( 2.5f,-2.5f,-DEPTH);
- glFogCoordf_ext(1.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f( 2.5f, 2.5f,-DEPTH);
- glFogCoordf_ext(1.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(-2.5f, 2.5f,-DEPTH);
- glEnd();
+ SetFogMode(fogMode);
- /* Floor */
- glBegin(GL_QUADS);
- glFogCoordf_ext(1.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(-2.5f,-2.5f,-DEPTH);
- glFogCoordf_ext(1.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f( 2.5f,-2.5f,-DEPTH);
- glFogCoordf_ext(0.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f( 2.5f,-2.5f, DEPTH);
- glFogCoordf_ext(0.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(-2.5f,-2.5f, DEPTH);
- glEnd();
+ glColor3f(1, 1, 1);
- /* Roof */
- glBegin(GL_QUADS);
- glFogCoordf_ext(1.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(-2.5f, 2.5f,-DEPTH);
- glFogCoordf_ext(1.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f( 2.5f, 2.5f,-DEPTH);
- glFogCoordf_ext(0.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f( 2.5f, 2.5f, DEPTH);
- glFogCoordf_ext(0.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(-2.5f, 2.5f, DEPTH);
- glEnd();
+ if (Texture)
+ glEnable(GL_TEXTURE_2D);
- /* Right */
- glBegin(GL_QUADS);
- glFogCoordf_ext(0.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f( 2.5f,-2.5f, DEPTH);
- glFogCoordf_ext(0.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f( 2.5f, 2.5f, DEPTH);
- glFogCoordf_ext(1.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f( 2.5f, 2.5f,-DEPTH);
- glFogCoordf_ext(1.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f( 2.5f,-2.5f,-DEPTH);
- glEnd();
+ if (Arrays) {
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+ glDrawElements(GL_QUADS, sizeof(vertex_index) / sizeof(vertex_index[0]),
+ GL_UNSIGNED_INT, vertex_index);
+ glDisableClientState(GL_VERTEX_ARRAY);
+ glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+ }
+ else {
+ /* Back */
+ glBegin(GL_QUADS);
+ glFogCoordf_ext(DEPTH); glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f,-1.0f,-DEPTH);
+ glFogCoordf_ext(DEPTH); glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f,-1.0f,-DEPTH);
+ glFogCoordf_ext(DEPTH); glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f,-DEPTH);
+ glFogCoordf_ext(DEPTH); glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f,-DEPTH);
+ glEnd();
+
+ /* Floor */
+ glBegin(GL_QUADS);
+ glFogCoordf_ext(DEPTH); glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f,-1.0f,-DEPTH);
+ glFogCoordf_ext(DEPTH); glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f,-1.0f,-DEPTH);
+ glFogCoordf_ext(0.0f); glTexCoord2f(1.0f, DEPTH); glVertex3f( 1.0f,-1.0f,0.0);
+ glFogCoordf_ext(0.0f); glTexCoord2f(0.0f, DEPTH); glVertex3f(-1.0f,-1.0f,0.0);
+ glEnd();
+
+ /* Roof */
+ glBegin(GL_QUADS);
+ glFogCoordf_ext(DEPTH); glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, 1.0f,-DEPTH);
+ glFogCoordf_ext(DEPTH); glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, 1.0f,-DEPTH);
+ glFogCoordf_ext(0.0f); glTexCoord2f(0.0f, DEPTH); glVertex3f( 1.0f, 1.0f,0.0);
+ glFogCoordf_ext(0.0f); glTexCoord2f(1.0f, DEPTH); glVertex3f(-1.0f, 1.0f,0.0);
+ glEnd();
+
+ /* Right */
+ glBegin(GL_QUADS);
+ glFogCoordf_ext(0.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f,-1.0f,0.0);
+ glFogCoordf_ext(0.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, 1.0f,0.0);
+ glFogCoordf_ext(DEPTH); glTexCoord2f(DEPTH, 0.0f); glVertex3f( 1.0f, 1.0f,-DEPTH);
+ glFogCoordf_ext(DEPTH); glTexCoord2f(DEPTH, 1.0f); glVertex3f( 1.0f,-1.0f,-DEPTH);
+ glEnd();
+
+ /* Left */
+ glBegin(GL_QUADS);
+ glFogCoordf_ext(0.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f,-1.0f,0.0);
+ glFogCoordf_ext(0.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f,0.0);
+ glFogCoordf_ext(DEPTH); glTexCoord2f(DEPTH, 1.0f); glVertex3f(-1.0f, 1.0f,-DEPTH);
+ glFogCoordf_ext(DEPTH); glTexCoord2f(DEPTH, 0.0f); glVertex3f(-1.0f,-1.0f,-DEPTH);
+ glEnd();
+ }
- /* Left */
- glBegin(GL_QUADS);
- glFogCoordf_ext(0.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(-2.5f,-2.5f, DEPTH);
- glFogCoordf_ext(0.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(-2.5f, 2.5f, DEPTH);
- glFogCoordf_ext(1.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f(-2.5f, 2.5f,-DEPTH);
- glFogCoordf_ext(1.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f(-2.5f,-2.5f,-DEPTH);
- glEnd();
-#endif
+ glDisable(GL_TEXTURE_2D);
+
+ PrintInfo();
glutSwapBuffers();
}
-static void Reshape( int width, int height )
+static void
+Reshape( int width, int height )
{
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
- gluPerspective(45.0f, (GLfloat)(width)/(GLfloat)(height), 0.1f, 100.0f);
+ glFrustum(-1, 1, -1, 1, 1.0, 100);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
-static void Key( unsigned char key, int x, int y )
+static void
+Key( unsigned char key, int x, int y )
{
(void) x;
(void) y;
switch (key) {
+ case 'a':
+ Arrays = !Arrays;
+ break;
case 'f':
+ case 'm':
fogMode = SetFogMode(fogMode + 1);
break;
- case '+':
- if (fogDensity < 1.0) {
- fogDensity += 0.05;
- }
+ case 'D':
+ fogDensity += 0.05;
SetFogMode(fogMode);
break;
- case '-':
+ case 'd':
if (fogDensity > 0.0) {
fogDensity -= 0.05;
}
@@ -311,31 +317,43 @@ static void Key( unsigned char key, int x, int y )
break;
case 's':
if (fogStart > 0.0) {
- fogStart -= 1.0;
+ fogStart -= 0.25;
}
SetFogMode(fogMode);
break;
case 'S':
- if (fogStart < fogEnd) {
- fogStart += 1.0;
+ if (fogStart < 100.0) {
+ fogStart += 0.25;
}
SetFogMode(fogMode);
break;
case 'e':
- if (fogEnd > fogStart) {
- fogEnd -= 1.0;
+ if (fogEnd > 0.0) {
+ fogEnd -= 0.25;
}
SetFogMode(fogMode);
break;
case 'E':
if (fogEnd < 100.0) {
- fogEnd += 1.0;
+ fogEnd += 0.25;
}
SetFogMode(fogMode);
break;
case 'c':
fogCoord = SetFogCoord(fogCoord ^ GL_TRUE);
break;
+ case 't':
+ Texture = !Texture;
+ break;
+ case 'z':
+ camz -= 0.1;
+ break;
+ case 'Z':
+ camz += 0.1;
+ break;
+ case 'r':
+ Reset();
+ break;
case 27:
exit(0);
break;
@@ -344,37 +362,28 @@ static void Key( unsigned char key, int x, int y )
}
-static void SpecialKey( int key, int x, int y )
+static void
+Init(void)
{
- (void) x;
- (void) y;
- switch (key) {
- case GLUT_KEY_UP:
- if (camz < (DEPTH - 1.0)) {
- camz += 1.0f;
- }
- break;
- case GLUT_KEY_DOWN:
- if (camz > -19.0) {
- camz -= 1.0f;
- }
- break;
- }
- glutPostRedisplay();
-}
+ static const GLubyte teximage[2][2][4] = {
+ { { 255, 255, 255, 255}, { 128, 128, 128, 255} },
+ { { 128, 128, 128, 255}, { 255, 255, 255, 255} }
+ };
+ printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
-static void Init( void )
-{
have_fog_coord = glutExtensionSupported("GL_EXT_fog_coord");
-
- if (BuildTexture(TEXTURE_FILE, texture) == -1) {
- exit(1);
+ if (!have_fog_coord) {
+ printf("GL_EXT_fog_coord not supported!\n");
}
- glEnable(GL_TEXTURE_2D);
- glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
- glClearDepth(1.0f);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0,
+ GL_RGBA, GL_UNSIGNED_BYTE, teximage);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+
+ glClearColor(0.1f, 0.1f, 0.1f, 0.0f);
+
glDepthFunc(GL_LEQUAL);
glEnable(GL_DEPTH_TEST);
glShadeModel(GL_SMOOTH);
@@ -383,11 +392,8 @@ static void Init( void )
glFogfv(GL_FOG_COLOR, fogColor);
glHint(GL_FOG_HINT, GL_NICEST);
fogCoord = SetFogCoord(GL_TRUE); /* try to enable fog_coord */
- fogMode = SetFogMode(2); /* GL_EXP */
-
- camz = -19.0f;
+ fogMode = SetFogMode(1);
-#if ARRAYS
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, vertex_pointer);
@@ -395,24 +401,24 @@ static void Init( void )
glTexCoordPointer(2, GL_FLOAT, 0, texcoord_pointer);
if (have_fog_coord) {
- glFogCoordPointer_ext = (GLFOGCOORDPOINTEREXTPROC)glutGetProcAddress("glFogCoordPointerEXT");
+ glFogCoordPointer_ext = (PFNGLFOGCOORDPOINTEREXTPROC)glutGetProcAddress("glFogCoordPointerEXT");
glEnableClientState(GL_FOG_COORDINATE_ARRAY_EXT);
glFogCoordPointer_ext(GL_FLOAT, 0, fogcoord_pointer);
}
-#endif
+
+ Reset();
}
-int main( int argc, char *argv[] )
+int
+main( int argc, char *argv[] )
{
glutInit( &argc, argv );
- glutInitWindowPosition( 0, 0 );
- glutInitWindowSize( 640, 480 );
+ glutInitWindowSize( 600, 600 );
glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
glutCreateWindow(argv[0]);
glutReshapeFunc( Reshape );
glutKeyboardFunc( Key );
- glutSpecialFunc( SpecialKey );
glutDisplayFunc( Display );
Init();
glutMainLoop();
diff --git a/progs/demos/fplight.c b/progs/demos/fplight.c
index c7a38248d3..fb510cccc8 100644
--- a/progs/demos/fplight.c
+++ b/progs/demos/fplight.c
@@ -24,7 +24,7 @@ static GLuint VertProg;
static GLboolean Anim = GL_TRUE;
static GLboolean Wire = GL_FALSE;
static GLboolean PixelLight = GL_TRUE;
-
+static GLint Win;
static GLfloat Xrot = 0, Yrot = 0;
@@ -136,8 +136,8 @@ static void Key( unsigned char key, int x, int y )
}
break;
case 27:
+ glutDestroyWindow(Win);
exit(0);
- break;
}
glutPostRedisplay();
}
@@ -272,7 +272,7 @@ int main( int argc, char *argv[] )
glutInitWindowPosition( 0, 0 );
glutInitWindowSize( 200, 200 );
glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
- glutCreateWindow(argv[0]);
+ Win = glutCreateWindow(argv[0]);
glutReshapeFunc( Reshape );
glutKeyboardFunc( Key );
glutSpecialFunc( SpecialKey );
diff --git a/progs/demos/fslight.c b/progs/demos/fslight.c
index 736cc48ac6..e6d83bf8fb 100644
--- a/progs/demos/fslight.c
+++ b/progs/demos/fslight.c
@@ -45,7 +45,7 @@ static GLint uTexture;
static GLuint SphereList, RectList, CurList;
static GLint win = 0;
-static GLboolean anim = GL_FALSE;
+static GLboolean anim = GL_TRUE;
static GLboolean wire = GL_FALSE;
static GLboolean pixelLight = GL_TRUE;
@@ -58,7 +58,7 @@ static GLfloat xRot = 90.0f, yRot = 0.0f;
static void
normalize(GLfloat *dst, const GLfloat *src)
{
- GLfloat len = sqrtf(src[0] * src[0] + src[1] * src[1] + src[2] * src[2]);
+ GLfloat len = sqrt(src[0] * src[0] + src[1] * src[1] + src[2] * src[2]);
dst[0] = src[0] / len;
dst[1] = src[1] / len;
dst[2] = src[2] / len;
@@ -477,8 +477,8 @@ Init(void)
version = (const char *) glGetString(GL_VERSION);
if (version[0] != '2' || version[1] != '.') {
- printf("Warning: this program expects OpenGL 2.0\n");
- /*exit(1);*/
+ printf("This program requires OpenGL 2.x, found %s\n", version);
+ exit(1);
}
GetExtensionFuncs();
@@ -579,6 +579,8 @@ Init(void)
#if 0
TestFunctions();
+#else
+ (void) TestFunctions;
#endif
}
@@ -603,7 +605,7 @@ main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitWindowPosition( 0, 0);
- glutInitWindowSize(100, 100);
+ glutInitWindowSize(200, 200);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
win = glutCreateWindow(argv[0]);
glutReshapeFunc(Reshape);
diff --git a/progs/demos/shadowtex.c b/progs/demos/shadowtex.c
index b32fb45b4f..b11c6f5363 100644
--- a/progs/demos/shadowtex.c
+++ b/progs/demos/shadowtex.c
@@ -296,14 +296,27 @@ RenderShadowMap(void)
0, 1, 0); /* up */
if (UseFBO) {
+ GLenum fbo_status;
+
glTexImage2D(GL_TEXTURE_2D, 0, depthFormat,
ShadowTexWidth, ShadowTexHeight, 0,
depthFormat, depthType, NULL);
+
+ /* Set the filter mode so that the texture is texture-complete.
+ * Otherwise it will cause the framebuffer to fail the framebuffer
+ * completeness test.
+ */
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, ShadowFBO);
glDrawBuffer(GL_NONE);
glReadBuffer(GL_NONE);
- assert(glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT)
- == GL_FRAMEBUFFER_COMPLETE_EXT);
+
+ fbo_status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
+ if (fbo_status != GL_FRAMEBUFFER_COMPLETE_EXT) {
+ fprintf(stderr, "FBO not complete! status = 0x%04x\n", fbo_status);
+ assert(fbo_status == GL_FRAMEBUFFER_COMPLETE_EXT);
+ }
}
assert(!glIsEnabled(GL_TEXTURE_1D));
diff --git a/progs/demos/tessdemo.c b/progs/demos/tessdemo.c
index 26403eee0a..f71cea1274 100644
--- a/progs/demos/tessdemo.c
+++ b/progs/demos/tessdemo.c
@@ -4,10 +4,10 @@
* Updated for GLU 1.3 tessellation by Gareth Hughes <gareth@valinux.com>
*/
-#include <GL/glut.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <GL/glut.h>
#define MAX_POINTS 256
#define MAX_CONTOURS 32