A strange problem posed itself to me in Linux last night, infact in OpenGL in general - this problem happened on OSX, Ubuntu, Fedora and Windows Vista for me... Here's the low down...
I've created a simple 3D view contained area in OpenGL
Into this I want to place items, buildings, people whatever... So, I start to define a rectangle, which is going to be a wall...
As you can see, on it I place my text texture, so I can tell left (red) from right (blue) and top (yellow) from bottom (white) to make sure my texture loading and texture coords are correct... But I can see that damn line between the two triangles... Yet I'm using the same vertices for the corners, there should be no gap.
Switching from glBegin(GL_TRIANGLES) to glBegin(GL_QUADS) I can still see a single line between the triangles, so its not my coordinates or triangles... What the heck can it be?
Now, I'm using pretty old OpenGL here, really really old stuff, so for 2012 the information available on the ground is pretty slim, there's alsorts of suggestions out there and no real documentation as to what is causing this...
In desparation I started to play about with the blending settings, to no avail, then I started to play with the smoothing mode:
glEnable(GL_SMOOTH);
glHint(GL_POLYGON_SMOOTH, GL_NICEST);
glEnable(GL_POLYGON_SMOOTH);
glShadeModel(GL_SMOOTH);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
None of this seemed to work... So I started to play with the multi-sampling...
glEnable(GL_MULTISAMPLE_ARB);
Still no joy....
But.. Disable the smoothing AND enable the multisampling and everything starts to work:
// Set Rendering smoothing
//glEnable(GL_SMOOTH);
//glHint(GL_POLYGON_SMOOTH, GL_NICEST);
//glEnable(GL_POLYGON_SMOOTH);
glShadeModel(GL_SMOOTH);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
glEnable(GL_MULTISAMPLE_ARB);
I can now start to add brick textures and make my boxes into buildings...
The real source of the problem is GL_POLYGON_SMOOTH, comment it out and it will all work even without GL_MULTISAMPLE_ARB
ReplyDeletehttp://www.gamedev.net/topic/573479-transparent-gaps-between-triangles-on-windows-7/
ReplyDeleteThe last message