View Full Version : 3D Cube
04-12-2001, 09: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.
04-12-2001, 11: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.
04-12-2001, 11: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.
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 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.
04-12-2001, 12:13 PM
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?
04-12-2001, 12:17 PM
glMatrixMode( GL_MODELVIEW )
glMatrixMode( GL_PROJECTION )
Is this what you are talking about?
I really don't know much about opengl at all.
04-12-2001, 12:20 PM
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.
04-12-2001, 03: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.
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.