OpenGL rendering is done by reimplementing QGraphicsScene's drawBackground() function. I also add two QGraphicsRectItem in the QGraphicsScene, one embeded a dialog with four buttons in it; another is a yellow Solid circle.
when the opengl codes are as follows included in drawBackground() of QGraphicsScene,
MTList=glGenLists(1);
glEnableClientState(GL_VERTEX_ARRAY);
Vertex_iterator vi = model.vertices_begin();
glVertexPointer(3, GL_DOUBLE, sizeof(Vertex), &(vi->point()[0]));
glDisable(GL_LIGHTING);
glNewList(MTList, GL_COMPILE);
glColor3f(1.0,0.0,1.0);
//glLineWidth(10.0);
//glDisable(GL_CULL_FACE);
//glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glDrawElements(GL_POINTS, 3*model.size_of_facets(), GL_UNSIGNED_INT, &modelfaces[0]);
glEndList();
glDisableClientState(GL_VERTEX_ARRAY);
MTList=glGenLists(1);
glEnableClientState(GL_VERTEX_ARRAY);
Vertex_iterator vi = model.vertices_begin();
glVertexPointer(3, GL_DOUBLE, sizeof(Vertex), &(vi->point()[0]));
glDisable(GL_LIGHTING);
glNewList(MTList, GL_COMPILE);
glColor3f(1.0,0.0,1.0);
//glLineWidth(10.0);
//glDisable(GL_CULL_FACE);
//glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glDrawElements(GL_POINTS, 3*model.size_of_facets(), GL_UNSIGNED_INT, &modelfaces[0]);
glEndList();
glDisableClientState(GL_VERTEX_ARRAY);
To copy to clipboard, switch view to plain text mode
at this time, the two items in QGraphicsScene display as expected:
1.jpg
However, when I uncomment //glPolygonMode(GL_FRONT_AND_BACK, GL_LINE):
glColor3f(1.0,0.0,1.0);
//glLineWidth(10.0);
//glDisable(GL_CULL_FACE);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glDrawElements(GL_POINTS, 3*model.size_of_facets(), GL_UNSIGNED_INT, &modelfaces[0]);
glColor3f(1.0,0.0,1.0);
//glLineWidth(10.0);
//glDisable(GL_CULL_FACE);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glDrawElements(GL_POINTS, 3*model.size_of_facets(), GL_UNSIGNED_INT, &modelfaces[0]);
To copy to clipboard, switch view to plain text mode
(I know I should also change GL_TRIAGNLES, however the result is the same.) then the two items as distorted like two slashes:
2.jpg
Why this weird display occur ?
Thanks a lot
Bookmarks