Jump to content
  • Advertisement
Sign in to follow this  
superwave

OpenGL Strange problem about OpenGL drawing in a QGraphicsView.

This topic is 2236 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

[color=#666666]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.
[color=#666666]when the opengl codes are as follows included in drawBackground() of QGraphicsScene,

[source lang="cpp"]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);[/source]

[color=#666666]at this time, the two items in QGraphicsScene display as expected:
[color=#666666]gallery_200313_467_12630.jpg

[color=#666666][background=rgb(247, 247, 247)]However, when I uncomment //glPolygonMode(GL_FRONT_AND_BACK, GL_LINE): [/background]

[source lang="cpp"]
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]);[/source]

[color=#666666](I know I should also change GL_TRIAGNLES, however the result is the same.) then the two items as distorted like two slashes:

[color=#666666]gallery_200313_467_2080.jpg

[color=#666666][background=rgb(247, 247, 247)]Why this weird display occur ?[/background]

[color=#666666]Thanks a lot Edited by superwave

Share this post


Link to post
Share on other sites
Advertisement
I revised the line to : glPolygonMode(GL_BACK, GL_LINE); the problem still exists,

HHHOoooWWwwever, glPolygonMode(GL_FRONT, GL_LINE); sloved the problem and the two items come out to be as expected.

Why?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!