Results 1 to 9 of 9

Thread: Qt and OpenGL

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Ohio
    Posts
    332
    Thanks
    37
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Smile Re: Qt and OpenGL

    Yes I meant GL_LINE_STRIP and not LINE_LOOP. Been working on my previous OpenGL project way too long... I didn't think this would be a Qt problem but didn't know since stuff was behaving very funny. Someone on the OpenGL forums said my problem was I made the znear and zfar values the same and that they need to be different. So I will try this out. Thanks though for your help and I will check out that library you mentioned, jwintz. Thanks!

  2. #2
    Join Date
    Jan 2006
    Location
    Ohio
    Posts
    332
    Thanks
    37
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Red face Re: Qt and OpenGL

    One other thing I am trying to do is draw a white box from the point a user clicks and drags until. I just trigger a bool to true when the user left clicks on the screen and set the bool to false when the user releases the left mouse button and while the button is held and the mouse is moved, I calculate the new position of the mouse. I want to draw a box from the initial click position to the current position. I know how to and successfully retrieve the screen coordinates. But how do I convert these to the grid coordinates? Especially if my grid goes from -x1 to +x2 and -y1 to +y2? I think this shouldn't be too bad if the grid lies entirely in the positive or negative planes, but when the grid overlaps, I have no idea how to approach this. Thanks for your help in trying to solve this problem!

  3. #3
    Join Date
    Apr 2006
    Posts
    29
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: Qt and OpenGL

    I guess this is for selection purposes. Once again this is not really a Qt issue, but in the libqglviewer library you have selection tools provided which draw selection regions. See http://artis.imag.fr/~Gilles.Debunne...ltiSelect.html

    If it is not for selection purpose, the same library provides the following functions :

    - virtual void startScreenCoordinatesSystem (bool upward=false) const
    - virtual void stopScreenCoordinatesSystem () const

    See http://artis.imag.fr/~Gilles.Debunne...QGLViewer.html, section Display functions.

    Of course the corresponding OpenGL code can be found here. I can provide you some code but it would be easier to use this ...

  4. #4
    Join Date
    May 2006
    Location
    Bangalore
    Posts
    23
    Thanks
    3
    Thanked 4 Times in 4 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt and OpenGL

    Quote Originally Posted by nupul
    Try using gluOrtho2d(-x,x,-y,y) and not just plain gluOrtho()
    Following is the relation between gluOrtho2d() and glOrtho().
    Qt Code:
    1. void GLAPIENTRY
    2. gluOrtho2D(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top)
    3. {
    4. glOrtho(left, right, bottom, top, -1, 1);
    5. }
    To copy to clipboard, switch view to plain text mode 
    For gluOrtho2D() is equivalent to calling glOrtho() with near = −1 and far = 1 .

    Quote Originally Posted by ToddAtWSU
    I know how to and successfully retrieve the screen coordinates. But how do I convert these to the grid coordinates? Especially if my grid goes from -x1 to +x2 and -y1 to +y2? I think this shouldn't be too bad if the grid lies entirely in the positive or negative planes, but when the grid overlaps, I have no idea how to approach this.
    What do you mean by Grid coordinates?
    In case you are looking for a conversion from window coordinates to object coordinates, you can use gluUnproject().
    You can get to know about gluUnproject() at gluUnproject man page and Nehe gluUnProject Article

    If you aren't using libQGLViewer, then you are looking at wrong place. You should rather refer to Nehe's GameDev Forum for a OpenGL related help.

    -Shobhit

  5. The following user says thank you to bits for this useful post:

    Mikael (28th September 2012)

  6. #5
    Join Date
    Jan 2006
    Location
    Ohio
    Posts
    332
    Thanks
    37
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Smile Re: Qt and OpenGL

    I just figured out my problem and I just did some quick mathematic conversions from the screen coordinates so I could convert them to my ortho (grid) coordinates. It appears to me that either OpenGL or Qt puts a default ortho of (-1, 1, -1, 1, -1, 1) if you provide a min and max as the same values. So sorry if this ended up not being a real Qt question, but when the orthos were acting in a way I had never seen when I used the glut functions, I thought maybe the QGLWidget did something a little different. But thanks for all your help!

Similar Threads

  1. Does OpenGL be supported in opensource of Qt-4.1.2?
    By showhand in forum Qt Programming
    Replies: 1
    Last Post: 15th May 2006, 10:46
  2. OpenGl 2d
    By Lele in forum Qt Programming
    Replies: 10
    Last Post: 9th May 2006, 21:37
  3. help on openGL context
    By mickey in forum Qt Programming
    Replies: 1
    Last Post: 29th March 2006, 19:21
  4. Qt's optimized OpenGL context switching
    By sverhoff in forum Qt Programming
    Replies: 0
    Last Post: 28th March 2006, 16:40
  5. Example OpenGL project?
    By brcain in forum Qt Tools
    Replies: 9
    Last Post: 23rd February 2006, 21:17

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.