Outline cube
void DrawCube(void)
{
static GLfloat wAngleX = 0.0f;
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glTranslatef(0.0f, 0.0f, 0.0f);
glRotatef(wAngleX, 0.0f, 1.0f, 0.0f);
wAngleX += 0.1f;
glBegin(GL_QUAD_STRIP);
glColor3f(1.0f, 0.0f, 0.0f);
glVertex3f(-0.5f, 0.5f, 0.5f);
glColor3f(1.0f, 0.0f, 0.0f);
glVertex3f(-0.5f, -0.5f, 0.5f);
glColor3f(1.0f, 0.0f, 0.0f);
glVertex3f(0.5f, 0.5f, 0.5f);
glColor3f(1.0f, 0.0f, 0.0f);
glVertex3f(0.5f, -0.5f, 0.5f);
glColor3f(1.0f, 0.0f, 0.0f);
glVertex3f(0.5f, 0.5f, -0.5f);
glColor3f(1.0f, 0.0f, 0.0f);
glVertex3f(0.5f, -0.5f, -0.5f);
glColor3f(1.0f, 0.0f, 0.0f);
glVertex3f(-0.5f, 0.5f, -0.5f);
glColor3f(1.0f, 0.0f, 0.0f);
glVertex3f(-0.5f, -0.5f, -0.5f);
glColor3f(1.0f, 0.0f, 0.0f);
glVertex3f(-0.5f, 0.5f, 0.5f);
glColor3f(1.0f, 0.0f, 0.0f);
glVertex3f(-0.5f, -0.5f, 0.5f);
glEnd();
glBegin(GL_QUADS);
glColor3f(1.0f, 0.0f, 0.0f);
glVertex3f(-0.5f, 0.5f, 0.5f);
glColor3f(1.0f, 0.0f, 0.0f);
glVertex3f(0.5f, 0.5f, 0.5f);
glColor3f(1.0f, 0.0f, 0.0f);
glVertex3f(0.5f, 0.5f, -0.5f);
glColor3f(1.0f, 0.0f, 0.0f);
glVertex3f(-0.5f, 0.5f, -0.5f);
glEnd();
glBegin(GL_QUADS);
glColor3f(1.0f, 0.0f, 0.0f);
glVertex3f(-0.5f, -0.5f, 0.5f);
glColor3f(1.0f, 0.0f, 0.0f);
glVertex3f(0.5f, -0.5f, 0.5f);
glColor3f(1.0f, 0.0f, 0.0f);
glVertex3f(0.5f, -0.5f, -0.5f);
glColor3f(1.0f, 0.0f, 0.0f);
glVertex3f(-0.5f, -0.5f, -0.5f);
glEnd();
glPopMatrix();
glFinish();
glutSwapBuffers();
}
This is part of my program to draw a red rotating cube...
Now, i am only able to see a solid red cube without any outline...
How can i edit the code above to display the outline of the cube??
Pls help!!
Ya he is right, but i used somthign like
glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
i think it does the same thing.
Peace
glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
i think it does the same thing.
Peace
quote:
Original post by DarkHunter
i think it does the same thing.
It applies the same thing, but to both front AND back faces.
-----------------------"When I have a problem on an Nvidia, I assume that it is my fault. With anyone else's drivers, I assume it is their fault" - John Carmack
Ok...
Thanks...
Now i''ve got a wireframe cube...
How do i apply color to this wireframe now? i.e red cube with black wireframe...
Thanks...
Now i''ve got a wireframe cube...
How do i apply color to this wireframe now? i.e red cube with black wireframe...
When you say red cube, with black wireframe, i dont understand. Just use glColor3f() for the color, before the wire you want to make that color. If that makes sense @ all...
I dont know what you mean red cube with black wireframe so if you can explain better on what you mean, maybe i can help you better.
I dont know what you mean red cube with black wireframe so if you can explain better on what you mean, maybe i can help you better.
Sorry...
what i meant was a red cube that is able to show its edges in black...
if that''s not clear enough, take it as a black wireframe cube, but i want to fill its interior with red...
imagine it as a red square with black outline...
Thanks...
what i meant was a red cube that is able to show its edges in black...
if that''s not clear enough, take it as a black wireframe cube, but i want to fill its interior with red...
imagine it as a red square with black outline...
Thanks...
glColor3f(1.0f, 0.0f, 0.0f);
DrawCube();
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glLineWidth(3.0f);
glEnable(GL_CULL_FACE);
glEdgeFlag(GL_FALSE);
glDepthFunc(GL_ALWAYS);
glColor3f(0.0f, 0.0f, 0.0f);
DrawCube();
glDepthFunc(GL_LEQUAL);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glDisable(GL_CULL_FACE);
DrawCube() Draws the cube using GL_QUADS.
Of course, you could just have a re texture with black borders and apply it to each side of your cube.
This has been a post by oglman, King of all that is holy.
DrawCube();
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glLineWidth(3.0f);
glEnable(GL_CULL_FACE);
glEdgeFlag(GL_FALSE);
glDepthFunc(GL_ALWAYS);
glColor3f(0.0f, 0.0f, 0.0f);
DrawCube();
glDepthFunc(GL_LEQUAL);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glDisable(GL_CULL_FACE);
DrawCube() Draws the cube using GL_QUADS.
Of course, you could just have a re texture with black borders and apply it to each side of your cube.
This has been a post by oglman, King of all that is holy.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement