Hello there,
I am a very begginer in the whole openGL matter.
I am writing a program in Qt Creator for windows to solve a Rubics Cube by an User. For the beggining I would like to draw a simple 6 coloder cube. Although I have meet an obstacle that I cannot seem to pass. So far I have draw 3 walls of the cube. Ive noticed I dont know how to set the visible surface side of the draw object. please cosider bellow picture:
[ATTACH=CONFIG]735[/ATTACH]
As one can see the blue square is visible from the wrong side. Its not visible from the other one. I thought the normal vector decides which side the surface is colored but it doesnt.
Those methods are called to init and draw the image:
void MyGLWidget::initializeGL()
{
qglClearColor(Qt::black);
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
glShadeModel(GL_SMOOTH);
}
void MyGLWidget::paintGL()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(0.0, 0.0, -10.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);
draw();
}
void MyGLWidget::draw()
{
qglColor(Qt::red);
glBegin(GL_QUADS);
glNormal3f(-2,0,0);
glVertex3f(-1,-1,1);
glVertex3f(-1,1,1);
glVertex3f(-1,1,-1);
glVertex3f(-1,-1,-1);
glEnd();
qglColor(Qt::yellow);
glBegin(GL_QUADS);
glNormal3f(0,0,2);
glVertex3f(-1,1,1);
glVertex3f(-1,-1,1);
glVertex3f(1,-1,1);
glVertex3f(1,1,1);
glEnd();
qglColor(Qt::blue);
glBegin(GL_QUADS);
glNormal3f(2,0,0);
glVertex3f(1,1,-1);
glVertex3f(1,-1,-1);
glVertex3f(1,-1,1);
glVertex3f(1,1,1);
glEnd();
}
I would aprichiate any help really.