glBegin(GL_TRIANGLES);<br> glVertex3f(-0.5,-0.5,0.0);<br> glVertex3f(0.5,0.0,0.0);<br> glVertex3f(0.0,0.5,0.0);<br><br>------------------------------------------------------<br>these thing are always the same.<br>no matter what , opengl/glut or director.<br>Save maybe different names<br>------------------------------------------------------<br><br>But you got to have basic knowlege of 3D principles.<br>e.g. Perspective<br> // Set the correct perspective.<br> gluPerspective(45,ratio,1,1000);<br> glMatrixMode(GL_MODELVIEW);<br> glLoadIdentity();<br> gluLookAt(0.0,0.0,5.0, <br> 0.0,0.0,-1.0,<br> 0.0f,1.0f,0.0f);<br>camera, diffuse, alpha, reflection, refraction and so on.<br><br>another example:<br>void drawSnowMan() {<br><br><br> glColor3f(1.0f, 1.0f, 1.0f);<br><br>// Draw Body <br> glTranslatef(0.0f ,0.75f, 0.0f);<br> glutSolidSphere(0.75f,20,20);<br><br><br>// Draw Head<br> glTranslatef(0.0f, 1.0f, 0.0f);<br> glutSolidSphere(0.25f,20,20);<br><br>// Draw Eyes<br> glPushMatrix();<br> glColor3f(0.0f,0.0f,0.0f);<br> glTranslatef(0.05f, 0.10f, 0.18f);<br> glutSolidSphere(0.05f,10,10);<br> glTranslatef(-0.1f, 0.0f, 0.0f);<br> glutSolidSphere(0.05f,10,10);<br> glPopMatrix();<br><br>// Draw Nose<br> glColor3f(1.0f, 0.5f , 0.5f);<br> glRotatef(0.0f,1.0f, 0.0f, 0.0f);<br> glutSolidCone(0.08f,0.5f,10,2);<br>}<br><br><br>All codes are from GLUT. |