Jump to content
  • Advertisement
Sign in to follow this  
kibokun

OpenGL Problem drawing 2d points

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


Link to post
Share on other sites
Advertisement
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 camera
glLoadIdentity()

# Draw
glBegin( GL_POINTS )
glVertex3f( 1, 1, -5 )
glVertex3f( 5, 5, -5 )
glVertex3f( 7, 8, -5 )
glVertex3f( 9, 10, -5 )
glVertex3f( 11, 12, -5 )
# ...
glEnd()




  • 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!