Jump to content
• Advertisement

# OpenGL Problem drawing 2d points

This topic is 3209 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

So I'm writing my first openGL program and it's just a simple 2d particle simulator with some pseudo-gravity calculation. Right now the problem I'm having is telling it actually WHERE on the window to draw these points. Here's my Draw function:
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)

glLoadIdentity()

#glTranslatef(0.0,0.0,-6.0)

glPointSize(20)

glTranslatef(1, 1,-5)
glBegin(GL_POINTS)
glVertex3f(0,0,0)
glEnd()

glTranslatef(4, 4,0)
glBegin(GL_POINTS)
glVertex3f(0,0,0)
glEnd()
pygame.display.flip()

What happens here is that if the coordinates passed to glTranslatef are even over 10 or so, they're drawn off screen. My resolution is 800, 600. I would expect to be able to draw in that full range. I learned this method of translate where you want, draw a point at the origin and repeat from a tutorial and it didn't explain WHY this was the way to do it. It seems very counter-intuitive so a new way would be greatly appreciated.

#### Share this post

##### Share on other sites
Advertisement
Can you show the code where you set up the camera and whatnot?

#### Share this post

##### Share on other sites
Try using glViewport.

Quote:
 I learned this method of translate where you want, draw a point at the origin and repeat from a tutorial and it didn't explain WHY this was the way to do it. It seems very counter-intuitive so a new way would be greatly appreciated.

What tutorial are you learning from? How familiar are you with 3D math?

# Set up the cameraglLoadIdentity()# DrawglBegin( GL_POINTS )glVertex3f( 1, 1, -5 )glVertex3f( 5, 5, -5 )glVertex3f( 7, 8, -5 )glVertex3f( 9, 10, -5 )glVertex3f( 11, 12, -5 )# ...glEnd()

• Advertisement

### Announcements

• Advertisement

• ### Popular Contributors

1. 1
2. 2
3. 3
Rutin
21
4. 4
5. 5
khawk
14
• Advertisement

• 9
• 11
• 11
• 23
• 10
• ### Forum Statistics

• Total Topics
633653
• Total Posts
3013152
×

## Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!