PDA

View Full Version : 3D Cube

pam coke
04-12-2001, 08:39 AM
I am trying to draw a simple cube. I am reading the x,y,z values from a file into a two-dimensional array. Currently I am using a for loop with glVertex3f(x,y,z), and GL_LINE_STRIPS. So far I get a square a line going through it, not a cube.

Deiussum
04-12-2001, 10:36 AM
Obviously you are not setting up your for loops correctly. http://www.opengl.org/discussion_boards/ubb/smile.gif

Without more info, there's really nothing more we can tell you, short of writing out the code for you. And you really should have a good enough grasp of programming to figure that out on your own before learning OpenGL.

pam coke
04-12-2001, 10:47 AM
So what you are saying is that the glVertex3f and GL_LINE_STRIP is correct and reading the information from the file is not creating a problem.
This is my loop. It is simple a loop that will continue until all the vertices are complete.
example
for(i=0;i<j;i++)
glVertex3f(x,y,z);

j being the index in the array were the vertices are stored.
Is this the information that you need?

rts
04-12-2001, 11:06 AM
This is just a wild guess based on what (little) info is available http://www.opengl.org/discussion_boards/ubb/smile.gif

It's probably a square because you're looking at one face straight on.

The "line through the middle" is probably a line from one corner to the opposite corner, probably comes from "closing the loop".

Hope that helps.

Deiussum
04-12-2001, 11:13 AM
Ahhh... didn't notice that you said you were reading the coordinates from a file so I assumed you were using the value of nested for loops to set the coordinates.

How do you setup your projection matrix? Are you certain the data in your file is correct?

pam coke
04-12-2001, 11:17 AM
glMatrixMode( GL_MODELVIEW )
glMatrixMode( GL_PROJECTION )

Is this what you are talking about?
I really don't know much about opengl at all.

nickn
04-12-2001, 11:20 AM
Try going to the Neon Helium site for some tutorials that will take you into OpenGL from the very start. They're at nehe.gamedev.com.

Deiussum
04-12-2001, 02:10 PM
Actually, I was wondering what you were using in the way of glFrustum, glOrtho, gluPerspective...

Check out the Nehe tutorials and try and find a copy of the Red Book. They'll help a lot.