Hello, I was partaking in the global game jam (where you have to try to make a game in 48 hours). I got my game pseudo-finished, but I cannot get it to render the scene properly. Here is the code related to the rendering:
Code for opengl initialization:
glClearColor(0.5f,0.5f,0.5f,1.0f);
float ambLight[]={0.5f,0.5f,0.5f,1.0f};
glLightfv(GL_LIGHT1,GL_AMBIENT,ambLight);
glEnable(GL_LIGHT1);
LoadTextures();
glEnable(GL_TEXTURE_2D);
glShadeModel(GL_SMOOTH);
glClearDepth(1.0f);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);
Code for opengl drawing (called every frame):
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(FOV,(double)winWidth/(double)winHeight,NEAR_RENDER,FAR_RENDER);
glMatrixMode(GL_MODELVIEW);
glViewport(0,0,winWidth,winHeight);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glRotatef(dty,1.0f,0.0f,0.0f);
glRotatef(dtx,0.0f,1.0f,0.0f);
glTranslatef(-x,PLAYER_HEIGHT_STAND, -y);
glBindTexture(GL_TEXTURE_2D,wall[level]);
glColor3f(1.0f,1.0f,1.0f);
//...
glBindTexture(GL_TEXTURE_2D,ground);
for (int yy=0; yy<mazeDimy; ++yy)
{
for (int xx=0; xx<mazeDimx; ++xx)
{
glBegin(GL_QUADS);
glTexCoord2f(0.0f,0.0f);
glVertex3f(xx*WALL_LENGTH,FLOOR_HEIGHT,yy*WALL_LENGTH);
glTexCoord2f(0.0f,1.0f);
glVertex3f(xx*WALL_LENGTH,FLOOR_HEIGHT,(yy+1)*WALL_LENGTH);
glTexCoord2f(1.0f,1.0f);
glVertex3f((xx+1)*WALL_LENGTH,FLOOR_HEIGHT,(yy+1)*WALL_LENGTH);
glTexCoord2f(1.0f,0.0f);
glVertex3f((xx+1)*WALL_LENGTH,FLOOR_HEIGHT,yy*WALL_LENGTH);
glEnd();
}
}
I have a window showing a gray background (my clear colour) so I know that it set up properly, but for some reason I can't seem to get it to draw any of my quads. Any ideas?