[Mesa-users] some weird issue related to glDrawElements
Gianluca Natale
natale at europe.altair.com
Wed Sep 19 12:23:25 UTC 2018
Hi,
I'm new to this forum, but not to OpenGL and graphics.
I used to develop graphics (OpenGL) on Win for many years.
Recently I had to port my application to Linux, and there started many graphic issues.
Specifically, I'm using a VM Linux (CentOS 6.6) on a Pc.
When I check the OpenGL implementation in my application, this is what it returns:
Vendor : VMware, Inc.
Renderer : Gallium 0.4 on llvmpipe (LLVM 3.6, 256 bits)
Version : 2.1 Mesa 11.0.7
So, yes, on that VM Linux, it is using a software emulation (correct? I've read that LLVM is a software emulation).
The issue that I'm experiencing is about using glDrawElements in selection mode (glRenderMode(GL_SELECT)).
I could narrow down the issue till a very simple case, whose behavior I cannot explain.
In detail, this is the sample code I'm calling:
GLfloat faceNodes[12];
faceNodes[ 0] = 0.1; faceNodes[ 1] = 0.1; faceNodes[ 2] = 0.0; // index 0
faceNodes[ 3] = -0.1; faceNodes[ 4] = 0.1; faceNodes[ 5] = 0.0; // index 1
faceNodes[ 6] = -0.1; faceNodes[ 7] = -0.1; faceNodes[ 8] = 0.0; // index 2
faceNodes[ 9] = 0.1; faceNodes[10] = -0.1; faceNodes[11] = 0.0; // index 3
glVertexPointer(3, GL_FLOAT, 0, faceNodes);
GLuint auxTriaIndices[6];
auxTriaIndices[0] = 0;
auxTriaIndices[1] = 1;
auxTriaIndices[2] = 2;
auxTriaIndices[3] = 2;
auxTriaIndices[4] = 3;
auxTriaIndices[5] = 0;
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, auxTriaIndices);
In GL_RENDER mode this code works fine. It renders a square made by 2 triangles (a top-left triangle, and a bottom-right triangle which share the diagonal of the square).
But when I'm in GL_SELECT mode, only the top-left triangle is picked. No OpenGL hit record triggered when I move my mouse onto the bottom-right triangle.
You've noticed that I'm using pure OpenGL 1.1 implementation, i.e. no VBO. But that should not be a problem (and in fact it renders correctly).
Furthermore, I tried to swap the indices of the 2 triangles in auxTriaIndices (i.e. from (0,1,2,2,3,0) to (2,3,0,0,1,2)), but it still picks the top-left triangle, and not the bottom-right.
In short, it seems to me that it works like if I called:
glDrawArrays(GL_TRIANGLES, 0, 6);
In fact it seems to ignore the second triangle (i.e. vertices 3,4,5 in the list 'faceNode', as nodes 4 and 5 are undefined), and only taking into count the first triangle.
As a further confirmation, I tried to add 2 additional vertices to 'faceNode'. And it now selects as the second triangle the one defined by the vertices 3,4,5 in the list 'faceNode', regardless of the indices I pass to glDrawElements.
How is that possible, as I'm using glDrawElements, in which I pass a list of indices?
And also, whay should it work in GL_RENDER mode, but not in GL_SELECT mode?
BTW, above code works fine on Win, both using direct graphic board (an nVidia graphic card) or by software emulation (Microsoft GDI, which means OpenGL 1.1).
Any idea what might be wrong?
My code seems correct. Or not?
Thanks,
Gianluca
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-users/attachments/20180919/1d12260e/attachment.html>
More information about the mesa-users
mailing list