diff options
Diffstat (limited to 'progs/demos')
-rw-r--r-- | progs/demos/.gitignore | 1 | ||||
-rw-r--r-- | progs/demos/copypix.c | 22 | ||||
-rw-r--r-- | progs/demos/cubemap.c | 59 | ||||
-rw-r--r-- | progs/demos/fbotexture.c | 28 | ||||
-rw-r--r-- | progs/demos/lodbias.c | 4 |
5 files changed, 94 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/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 0a3e10dac08..20332b1d960 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; @@ -53,6 +56,9 @@ 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 GLuint TexObj = 0; static GLint T0 = 0; static GLint Frames = 0; @@ -93,7 +99,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[] = { @@ -233,6 +241,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); @@ -337,6 +352,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", @@ -518,25 +538,32 @@ 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 / auto mipmapping - */ - if (strstr(exten, "GL_EXT_framebuffer_object")) { - supportFBO = GL_TRUE; - } - else if (!strstr(exten, "GL_SGIS_generate_mipmap")) { - printf("Sorry, this demo requires GL_EXT_framebuffer_object or GL_SGIS_generate_mipmap\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)); + + glGenTextures(1, &TexObj); + glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, TexObj); + if (useImageFiles) { load_envmaps(); } diff --git a/progs/demos/fbotexture.c b/progs/demos/fbotexture.c index 3b36f755a04..56482663dc4 100644 --- a/progs/demos/fbotexture.c +++ b/progs/demos/fbotexture.c @@ -498,7 +498,7 @@ SetupFunctionPointers(void) * Make FBO to render into given texture. */ static GLuint -MakeFBO_RenderTexture(GLuint TexObj) +MakeFBO_RenderTexture(GLuint texObj) { GLuint fb; GLint sizeFudge = 0; @@ -507,7 +507,7 @@ MakeFBO_RenderTexture(GLuint TexObj) glBindFramebuffer_func(GL_FRAMEBUFFER_EXT, fb); /* Render color to texture */ glFramebufferTexture2D_func(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, - TexTarget, TexObj, TextureLevel); + TexTarget, texObj, TextureLevel); if (Use_ARB_fbo) { /* use a smaller depth buffer to see what happens */ @@ -541,7 +541,7 @@ MakeFBO_RenderTexture(GLuint TexObj) /* queries */ { - GLint bits, w, h; + GLint bits, w, h, name; glBindRenderbuffer_func(GL_RENDERBUFFER_EXT, DepthRB); glGetRenderbufferParameteriv_func(GL_RENDERBUFFER_EXT, @@ -559,8 +559,28 @@ MakeFBO_RenderTexture(GLuint TexObj) glGetRenderbufferParameteriv_func(GL_RENDERBUFFER_EXT, GL_RENDERBUFFER_STENCIL_SIZE_EXT, &bits); printf("Stencil renderbuffer size = %d bits\n", bits); - } + glGetFramebufferAttachmentParameteriv_func(GL_FRAMEBUFFER_EXT, + GL_COLOR_ATTACHMENT0, + GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT, + &name); + printf("Render to texture name: %d\n", texObj); + printf("Color attachment[0] name: %d\n", name); + assert(texObj == name); + + glGetFramebufferAttachmentParameteriv_func(GL_FRAMEBUFFER_EXT, + GL_STENCIL_ATTACHMENT, + GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT, + &name); + printf("Stencil attachment name: %d\n", name); + + glGetFramebufferAttachmentParameteriv_func(GL_FRAMEBUFFER_EXT, + GL_DEPTH_ATTACHMENT, + GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT, + &name); + printf("Depth attachment name: %d\n", name); + + } /* bind the regular framebuffer */ glBindFramebuffer_func(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; |