Jump to content
  • Advertisement
Sign in to follow this  
CryonicGhost

OpenGL Simple Vertex Question

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

I'm new to using OpenGL and have a simple question regarding vertices. Why will the following code display a line: // Draw a line from the center towards the top right hand corner glTranslatef(0.0f,0.0f,0.0f) glBegin(GL_LINES); glVertex3f(0.0f, 0.0f, 0.0f); glVertex3f(1.0f, 1.0f, 0.0f); // Draw a 45deg line glEnd(); but the follwing code won't // Draw a translated line towards the center i.e. from the top left hand corner down towards the center of the view glTranslatef(-1.0f,1.0f,0.0f) glBegin(GL_LINES); glVertex3f(0.0f, 0.0f, 0.0f); glVertex3f(0.8f, -1.0f, 0.0f); // Draw a steeper line, NOTE: 0.8f glEnd(); It won't seem to draw a line in the second case unless the values for the coeffecients are all 1.0f or 0.0f i.e. only horizontal,vertical and 45degree lines will be displayed. Is there something I'm doing wrong/have I missed something or is my logic regarding translations etc wrong?

Share this post


Link to post
Share on other sites
Advertisement
try changing
glTranslatef(-1.0f,1.0f,0.0f)
to
glTranslatef(-0.0001f,0.0f,0.0f)

u shold see the line slowly moving ( i assume the problem is youre not restting the modelview matrix ever frame thus the translations are accumulating)

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!