Jump to content
  • Advertisement
Sign in to follow this  
FlowingOoze

ATI's glLoadTransposeMatrix broken?

This topic is 4974 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

This time I'm sure it's a bug. I've managed to replicate it in a small Glut program. Here are the OGL calls of the draw() function (called by idle and display functions):
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	glFrustum(-0.01,0.01,-0.01,0.01,0.01,100);
	glMatrixMode(GL_MODELVIEW);

	glLoadTransposeMatrixf(m);
	//glLoadMatrixf(m);
	
	float p[4];
	p[0]=2; p[1]=0; p[2]=0; p[3]=1;
	glLightfv(GL_LIGHT0,GL_POSITION,p);
	
	glPushMatrix();
	
	glTranslatef(0,0,-2);
	glBegin(GL_QUADS);
	glNormal3f(0,0,1);
	glVertex3f(-1,-1,0);
	glVertex3f( 1,-1,0);
	glVertex3f( 1, 1,0);
	glVertex3f(-1, 1,0);
	glEnd();
	
	glPopMatrix();
	
	glutSwapBuffers();

Lighting is enable with specular color set to 0. The matrix loaded as the model view matrix is a simple rotation matrix around Y-axis. So there's a quad and a light that rotate around the viewer. Thus the vertex colors should remain constant. What actually happens is that the light position seems to remain untransformed by the modelview matrix, so the vertex colors change as the quad rotates. This problem disappears if I do any of the following: 1. Use glLoadMatrixf instead of glLoadTransposeMatrixf 2. Remove glPushMatrix() and glPopMatrix() 3. Add a dummy glTranslatef(0,0,0) before a call to glLightfv() I've got Radeon 9800 Pro, with fglrx_6_8_0-8.10.19-1, running on Fedora Core 3.

Share this post


Link to post
Share on other sites
Advertisement
For those interrested in trying it, here's the whole source

#include <GL/glut.h>
#include <iostream>
#include <cmath>

using namespace std;

void keyboard(unsigned char key,int x,int y)
{
}


void draw()
{
static float angle=0;
static float dir=1;
angle+=dir*0.1/180*M_PI;
if (angle>M_PI/180*30) dir=-1;
if (angle<-M_PI/180*30) dir=1;

float m[16];
for(int i=0;i<16;i++) m=0;
m[0]=m[5]=m[10]=m[15]=1;
m[0]=m[10]=cos(angle);
m[2]=-sin(angle);
m[8]=sin(angle);

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(-0.01,0.01,-0.01,0.01,0.01,100);
glMatrixMode(GL_MODELVIEW);
glLoadTransposeMatrixf(m);
//glLoadMatrixf(m);

//glTranslatef(0,0,0);

float p[4];
p[0]=2; p[1]=0; p[2]=0; p[3]=1;
glLightfv(GL_LIGHT0,GL_POSITION,p);

glPushMatrix();

glTranslatef(0,0,-2);
glBegin(GL_QUADS);
glNormal3f(0,0,1);
glVertex3f(-1,-1,0);
glVertex3f( 1,-1,0);
glVertex3f( 1, 1,0);
glVertex3f(-1, 1,0);
glEnd();

glPopMatrix();

glutSwapBuffers();
}

void display()
{
draw();
}

void idle()
{
draw();
}

int main(int argc,char *argv[])
{
cout << "GL Suck test!\n";
glutInit(&argc,argv);

glutInitDisplayMode( GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH );
glutCreateWindow("GL Suck Test");
glutInitWindowSize(800,800);
glutDisplayFunc(display);
glutKeyboardFunc(keyboard);
glutIdleFunc(idle);

glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
float c[4];
c[0]=0.1; c[1]=0.2; c[3]=0.8; c[4]=1;
glLightModelfv(GL_LIGHT_MODEL_AMBIENT,c);
c[0]=c[1]=c[2]=c[3]=0;
glLightfv(GL_LIGHT0,GL_SPECULAR,c);

glutMainLoop();

return 0;
}



Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!