Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <GL/glut.h>
- void InitGL(void)
- {
- glClearColor(0.0, 0.8, 0.8, 0.0);
- glClearDepth( 1.0 );
- glEnable( GL_DEPTH_TEST ); //rysowanie z glebią ekranu
- }
- void text(char*string)
- {
- char*p;
- for(p=string;*p;p++)
- glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, *p);
- }
- void reshape(int w, int h)
- {
- GLdouble aspect = (GLdouble) w / h;
- glViewport (0, 0, (GLsizei) w, (GLsizei) h);
- glMatrixMode(GL_PROJECTION); //macierz projekcji
- glLoadIdentity(); //zerowanie macierzy
- if (w <= h)
- glOrtho(-250.0, 250, -250./ aspect, 250.0/ aspect, -100, 100);
- else
- glOrtho (-250.*aspect, 250.*aspect, -250, 250, -100.0, 100);
- glMatrixMode(GL_MODELVIEW); //macierz wyglądu
- glLoadIdentity();
- }
- void displayCallBack(void)
- {
- glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); //czyszczenie buforów
- glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
- glColor3d(0.1,0.3,0);
- glRotatef(15, 1, 1, 0);
- glRotatef(15,0,1,0);
- glutSolidCube(100);
- glLoadIdentity();
- glColor3d(0,0,0);
- glRasterPos2f(-200,200);
- text("Biblioteka GLUT:teskst");
- glFlush();
- glutSwapBuffers(); //zamienia bufory
- }
- void main(int argc, char** argv)
- {
- glutInit(&argc, argv);
- glutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE );
- glutInitWindowSize(600, 600);
- glutCreateWindow("Program_1");
- InitGL();
- float pos[4] = { 1.50F, 3.50F, 0.25F, 0.00F };
- float dir[3] = {-1, -1, -1};
- glEnable(GL_COLOR_MATERIAL);
- glEnable(GL_LIGHTING);
- glEnable(GL_LIGHT0);
- glLightfv(GL_LIGHT0, GL_POSITION, pos);
- glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, dir);
- glutReshapeFunc(reshape);
- glutDisplayFunc(displayCallBack);
- glutMainLoop();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement