Results 1 to 2 of 2

Thread: Strange problem about OpenGL drawing in a QGraphicsView.

  1. #1
    Join Date
    May 2011
    Location
    North Carolina
    Posts
    23
    Thanks
    10
    Qt products
    Qt4

    Default Strange problem about OpenGL drawing in a QGraphicsView.

    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,
    Qt Code:
    1. MTList=glGenLists(1);
    2.  
    3. glEnableClientState(GL_VERTEX_ARRAY);
    4. Vertex_iterator vi = model.vertices_begin();
    5. glVertexPointer(3, GL_DOUBLE, sizeof(Vertex), &(vi->point()[0]));
    6.  
    7. glDisable(GL_LIGHTING);
    8. glNewList(MTList, GL_COMPILE);
    9. glColor3f(1.0,0.0,1.0);
    10.  
    11. //glLineWidth(10.0);
    12. //glDisable(GL_CULL_FACE);
    13. //glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
    14.  
    15. glDrawElements(GL_POINTS, 3*model.size_of_facets(), GL_UNSIGNED_INT, &modelfaces[0]);
    16. glEndList();
    17.  
    18. 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):
    Qt Code:
    1. glColor3f(1.0,0.0,1.0);
    2.  
    3. //glLineWidth(10.0);
    4. //glDisable(GL_CULL_FACE);
    5. glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
    6.  
    7. 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

  2. #2
    Join Date
    May 2011
    Location
    North Carolina
    Posts
    23
    Thanks
    10
    Qt products
    Qt4

    Default Re: Strange problem about OpenGL drawing in a QGraphicsView.

    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?

Similar Threads

  1. OpenGL 2D drawing problem
    By kuku83 in forum Qt Programming
    Replies: 1
    Last Post: 25th February 2011, 10:10
  2. Replies: 4
    Last Post: 20th October 2010, 08:13
  3. Strange whiskers when drawing a polygon
    By feraudyh in forum Newbie
    Replies: 0
    Last Post: 22nd November 2009, 16:20
  4. problem in rendering opengl on QGraphicsView
    By Sandip in forum Qt Programming
    Replies: 17
    Last Post: 15th April 2008, 08:27
  5. strange problem in QGraphicsView
    By Shawn in forum Qt Programming
    Replies: 3
    Last Post: 29th June 2007, 09:24

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.