special line rendering

Hi,

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

hilite wireframe box

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!

i think it will work if you do the same thing, but draw the lines front to back.

sorry, i mean back to front

could you tell what it means in code ?, an example perhaps…

Thanks!

Polygon offset affects lines too. You just have to enable is separately with glEnable(GL_POLYGON_OFFSET_LINE).

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.

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.

mmm… any hints ???, I can’t find a solution yet… :confused:

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(&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;
}