diff options
author | Brian Paul <[email protected]> | 2002-03-23 16:34:18 +0000 |
---|---|---|
committer | Brian Paul <[email protected]> | 2002-03-23 16:34:18 +0000 |
commit | 3c70f6f2ac833dbbe9b6a9908e344095e499f295 (patch) | |
tree | b6a0e38362d54fba52e2ea2f28cda038018bc3af /progs/demos/shadowtex.c | |
parent | 636b2801d981872d3111be0cd11aa79b4cc8643b (diff) |
exercise GL_EXT_shadow_funcs
Diffstat (limited to 'progs/demos/shadowtex.c')
-rw-r--r-- | progs/demos/shadowtex.c | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/progs/demos/shadowtex.c b/progs/demos/shadowtex.c index 36763287a9a..c5251727d67 100644 --- a/progs/demos/shadowtex.c +++ b/progs/demos/shadowtex.c @@ -1,4 +1,4 @@ -/* $Id: shadowtex.c,v 1.5 2002/02/16 14:54:18 brianp Exp $ */ +/* $Id: shadowtex.c,v 1.6 2002/03/23 16:34:18 brianp Exp $ */ /* * Shadow demo using the GL_ARB_depth_texture, GL_ARB_shadow and @@ -7,6 +7,8 @@ * Brian Paul * 19 Feb 2001 * + * Added GL_EXT_shadow_funcs support on 23 March 2002 + * * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -67,6 +69,16 @@ static GLfloat Bias = -0.06; static GLboolean Anim = GL_TRUE; +static GLboolean HaveEXTshadowFuncs = GL_FALSE; +static GLint Operator = 0; +static const GLenum OperatorFunc[8] = { + GL_LEQUAL, GL_LESS, GL_GEQUAL, GL_GREATER, + GL_EQUAL, GL_NOTEQUAL, GL_ALWAYS, GL_NEVER }; +static const char *OperatorName[8] = { + "GL_LEQUAL", "GL_LESS", "GL_GEQUAL", "GL_GREATER", + "GL_EQUAL", "GL_NOTEQUAL", "GL_ALWAYS", "GL_NEVER" }; + + static GLuint DisplayMode; #define SHOW_NORMAL 0 #define SHOW_DEPTH_IMAGE 1 @@ -237,6 +249,7 @@ Display(void) { GLfloat ar = (GLfloat) WindowWidth / (GLfloat) WindowHeight; GLfloat d; + GLenum error; ComputeLightPos(LightDist, LightLatitude, LightLongitude, LightPos, SpotDir); @@ -346,6 +359,11 @@ Display(void) } glutSwapBuffers(); + + error = glGetError(); + if (error) { + printf("GL Error: %s\n", gluErrorString(error)); + } } @@ -415,6 +433,16 @@ Key(unsigned char key, int x, int y) case ' ': DisplayMode = SHOW_NORMAL; break; + case 'o': + if (HaveEXTshadowFuncs) { + Operator++; + if (Operator >= 8) + Operator = 0; + printf("Operator: %s\n", OperatorName[Operator]); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB, + OperatorFunc[Operator]); + } + break; case 'z': Zrot -= step; break; @@ -484,6 +512,7 @@ Init(void) } printf("Using GL_SGIX_depth_texture and GL_SGIX_shadow\n"); #endif + HaveEXTshadowFuncs = glutExtensionSupported("GL_EXT_shadow_funcs"); glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); @@ -541,6 +570,8 @@ PrintHelp(void) printf(" b/B = decrease/increase shadow map Z bias\n"); printf(" cursor keys = rotate scene\n"); printf(" <shift> + cursor keys = rotate light source\n"); + if (HaveEXTshadowFuncs) + printf(" o = cycle through comparison modes\n"); } |