PDA

View Full Version : How to remove lines inside triangle meshes



evilfer
07-14-2011, 01:17 AM
Hi,
I'm having a problem in an OpenGL app. This application draws some meshes (cubes, triangles and squares), using FreeGLUT.

I've coded this on Window7, and the meshes look right in my system. However, one guy who tried the tool in another system took this screenshot:

http://www.orbiter-forum.com/attachment.php?attachmentid=7896&d=1310578797

which shows grey lines around every triangle in each mesh. On Windows 7 I don't get any of these grey lines. I distribute the app with the following .dlls:

freeglut.dll, msvcp100.dll, mscrv100.dll, freetype6.dll and ftgl.dll.


How could I remove these lines?
Thank you!

Alfonse Reinheart
07-14-2011, 01:49 AM
However, one guy who tried the tool in another system took this screenshot:

That forum requires registration to view its contents. Can you put the picture up elsewhere?

evilfer
07-14-2011, 02:08 AM
That forum requires registration to view its contents. Can you put the picture up elsewhere?

Sorry!! I've attached the image file :).

mobeen
07-14-2011, 05:54 AM
Hi,
My guess is that probably u r getting the error bit set somewhere which on the other machine is giving you those lines and it is silently ignored on your machine. U can double check by putting an assertion in the render function like this.


#include <cassert>
void Display() {
assert(glGetError()==GL_NO_ERROR);
... rest of display func.
}

See if u get an assertion.

mhagain
07-14-2011, 06:26 AM
Are you using polygon offset to remove the lines (per http://glprogramming.com/red/chapter14.html#name16)? If so you should be aware that polygon offset is allowed to be implementation-dependent and so may give different results on different hardware.

evilfer
07-14-2011, 08:04 AM
Thank you for your ideas!


Hi,
My guess is that probably u r getting the error bit set somewhere which on the other machine is giving you those lines and it is silently ignored on your machine. U can double check by putting an assertion in the render function like this.


#include <cassert>
void Display() {
assert(glGetError()==GL_NO_ERROR);
... rest of display func.
}

See if u get an assertion.

I tried that, but got no assertions :S.



Are you using polygon offset to remove the lines (per http://glprogramming.com/red/chapter14.html#name16)? If so you should be aware that polygon offset is allowed to be implementation-dependent and so may give different results on different hardware.

I don't user polygon fill (nor did I knew about it until right now!), here is the code that sets the rendering mode:




glutInitDisplayMode (GLUT_DOUBLE | GLUT_DEPTH);

.
.
.

glShadeModel(GL_SMOOTH);
glClearDepth(1.0);

glDepthFunc(GL_LESS);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);
glEnable(GL_DEPTH_TEST);
glDepthMask(GL_TRUE);


glEnable(GL_ALPHA_TEST);
glEnable(GL_DITHER);
glEnable(GL_BLEND);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_POLYGON_SMOOTH);

glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
glEnable(GL_COLOR_MATERIAL);
float global_ambient[] = { 0.5f, 0.5f, 0.5f, 1.0f };
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, global_ambient);
glEnable(GL_LIGHT0);

/* Light 0 is the sun, its position is set later */

float ambientLight[] = { 0.0f, 0.0f, 0.0f, 1.0f };
float diffuseLight[] = { 0.8f, 0.8f, 0.8f, 1.0f };
float specularLight[] = { 0.5f, 0.5f, 0.5f, 1.0f };


glLightfv(GL_LIGHT0, GL_AMBIENT, ambientLight);
glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuseLight);
glLightfv(GL_LIGHT0, GL_SPECULAR, specularLight);



I admit that I wrote much of the above code without knowing exactly the differences between modes...

Anyway, I thought this would be a typical newbie problem! :)