Results 1 to 2 of 2

Thread: Qt & OpenGl, calling gl-commands within other classes

  1. #1
    Join Date
    Sep 2010
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Post Qt & OpenGl, calling gl-commands within other classes

    hi, I've searched for this already long time, but couldn't find any solution so far.

    The problem is the following thing:

    I created a GLWidget which is derived from QGLWidget, in this class I have overriden the method paintGL(), in which I can successfully call the gl commands like glVertex3f(..) and so on. So that works fine.

    Now I am trying to make a Cube class, in which I want to make a method like drawCube(...), in which the glCommands for exactly a cube are called. I then want to call the drawCube method in the QGLWidget e.g:

    Qt Code:
    1. public GLWidget::paintGL()
    2. {
    3.  
    4. mycube.drawCube(this); // I am not sure which parameter I should give the cube
    5.  
    6. }
    To copy to clipboard, switch view to plain text mode 

    The problem I get is I don't know how to reference the GLWidget, to the Cube class, so I can actually call there its methods. (the glVertex3f(..) for example)

    I hope I described my problem clear enough to understand.

    Any help is very appreciated, since it would be horrible to writing all the glPaint code in only one method

    thanks in advance

  2. #2
    Join Date
    Sep 2010
    Location
    Israel
    Posts
    24
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qt & OpenGl, calling gl-commands within other classes

    Shouldn't you just reference qgl.h or any other required files in your cube class header so that it'll know these commands?

Similar Threads

  1. how to write QT openGL code in two classes
    By qtUse in forum Qt Programming
    Replies: 8
    Last Post: 31st August 2010, 05:41
  2. Replies: 7
    Last Post: 15th January 2010, 20:45
  3. Executing AT commands
    By jay in forum Qt Programming
    Replies: 4
    Last Post: 8th December 2009, 09:49
  4. Mac Commands
    By shyam prasad in forum Qt Programming
    Replies: 1
    Last Post: 9th January 2007, 15:30

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.