Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <GL/glut.h>
- void init();
- void display();
- void reshape(int w,int h);
- int main(){
- glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
- glutInitWindowPosition(100,100);
- glutInitWindowSize(500,500);
- glutCreateWindow("test");
- init();
- glutReshapeFunc(reshape);
- glutDisplayFunc(display);
- glutIdleFunc(display);
- glutMainLoop();
- return 0;
- }
- void init(){
- glClearColor (0.0, 0.90, 1.0, 0.0);
- }
- void reshape(int w, int h){
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glViewport(0,0,w,h);
- gluPerspective(45.0f, w/h, 0.1f, 100.0f);
- glMatrixMode(GL_MODELVIEW);
- }
- void display(){
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- glLoadIdentity();
- glTranslatef(0.0f,0.0f,-6.0f);
- glColor3f(1.0f,0.0f,0.0f);
- glBegin(GL_QUADS);
- glVertex3f( -1.0f, 1.0f, -1.5f);
- glVertex3f( -1.0f, -1.0f, -1.5f);
- glVertex3f( 1.0f, -1.0f, -1.5f);
- glVertex3f( 1.0f, 1.0f, -1.5f);
- glEnd();
- glColor3f(1.0f,1.0f,0.0f);
- glBegin(GL_TRIANGLES);
- glVertex3f( 0.0f, 1.0f, 0.0f);
- glVertex3f( -1.0f, -1.0f, 0.0f);
- glVertex3f( 1.0f, -1.0f, 0.0f);
- glEnd();
- glutSwapBuffers();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement