الدرس السابق OpenGL .. الدرس رقم 3 تعريف بالدرس .. لقد قمنا بإنشاء كل من المثلث والمربع وقمنا بتلوينهما وتحريكهما .. الآن سوف نتعلم كيف نجعل كل منهما ثلاثي الابعاد .. سوف نقوم بتحويل المثلث الى شكل هرمي ذو الوان متعددة وممتزجة .. بينما سوف نقوم بتحويل المربع الى مكعب يحتوي كل وجه منه على لون معين .. سوف نضيف الى المثلث ثلاثة اوجه ( اليمين – اليسار والخلف ) .. بينما سنضيف الى المربع 5 اوجه (اليسار – اليمين – الخلف – فوق – تحت ) الدرس ..
int DrawGLScene(GLvoid){glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);glLoadIdentity();glTranslatef(-1.5f,0.0f,-6.0f);glRotatef(rtri,0.0f,1.0f,0.0f);glBegin(GL_TRIANGLES);
glColor3f(1.0f,0.0f,0.0f);glVertex3f( 0.0f, 1.0f, 0.0f);glColor3f(0.0f,1.0f,0.0f);glVertex3f(-1.0f,-1.0f, 1.0f);glColor3f(0.0f,0.0f,1.0f);glVertex3f( 1.0f,-1.0f, 1.0f);
glColor3f(1.0f,0.0f,0.0f);glVertex3f( 0.0f, 1.0f, 0.0f);glColor3f(0.0f,0.0f,1.0f);glVertex3f( 1.0f,-1.0f, 1.0f);glColor3f(0.0f,1.0f,0.0f);glVertex3f( 1.0f,-1.0f, -1.0f);
glColor3f(1.0f,0.0f,0.0f);glVertex3f( 0.0f, 1.0f, 0.0f);glColor3f(0.0f,1.0f,0.0f);glVertex3f( 1.0f,-1.0f, -1.0f);glColor3f(0.0f,0.0f,1.0f);glVertex3f(-1.0f,-1.0f, -1.0f);
glColor3f(1.0f,0.0f,0.0f);glVertex3f( 0.0f, 1.0f, 0.0f);glColor3f(0.0f,0.0f,1.0f);glVertex3f(-1.0f,-1.0f,-1.0f);glColor3f(0.0f,1.0f,0.0f);glVertex3f(-1.0f,-1.0f, 1.0f);glEnd();
glLoadIdentity();glTranslatef(1.5f,0.0f,-7.0f);glRotatef(rquad,1.0f,1.0f,1.0f);glBegin(GL_QUADS);
glColor3f(0.0f,1.0f,0.0f);glVertex3f( 1.0f, 1.0f,-1.0f);glVertex3f(-1.0f, 1.0f,-1.0f);glVertex3f(-1.0f, 1.0f, 1.0f);glVertex3f( 1.0f, 1.0f, 1.0f);
glColor3f(1.0f,0.5f,0.0f);glVertex3f( 1.0f,-1.0f, 1.0f);glVertex3f(-1.0f,-1.0f, 1.0f);glVertex3f(-1.0f,-1.0f,-1.0f);glVertex3f( 1.0f,-1.0f,-1.0f);
glColor3f(1.0f,0.0f,0.0f);glVertex3f( 1.0f, 1.0f, 1.0f);glVertex3f(-1.0f, 1.0f, 1.0f);glVertex3f(-1.0f,-1.0f, 1.0f);glVertex3f( 1.0f,-1.0f, 1.0f);
glColor3f(1.0f,1.0f,0.0f);glVertex3f( 1.0f,-1.0f,-1.0f);glVertex3f(-1.0f,-1.0f,-1.0f);glVertex3f(-1.0f, 1.0f,-1.0f);glVertex3f( 1.0f, 1.0f,-1.0f);
glColor3f(0.0f,0.0f,1.0f);glVertex3f(-1.0f, 1.0f, 1.0f);glVertex3f(-1.0f, 1.0f,-1.0f);glVertex3f(-1.0f,-1.0f,-1.0f);glVertex3f(-1.0f,-1.0f, 1.0f);
glColor3f(1.0f,0.0f,1.0f);glVertex3f( 1.0f, 1.0f,-1.0f);glVertex3f( 1.0f, 1.0f, 1.0f);glVertex3f( 1.0f,-1.0f, 1.0f);glVertex3f( 1.0f,-1.0f,-1.0f);glEnd();