# OpenGL Co-ordinate System

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

## Recommended Posts

Hi, I'm having a bit of trouble with the co-ordinate system in OpenGL. I thought I had a good enough understanding to draw some basic shapes, but my code isn't working right and I don't know why. It's a pong clone, the paddles display fine, but the ball doesn't (doesn't appear). I've just copied the important bits Thanks in advance.
...float P1Height = 1.0;
float P2Height = 1.0;

float BCenter = 0.0f;
float P1Center = 0.0f;
float P2Center = 0.0f;

float BSpeed = 0.2f;...

//Player One - left side
glVertex3f( -6.5f, P1Center + P1Height, -10.0f);		// Top Left
glVertex3f( -6.2f, P1Center + P1Height, -10.0f);		// Top Right
glVertex3f( -6.2f, P1Center - P1Height, -10.0f);		// Bottom Right
glVertex3f( -6.5f, P1Center - P1Height, -10.0f);		// Bottom Left

//Player Two - right side
glVertex3f( 6.5f, P2Center - P2Height, -10.0f);		// Top Left
glVertex3f( 6.2f, P2Center - P2Height, -10.0f);		// Top Right
glVertex3f( 6.2f, P2Center + P2Height, -10.0f);		// Bottom Right
glVertex3f( 6.5f, P2Center + P2Height, -10.0f);		// Bottom Left

//Ball - center

glEnd(); //End quadrilateral coordinates...
[Edited by - Kewley on March 30, 2008 5:12:32 PM]

##### Share on other sites
Check the order of your vertices when drawing the ball. In your code, you're going from the bottom left corner to the top right. Either go clockwise or counter-clockwise around the polygon :)

EDIT: You also appear to be placing vertices in the same place when drawing the ball :s

##### Share on other sites
Sorry I've taken a while to reply. I'm having a few problems with my laptop at the moment, and on top of that Visual Studio keep throwing errors at me left, right and center every time I start up an IDE. I'm going to try and fix it all next weekend and then hopefully get back on this. Sorry.

1. 1
2. 2
3. 3
4. 4
5. 5
Rutin
18

• 11
• 12
• 9
• 12
• 37
• ### Forum Statistics

• Total Topics
631420
• Total Posts
2999990
×