How to draw a 3d cube in OpenGL using GLUT?? WIndows XP

Hi guys, I’m a newbie on this of computer graphics. I want to learn how to draw a 3d cube. I have no information about how to draw abything. I need help to draw my 3d cube Currently, I am looking for tutorials around the web, but i think that this place can help more. I have a good understanding of C/C++ language

Please, I am using windows xp running a codeblocks instance. Try to avoid to use newer version of OpenGL that doesn’t work with Opengl. I am using GLUT to access opengl API. Is it right?? Or I should change?? I am newbie.

Any piece of code is accepted. Thanks.

Look at the Nehe Legacy Opengl tutorials.
Also, look at the codeblocks documentation.
They provide simple examples of Opengl projects.
Starting from one of those, it should be easy to make a cube.
Have fun.

Hi there,

maybe you wanne start here:
Its my tutorial for almost exactly what you wanne do … but we end up with a triangle and not a cube.
But its a slow introduction to “older” Opengl with freGlut and Glew in Codeblocks.


Hopefully I’ll have something published on the Internet regarding that in the near future for modern OGL.

But if you have a triangle tutorial that is in world space coordinates (not normalized device space), you can just add vertices to turn it into a cube.

Two triangles can make a quad (quadrilateral/rectangle). If you can make that, you can arrange 6 quads into a cube. When your shapes start becoming any more complex than this, you will want to use a modeling program. But doing the cube by hand is a great learning experience that will teach you very quickly that you don’t want to model by hand, especially if you do UV texturing and trying to calculate vertex normals for a cube that has only 8 vertices.

Instead, you probably want to make your cube where no vertex in the cube is shared, or where only two vertices of a quad are shared so that you can basically have one normal for each vertex in the quad that all point in the same direction. In other words, you don’t want to use smooth shading with a cube.

But anyway, you’ll quickly discover the value of a modeling program like 3D Studio Max, Maya, Blender, etc.

So, if you have a good triangle tutorial it can be extended to draw a cube.