Advertisement

Displaying a line with OpenGL help.......

Started by March 14, 2003 06:51 PM
6 comments, last by incognito 21 years, 11 months ago
What's wrong with this?
  

          glBegin(GL_LINES);
     
          glColor3ub( 255, 255, 255);
          glVertex3f(10,  20,30);
		  glVertex3f(20,  30,0);
       
          glEnd();

   
PROGRAMMING IS THE FUTURE........ THE FUTURE IS HERE!!!!!!! [edited by - incognito on March 14, 2003 8:21:47 PM]
PROGRAMMING IS THE FUTURE........ THE FUTURE IS HERE!!!!!!!
Nothing. But there are more thing than these five lines of code that affects what is drawn and how it''s drawn.
Advertisement
Quite simple
on your x,y,z vertex, you set z to +30, which is way out of the screen
try this

        glBegin(GL_LINES);	glColor3ub( 255, 255, 255);	glVertex3f(0,  0,-30);	glVertex3f(0,  1, -30);      glEnd();  


-ErayMan
oh thanks guys, (obviously you can tell I am a beginneer.....btw how do you use code tags on this board?

PROGRAMMING IS THE FUTURE........ THE FUTURE IS HERE!!!!!!!
PROGRAMMING IS THE FUTURE........ THE FUTURE IS HERE!!!!!!!
[ source ] ... code goes here ... [ /source ] minus the spaces. It''s all in the Forum FAQ.
ReactOS - an Open-source operating system compatible with Windows NT apps and drivers
Sorry it''s me again........what''s wrong with THIS....



  		glBegin(GL_TRIANGLES);		glVertex3f(2.0,  1.0,0.0);		glVertex3f(3.0,  1.0, 00);		glVertex3f(0.0,  3.0,0.0);		glEnd();  
PROGRAMMING IS THE FUTURE........ THE FUTURE IS HERE!!!!!!!
Advertisement
well, first of all, that double 0 there, you should change it to 0.0
then, drawing a triangle with "z" being equal to "0" at it''s ends will probably not be in the screen

think of it as this:
when you''re drawing your triangle:

when z = 5, it means that the line will be drawn 5 units from the screen, BETWEEN you and your screen, which, obviously, can''t be seen in your monitor

when z = -5, it means that the line will be drawn 5 units INSIDE the screen, which you can see very well

when z = 0, it draw not in the screen, neither it does not draw toward you, but directly on the lens of your monitor, which is between the screen where everything is drawn and you, so you will have a hard time seeing it
try putting it right in the middle of the screen, and a little bit inside so that you can see it:

glBegin(GL_TRIANGLES);
glVertex3f(-1.0f, -1.0f, -0.1f);
glVertex3f( 0.0f, 1.0f, -0.1f);
glVertex3f( 1.0f, -1.0f, -0.1f);
glEnd();

there, this draw a triangle right in the middle of the screen, and a little bit inside

now, it is so close to te lens of the monitor that you probably see nothing else but the triangle, so try setting the "z" value to -10.0, and see for yourself, hope this helps!

(btw, it is good practice to put an lowercase "f" after these number, just to say that they really are floats numbers and nothing else

this will get rid of some warning in visual c++)
-ErayMan
whoa, cool thank you guys, it works now. I think I might have gotten myself ahead of the book, because I think that's explained further into the book.

PROGRAMMING IS THE FUTURE........ THE FUTURE IS HERE!!!!!!!

[edited by - incognito on March 15, 2003 8:15:51 AM]
PROGRAMMING IS THE FUTURE........ THE FUTURE IS HERE!!!!!!!

This topic is closed to new replies.

Advertisement