diff options
Diffstat (limited to 'progs/tests')
-rw-r--r-- | progs/tests/Makefile | 1 | ||||
-rw-r--r-- | progs/tests/SConscript | 1 | ||||
-rw-r--r-- | progs/tests/arbgpuprog.c | 4 | ||||
-rw-r--r-- | progs/tests/blitfb.c | 259 | ||||
-rw-r--r-- | progs/tests/drawbuffers.c | 17 | ||||
-rw-r--r-- | progs/tests/getprocaddress.c | 2 | ||||
-rw-r--r-- | progs/tests/getteximage.c | 20 | ||||
-rw-r--r-- | progs/tests/mipmap_comp.c | 6 | ||||
-rw-r--r-- | progs/tests/packedpixels.c | 79 | ||||
-rw-r--r-- | progs/tests/prog_parameter.c | 16 | ||||
-rw-r--r-- | progs/tests/shader_api.c | 6 | ||||
-rw-r--r-- | progs/tests/sharedtex.c | 8 | ||||
-rw-r--r-- | progs/tests/stencil_twoside.c | 6 | ||||
-rw-r--r-- | progs/tests/texcmp.c | 25 | ||||
-rw-r--r-- | progs/tests/texcompsub.c | 8 | ||||
-rw-r--r-- | progs/tests/texdown.c | 2 | ||||
-rw-r--r-- | progs/tests/vao-01.c | 8 | ||||
-rw-r--r-- | progs/tests/vao-02.c | 8 | ||||
-rw-r--r-- | progs/tests/zreaddraw.c | 5 |
19 files changed, 424 insertions, 57 deletions
diff --git a/progs/tests/Makefile b/progs/tests/Makefile index 2b93aa5464f..197e14d5b00 100644 --- a/progs/tests/Makefile +++ b/progs/tests/Makefile @@ -29,6 +29,7 @@ SOURCES = \ blendminmax.c \ blendsquare.c \ blendxor.c \ + blitfb.c \ bufferobj.c \ bumpmap.c \ bug_3050.c \ diff --git a/progs/tests/SConscript b/progs/tests/SConscript index bb6a1d2b8a9..3a0da62717c 100644 --- a/progs/tests/SConscript +++ b/progs/tests/SConscript @@ -52,6 +52,7 @@ progs = [ 'blendminmax', 'blendsquare', 'blendxor', + 'blitfb', 'bufferobj', 'bug_3050', 'bug_3101', diff --git a/progs/tests/arbgpuprog.c b/progs/tests/arbgpuprog.c index 23aa899d963..6098dca787b 100644 --- a/progs/tests/arbgpuprog.c +++ b/progs/tests/arbgpuprog.c @@ -134,6 +134,8 @@ static void Init( const char *vertProgFile, } len = fread(buf, 1, 10*1000,f); + fclose(f); + glProgramStringARB_func(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, len, @@ -170,6 +172,8 @@ static void Init( const char *vertProgFile, } len = fread(buf, 1, 10*1000,f); + fclose(f); + glProgramStringARB_func(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, len, diff --git a/progs/tests/blitfb.c b/progs/tests/blitfb.c new file mode 100644 index 00000000000..18c8380a5e2 --- /dev/null +++ b/progs/tests/blitfb.c @@ -0,0 +1,259 @@ +/** + * Test glFramebufferBlit() + * Brian Paul + * 27 Oct 2009 + */ + +#include <assert.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <math.h> +#include <GL/glew.h> +#include <GL/glut.h> + + +static int Win; +static int WinWidth = 1100, WinHeight = 600; + +static int SrcWidth = 512, SrcHeight = 512; +static int DstWidth = 512, DstHeight = 512; + +static GLuint SrcFB, DstFB; +static GLuint SrcTex, DstTex; + +#if 0 +static GLenum SrcTexTarget = GL_TEXTURE_2D, SrcTexFace = GL_TEXTURE_2D; +#else +static GLenum SrcTexTarget = GL_TEXTURE_CUBE_MAP, SrcTexFace = GL_TEXTURE_CUBE_MAP_POSITIVE_X; +#endif + +static GLenum DstTexTarget = GL_TEXTURE_2D, DstTexFace = GL_TEXTURE_2D; + +static GLuint SrcTexLevel = 01, DstTexLevel = 0; + + +static void +Draw(void) +{ + GLboolean rp = GL_FALSE; + GLubyte *buf; + GLint srcWidth = SrcWidth >> SrcTexLevel; + GLint srcHeight = SrcHeight >> SrcTexLevel; + GLint dstWidth = DstWidth >> DstTexLevel; + GLint dstHeight = DstHeight >> DstTexLevel; + GLenum status; + + /* clear window */ + glBindFramebufferEXT(GL_FRAMEBUFFER, 0); + glClearColor(0.5, 0.5, 0.5, 1.0); + glClear(GL_COLOR_BUFFER_BIT); + + + /* clear src buf */ + glBindFramebufferEXT(GL_FRAMEBUFFER, SrcFB); + status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); + assert(status == GL_FRAMEBUFFER_COMPLETE_EXT); + glClearColor(0, 1, 0, 0); + glClear(GL_COLOR_BUFFER_BIT); + + /* clear dst buf */ + glBindFramebufferEXT(GL_FRAMEBUFFER, DstFB); + status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); + assert(status == GL_FRAMEBUFFER_COMPLETE_EXT); + glClearColor(1, 0, 0, 0); + glClear(GL_COLOR_BUFFER_BIT); + + /* blit src -> dst */ + glBindFramebufferEXT(GL_READ_FRAMEBUFFER, SrcFB); + glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, DstFB); + glBlitFramebufferEXT(0, 0, srcWidth, srcHeight, + 0, 0, dstWidth, dstHeight, + GL_COLOR_BUFFER_BIT, GL_NEAREST); + +#if 01 + /* read src results */ + buf = malloc(4 * srcWidth * srcHeight); + memset(buf, 0x88, 4 * srcWidth * srcHeight); + glBindFramebufferEXT(GL_FRAMEBUFFER, SrcFB); + if (rp) + glReadPixels(0, 0, srcWidth, srcHeight, GL_RGBA, GL_UNSIGNED_BYTE, buf); + else { + glBindTexture(SrcTexTarget, SrcTex); + glGetTexImage(SrcTexFace, SrcTexLevel, GL_RGBA, GL_UNSIGNED_BYTE, buf); + } + + /* draw dst in window */ + glBindFramebufferEXT(GL_FRAMEBUFFER, 0); + glWindowPos2i(0, 0); + glDrawPixels(srcWidth, srcHeight, GL_RGBA, GL_UNSIGNED_BYTE, buf); + + printf("Src Pix[0] = %d %d %d %d\n", buf[0], buf[1], buf[2], buf[3]); + free(buf); +#endif + + glFinish(); + + /* read dst results */ + buf = malloc(4 * dstWidth * dstHeight); + memset(buf, 0x88, 4 * dstWidth * dstHeight); + glBindFramebufferEXT(GL_FRAMEBUFFER, DstFB); + if (rp) + glReadPixels(0, 0, dstWidth, dstHeight, GL_RGBA, GL_UNSIGNED_BYTE, buf); + else { + glBindTexture(DstTexTarget, DstTex); + glGetTexImage(DstTexFace, DstTexLevel, GL_RGBA, GL_UNSIGNED_BYTE, buf); + } + + /* draw dst in window */ + glBindFramebufferEXT(GL_FRAMEBUFFER, 0); + glWindowPos2i(srcWidth + 2, 0); + glDrawPixels(dstWidth, dstHeight, GL_RGBA, GL_UNSIGNED_BYTE, buf); + + printf("Dst Pix[0] = %d %d %d %d\n", buf[0], buf[1], buf[2], buf[3]); + free(buf); + + glFinish(); + + glutSwapBuffers(); +} + + +static void +Reshape(int width, int height) +{ + WinWidth = width; + WinHeight = height; + glViewport(0, 0, width, height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum(-1.0, 1.0, -1.0, 1.0, 5.0, 25.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0.0, 0.0, -15.0); +} + + +static void +Key(unsigned char key, int x, int y) +{ + (void) x; + (void) y; + switch (key) { + case 27: + glutDestroyWindow(Win); + exit(0); + break; + } + glutPostRedisplay(); +} + + +static void +SpecialKey(int key, int x, int y) +{ + (void) x; + (void) y; + switch (key) { + } + glutPostRedisplay(); +} + + +static void +InitFBOs(void) +{ + GLuint w, h, lvl; + + /* Src */ + glGenTextures(1, &SrcTex); + glBindTexture(SrcTexTarget, SrcTex); + w = SrcWidth; + h = SrcHeight; + lvl = 0; + for (lvl = 0; ; lvl++) { + if (SrcTexTarget == GL_TEXTURE_CUBE_MAP) { + GLuint f; + for (f = 0; f < 6; f++) { + glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + f, lvl, GL_RGBA8, + w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); + } + } + else { + /* single face */ + glTexImage2D(SrcTexFace, lvl, GL_RGBA8, w, h, 0, + GL_RGBA, GL_UNSIGNED_BYTE, NULL); + } + if (w == 1 && h == 1) + break; + if (w > 1) + w /= 2; + if (h > 1) + h /= 2; + } + + glGenFramebuffersEXT(1, &SrcFB); + glBindFramebufferEXT(GL_FRAMEBUFFER, SrcFB); + glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, + SrcTexFace, SrcTex, SrcTexLevel); + + /* Dst */ + glGenTextures(1, &DstTex); + glBindTexture(DstTexTarget, DstTex); + w = DstWidth; + h = DstHeight; + lvl = 0; + for (lvl = 0; ; lvl++) { + glTexImage2D(DstTexFace, lvl, GL_RGBA8, w, h, 0, + GL_RGBA, GL_UNSIGNED_BYTE, NULL); + if (w == 1 && h == 1) + break; + if (w > 1) + w /= 2; + if (h > 1) + h /= 2; + } + + glGenFramebuffersEXT(1, &DstFB); + glBindFramebufferEXT(GL_FRAMEBUFFER, DstFB); + glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, + DstTexFace, DstTex, DstTexLevel); +} + + +static void +Init(void) +{ + if (!glutExtensionSupported("GL_EXT_framebuffer_object")) { + fprintf(stderr, "This test requires GL_EXT_framebuffer_object\n"); + exit(1); + } + + if (!glutExtensionSupported("GL_EXT_framebuffer_blit")) { + fprintf(stderr, "This test requires GL_EXT_framebuffer_blit,\n"); + exit(1); + } + + InitFBOs(); + + printf("Left rect = src FBO, Right rect = dst FBO.\n"); + printf("Both should be green.\n"); +} + + +int +main(int argc, char *argv[]) +{ + glutInit(&argc, argv); + glutInitWindowSize(WinWidth, WinHeight); + glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); + Win = glutCreateWindow(argv[0]); + glewInit(); + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutSpecialFunc(SpecialKey); + glutDisplayFunc(Draw); + Init(); + glutMainLoop(); + return 0; +} diff --git a/progs/tests/drawbuffers.c b/progs/tests/drawbuffers.c index d75a870c26b..7a19933e627 100644 --- a/progs/tests/drawbuffers.c +++ b/progs/tests/drawbuffers.c @@ -43,6 +43,8 @@ Display(void) glUseProgram_func(Program); + glEnable(GL_DEPTH_TEST); + /* draw to user framebuffer */ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, FBobject); @@ -68,18 +70,23 @@ Display(void) glPopMatrix(); /* read from user framebuffer */ - /* bottom half = colorbuffer 0 */ + /* left half = colorbuffer 0 */ glReadBuffer(GL_COLOR_ATTACHMENT0_EXT); - glReadPixels(0, 0, Width, Height / 2, GL_RGBA, GL_UNSIGNED_BYTE, + glPixelStorei(GL_PACK_ROW_LENGTH, Width); + glPixelStorei(GL_PACK_SKIP_PIXELS, 0); + glReadPixels(0, 0, Width / 2, Height, GL_RGBA, GL_UNSIGNED_BYTE, buffer); - /* top half = colorbuffer 1 */ + + /* right half = colorbuffer 1 */ glReadBuffer(GL_COLOR_ATTACHMENT1_EXT); - glReadPixels(0, Height/2, Width, Height - Height / 2, + glPixelStorei(GL_PACK_SKIP_PIXELS, Width / 2); + glReadPixels(Width / 2, 0, Width - Width / 2, Height, GL_RGBA, GL_UNSIGNED_BYTE, - buffer + Width * (Height / 2) * 4); + buffer); /* draw to window */ glUseProgram_func(0); + glDisable(GL_DEPTH_TEST); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); glWindowPos2iARB(0, 0); glDrawPixels(Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, buffer); diff --git a/progs/tests/getprocaddress.c b/progs/tests/getprocaddress.c index a09ea58e1da..b905eeaf81b 100644 --- a/progs/tests/getprocaddress.c +++ b/progs/tests/getprocaddress.c @@ -3516,7 +3516,7 @@ check_functions( const char *extensions ) struct name_test_pair *entry; int failures = 0, passes = 0, untested = 0; int totalFail = 0, totalPass = 0, totalUntested = 0, totalUnsupported = 0; - int doTests; + int doTests = 0; const char *version = (const char *) glGetString(GL_VERSION); /* The functions list will have "real" entries (consisting of diff --git a/progs/tests/getteximage.c b/progs/tests/getteximage.c index 71f29b4ac84..e4053b8de1a 100644 --- a/progs/tests/getteximage.c +++ b/progs/tests/getteximage.c @@ -58,6 +58,26 @@ TestGetTexImage(GLboolean npot) abort(); } } + + /* get as BGRA */ + glGetTexImage(GL_TEXTURE_2D, level, GL_BGRA, GL_UNSIGNED_BYTE, data2); + + /* compare */ + { + const GLubyte *rgba = (GLubyte *) data; + const GLubyte *bgra = (GLubyte *) data2; + for (i = 0; i < w * h; i += 4) { + if (rgba[i+0] != bgra[i+2] || + rgba[i+1] != bgra[i+1] || + rgba[i+2] != bgra[i+0] || + rgba[i+3] != bgra[i+3]) { + printf("glTexImage + glGetTexImage(GL_BGRA) failure!\n"); + printf("Expected value %d, found %d\n", data[i], data2[i]); + abort(); + } + } + } + } printf("Passed\n"); diff --git a/progs/tests/mipmap_comp.c b/progs/tests/mipmap_comp.c index 5842e2b8805..dd2232113b6 100644 --- a/progs/tests/mipmap_comp.c +++ b/progs/tests/mipmap_comp.c @@ -285,6 +285,12 @@ main(int argc, char** argv) glutInitWindowSize (600, 600); glutCreateWindow (argv[0]); glewInit(); + + if (!glutExtensionSupported("GL_EXT_texture_compression_s3tc")) { + fprintf(stderr, "This test requires GL_EXT_texture_compression_s3tc.\n"); + exit(1); + } + myInit(); glutReshapeFunc (myReshape); glutDisplayFunc(display); diff --git a/progs/tests/packedpixels.c b/progs/tests/packedpixels.c index 1703b271cb0..c8884bb79f1 100644 --- a/progs/tests/packedpixels.c +++ b/progs/tests/packedpixels.c @@ -17,53 +17,53 @@ struct pixel_format { GLenum format; GLenum type; GLint bytes; - GLuint redTexel, greenTexel; + GLuint redTexel, greenTexel; /* with approx 51% alpha, when applicable */ }; static const struct pixel_format Formats[] = { { "GL_RGBA/GL_UNSIGNED_INT_8_8_8_8", - GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, 4, 0xff000000, 0x00ff0000 }, + GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, 4, 0xff000080, 0x00ff0080 }, { "GL_RGBA/GL_UNSIGNED_INT_8_8_8_8_REV", - GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, 4, 0x000000ff, 0x0000ff00 }, + GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, 4, 0x800000ff, 0x8000ff00 }, { "GL_RGBA/GL_UNSIGNED_INT_10_10_10_2", - GL_RGBA, GL_UNSIGNED_INT_10_10_10_2, 4, 0xffc00000, 0x3ff000 }, + GL_RGBA, GL_UNSIGNED_INT_10_10_10_2, 4, 0xffc00002, 0x3ff002 }, { "GL_RGBA/GL_UNSIGNED_INT_2_10_10_10_REV", - GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, 4, 0x3ff, 0xffc00 }, + GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, 4, 0xc00003ff, 0xc00ffc00 }, { "GL_RGBA/GL_UNSIGNED_SHORT_4_4_4_4", - GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 2, 0xf000, 0x0f00 }, + GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 2, 0xf008, 0x0f08 }, { "GL_RGBA/GL_UNSIGNED_SHORT_4_4_4_4_REV", - GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4_REV, 2, 0x000f, 0x00f0 }, + GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4_REV, 2, 0x800f, 0x80f0 }, { "GL_RGBA/GL_UNSIGNED_SHORT_5_5_5_1", - GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, 2, 0xf800, 0x7c0 }, + GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, 2, 0xf801, 0x7c1 }, { "GL_RGBA/GL_UNSIGNED_SHORT_1_5_5_5_REV", - GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, 2, 0x1f, 0x3e0 }, + GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, 2, 0x801f, 0x83e0 }, { "GL_BGRA/GL_UNSIGNED_INT_8_8_8_8", - GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, 4, 0x0000ff00, 0x00ff0000 }, + GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, 4, 0x0000ff80, 0x00ff0080 }, { "GL_BGRA/GL_UNSIGNED_INT_8_8_8_8_REV", - GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, 4, 0x00ff0000, 0x0000ff00 }, + GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, 4, 0x80ff0000, 0x8000ff00 }, { "GL_BGRA/GL_UNSIGNED_SHORT_4_4_4_4", - GL_BGRA, GL_UNSIGNED_SHORT_4_4_4_4, 2, 0x00f0, 0x0f00 }, + GL_BGRA, GL_UNSIGNED_SHORT_4_4_4_4, 2, 0x00f8, 0x0f08 }, { "GL_BGRA/GL_UNSIGNED_SHORT_4_4_4_4_REV", - GL_BGRA, GL_UNSIGNED_SHORT_4_4_4_4_REV, 2, 0x0f00, 0x00f0 }, + GL_BGRA, GL_UNSIGNED_SHORT_4_4_4_4_REV, 2, 0x8f00, 0x80f0 }, { "GL_BGRA/GL_UNSIGNED_SHORT_5_5_5_1", - GL_BGRA, GL_UNSIGNED_SHORT_5_5_5_1, 2, 0x3e, 0x7c0 }, + GL_BGRA, GL_UNSIGNED_SHORT_5_5_5_1, 2, 0x3f, 0x7c1 }, { "GL_BGRA/GL_UNSIGNED_SHORT_1_5_5_5_REV", - GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV, 2, 0x7c00, 0x3e0 }, + GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV, 2, 0xfc00, 0x83e0 }, { "GL_ABGR_EXT/GL_UNSIGNED_INT_8_8_8_8", - GL_ABGR_EXT, GL_UNSIGNED_INT_8_8_8_8, 4, 0x000000ff, 0x0000ff00 }, + GL_ABGR_EXT, GL_UNSIGNED_INT_8_8_8_8, 4, 0x800000ff, 0x8000ff00 }, { "GL_ABGR_EXT/GL_UNSIGNED_INT_8_8_8_8_REV", - GL_ABGR_EXT, GL_UNSIGNED_INT_8_8_8_8_REV, 4, 0xff000000, 0x00ff0000 }, + GL_ABGR_EXT, GL_UNSIGNED_INT_8_8_8_8_REV, 4, 0xff000080, 0x00ff0080 }, { "GL_ABGR_EXT/GL_UNSIGNED_SHORT_4_4_4_4", - GL_ABGR_EXT, GL_UNSIGNED_SHORT_4_4_4_4, 2, 0x000f, 0x00f0 }, + GL_ABGR_EXT, GL_UNSIGNED_SHORT_4_4_4_4, 2, 0x800f, 0x80f0 }, { "GL_ABGR_EXT/GL_UNSIGNED_SHORT_4_4_4_4_REV", - GL_ABGR_EXT, GL_UNSIGNED_SHORT_4_4_4_4_REV, 2, 0xf000, 0x0f00 }, + GL_ABGR_EXT, GL_UNSIGNED_SHORT_4_4_4_4_REV, 2, 0xf008, 0x0f08 }, { "GL_ABGR_EXT/GL_UNSIGNED_SHORT_5_5_5_1", - GL_ABGR_EXT, GL_UNSIGNED_SHORT_5_5_5_1, 2, 0x1, 0x3e }, + GL_ABGR_EXT, GL_UNSIGNED_SHORT_5_5_5_1, 2, 0xf801, 0xf83e }, { "GL_ABGR_EXT/GL_UNSIGNED_SHORT_1_5_5_5_REV", - GL_ABGR_EXT, GL_UNSIGNED_SHORT_1_5_5_5_REV, 2, 0x8000, 0x7c00 }, + GL_ABGR_EXT, GL_UNSIGNED_SHORT_1_5_5_5_REV, 2, 0x800f, 0x7c0f }, { "GL_RGB/GL_UNSIGNED_SHORT_5_6_5", GL_RGB, GL_UNSIGNED_SHORT_5_6_5, 2, 0xf800, 0x7e0 }, @@ -108,7 +108,7 @@ static const struct name_format IntFormats[] = { static GLuint CurFormat = 0; static GLboolean Test3D = GL_FALSE; - +static GLboolean Blend = GL_FALSE; static void @@ -191,6 +191,19 @@ MakeTexture(const struct pixel_format *format, GLenum intFormat, GLboolean swap) format->format, format->type, texBuffer); } + if (0) { + GLint r, g, b, a, l, i; + glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_RED_SIZE, &r); + glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_GREEN_SIZE, &g); + glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_BLUE_SIZE, &b); + glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_ALPHA_SIZE, &a); + glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_LUMINANCE_SIZE, &l); + glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_INTENSITY_SIZE, &i); + printf("IntFormat: 0x%x R %d G %d B %d A %d L %d I %d\n", + intFormat, r, g, b, a, l, i); + glGetError(); + } + if (glGetError()) { printf("GL Error for %s\n", format->name); memset(texBuffer, 255, 1000); @@ -221,6 +234,10 @@ Draw(void) glEnable(GL_TEXTURE_3D); else glEnable(GL_TEXTURE_2D); + + if (Blend) + glEnable(GL_BLEND); + glBegin(GL_POLYGON); glTexCoord3f(0, 0, 0.5); glVertex2f(0, 0); glTexCoord3f(1, 0, 0.5); glVertex2f(w, 0); @@ -232,6 +249,9 @@ Draw(void) glDisable(GL_TEXTURE_3D); else glDisable(GL_TEXTURE_2D); + + glDisable(GL_BLEND); + glColor3f(0, 0, 0); glRasterPos2i(8, 6); PrintString(Formats[i].name); @@ -252,7 +272,7 @@ Draw(void) glPushMatrix(); glTranslatef(2, (i + 1) * (h + 2), 0); glRasterPos2i(8, 6); - sprintf(s, "Internal Texture Format [f/F]: %s (%d of %d)", + sprintf(s, "Internal Texture Format [f/F]: %s (%d of %lu)", IntFormats[CurFormat].name, CurFormat + 1, NUM_INT_FORMATS); PrintString(s); glPopMatrix(); @@ -266,6 +286,15 @@ Draw(void) PrintString("Target [2/3]: GL_TEXTURE_2D"); glPopMatrix(); + glPushMatrix(); + glTranslatef(2, (i + 3) * (h + 2), 0); + glRasterPos2i(8, 6); + if (Blend) + PrintString("Blend: Yes"); + else + PrintString("Blend: No"); + glPopMatrix(); + glutSwapBuffers(); } @@ -288,6 +317,9 @@ Key(unsigned char key, int x, int y) (void) x; (void) y; switch (key) { + case 'b': + Blend = !Blend; + break; case 'F': if (CurFormat == 0) CurFormat = NUM_INT_FORMATS - 1; @@ -323,6 +355,7 @@ Init(void) glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } diff --git a/progs/tests/prog_parameter.c b/progs/tests/prog_parameter.c index 28e3b537acd..0241f3a2496 100644 --- a/progs/tests/prog_parameter.c +++ b/progs/tests/prog_parameter.c @@ -203,20 +203,20 @@ static void Init( void ) } - program_local_parameter4fv = glutGetProcAddress( "glProgramLocalParameter4fvARB" ); - program_env_parameter4fv = glutGetProcAddress( "glProgramEnvParameter4fvARB" ); + program_local_parameter4fv = (PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) glutGetProcAddress( "glProgramLocalParameter4fvARB" ); + program_env_parameter4fv = (PFNGLPROGRAMENVPARAMETER4FVARBPROC) glutGetProcAddress( "glProgramEnvParameter4fvARB" ); - get_program_local_parameterfv = glutGetProcAddress( "glGetProgramLocalParameterfvARB" ); - get_program_env_parameterfv = glutGetProcAddress( "glGetProgramEnvParameterfvARB" ); + get_program_local_parameterfv = (PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) glutGetProcAddress( "glGetProgramLocalParameterfvARB" ); + get_program_env_parameterfv = (PFNGLGETPROGRAMENVPARAMETERFVARBPROC) glutGetProcAddress( "glGetProgramEnvParameterfvARB" ); - bind_program = glutGetProcAddress( "glBindProgramARB" ); - get_program = glutGetProcAddress( "glGetProgramivARB" ); + bind_program = (PFNGLBINDPROGRAMARBPROC) glutGetProcAddress( "glBindProgramARB" ); + get_program = (PFNGLGETPROGRAMIVARBPROC) glutGetProcAddress( "glGetProgramivARB" ); if ( glutExtensionSupported("GL_EXT_gpu_program_parameters") ) { printf("GL_EXT_gpu_program_parameters available, testing that path.\n"); - program_local_parameters4fv = glutGetProcAddress( "glProgramLocalParameters4fvEXT" ); - program_env_parameters4fv = glutGetProcAddress( "glProgramEnvParameters4fvEXT" ); + program_local_parameters4fv = (PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC) glutGetProcAddress( "glProgramLocalParameters4fvEXT" ); + program_env_parameters4fv = (PFNGLPROGRAMENVPARAMETERS4FVEXTPROC) glutGetProcAddress( "glProgramEnvParameters4fvEXT" ); } else { printf("GL_EXT_gpu_program_parameters not available.\n"); diff --git a/progs/tests/shader_api.c b/progs/tests/shader_api.c index 6453856345c..fa0a992540c 100644 --- a/progs/tests/shader_api.c +++ b/progs/tests/shader_api.c @@ -8,6 +8,10 @@ #include <GL/glew.h> #include <GL/glut.h> +#ifndef APIENTRY +#define APIENTRY +#endif + static void assert_test(const char *file, int line, int cond, const char *msg) { if (!cond) @@ -42,7 +46,7 @@ static void assert_error_test(const char *file, int line, GLenum expect) #define assert_error(err) assert_error_test(__FILE__, __LINE__, (err)) -static void check_status(GLuint id, GLenum pname, void (*query)(GLuint, GLenum, GLint *)) +static void check_status(GLuint id, GLenum pname, void (APIENTRY *query)(GLuint, GLenum, GLint *)) { GLint status; diff --git a/progs/tests/sharedtex.c b/progs/tests/sharedtex.c index c07ebd719c7..2337b88d3ff 100644 --- a/progs/tests/sharedtex.c +++ b/progs/tests/sharedtex.c @@ -424,13 +424,13 @@ main(int argc, char *argv[]) { const char *dpyName = XDisplayName(NULL); - struct window *h0, *h1, *h2, *h3; + struct window *h0; /* four windows and contexts sharing display lists and texture objects */ h0 = AddWindow(dpyName, 10, 10, NULL); - h1 = AddWindow(dpyName, 330, 10, h0); - h2 = AddWindow(dpyName, 10, 350, h0); - h3 = AddWindow(dpyName, 330, 350, h0); + (void) AddWindow(dpyName, 330, 10, h0); + (void) AddWindow(dpyName, 10, 350, h0); + (void) AddWindow(dpyName, 330, 350, h0); InitGLstuff(h0); diff --git a/progs/tests/stencil_twoside.c b/progs/tests/stencil_twoside.c index 1e18ca6b5ea..7d871e5877f 100644 --- a/progs/tests/stencil_twoside.c +++ b/progs/tests/stencil_twoside.c @@ -274,9 +274,9 @@ static void Init( void ) if (atof( ver_string ) < 2.0) { use20syntax = 0; } - stencil_func_separate = glutGetProcAddress( "glStencilFuncSeparate" ); - stencil_func_separate_ati = glutGetProcAddress( "glStencilFuncSeparateATI" ); - stencil_op_separate = glutGetProcAddress( "glStencilOpSeparate" ); + stencil_func_separate = (PFNGLSTENCILFUNCSEPARATEPROC) glutGetProcAddress( "glStencilFuncSeparate" ); + stencil_func_separate_ati = (PFNGLSTENCILFUNCSEPARATEATIPROC) glutGetProcAddress( "glStencilFuncSeparateATI" ); + stencil_op_separate = (PFNGLSTENCILOPSEPARATEPROC) glutGetProcAddress( "glStencilOpSeparate" ); printf("\nAll 5 squares should be the same color.\n"); } diff --git a/progs/tests/texcmp.c b/progs/tests/texcmp.c index d1e829d1b73..c5d352fdaed 100644 --- a/progs/tests/texcmp.c +++ b/progs/tests/texcmp.c @@ -106,6 +106,8 @@ static void Display( void ) glRotatef(Rot, 0, 0, 1); glEnable(GL_TEXTURE_2D); + glEnable(GL_BLEND); + glBegin(GL_POLYGON); glTexCoord2f(0, 1); glVertex2f(-1, -0.5); glTexCoord2f(1, 1); glVertex2f( 1, -0.5); @@ -115,7 +117,10 @@ static void Display( void ) glPopMatrix(); + glDisable(GL_TEXTURE_2D); + /* info */ + glDisable(GL_BLEND); glColor4f(1, 1, 1, 1); glRasterPos3f(-1.2, -0.7, 0); @@ -149,7 +154,7 @@ static void Reshape( int width, int height ) static void ReInit( GLenum TC, TEXTURE *Tx ) { - GLint rv; + GLint rv, v; if ((Tx->TC == TC) && (Tx->cData != NULL)) { glCompressedTexImage2DARB(GL_TEXTURE_2D, /* target */ @@ -170,6 +175,24 @@ static void ReInit( GLenum TC, TEXTURE *Tx ) GL_UNSIGNED_BYTE, /* texture type */ Tx->data); /* the texture */ + + v = 0; + glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, + GL_TEXTURE_INTERNAL_FORMAT, &v); + printf("Requested internal format = 0x%x, actual = 0x%x\n", TC, v); + + if (0) { + GLint r, g, b, a, l, i; + glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_RED_SIZE, &r); + glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_GREEN_SIZE, &g); + glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_BLUE_SIZE, &b); + glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_ALPHA_SIZE, &a); + glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_LUMINANCE_SIZE, &l); + glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_INTENSITY_SIZE, &i); + printf("Compressed Bits per R: %d G: %d B: %d A: %d L: %d I: %d\n", + r, g, b, a, l, i); + } + /* okay, now cache the compressed texture */ Tx->TC = TC; if (Tx->cData != NULL) { diff --git a/progs/tests/texcompsub.c b/progs/tests/texcompsub.c index 50106bf1e22..215f5711d95 100644 --- a/progs/tests/texcompsub.c +++ b/progs/tests/texcompsub.c @@ -35,6 +35,8 @@ LoadCompressedImage(void) unsigned char ImgDataTemp[ImgSize / 4]; unsigned i; const GLenum filter = GL_LINEAR; + const int half = ImgSize / 2; + glTexImage2D(Target, 0, CompFormat, ImgWidth, ImgHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL); @@ -42,11 +44,11 @@ LoadCompressedImage(void) glCompressedTexSubImage2DARB(Target, 0, 0, 0, /* pos */ ImgWidth, ImgHeight / 2, - CompFormat, ImgSize / 2, ImgData + ImgSize / 2); + CompFormat, ImgSize / 2, ImgData /*+ ImgSize / 2*/); /* top left */ for (i = 0; i < ImgHeight / 8; i++) { - memcpy(&ImgDataTemp[i * ImgWidth], &ImgData[i * 2 * ImgWidth], ImgWidth); + memcpy(&ImgDataTemp[i * ImgWidth], &ImgData[half + i * 2 * ImgWidth], ImgWidth); } glCompressedTexSubImage2DARB(Target, 0, 0, ImgHeight / 2, /* pos */ @@ -55,7 +57,7 @@ LoadCompressedImage(void) /* top right */ for (i = 0; i < ImgHeight / 8; i++) { - memcpy(&ImgDataTemp[i * ImgWidth], &ImgData[i * 2 * ImgWidth + ImgWidth], ImgWidth); + memcpy(&ImgDataTemp[i * ImgWidth], &ImgData[half + i * 2 * ImgWidth + ImgWidth], ImgWidth); } glCompressedTexSubImage2DARB(Target, 0, ImgWidth / 2, ImgHeight / 2, /* pos */ diff --git a/progs/tests/texdown.c b/progs/tests/texdown.c index 7e460458325..e6881d39a0a 100644 --- a/progs/tests/texdown.c +++ b/progs/tests/texdown.c @@ -176,6 +176,8 @@ MeasureDownloadRate(void) orig_getImage = (GLubyte *) malloc(image_bytes + ALIGN); if (!orig_texImage || !orig_getImage) { DownloadRate = 0.0; + free(orig_texImage); + free(orig_getImage); return; } diff --git a/progs/tests/vao-01.c b/progs/tests/vao-01.c index 117fae8bd9e..e4a89cb19db 100644 --- a/progs/tests/vao-01.c +++ b/progs/tests/vao-01.c @@ -124,10 +124,10 @@ static void Init( void ) exit(2); } - bind_vertex_array = glutGetProcAddress( "glBindVertexArrayAPPLE" ); - gen_vertex_arrays = glutGetProcAddress( "glGenVertexArraysAPPLE" ); - delete_vertex_arrays = glutGetProcAddress( "glDeleteVertexArraysAPPLE" ); - is_vertex_array = glutGetProcAddress( "glIsVertexArrayAPPLE" ); + bind_vertex_array = (PFNGLBINDVERTEXARRAYAPPLEPROC) glutGetProcAddress( "glBindVertexArrayAPPLE" ); + gen_vertex_arrays = (PFNGLGENVERTEXARRAYSAPPLEPROC) glutGetProcAddress( "glGenVertexArraysAPPLE" ); + delete_vertex_arrays = (PFNGLDELETEVERTEXARRAYSAPPLEPROC) glutGetProcAddress( "glDeleteVertexArraysAPPLE" ); + is_vertex_array = (PFNGLISVERTEXARRAYAPPLEPROC) glutGetProcAddress( "glIsVertexArrayAPPLE" ); (*gen_vertex_arrays)( 1, & obj ); diff --git a/progs/tests/vao-02.c b/progs/tests/vao-02.c index 7764ed51061..9f7f5c27792 100644 --- a/progs/tests/vao-02.c +++ b/progs/tests/vao-02.c @@ -125,10 +125,10 @@ static void Init( void ) exit(2); } - bind_vertex_array = glutGetProcAddress( "glBindVertexArrayAPPLE" ); - gen_vertex_arrays = glutGetProcAddress( "glGenVertexArraysAPPLE" ); - delete_vertex_arrays = glutGetProcAddress( "glDeleteVertexArraysAPPLE" ); - is_vertex_array = glutGetProcAddress( "glIsVertexArrayAPPLE" ); + bind_vertex_array = (PFNGLBINDVERTEXARRAYAPPLEPROC) glutGetProcAddress( "glBindVertexArrayAPPLE" ); + gen_vertex_arrays = (PFNGLGENVERTEXARRAYSAPPLEPROC) glutGetProcAddress( "glGenVertexArraysAPPLE" ); + delete_vertex_arrays = (PFNGLDELETEVERTEXARRAYSAPPLEPROC) glutGetProcAddress( "glDeleteVertexArraysAPPLE" ); + is_vertex_array = (PFNGLISVERTEXARRAYAPPLEPROC) glutGetProcAddress( "glIsVertexArrayAPPLE" ); (*gen_vertex_arrays)( 1, & obj ); diff --git a/progs/tests/zreaddraw.c b/progs/tests/zreaddraw.c index 7dfed20cfb9..7740695bb66 100644 --- a/progs/tests/zreaddraw.c +++ b/progs/tests/zreaddraw.c @@ -58,6 +58,10 @@ static void Display(void) printf("Depth value range: [%f, %f]\n", min, max); } + /* Draw the Z image as luminance above original rendering */ + glWindowPos2i(0, 100); + glDrawPixels(100, 100, GL_LUMINANCE, depthType, depth); + if (TestPacking) { glPixelStorei(GL_PACK_ROW_LENGTH, 0); glPixelStorei(GL_PACK_SKIP_PIXELS, 0); @@ -100,6 +104,7 @@ static void Display(void) glReadPixels(100, 0, 400, 400, GL_DEPTH_COMPONENT, GL_FLOAT, depth2); /* draw as luminance */ glPixelZoom(1.0, 1.0); + glWindowPos2i(100, 0); glDrawPixels(400, 400, GL_LUMINANCE, GL_FLOAT, depth2); glutSwapBuffers(); |