PDA

View Full Version : Changing Lines to Quads?

CroCodile
10-07-2013, 01:55 PM
I have a code to draw cube(frame wire). I want replace them with quads instead of lines.
The following code draws the lines

static const HDint aLines[12][2] =
{
{ 0, 1 }, { 1, 3 }, { 3, 2 }, { 2, 0 },
{ 4, 5 }, { 5, 7 }, { 7, 6 }, { 6, 4 },
{ 0, 4 }, { 1, 5 }, { 2, 6 }, { 3, 7 }
};
glBegin(GL_LINES);
for (i = 0; i < 12; i++)
{
glVertex3d((aLines[i][0] & (1 << 0)) ? minPt[0] : maxPt[0],
(aLines[i][0] & (1 << 1)) ? minPt[1] : maxPt[1],
(aLines[i][0] & (1 << 2)) ? minPt[2] : maxPt[2]);

glVertex3d((aLines[i][1] & (1 << 0)) ? minPt[0] : maxPt[0],
(aLines[i][1] & (1 << 1)) ? minPt[1] : maxPt[1],
(aLines[i][1] & (1 << 2)) ? minPt[2] : maxPt[2]);
}
glEnd();

The cube should have five faces.

The Little Body
10-23-2013, 03:37 PM
You can use glLineWidth( GLfloat width) if you want lines with a thickness > 1
(if what you think when you say "replace them with quads instead of lines" is lines with a thickness larger than one)

Or you want to display a solid cube instead a wireframe cube ?
(in this case, you can use glTranslatef()/glScalef() + glutSolidCube() for to handle this)

PS : what is a cube with five faces ??? (a cube have normaly six faces)