PDA

View Full Version : Qt & OpenGl, calling gl-commands within other classes



KnufflPuffl
28th September 2010, 10:14
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:



public GLWidget::paintGL()
{

mycube.drawCube(this); // I am not sure which parameter I should give the cube

}


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

Sabre Runner
24th January 2011, 11:44
Shouldn't you just reference qgl.h or any other required files in your cube class header so that it'll know these commands?