NeHe Tutorials OpenGL
 5. OpenGL

Solid Objects

, , , 2D 3D . , , , , . , .

, , .

GLvoid 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);// Y
glBegin(GL_TRIANGLES);//

3D . , : " , ? , ". , . , 0 X, 0 Y, 0 Z.

. , . (), , .

, . , , , , , , .

. , . . . . , .

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);//

. , , Y, X. .

, . , , . .

, glBegin(GL_TRIANGLES) glEnd(), . , OpenGL , . , , OpenGL , . , OpenGL . . , .

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);// ()

. . , . , .

. Y, , . , , X , . , , .

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();//

. . . , , , , . , , , , , , , .

, . . 6 , , . , , . - . :).

glLoadIdentity();
glTranslatef(1.5f,0.0f,-7.0f);//
glRotatef(rquad,1.0f,1.0f,1.0f);// X, Y & Z
glBegin(GL_QUADS);//

. . , Y . Z . . , . . , . , , . ?

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);//

, , , . , Y . , , , , . , , . , .

( ), , Y , , , , , .

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);//

. , . , Z . Z . , Z . Z , , , . , ;).

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);//

, . , Z .

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);//

. . X . .

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);//

. X . . , ;).

, , . Evil . TAB. , .

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();//

rtri+=0.2f;//
rquad-=0.15f;//
}

, 3D . OpenGL, , . . , , . , 3D .

3D , . . . , . , , , .

Jeff Molofee (NeHe)

PMG  12 2001 (c)