Package: libgl1-mesa-dri Version: 6.5.0.cvs.20060524-1.1 Severity: normal When using GL_ARB_texture_cube_map with the R200 DRI driver and GL_REFLECTION_MAP_ARB, the generated texture coordinates are flipped from what they should be. That is, rotating the texture 180 degrees around the X axis and then 180 degrees around the Y axis will result in a "correct" image.
I'm judging "correct" by comparing it to non-DRI MESA using the GLX Indirect renderer, and also compared this to ATI's proprietary fglrx renderer. I will try to attach the following: - A modification of Brian Paul's cube map demo program from 2000, slightly modified and with initial comments describing the problem. - Images of the demo's output for different renderers. -- System Information: Debian Release: testing/unstable APT prefers testing APT policy: (990, 'testing'), (800, 'unstable'), (700, 'experimental') Architecture: i386 (i686) Shell: /bin/sh linked to /bin/bash Kernel: Linux 2.6.17 Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) Versions of packages libgl1-mesa-dri depends on: ii libc6 2.3.6.ds1-4 GNU C Library: Shared libraries ii libdrm2 2.0.1-1 Userspace interface to kernel DRM ii libexpat1 1.95.8-3.3 XML parsing C library - runtime li ii libgl1-mesa-glx 6.5.0.cvs.20060524-1.1 A free implementation of the OpenG libgl1-mesa-dri recommends no packages. -- no debconf information
/* $Id: cubemap.c,v 1.3 2000/06/27 17:04:43 brianp Exp $ */
/*
* GL_ARB_texture_cube_map demo
*
* Brian Paul
* May 2000
*
*
* Copyright (C) 2000 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/*
* This is a pretty minimalistic demo for now. Eventually, use some
* interesting cube map textures and 3D objects.
* For now, we use 6 checkerboard "walls" and a sphere (good for
* verification purposes).
*/
/*
* modified 9/24/06 by Dan Torop to try to figure out if
* Mesa's R200 DRI driver is flipping textures compared to ATI's
* proprietary driver
*/
/*
* For the Mesa R200 DRI:
* renderer: Mesa DRI R200 20060327 AGP 4x TCL
* version: 1.3 Mesa 6.5.1
*
* GL_REFLECTION_MAP_ARB (r200-reflection.png):
* 3 (green)
* 2 (cyan) 6 (yellow) 1 (red)
* 4 (magenta)
*
* 5 (blue) is in back
*
* GL_NORMAL_MAP_ARB (r200-normal.png):
* 3 (green)
* 2 (cyan) 6 (yellow) 1 (red)
* 4 (magenta)
*
* 5 (blue) is in back
*
* -----------------------------------------------------------------------
*
* MESA without DRI:
* renderer: Mesa GLX Indirect
* version: 1.2 (1.5 Mesa 6.5.1)
*
* GL_REFLECTION_MAP_ARB (mesa-reflection.png):
* 4 (magenta)
* 1 (red) 5 (blue) 2 (cyan)
* 3 (green)
*
* 6 (yellow) is in back
*
* GL_NORMAL_MAP_ARB (mesa-normal.png):
* 3 (green)
* 2 (cyan) 6 (yellow) 1 (red)
* 4 (magenta)
*
* 5 (blue) is in back
*
* -----------------------------------------------------------------------
*
* For ATI's proprietary fglrx:
* renderer: FireMV 2400 PCI DDR Pentium 4 (SSE2) (FireGL) (GNU_ICD)
* version: 1.3.1091 (X4.3.0-8.28.8)
*
* GL_REFLECTION_MAP_ARB (ati-reflection.png):
* 4 (magenta)
* 1 (red) 5 (blue) 2 (cyan)
* 3 (green)
*
* 6 (yellow) is in back
*
* GL_NORMAL_MAP_ARB (ati-normal.png):
* 3 (green)
* 2 (cyan) 6 (yellow) 1 (red)
* 4 (magenta)
*
* 5 (blue) is in back
*
*/
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "GL/glut.h"
static GLfloat Xrot = 0, Yrot = 0;
static void draw( void )
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glRotatef(Xrot, 1, 0, 0);
glRotatef(Yrot, 0, 1, 0);
glutSolidSphere(2.0, 20, 20);
glMatrixMode(GL_MODELVIEW);
glutSwapBuffers();
}
static void set_mode(GLuint mode)
{
if (mode == 0) {
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_ARB);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_ARB);
glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_ARB);
printf("GL_REFLECTION_MAP_ARB mode\n");
}
else if (mode == 1) {
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_ARB);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_ARB);
glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_ARB);
printf("GL_NORMAL_MAP_ARB mode\n");
}
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glEnable(GL_TEXTURE_GEN_R);
}
static void key(unsigned char k, int x, int y)
{
static GLuint mode = 0;
switch (k) {
case 'm':
mode = !mode;
set_mode(mode);
break;
case 27:
exit(0);
}
glutPostRedisplay();
}
static void specialkey(int key, int x, int y)
{
GLfloat step = 10;
(void) x;
(void) y;
switch (key) {
case GLUT_KEY_UP:
Xrot -= step;
break;
case GLUT_KEY_DOWN:
Xrot += step;
break;
case GLUT_KEY_LEFT:
Yrot -= step;
break;
case GLUT_KEY_RIGHT:
Yrot += step;
break;
}
glutPostRedisplay();
}
/* new window size or exposure */
static void reshape(int width, int height)
{
glViewport(0, 0, (GLint)width, (GLint)height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum( -2.0, 2.0, -2.0, 2.0, 6.0, 20.0 );
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef( 0.0, 0.0, -8.0 );
}
static void init( void )
{
#define CUBE_TEX_SIZE 64
GLubyte image[CUBE_TEX_SIZE][CUBE_TEX_SIZE][3];
static const GLubyte colors[6][3] = {
{ 255, 0, 0 },
{ 0, 255, 255 },
{ 0, 255, 0 },
{ 255, 0, 255 },
{ 0, 0, 255 },
{ 255, 255, 0 }
};
#define NUM_HEIGHT 8
#define NUM_WIDTH 4
static const GLubyte crude_nums[6][NUM_HEIGHT][NUM_WIDTH] = {
// 1
{
{ 0, 0, 1, 0 },
{ 0, 1, 1, 0 },
{ 0, 0, 1, 0 },
{ 0, 0, 1, 0 },
{ 0, 0, 1, 0 },
{ 0, 0, 1, 0 },
{ 0, 0, 1, 0 },
{ 0, 1, 1, 1 },
},
// 2
{
{ 0, 1, 1, 0 },
{ 1, 0, 0, 1 },
{ 0, 0, 0, 1 },
{ 0, 0, 1, 0 },
{ 0, 0, 1, 0 },
{ 0, 1, 0, 0 },
{ 1, 0, 0, 0 },
{ 1, 1, 1, 1 },
},
// 3
{
{ 0, 1, 1, 0 },
{ 1, 0, 0, 1 },
{ 0, 0, 0, 1 },
{ 0, 0, 0, 0 },
{ 0, 1, 1, 0 },
{ 0, 0, 0, 1 },
{ 1, 0, 0, 1 },
{ 0, 1, 1, 0 },
},
// 4
{
{ 1, 0, 0, 1 },
{ 1, 0, 0, 1 },
{ 1, 0, 0, 1 },
{ 1, 1, 1, 1 },
{ 0, 0, 0, 1 },
{ 0, 0, 0, 1 },
{ 0, 0, 0, 1 },
{ 0, 0, 0, 1 },
},
// 5
{
{ 1, 1, 1, 1 },
{ 1, 0, 0, 0 },
{ 1, 0, 0, 0 },
{ 1, 1, 1, 0 },
{ 0, 0, 0, 1 },
{ 0, 0, 0, 1 },
{ 0, 0, 0, 1 },
{ 1, 1, 1, 0 },
},
// 6
{
{ 0, 1, 1, 0 },
{ 1, 0, 0, 1 },
{ 1, 0, 0, 0 },
{ 1, 0, 0, 0 },
{ 1, 1, 1, 0 },
{ 1, 0, 0, 1 },
{ 1, 0, 0, 1 },
{ 0, 1, 1, 0 },
}
};
static const GLenum targets[6] = {
GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB,
GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB,
GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB,
GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB,
GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB,
GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB
};
GLint i, j, f;
/* check for extension */
{
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);
}
}
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
/* make colored checkerboard cube faces */
for (f = 0; f < 6; f++) {
for (i = 0; i < CUBE_TEX_SIZE; i++) {
for (j = 0; j < CUBE_TEX_SIZE; j++) {
image[i][j][0] = colors[f][0];
image[i][j][1] = colors[f][1];
image[i][j][2] = colors[f][2];
}
}
// crudely draw numbers in the center
for (i = 0; i < NUM_HEIGHT; ++i) {
for (j = 0; j < NUM_WIDTH; ++j) {
if (crude_nums[f][i][j]) {
int x=CUBE_TEX_SIZE/2-i;
int y=CUBE_TEX_SIZE/2-j;
image[x][y][0] = image[x][y][1] = image[x][y][2] = 0;
}
}
}
glTexImage2D(targets[f], 0, GL_RGB, CUBE_TEX_SIZE, CUBE_TEX_SIZE, 0,
GL_RGB, GL_UNSIGNED_BYTE, image);
}
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glEnable(GL_TEXTURE_CUBE_MAP_ARB);
glClearColor(.3, .3, .3, 0);
glColor3f( 1.0, 1.0, 1.0 );
set_mode(0);
}
static void usage(void)
{
printf("keys:\n");
printf(" CURSOR KEYS - rotation\n");
printf(" m - toggle texgen reflection mode\n");
}
int main( int argc, char *argv[] )
{
glutInit(&argc, argv);
glutInitWindowPosition(0, 0);
glutInitWindowSize(300, 300);
glutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE );
glutCreateWindow("Texture Cube Maping");
init();
glutReshapeFunc( reshape );
glutKeyboardFunc( key );
glutSpecialFunc( specialkey );
glutDisplayFunc( draw );
usage();
glutMainLoop();
return 0;
}
CC= gcc
LDFLAGS=-L/usr/X11R6/lib
LIBS= -lglut -lGL -lGLU -lX11 -lXext -lXmu -lXi -lm
TARGET = cubemap
OBJS = cubemap.o
.c.o:
$(CC) -Wall -O2 -c -o $@ $<
$(TARGET): $(OBJS)
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
clean:
$(RM) $(TARGET) $(OBJS)
r200-reflection.png
Description: PNG image
r200-normal.png
Description: PNG image
mesa-reflection.png
Description: PNG image
mesa-normal.png
Description: PNG image
ati-reflection.png
Description: PNG image
ati-normal.png
Description: PNG image

