-/* $Id: texwrap.c,v 1.5 2003/02/04 02:35:00 brianp Exp $ */
/*
* Test texture wrap modes.
*/
-#define GL_GLEXT_PROTOTYPES
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
+#include <GL/glew.h>
#include <GL/glut.h>
#define GL_MIRRORED_REPEAT 0x8370
#endif
-#ifndef GL_ATI_texture_mirror_once
-#define GL_MIRROR_CLAMP_ATI 0x8742
-#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743
+#ifndef GL_EXT_texture_mirror_clamp
+#define GL_MIRROR_CLAMP_EXT 0x8742
+#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743
+#define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912
#endif
#define BORDER_TEXTURE 1
#define NO_BORDER_TEXTURE 2
+#define COLOR_TEX_CORNERS 0
#define SIZE 8
static GLubyte BorderImage[SIZE+2][SIZE+2][4];
static GLubyte NoBorderImage[SIZE][SIZE][4];
-static GLuint Border = 1;
+static GLuint Border = 0;
+#define TILE_SIZE 110
#define WRAP_MODE(m) { m , # m, GL_TRUE, 1.0, { NULL, NULL } }
#define WRAP_EXT(m,e1,e2,v) { m , # m, GL_FALSE, v, { e1, e2 } }
WRAP_EXT ( GL_MIRRORED_REPEAT, "GL_ARB_texture_mirrored_repeat",
"GL_IBM_texture_mirrored_repeat",
1.4 ),
- WRAP_EXT ( GL_MIRROR_CLAMP_ATI, "GL_ATI_texture_mirror_once",
- NULL,
+ WRAP_EXT ( GL_MIRROR_CLAMP_EXT, "GL_ATI_texture_mirror_once",
+ "GL_EXT_texture_mirror_clamp",
999.0 ),
- WRAP_EXT ( GL_MIRROR_CLAMP_TO_EDGE_ATI, "GL_ATI_texture_mirror_once",
- NULL,
+ WRAP_EXT ( GL_MIRROR_CLAMP_TO_BORDER_EXT, "GL_EXT_texture_mirror_clamp",
+ NULL,
999.0 ),
- { 0 }
+ WRAP_EXT ( GL_MIRROR_CLAMP_TO_EDGE_EXT, "GL_ATI_texture_mirror_once",
+ "GL_EXT_texture_mirror_clamp",
+ 999.0 ),
+ { 0, NULL, GL_FALSE, 0.0, { NULL, NULL } }
};
static void
}
/* loop over border modes */
- for (j = 0; j < modes[j].mode != 0; j++) {
- const GLfloat x0 = 0, y0 = 0, x1 = 140, y1 = 140;
- const GLfloat b = 0.2;
+ for (j = 0; modes[j].mode != 0; j++) {
+ const GLfloat x0 = 0, y0 = 0, x1 = (TILE_SIZE - 10), y1 = (TILE_SIZE - 10);
+ const GLfloat b = 1.2;
const GLfloat s0 = -b, t0 = -b, s1 = 1.0+b, t1 = 1.0+b;
if ( modes[j].supported != GL_TRUE )
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, modes[j].mode);
glPushMatrix();
- glTranslatef(offset * 150 + 10, i * 150 + 40, 0);
+ glTranslatef(offset * TILE_SIZE + 10, i * TILE_SIZE + 40, 0);
offset++;
glEnable(GL_TEXTURE_2D);
glDisable(GL_TEXTURE_2D);
glColor3f(1, 1, 1);
offset = 0;
- for (i = 0; i < modes[i].mode != 0; i++) {
+ for (i = 0; modes[i].mode != 0; i++) {
if ( modes[i].supported ) {
- glWindowPos2iARB( offset * 150 + 10, 5 + ((offset & 1) * 15) );
+ glWindowPos2iARB( offset * TILE_SIZE + 10, 5 + ((offset & 1) * 15) );
PrintString(modes[i].name);
offset++;
}
}
glBindTexture(GL_TEXTURE_2D, BORDER_TEXTURE);
+#ifdef TEST_PBO_DLIST
+ /* test fetching teximage from PBO in display list */
+ {
+ GLuint b = 42, l = 10;
+
+ glBindBufferARB(GL_PIXEL_UNPACK_BUFFER, b);
+ glBufferDataARB(GL_PIXEL_UNPACK_BUFFER, sizeof(BorderImage),
+ BorderImage, GL_STREAM_DRAW);
+
+ glNewList(l, GL_COMPILE);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, SIZE+2, SIZE+2, 1,
+ GL_RGBA, GL_UNSIGNED_BYTE, (void *) 0/* BorderImage*/);
+ glEndList();
+ glCallList(l);
+ glBindBufferARB(GL_PIXEL_UNPACK_BUFFER, 0);
+ }
+#else
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, SIZE+2, SIZE+2, 1,
GL_RGBA, GL_UNSIGNED_BYTE, (void *) BorderImage);
+#endif
for (i = 0; i < SIZE; i++) {
for (j = 0; j < SIZE; j++) {
+#if COLOR_TEX_CORNERS
+ if (i == 0 && j == 0) {
+ /* lower-left texel = RED */
+ NoBorderImage[i][j][0] = 255;
+ NoBorderImage[i][j][1] = 0;
+ NoBorderImage[i][j][2] = 0;
+ NoBorderImage[i][j][3] = 255;
+ }
+ else if (i == 0 && j == SIZE-1) {
+ /* lower-right corner = GREEN */
+ NoBorderImage[i][j][0] = 0;
+ NoBorderImage[i][j][1] = 255;
+ NoBorderImage[i][j][2] = 0;
+ NoBorderImage[i][j][3] = 255;
+ }
+ else if (i == SIZE-1 && j == 0) {
+ /* upper-left corner = BLUE */
+ NoBorderImage[i][j][0] = 0;
+ NoBorderImage[i][j][1] = 0;
+ NoBorderImage[i][j][2] = 255;
+ NoBorderImage[i][j][3] = 255;
+ }
+ else if (i == SIZE-1 && j == SIZE-1) {
+ /* upper-right corner = YELLOW */
+ NoBorderImage[i][j][0] = 255;
+ NoBorderImage[i][j][1] = 255;
+ NoBorderImage[i][j][2] = 0;
+ NoBorderImage[i][j][3] = 255;
+ }
+ else
+#endif
if ((i + j) & 1) {
/* white */
NoBorderImage[i][j][0] = 255;
{
glutInit( &argc, argv );
glutInitWindowPosition( 0, 0 );
- glutInitWindowSize( 800, 355 );
+ glutInitWindowSize( 1000, 270 );
glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
glutCreateWindow(argv[0]);
+ glewInit();
glutReshapeFunc( Reshape );
glutKeyboardFunc( Key );
glutDisplayFunc( Display );