3D Cube

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.
Please Help

Obviously you are not setting up your for loops correctly.

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.

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?

This is just a wild guess based on what (little) info is available

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.

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?

glMatrixMode( GL_MODELVIEW )
glMatrixMode( GL_PROJECTION )

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

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.

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.