I am trying to create a cube. I want the cube itself to be clear (black since the background is black), but I’d like the 12 lines to be thin and white. Is the only way to do this to create lines and lay them on top of the edges? Or is there a different way to approach it?
The reason being I have to create balls bouncing around inside the box.
Maybe I should just do glBegin(GL_LINES) and not even worry about surfaces to collide against since I can just create that mathematically?
I am just creating my sides like this:
glBegin(GL_POLYGON);
glVertex3f( -0.5, -0.5, 0.5 );
glVertex3f( -0.5, 0.5, 0.5 );
glVertex3f( -0.5, 0.5, -0.5 );
glVertex3f( -0.5, -0.5, -0.5 );
glEnd();
You can just draw the ‘wireframe’ cube. You will see the edges but no faces. Set the fill mode to wire and render lines instead of polygons.
Now, this isn’t the most efficient. You could use a line strip perhaps, or just draw 6 quads. But since this is “day one”, this might be an easy start.
Eventually you’ll want to not used fixed-functionality at all – it’s deprecated. But this will give you an environment in which to get comfortable with matrices and lighting, etc. When you have serious gemoetry to render, you’ll put it in buffers and send it off to the GPU in big chunks, letting your GLSL shaders process the data on the graphics card.
Welcome to graphics!