Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * GLUT Shapes Demo
- *
- * Written by Nigel Stewart November 2003
- *
- * This program is test harness for the sphere, cone
- * and torus shapes in GLUT.
- *
- * Spinning wireframe and smooth shaded shapes are
- * displayed until the ESC or q key is pressed. The
- * number of geometry stacks and slices can be adjusted
- * using the + and - keys.
- */
- #ifdef __APPLE__
- #include <GLUT/glut.h>
- #else
- #include <GL/glut.h>
- #endif
- #include <stdlib.h>
- GLfloat angle = 0.0f;
- int refreshMillis = 300;
- void initGL()
- {
- glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
- }
- void idle() {
- glutPostRedisplay();
- }
- void display() {
- glClear(GL_COLOR_BUFFER_BIT);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- glPushMatrix();
- glTranslatef(0.0f, 0.0f, 0.0f);
- glRotatef(angle, 1.0f, 1.0f, 0.0f);
- glBegin(GL_QUADS);
- glColor3ub(0, 255, 0);
- glVertex2f(-0.3f, -0.3f);
- glVertex2f(0.3f, -0.3f);
- glVertex2f(0.3f, 0.3f);
- glVertex2f(-0.3f, 0.3f);
- glEnd();
- glPopMatrix();
- glutSwapBuffers();
- //glFlush();
- angle += 1.9f;
- }
- void reshape(GLsizei width, GLsizei height = 1)
- {
- if (height == 0) height = 1;
- GLfloat aspect = (GLfloat)width / (GLfloat)height;
- glViewport(0,0, width, height);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- if(width >= height)
- {
- gluOrtho2D(-1.0 * aspect,
- 1.0 * aspect,
- -1.0, 1.0);
- }
- }
- void Timer(int value)
- {
- glutPostRedisplay();
- glutTimerFunc(refreshMillis, Timer, 0);
- }
- int main(int argc, char *argv[])
- {
- glutInit(&argc, argv);
- glutInitDisplayMode(GLUT_DOUBLE);
- glutCreateWindow("Zadanie 4.1");
- glutInitWindowSize(600,600);
- glutInitWindowPosition(300,300);
- glutDisplayFunc(display);
- glutReshapeFunc(reshape);
- //glutIdleFunc(idle);
- glutTimerFunc(0, Timer, 0);
- initGL();
- glutMainLoop();
- return EXIT_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement