summaryrefslogtreecommitdiffstats
path: root/progs/demos
diff options
context:
space:
mode:
Diffstat (limited to 'progs/demos')
-rw-r--r--progs/demos/.gitignore1
-rw-r--r--progs/demos/cubemap.c59
-rw-r--r--progs/demos/isosurf.c4
-rw-r--r--progs/demos/pointblast.c4
-rw-r--r--progs/demos/spriteblast.c4
-rw-r--r--progs/demos/vao_demo.c2
6 files changed, 54 insertions, 20 deletions
diff --git a/progs/demos/.gitignore b/progs/demos/.gitignore
index f3c7091bcc2..5dd974b63dc 100644
--- a/progs/demos/.gitignore
+++ b/progs/demos/.gitignore
@@ -63,3 +63,4 @@ tunnel2
vao_demo
Windows
winpos
+*.rgb
diff --git a/progs/demos/cubemap.c b/progs/demos/cubemap.c
index 26db42aed5e..0df5ff09c33 100644
--- a/progs/demos/cubemap.c
+++ b/progs/demos/cubemap.c
@@ -43,6 +43,9 @@
#include "GL/glut.h"
#include "readtex.h"
+#ifndef GL_TEXTURE_CUBE_MAP_SEAMLESS
+#define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F
+#endif
static GLfloat Xrot = 0, Yrot = 0;
static GLfloat EyeDist = 10;
@@ -52,6 +55,9 @@ static GLboolean NoClear = GL_FALSE;
static GLint FrameParity = 0;
static GLenum FilterIndex = 0;
static GLint ClampIndex = 0;
+static GLboolean supportFBO = GL_FALSE;
+static GLboolean supportSeamless = GL_FALSE;
+static GLboolean seamless = GL_FALSE;
static struct {
@@ -90,7 +96,9 @@ static struct {
-#define eps1 0.99
+/* The effects of GL_ARB_seamless_cube_map don't show up unless eps1 is 1.0.
+ */
+#define eps1 1.0 /*0.99*/
#define br 20.0 /* box radius */
static const GLfloat tex_coords[] = {
@@ -230,6 +238,13 @@ static void draw( void )
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MAG_FILTER,
FilterModes[FilterIndex].mag_mode);
+ if (supportSeamless) {
+ if (seamless) {
+ glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS);
+ } else {
+ glDisable(GL_TEXTURE_CUBE_MAP_SEAMLESS);
+ }
+ }
wrap = ClampModes[ClampIndex].mode;
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_S, wrap);
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_T, wrap);
@@ -320,6 +335,11 @@ static void key(unsigned char k, int x, int y)
mode = !mode;
set_mode(mode);
break;
+ case 's':
+ seamless = ! seamless;
+ printf("Seamless cube map filtering is %sabled\n",
+ (seamless) ? "en" : "dis" );
+ break;
case 'v':
use_vertex_arrays = ! use_vertex_arrays;
printf( "Vertex arrays are %sabled\n",
@@ -403,6 +423,10 @@ static void init_checkers( void )
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+ if (!supportFBO)
+ glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_GENERATE_MIPMAP_SGIS, GL_TRUE);
+
+
/* make colored checkerboard cube faces */
for (f = 0; f < 6; f++) {
for (i = 0; i < CUBE_TEX_SIZE; i++) {
@@ -426,7 +450,8 @@ static void init_checkers( void )
GL_BGRA, GL_UNSIGNED_BYTE, image);
}
- glGenerateMipmapEXT(GL_TEXTURE_CUBE_MAP_ARB);
+ if (supportFBO)
+ glGenerateMipmapEXT(GL_TEXTURE_CUBE_MAP_ARB);
}
@@ -496,20 +521,26 @@ static void load_envmaps(void)
static void init( GLboolean useImageFiles )
{
/* check for extensions */
- {
- char *exten = (char *) glGetString(GL_EXTENSIONS);
- if (!strstr(exten, "GL_ARB_texture_cube_map")) {
- printf("Sorry, this demo requires GL_ARB_texture_cube_map\n");
- exit(0);
- }
+ if (!GLEW_ARB_texture_cube_map) {
+ printf("Sorry, this demo requires GL_ARB_texture_cube_map\n");
+ exit(0);
+ }
- /* Needed for glGenerateMipmapEXT
- */
- if (!strstr(exten, "GL_EXT_framebuffer_object")) {
- printf("Sorry, this demo requires GL_EXT_framebuffer_object\n");
- exit(0);
- }
+ /* Needed for glGenerateMipmapEXT / auto mipmapping
+ */
+ supportFBO = GLEW_EXT_framebuffer_object;
+
+ if (!supportFBO && !GLEW_SGIS_generate_mipmap) {
+ printf("Sorry, this demo requires GL_EXT_framebuffer_object or "
+ "GL_SGIS_generate_mipmap\n");
+ exit(0);
}
+
+ /* GLEW doesn't know about this extension yet, so use the old GLUT function
+ * to check for availability.
+ */
+ supportSeamless = glutExtensionSupported("GL_ARB_seamless_cube_map");
+
printf("GL_RENDERER: %s\n", (char *) glGetString(GL_RENDERER));
if (useImageFiles) {
diff --git a/progs/demos/isosurf.c b/progs/demos/isosurf.c
index 6923ca2bba8..2e9dff17261 100644
--- a/progs/demos/isosurf.c
+++ b/progs/demos/isosurf.c
@@ -847,8 +847,8 @@ static void Init(int argc, char *argv[])
glClearColor(0.0, 0.0, 1.0, 0.0);
glEnable( GL_DEPTH_TEST );
- glEnable( GL_VERTEX_ARRAY_EXT );
- glEnable( GL_NORMAL_ARRAY_EXT );
+ glEnableClientState( GL_VERTEX_ARRAY );
+ glEnableClientState( GL_NORMAL_ARRAY );
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
diff --git a/progs/demos/pointblast.c b/progs/demos/pointblast.c
index 2a91b76ad32..2d70b725894 100644
--- a/progs/demos/pointblast.c
+++ b/progs/demos/pointblast.c
@@ -194,11 +194,11 @@ redraw(void)
{
int i;
+ glDepthMask(GL_TRUE);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
if (newModel)
recalcModelView();
- glDepthMask(GL_FALSE);
/* Draw the floor. */
/* glEnable(GL_TEXTURE_2D);*/
@@ -215,7 +215,7 @@ redraw(void)
glEnd();
/* Allow particles to blend with each other. */
- glDepthMask(GL_TRUE);
+ glDepthMask(GL_FALSE);
if (blend)
glEnable(GL_BLEND);
diff --git a/progs/demos/spriteblast.c b/progs/demos/spriteblast.c
index f6630c25d07..d73b680b791 100644
--- a/progs/demos/spriteblast.c
+++ b/progs/demos/spriteblast.c
@@ -209,13 +209,13 @@ redraw(void)
{
int i;
+ glDepthMask(GL_TRUE);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotatef(15.0, 1.0, 0.0, 0.0);
glRotatef(angle, 0.0, 1.0, 0.0);
- glDepthMask(GL_FALSE);
/* Draw the floor. */
/* glEnable(GL_TEXTURE_2D);*/
@@ -232,7 +232,7 @@ redraw(void)
glEnd();
/* Allow particles to blend with each other. */
- glDepthMask(GL_TRUE);
+ glDepthMask(GL_FALSE);
if (blend)
glEnable(GL_BLEND);
diff --git a/progs/demos/vao_demo.c b/progs/demos/vao_demo.c
index ce416712fe2..206e06fc6c7 100644
--- a/progs/demos/vao_demo.c
+++ b/progs/demos/vao_demo.c
@@ -260,6 +260,8 @@ static void Key( unsigned char key, int x, int y )
(void) y;
switch (key) {
case 27:
+ (*delete_vertex_arrays)( 1, & cube_array_obj );
+ (*delete_vertex_arrays)( 1, & oct_array_obj );
glutDestroyWindow(Win);
exit(0);
break;