glTexCoord2f ( 0, 0 ) ;
glVertex3f ( xl, yl, zl );
glTexCoord2f ( 1, 0 ) ,-
glVertex3f ( x2, yl, zl ); glEnd ();
}
void init () {
glClearColor ( 0.0, 0.0, 0.0, 1.0 ),-
glEnable ( GL_DEPTH_TEST );

Основы библиотеки OpenGL

glEnable ( GL_TEXTURE_2D ) ;
glPixelStorei ( GL_PACK_ALIGNMENT, 1 );
glPixelStorei ( GL_UNPACK_ALIGNMENT, 1 );
}
void animate () {
angle += 0.75f; angle2 += O.lf;
glutPostRedisplay ();
}
void display () {
glClear ( GL_COLOR_BUFFER_B.IT | GL_DEPTH_BUFFER_BIT );
glMatrixMbde ( GL_MODELVIEW ); glLoadldentity ();
gluLookAt ( 0, 0, 0, // eye
1, 1, 1, II center
0,1,0); // up
glTranslatef (4, 4, 4 ); glRotatef ( angle2, 1, -1, 0 ); glTranslatef ( d - 1.5f, d - 1.5f, d - 1.5f ) ;
glTranslatef ( 1.5f, 1.5f, 1.5f ) ;
// move cube from the center glRotatef ( angle, l.Of, i.Of, O.Of ) ; glTranslatef ( -1.5f, -1.5f, -1.5f ) ;
// move cube into the center
drawBox ( 1, 2, 1, 2, 1, 2 ); glutSwapBuffers () ;
}
void reshape ( int w, int h ) {
glViewport ( 0, 0, (GLsizei)w, (GLsizei)h );
glMatrixMode ( GL_PROJECTION ); glLoadldentity ();
gluPerspective ( 60.0, (GLfloat)w/(GLfloat)h, 1.0, 60.0 ) ;
glMatrixMode ( GL_MODELVIEW ) ; glLoadldentity () ;
gluLookAt ( 0.0, 0.0, 0.0, // eye
1.0, 1.0, 1.0, // center
0.0, 1.0, 0.0 ) ;
}
void key ( unsigned char key, int x, int y ) {
if < key ==27 || key == 'q' || key == 'Q* > exit ( 0 ); // quit requested
}
int main ( int arge, char ** argv ) {
// initialise glut glutlnit ( &argc, argv );
glutlnitDisplayMode ( GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH ); glutlnitWindowSize ( 400, 400 );
// create window int glwin = glutCreateWindow ( "OpenGL example 6" ) ,-
initO ;
// register handlers ' glutDisplayFunc ( display ); glutReshapeFunc ( reshape ); glutKeyboardFunc ( key ); glutldleFunc ( animate ); '

⇐ Предыдущая| |Следующая ⇒