Created
April 6, 2018 12:16
-
-
Save HelloAlberuni/12b823ebcaf073e8d20b0d1202802b5b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * 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. | |
| */ | |
| #include<windows.h> | |
| #ifdef __APPLE__ | |
| #include <GLUT/glut.h> | |
| #else | |
| #include <GL/glut.h> | |
| #endif | |
| #include <stdlib.h> | |
| /* GLUT callback Handlers */ | |
| float color1=1.0,olor2=1.0,olor3=1.0; | |
| static void init(int w, int h) | |
| { | |
| glClearColor(0.0,0.0,0.0,0.0); | |
| glViewport(0,0,(GLsizei)w,(GLsizei)h); | |
| glMatrixMode(GL_PROJECTION); | |
| glLoadIdentity(); | |
| gluOrtho2D(0.0,(GLdouble)w,0.0,(GLdouble)h); | |
| } | |
| static void display(void) | |
| { | |
| glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); | |
| glColor4f(color1=1.0,olor2=1.0,olor3=1.0,1.0); | |
| glBegin(GL_TRIANGLES); | |
| glVertex3f(200,200,0); | |
| glVertex3f(400,200,0); | |
| glVertex3f(300,300,0); | |
| glEnd(); | |
| glBegin(GL_POLYGON); | |
| glVertex3f(220,0,0); | |
| glVertex3f(220,200,0); | |
| glVertex3f(380,200,0); | |
| glVertex3f(380,0,0); | |
| glEnd(); | |
| glPushMatrix(); | |
| glTranslated(300,300,0); | |
| glBegin(GL_TRIANGLES); | |
| glVertex3f(200,200,0); | |
| glVertex3f(400,200,0); | |
| glVertex3f(300,300,0); | |
| glEnd(); | |
| glBegin(GL_POLYGON); | |
| glVertex3f(220,0,0); | |
| glVertex3f(220,200,0); | |
| glVertex3f(380,200,0); | |
| glVertex3f(380,0,0); | |
| glEnd(); | |
| glPopMatrix(); | |
| glutSwapBuffers(); | |
| } | |
| /* | |
| static void key(unsigned char key, int x, int y) | |
| { | |
| switch (key) | |
| { | |
| case 27 : | |
| exit(0); | |
| break; | |
| case 'r': | |
| color1=1.0,olor2=0.0,olor3=0.0; | |
| break; | |
| case 'b': | |
| color1=0.0,olor2=1.0,olor3=0.0; | |
| break; | |
| case 'g': | |
| color1=0.0,olor2=0.0,olor3=1.0; | |
| break; | |
| } | |
| glutPostRedisplay(); | |
| } | |
| */ | |
| static void idle(void) | |
| { | |
| glutPostRedisplay(); | |
| } | |
| /* Program entry point */ | |
| int main(int argc, char *argv[]) | |
| { | |
| glutInit(&argc, argv); | |
| glutInitWindowSize(640,480); | |
| glutInitWindowPosition(10,10); | |
| glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); | |
| glutCreateWindow("GLUT Shapes"); | |
| init(700,600); | |
| glutDisplayFunc(display); | |
| //glutKeyboardFunc(key); | |
| glutMainLoop(); | |
| return 1; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment