Results 1 to 2 of 2

Thread: Draw QGraphicsScene background with OpenGL: How to match coordinate systems?

  1. #1
    Join Date
    Dec 2011
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Draw QGraphicsScene background with OpenGL: How to match coordinate systems?

    Hello everyone,

    I'm trying to draw the background of a QGraphicsScene via OpenGL. I have working code below, which has some issues.
    In OpenGL, I draw an image decomposed into tiles as a background. On top of this image, I want to overlay any QGraphicsItems, so that
    the coordinate systems of QGraphicsScene and OpenGL match.

    I have pushed my current code here:

    https://github.com/thorbenk/tiled

    A simple qmake tiled.pro; qmake; make; ./tiled should work.

    Zooming (wheel) and panning (left drag) works as expected. However, when I resize the window, the textures gets contorted.

    Why?

    I believe the critical parts is the set-up of matrices in the drawBackground function, which you can view here:

    https://github.com/thorbenk/tiled/bl...tiled.cpp#L412

    Thanks for any help,

    Thorben

  2. #2
    Join Date
    Dec 2011
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Draw QGraphicsScene background with OpenGL: How to match coordinate systems?

    I think I have found one problem: While porting from the original example, I overlooked some gl code in the function setViewModelMatrix... I'll update when I have the code properly cleaned up

Similar Threads

  1. Replies: 9
    Last Post: 2nd July 2014, 12:21
  2. QGraphicsItem coordinate systems
    By d_stranz in forum Qt Programming
    Replies: 3
    Last Post: 15th June 2011, 20:27
  3. Replies: 1
    Last Post: 9th April 2009, 15:54
  4. Replies: 0
    Last Post: 24th November 2008, 09:52
  5. OpenGL texture on QGraphicsScene background
    By Ovnan in forum Qt Programming
    Replies: 5
    Last Post: 11th July 2008, 11:39

Tags for this Thread

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.