Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define GLUT_DISABLE_ATEXIT_HACK
- #include <GL/gl.h>
- #include <GL/glu.h>
- #include <GL/glut.h>
- int screenWidth = 600;
- int screenHeight = 600;
- void display() {
- glClear(GL_COLOR_BUFFER_BIT);
- glColor3f(0.0, 1.0, 0.0);
- glBegin(GL_LINE_LOOP);
- glVertex3f(100, 100, 0);
- glVertex3f(150, 100, 0);
- glVertex3f(150, 300, 0);
- glVertex3f(300, 300, 0);
- glVertex3f(300, 350, 0);
- glVertex3f(150, 350, 0);
- glVertex3f(150, 370, 0);
- glVertex3f(300, 370, 0);
- glVertex3f(300, 420, 0);
- glVertex3f(100, 420, 0);
- glEnd();
- glutSwapBuffers();
- }
- void reshape(int w, int h) {
- glViewport(0, 0, (GLsizei) w, (GLsizei) h);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glOrtho(0.0, (GLdouble) w, 0.0, (GLdouble) h, 100, -100);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- }
- void keyboard(unsigned char key, int x, int y){
- switch (key){
- case 27 :
- case 'q':
- exit(0);
- break;
- }
- }
- int main(int argc, char *argv[]) {
- glutInit(&argc, argv);
- glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
- glutInitWindowSize(screenWidth, screenHeight);
- glutCreateWindow(argv[0]);
- glutDisplayFunc(display);
- glutReshapeFunc(reshape);
- glutKeyboardFunc(keyboard);
- glutMainLoop();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement