I am making a GUIon in Qt and I am using QGLWidgt to dispaly motion of an object.
For debugging puposes, I hard coded on matrix for try to display a teapot, but nothing is showing up on the screen. I have tried many things, I just dont know what is wrong.
EDIT
I figured out that it is showing the teapot, but the scaling is way off.. If i change the position was far from where it was. When I changed the position from -2.700, 2.000, 0.000 to -0.0270, 0.0200, 0.000, I could see it. I guess my question now is how to set the size of the screen to show what is being displayed??
The paintGL, resideGL and intializeGL are given below.
void GLWidget::initializeGL()
{
glClearColor(1.0,1.0,1.0,1.0);
GLUquadricObj *qobj = gluNewQuadric();
gluQuadricDrawStyle(qobj,GLU_FILL);
gluQuadricNormals(qobj,GLU_SMOOTH);
glClearDepth( 1.0f );
glEnable(GL_DEPTH_TEST);
glShadeModel(GL_SMOOTH);
double eqn[] = {0.01f,0.0f,0.01f,-1.0f};
// enable clip plane
::glClipPlane(GL_CLIP_PLANE0,eqn);
setupLight();
}
void GLWidget::paintGL() {
double MOpenGLStack[16] = {0.4314, 0.875, 0.2181, 0.000,
0.0567, -0.267, 0.961, 0.000,
0.900, -0.402, -0.165, 0.000,
-2.700, 2.000, 0.000, 1.000};
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.0, 0.0, -5.0);
glRotatef(xRot / 16.0, 1.0, 0.0, 0.0);
glRotatef(yRot / 16.0, 0.0, 1.0, 0.0);
glRotatef(zRot / 16.0, 0.0, 0.0, 1.0);
glTranslated(xTrans / 16.0, yTrans/ 16.0, 0.0f);
::glPushMatrix();
::glMultMatrixd(MOpenGLStack);
glutSolidTeapot(0.15);
::glPopMatrix();
}
void GLWidget::resizeGL(int w, int h){
int side = qMin(w, h);
glViewport((w - side) / 2, (h - side) / 2, side, side);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(30.0f, (double)w/(double)h, 0.1f, 1000.0f);
glOrtho(-0.5, +0.5, -0.5, +0.5, 4.0, 15.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity ();
glTranslatef(0.0f, 0.0f, -10.0f);
}