PDA

View Full Version : special line rendering



vbovio
10-18-2006, 01:40 PM
Hi,

I need to draw wireframe objects like the box in this image:

hilite wireframe box (http://img172.imageshack.us/my.php?image=boxaq7.png)

what I tried was:

for each line,
render a thicker line with background color, and render again the line with the object color, thiner, and scaled a bit.

but does not give the effect.. I looked at polygon offset, but looks like there is no something similar with lines..
Any Ideas ??

Thanks!

10-18-2006, 02:58 PM
i think it will work if you do the same thing, but draw the lines front to back.

10-18-2006, 03:00 PM
sorry, i mean back to front

vbovio
10-19-2006, 04:38 AM
could you tell what it means in code ?, an example perhaps..

Thanks!

memfr0b
10-19-2006, 05:50 AM
Polygon offset affects lines too. You just have to enable is separately with glEnable(GL_POLYGON_OFFSET_LINE).

vbovio
10-19-2006, 06:24 AM
I tried that already, but does not do anything different.. I'm just drawing lines, not polygons, the lines are arbitrary, they may or not form a wireframe object.

Relic
10-19-2006, 07:08 AM
Originally posted by memfr0b:
Polygon offset affects lines too. You just have to enable is separately with glEnable(GL_POLYGON_OFFSET_LINE). No, glPolygonOffset enables for point, line and fill affect your selected glPolygonMode style GL_POINT, GL_LINE and GL_FILL.
PolgonOffset does NOT affect point or line primitives. It needs a face to calculate the offset.

vbovio
10-19-2006, 08:04 AM
mmm.. any hints ???, I can't find a solution yet.. :confused:

10-19-2006, 07:20 PM
like the previous poster said, polygon offset doesnt affect GL_LINES, so you need to set your polygon mode to GL_LINE and draw the polygon faces of the cube.


GLdouble vert[8][3] = {
{-.5, -.5, -.5}, {.5, -.5, -.5},
{-.5, .5, -.5}, {.5, .5, -.5},
{-.5, -.5, .5}, {.5, -.5, .5},
{-.5, .5, .5}, {.5, .5, .5}
};

int quads[6][4] = {
{0, 1, 3, 2}, {4, 5, 7, 6},
{0, 1, 5, 4}, {2, 3, 7, 6},
{0, 2, 6, 4}, {1, 3, 7, 5}
};

void display(void)
{
int i;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glPolygonOffset(1, 1);
for (i = 0; i < 6; i++) {
glEnable(GL_POLYGON_OFFSET_LINE);
glLineWidth(9);
glColor3f(0, 0, 0);

glBegin(GL_QUADS);
glVertex3dv(vert[quads[i][0]]);
glVertex3dv(vert[quads[i][1]]);
glVertex3dv(vert[quads[i][2]]);
glVertex3dv(vert[quads[i][3]]);
glEnd();
glDisable(GL_POLYGON_OFFSET_LINE);

glLineWidth(1);
glColor3f(1, 1, 1);

glBegin(GL_QUADS);
glVertex3dv(vert[quads[i][0]]);
glVertex3dv(vert[quads[i][1]]);
glVertex3dv(vert[quads[i][2]]);
glVertex3dv(vert[quads[i][3]]);
glEnd();
}
glFlush();
}

int main(int argc, char **argv)
{
glutInit(&amp;argc, argv);
glutInitDisplayMode(GLUT_RGBA | GLUT_SINGLE | GLUT_DEPTH);
glutCreateWindow(argv[0]);

glClearColor(0, 0, 0, 0);
glEnable(GL_DEPTH_TEST);
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutMainLoop();
return 0;
}