void DrawWorld(HDC hMyDC)
{
int iPolyCount =0;
float eyex,eyey,eyez,lookx,looky,lookz;
//Initialization
glClearColor(0.0f, 0.0f,0.0f,0.0f);
glShadeModel(GL_SMOOTH);
glFrontFace(GL_CCW);
glEnable(GL_CULL_FACE);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glClearColor (0.0f, 0.0f, 0.0f, 0.0f);
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix ();
eyex=con.getTranslateX();
eyey=con.getTranslateY();
eyez=con.getTranslateZ();
lookx=eyex;//sin(con.getRotateZ() * 3.14159/180)*eyex;
looky=eyey + 5;//cos(con.getRotateZ() * 3.14159/180)*eyey;
lookz=-9.5;//eyez;
gluLookAt(eyex, eyey, eyez,//eye
lookx,looky,lookz, //look at point
0,0,1);
//100 x 100 m, each cell is 5 x 5 m
glBegin(GL_LINES);
glColor3f(0.0f, 0.4f, 0.0f);
for(int i=-10;i<11;i++){
glVertex3f(i,-10,-10);
glVertex3f(i,10,-10);
glVertex3f(-10, i,-10);
glVertex3f(10,i,-10);
}
//triaxial coordinate reference
glLineWidth(3);
glColor3d(255,0,0); //red line +X axis
glVertex3f(0.0f,0.0f,-10.0f);
glVertex3f(1.0f,0.0f,-10.0f);
glColor3d(0,255,0); //green line +Y axis
glVertex3f(0.0f,0.0f,-10.0f);
glVertex3f(0.0f,1.0f,-10.0f);
glColor3d(0,0,255); //blue line +Z axis
glVertex3f(0.0f,0.0f,-10.0f);
glVertex3f(0.0f,0.0f,-9.0);
glEnd();
glLineWidth(1);
//north wall 100 x 5 m
glPolygonMode(GL_FRONT, GL_LINE);
texture3.select();
glEnable(GL_TEXTURE_2D);
glColor3d(255,255,255);
glBegin(GL_TRIANGLES);
for(int i=-50;i<50;i++){
for(int j=0;j<5;j++){
glTexCoord2f(0.0f, 1.0f);
glVertex3f(i * .2 ,10,-9 - j * .2); //top-left triangle CCW
glTexCoord2f(0.0f, 0.0f);
glVertex3f(i *.2,10,-9 - (j * .2) - .2);
glTexCoord2f(1.0f, 1.0f);
glVertex3f(i * .2 + .2,10,-9 - j * .2);
glTexCoord2f(0.0f, 0.0f);
glVertex3f(i * .2,10,-9 - (j * .2) - .2); //bottom-right triangle CCW
glTexCoord2f(1.0f, 0.0f);
glVertex3f(i * .2 + .2,10,-9 - (j * .2) - .2);
glTexCoord2f(1.0f, 1.0f);
glVertex3f(i * .2 + .2,10,-9 - j * .2);
iPolyCount += 2;
}
}
glEnd();
char szWindowTitle[30];
sprintf(szWindowTitle, "Polygon Count: %d", iPolyCount);
SetWindowText(g_hWnd, szWindowTitle);
glPopMatrix ();
SwapBuffers (hMyDC);
}