[SDL] SDL/OpenGL

Nathan Cournia acnatha at vr.clemson.edu
Wed Sep 11 18:36:01 PDT 2002


This is an OpenGL question.  Check out these sites for great tutorials
on OpenGL:

http://nehe.gamedev.net/
http://www.gametutorials.com/

nathan


On Wed, 2002-09-11 at 21:29, Byron Wright wrote:
> Hi all,
> 
> 
> Not sure if this is SDL or OpenGL related, I am trying to simple rotate
> a QUAD (yes very newbie question) but am not getting the results I want.
> Basically what's happening is that the QUAD is rotating around the top
> left vertex and not around the quad's center. I would like it to rotate
> around the center of the quad. This this how OpenGL works or am I doing
> something wrong? The code is as follow:
> 
> 	glPushMatrix();	//push projection onto stack
> 	glTranslatef(mPosition.x,mPosition.y,mPosition.z);
> 	glRotatef(rotation,0.0f,0.0f,1.0f);//rotate around z axis
> 		glBegin(GL_QUADS);		
> 			glColor3f(1.0f, 0.0f, 0.0f); 
> 			glVertex2f(0.0f, 0.0f); 
> 			glVertex2f(64.0f, 0.0f); 
> 			glVertex2f(64.0f, 32.0f); 
> 			glVertex2f(0.0f, 32.0f); 
> 		glEnd();
> 	glPopMatrix(); 
> 
> 
> This is how my projection matrix is set up:
> 
> glViewport(0, 0, 640, 480); 	
> glMatrixMode(GL_PROJECTION);
> glLoadIdentity(); //clear
> glOrtho(0.0f,640,480,0,-1.0f,1.0f);
> glMatrixMode(GL_MODELVIEW);
> glLoadIdentity();
> 
> Any help would be gladly appreciated.
> 
> -Byron
> 
> 
> _______________________________________________
> SDL mailing list
> SDL at libsdl.org
> http://www.libsdl.org/mailman/listinfo/sdl
> 





More information about the SDL mailing list