* We use a destructor to ensure that any OpenGL-specific
* data structures are deleted when the widget is no longer
* needed (although in this case nothing needs cleaning up).
*/
//In helloGL example: nothin needs cleaning up.
}
/*
* We provide size hint functions to ensure that
* the widgetis shown at a reasonable size:
*/
QSizeMyGLWidget::minimumSizeHint()const
{
returnQSize(50,50);
}
/*
* We provide size hint functions to ensure that
* the widgetis shown at a reasonable size:
*/
QSizeMyGLWidget::sizeHint()const
{
returnQSize(600,400);
}
voidMyGLWidget::initializeGL()
{
glClearColor(0.0,0.0,0.0,0.0);//TODO brauch ich das?
glEnable(GL_DEPTH_TEST);//TODO warum genau?
// glEnable(GL_CULL_FACE);//backface culling
// glCullFace(GL_BACK);//backface culling
// glEnable(GL_COLOR_MATERIAL); //Habe ich für glColor3f gebraucht. Wieder raus für Material. //In order to use both color and lighting you must activate openGL color materials
//4.1.1
/*
* The initial state of the OpenGL state machine is defined in
initializeGL(). Furthermore, you can set all OpenGL parameters
that will not change during program execution here as well, for
qDebug()<<"Resize to "<<width<<","<<height<<", Perspective: "<<p;
//old:
// GLInt x = 0;//The lower-left corner of the viewport rectangle, in pixels. The default is (0,0).
// GLInt y = 0;//The lower-left corner of the viewport rectangle, in pixels. The default is (0,0).
// glViewport(x,y,width,height);//The width of the viewport. When an OpenGL context is first attached to a window, width and height are set to the dimensions of that window.
glViewport(0,0,width,height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0,p,0.1,1000);//TODO komisch: wenn schmaler als hoch auf einmal grau.