summaryrefslogtreecommitdiffstats
path: root/progs/demos
diff options
context:
space:
mode:
Diffstat (limited to 'progs/demos')
-rw-r--r--progs/demos/copypix.c22
-rw-r--r--progs/demos/cubemap.c21
-rw-r--r--progs/demos/fbo_firecube.c36
-rw-r--r--progs/demos/lodbias.c4
-rw-r--r--progs/demos/morph3d.c3
-rw-r--r--progs/demos/multiarb.c16
-rw-r--r--progs/demos/textures.c2
7 files changed, 94 insertions, 10 deletions
diff --git a/progs/demos/copypix.c b/progs/demos/copypix.c
index 51435acfa0f..a13339ea62f 100644
--- a/progs/demos/copypix.c
+++ b/progs/demos/copypix.c
@@ -26,6 +26,7 @@ static int Scissor = 0;
static float Xzoom, Yzoom;
static GLboolean DrawFront = GL_FALSE;
static GLboolean Dither = GL_TRUE;
+static GLboolean Invert = GL_FALSE;
static void Reset( void )
@@ -59,6 +60,15 @@ static void Display( void )
if (Scissor)
glEnable(GL_SCISSOR_TEST);
+ if (Invert) {
+ glPixelTransferf(GL_RED_SCALE, -1.0);
+ glPixelTransferf(GL_GREEN_SCALE, -1.0);
+ glPixelTransferf(GL_BLUE_SCALE, -1.0);
+ glPixelTransferf(GL_RED_BIAS, 1.0);
+ glPixelTransferf(GL_GREEN_BIAS, 1.0);
+ glPixelTransferf(GL_BLUE_BIAS, 1.0);
+ }
+
/* draw copy */
glPixelZoom(Xzoom, Yzoom);
glWindowPos2iARB(Xpos, Ypos);
@@ -67,6 +77,15 @@ static void Display( void )
glDisable(GL_SCISSOR_TEST);
+ if (Invert) {
+ glPixelTransferf(GL_RED_SCALE, 1.0);
+ glPixelTransferf(GL_GREEN_SCALE, 1.0);
+ glPixelTransferf(GL_BLUE_SCALE, 1.0);
+ glPixelTransferf(GL_RED_BIAS, 0.0);
+ glPixelTransferf(GL_GREEN_BIAS, 0.0);
+ glPixelTransferf(GL_BLUE_BIAS, 0.0);
+ }
+
if (DrawFront)
glFinish();
else
@@ -105,6 +124,9 @@ static void Key( unsigned char key, int x, int y )
else
glDisable(GL_DITHER);
break;
+ case 'i':
+ Invert = !Invert;
+ break;
case 's':
Scissor = !Scissor;
break;
diff --git a/progs/demos/cubemap.c b/progs/demos/cubemap.c
index 0df5ff09c33..20332b1d960 100644
--- a/progs/demos/cubemap.c
+++ b/progs/demos/cubemap.c
@@ -58,6 +58,9 @@ static GLint ClampIndex = 0;
static GLboolean supportFBO = GL_FALSE;
static GLboolean supportSeamless = GL_FALSE;
static GLboolean seamless = GL_FALSE;
+static GLuint TexObj = 0;
+static GLint T0 = 0;
+static GLint Frames = 0;
static struct {
@@ -282,6 +285,20 @@ static void draw( void )
glPopMatrix();
glutSwapBuffers();
+
+ Frames++;
+
+ {
+ GLint t = glutGet(GLUT_ELAPSED_TIME);
+ if (t - T0 >= 5000) {
+ GLfloat seconds = (t - T0) / 1000.0;
+ GLfloat fps = Frames / seconds;
+ printf("%d frames in %6.3f seconds = %6.3f FPS\n", Frames, seconds, fps);
+ fflush(stdout);
+ T0 = t;
+ Frames = 0;
+ }
+ }
}
@@ -543,6 +560,10 @@ static void init( GLboolean useImageFiles )
printf("GL_RENDERER: %s\n", (char *) glGetString(GL_RENDERER));
+
+ glGenTextures(1, &TexObj);
+ glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, TexObj);
+
if (useImageFiles) {
load_envmaps();
}
diff --git a/progs/demos/fbo_firecube.c b/progs/demos/fbo_firecube.c
index 4e42924a09e..b3f7e00e5af 100644
--- a/progs/demos/fbo_firecube.c
+++ b/progs/demos/fbo_firecube.c
@@ -938,7 +938,14 @@ reshape(int width, int height)
static void
init_fbotexture()
{
+ static const GLenum depthFormats[] = {
+ GL_DEPTH_COMPONENT,
+ GL_DEPTH_COMPONENT16,
+ GL_DEPTH_COMPONENT32
+ };
+ static int numDepthFormats = sizeof(depthFormats) / sizeof(depthFormats[0]);
GLint i;
+ GLenum stat;
/* gen framebuffer id, delete it, do some assertions, just for testing */
glGenFramebuffersEXT(1, &MyFB);
@@ -969,18 +976,31 @@ init_fbotexture()
/* make depth renderbuffer */
glGenRenderbuffersEXT(1, &DepthRB);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, DepthRB);
- glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT16,
- TexWidth, TexHeight);
- CheckError(__LINE__);
+ /* we may have to try several formats */
+ for (i = 0; i < numDepthFormats; i++) {
+ glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, depthFormats[i],
+ TexWidth, TexHeight);
+ CheckError(__LINE__);
+
+ glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
+ GL_RENDERBUFFER_EXT, DepthRB);
+ CheckError(__LINE__);
+ stat = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
+ if (stat == GL_FRAMEBUFFER_COMPLETE_EXT) {
+ break;
+ }
+ }
+
+ if (stat != GL_FRAMEBUFFER_COMPLETE_EXT) {
+ fprintf(stderr, "Error: unable to get usable FBO combination!\n");
+ exit(1);
+ }
+
glGetRenderbufferParameterivEXT(GL_RENDERBUFFER_EXT,
- GL_RENDERBUFFER_DEPTH_SIZE_EXT, &i);
+ GL_RENDERBUFFER_DEPTH_SIZE_EXT, &i);
CheckError(__LINE__);
printf("Depth renderbuffer size = %d bits\n", i);
- /* attach DepthRB to MyFB */
- glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
- GL_RENDERBUFFER_EXT, DepthRB);
- CheckError(__LINE__);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
/*
diff --git a/progs/demos/lodbias.c b/progs/demos/lodbias.c
index 30b1ed13d5f..8d39bd605a7 100644
--- a/progs/demos/lodbias.c
+++ b/progs/demos/lodbias.c
@@ -43,6 +43,7 @@ static GLboolean Anim = GL_TRUE;
static GLint Bias = 0, BiasStepSign = +1; /* ints avoid fp precision problem */
static GLint BiasMin = -400, BiasMax = 400;
static int win = 0;
+static GLuint TexObj = 0;
static void
@@ -214,6 +215,9 @@ static void Init( void )
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+ glGenTextures(1, &TexObj);
+ glBindTexture(GL_TEXTURE_2D, TexObj);
+
if (glutExtensionSupported("GL_SGIS_generate_mipmap")) {
/* test auto mipmap generation */
GLint width, height, i;
diff --git a/progs/demos/morph3d.c b/progs/demos/morph3d.c
index 6aca8270ff5..01a06aba0ff 100644
--- a/progs/demos/morph3d.c
+++ b/progs/demos/morph3d.c
@@ -887,5 +887,6 @@ int main(int argc, char **argv)
glutIdleFunc( idle_ );
glutDisplayFunc( draw );
glutMainLoop();
-
+
+ return 0;
}
diff --git a/progs/demos/multiarb.c b/progs/demos/multiarb.c
index 85c4e3a266c..3d89d3a13e9 100644
--- a/progs/demos/multiarb.c
+++ b/progs/demos/multiarb.c
@@ -27,6 +27,8 @@
#define ANIMATE 10
#define QUIT 100
+static GLint T0 = 0;
+static GLint Frames = 0;
static GLboolean Animate = GL_TRUE;
static GLint NumUnits = 1;
static GLboolean TexEnabled[8];
@@ -105,6 +107,20 @@ static void Display( void )
glPopMatrix();
glutSwapBuffers();
+
+ Frames++;
+
+ {
+ GLint t = glutGet(GLUT_ELAPSED_TIME);
+ if (t - T0 >= 5000) {
+ GLfloat seconds = (t - T0) / 1000.0;
+ GLfloat fps = Frames / seconds;
+ printf("%d frames in %6.3f seconds = %6.3f FPS\n", Frames, seconds, fps);
+ fflush(stdout);
+ T0 = t;
+ Frames = 0;
+ }
+ }
}
diff --git a/progs/demos/textures.c b/progs/demos/textures.c
index b7bf135d219..d94154a2008 100644
--- a/progs/demos/textures.c
+++ b/progs/demos/textures.c
@@ -57,7 +57,7 @@ Idle(void)
{
Xrot = glutGet(GLUT_ELAPSED_TIME) * 0.02;
Yrot = glutGet(GLUT_ELAPSED_TIME) * 0.04;
- //Zrot += 2.0;
+ /*Zrot += 2.0;*/
glutPostRedisplay();
}