Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- #include<math.h>
- #include<windows.h>
- #include<GL/glut.h>
- #include<iostream>
- #include<vector>
- using namespace std;
- #define pb push_back
- #define PI 2*acos(0)
- #define pi 2*acos(0)
- double cameraHeight;
- double cameraAngle;
- int drawgrid;
- int drawaxes;
- double angle;
- ///prototypes
- void drawsphere(float radius,int slices,int stacks);
- void drawCircularStrip();
- void drawCylinder(float height, float radius, int stacks, int slices);
- ///
- struct point
- {
- double x,y,z;
- // point(double a , double b, double c)
- // {
- // x=a;
- // y=b;
- // z=c;
- // }
- };
- void drawAxes()
- {
- if(drawaxes==1)
- {
- glColor3f(1.0, 1.0, 1.0);
- glBegin(GL_LINES);{
- glVertex3f( 1000,0,0);
- glVertex3f(-1000,0,0);
- glVertex3f(0,-1000,0);
- glVertex3f(0, 1000,0);
- glVertex3f(0,0, 1000);
- glVertex3f(0,0,-1000);
- }glEnd();
- }
- }
- void drawCurvedCylinder(float length, float angle, float radius)
- {
- float ang=0;
- for(int i=0;i<1000;i++)
- {
- ang=ang+angle/1000;
- glPushMatrix();{
- glTranslatef(-radius*cos(pi*ang/180),0,radius*sin(ang*pi/180));
- glRotatef(ang,0,1,0);
- drawCylinder(length/900,radius,10,10);
- }glPopMatrix();
- }
- }
- void drawGrid()
- {
- int i;
- if(drawgrid==1)
- {
- glColor3f(0.6, 0.6, 0.6); //grey
- glBegin(GL_LINES);{
- for(i=-8;i<=8;i++){
- if(i==0)
- continue; //SKIP the MAIN axes
- //lines parallel to Y-axis
- glVertex3f(i*10, -90, 0);
- glVertex3f(i*10, 90, 0);
- //lines parallel to X-axis
- glVertex3f(-90, i*10, 0);
- glVertex3f( 90, i*10, 0);
- }
- }glEnd();
- }
- }
- void drawSquare(float a)
- {
- glBegin(GL_QUADS);{
- glVertex3f( a, a,2);
- glVertex3f( a,-a,2);
- glVertex3f(-a,-a,2);
- glVertex3f(-a, a,2);
- }glEnd();
- }
- void triangularBasic(float first, float third, float width )
- {
- glBegin(GL_QUADS);{
- glVertex3f(third/2,0,width);
- glVertex3f(0,sqrt(first*first-third*third/4),width);
- glVertex3f(0,sqrt(first*first-third*third/4),width);
- glVertex3f(-third/2,0,width);
- }glEnd();
- glBegin(GL_QUADS);{
- glVertex3f(third/2,0,width);
- glVertex3f(third/2,0,0);
- glVertex3f(0,sqrt(first*first-third*third/4),0);
- glVertex3f(0,sqrt(first*first-third*third/4),width);
- }glEnd();
- glBegin(GL_QUADS);{
- glVertex3f(-third/2,0,width);
- glVertex3f(-third/2,0,0);
- glVertex3f(0,sqrt(first*first-third*third/4),0);
- glVertex3f(0,sqrt(first*first-third*third/4),width);
- }glEnd();
- glBegin(GL_QUADS);{
- glVertex3f(third/2,0,0);
- glVertex3f(0,sqrt(first*first-third*third/4),0);
- glVertex3f(0,sqrt(first*first-third*third/4),0);
- glVertex3f(-third/2,0,0);
- }glEnd();
- glBegin(GL_QUADS);{
- glVertex3f(third/2, 0,width);
- glVertex3f(third/2, 0,0);
- glVertex3f(-third/2, 0,0);
- glVertex3f(-third/2, 0,width);
- }glEnd();
- }
- void triangular(float first, float third, float width, int clip )
- {
- glPushMatrix();{
- double equ[4];
- equ[0] = 0; //0.x
- equ[1] = -1; //0.y
- equ[2] = 0;//-1.z
- equ[3] = clip;//30
- glClipPlane(GL_CLIP_PLANE0,equ);
- glEnable(GL_CLIP_PLANE0);{
- triangularBasic(1000,70,10);
- }glDisable(GL_CLIP_PLANE0);
- }glPopMatrix();
- triangularBasic( first, third, width );
- }
- void drawHexCap(float height, float side)
- {
- glColor3f(200,200,200);
- glBegin(GL_QUADS);{
- glVertex3f(side, 0,0);
- glVertex3f(side*cos(pi/3),side*cos(pi/6),0);
- glVertex3f(0,0,height);
- glVertex3f(0,0,height);
- }glEnd();;
- glBegin(GL_QUADS);{
- glVertex3f(side*cos(pi/3),side*cos(pi/6),0);
- glVertex3f(-side*cos(pi/3),side*cos(pi/6),0);
- glVertex3f(0,0,height);
- glVertex3f(0,0,height);
- }glEnd();
- glBegin(GL_QUADS);{
- glVertex3f(-side*cos(pi/3),side*cos(pi/6),0);
- glVertex3f(-side,0,0);
- glVertex3f(0,0,height);
- glVertex3f(0,0,height);
- }glEnd();
- glBegin(GL_QUADS);{
- glVertex3f(-side,0,0);
- glVertex3f(-side*cos(pi/3),-side*cos(pi/6),0);
- glVertex3f(0,0,height);
- glVertex3f(0,0,height);
- }glEnd();
- glBegin(GL_QUADS);{
- glVertex3f(-side*cos(pi/3),-side*cos(pi/6),0);
- glVertex3f(side*cos(pi/3),-side*cos(pi/6),0);
- glVertex3f(0,0,height);
- glVertex3f(0,0,height);
- }glEnd();
- glBegin(GL_QUADS);{
- glVertex3f(side*cos(pi/3),-side*cos(pi/6),0);
- glVertex3f(side,0,0);
- glVertex3f(0,0,height);
- glVertex3f(0,0,height);
- }glEnd();
- }
- void drawRectBarBasic(float length, float side)
- {
- glBegin(GL_QUADS);{
- glColor3f((float)240/256,(float)248/256,(float)255/256);
- glVertex3f(length/2,-side/2,side/2);
- glVertex3f(length/2,-side/2,-side/2);
- glVertex3f(-length/2,-side/2,-side/2);
- glVertex3f(-length/2,-side/2,side/2);
- }glEnd();
- }
- void drawRectBar(float length, float side)
- {
- drawRectBarBasic(length,side);
- glPushMatrix();
- {
- glTranslatef(0,side,0);
- drawRectBarBasic(length,side);
- }glPopMatrix();
- glPushMatrix();
- {
- glRotatef(90,1,0,0);
- glColor3f(1,0,0);
- drawRectBarBasic(length,side);
- }glPopMatrix();
- glPushMatrix();
- {
- glRotatef(-90,1,0,0);
- glColor3f(1,0,0);
- drawRectBarBasic(length,side);
- }glPopMatrix();
- }
- void HexColumnBasic(float length, float side)
- {
- glBegin(GL_QUADS);{
- glVertex3f(0,0,0);
- glVertex3f(side,0,0);
- glVertex3f(side,0,length);
- glVertex3f(0,0,length);
- }glEnd();;
- }
- void drawHexColumn(float length, float side)
- {
- glColor3f(200,200,200);
- glPushMatrix();{
- glTranslated((float)side*cos(pi/3),-(float)side*cos(pi/6),0);
- //glTranslated(side,0,0);
- glRotated(60,0,0,1);
- HexColumnBasic(length,side);
- }glPopMatrix();
- glColor3f(200,200,200);
- glPushMatrix();{
- glTranslated(-side,0,0);
- glRotated(60,0,0,1);
- HexColumnBasic(length,side);
- }glPopMatrix();
- glColor3f(200,200,200);
- glPushMatrix();{
- glTranslated(-side/2,(float)side*cos(pi/6),0);
- //glRotated(60,0,0,1);
- HexColumnBasic(length,side);
- }glPopMatrix();
- glColor3f(200,200,200);
- glPushMatrix();{
- glTranslated(-side/2,-(float)side*cos(pi/6),0);
- //glRotated(60,0,0,1);
- HexColumnBasic(length,side);
- }glPopMatrix();
- glColor3f(200,200,200);
- glPushMatrix();{
- glTranslated(-side,0,0);
- //glTranslated(side,0,0);
- glRotated(300,0,0,1);
- HexColumnBasic(length,side);
- }glPopMatrix();
- glColor3f(200,200,200);
- glPushMatrix();{
- glTranslated(side/2,(float)side*cos(pi/6),0);
- //glTranslated(side,0,0);
- glRotated(300,0,0,1);
- HexColumnBasic(length,side);
- }glPopMatrix();
- }
- void drawCylinder(float height, float radius, int stacks, int slices)
- {
- struct point points[100][100];
- int i,j;
- double h,r;
- for(i=0;i<=stacks;i++)
- {
- h=height*(double)i/(double)stacks/2;
- r=radius;
- for(j=0;j<=slices;j++)
- {
- points[i][j].x=r*cos(((double)j/(double)slices)*2*pi);
- points[i][j].y=r*sin(((double)j/(double)slices)*2*pi);
- points[i][j].z=h; ///this creates the upper half
- }
- }
- for(i=0;i<stacks;i++)
- {
- for(j=0;j<slices;j++)
- {
- glColor3f(200,200,200);
- glBegin(GL_QUADS);{
- glVertex3f(points[i][j].x,points[i][j].y,points[i][j].z);
- glVertex3f(points[i][j+1].x,points[i][j+1].y,points[i][j+1].z);
- glVertex3f(points[i+1][j+1].x,points[i+1][j+1].y,points[i+1][j+1].z);
- glVertex3f(points[i+1][j].x,points[i+1][j].y,points[i+1][j].z);
- }glEnd();
- }
- }
- for(i=0;i<=stacks;i++)
- {
- h=height*(double)i/(double)stacks/2;
- r=radius;
- for(j=0;j<=slices;j++)
- {
- points[i][j].x=r*cos(((double)j/(double)slices)*2*pi);
- points[i][j].y=r*sin(((double)j/(double)slices)*2*pi);
- points[i][j].z=-h; ///this creates the lower half
- }
- }
- for(i=0;i<stacks;i++)
- {
- for(j=0;j<slices;j++)
- {
- glColor3f(200,200,200);
- glBegin(GL_QUADS);{
- glVertex3f(points[i][j].x,points[i][j].y,points[i][j].z);
- glVertex3f(points[i][j+1].x,points[i][j+1].y,points[i][j+1].z);
- glVertex3f(points[i+1][j+1].x,points[i+1][j+1].y,points[i+1][j+1].z);
- glVertex3f(points[i+1][j].x,points[i+1][j].y,points[i+1][j].z);
- }glEnd();
- }
- }
- }
- void twoColumn()
- {
- float length=1014.73;
- glPushMatrix();{
- glTranslated(-105,0,0);
- glRotated(6,0,1,0);
- drawHexColumn(length,33.13);
- }glPopMatrix();
- glPushMatrix();{
- glTranslated(105,0,0);
- glRotated(-6,0,1,0);
- drawHexColumn(length,33.13);
- }glPopMatrix();
- glPushMatrix(); ///strip
- {
- glTranslatef(0,0,100);
- glRotatef(4,1,0,0);
- float x,y,z,xa,ya,za;
- x=150;
- y=300;
- z=600;
- xa=90;
- za=30;
- glPushMatrix();{
- glTranslatef(-x,y,z);
- glRotatef(za,0,0,1);
- glRotatef(90,1,0,0);
- drawCircularStrip();
- }glPopMatrix();
- glPushMatrix();{
- glTranslatef(x,y,z);
- glRotatef(-za,0,0,1);
- glRotatef(90,1,0,0);
- drawCircularStrip();
- }glPopMatrix();
- }glPopMatrix();
- glPushMatrix();{
- glTranslatef(0,0,250);
- drawRectBar(200,20);
- }glPopMatrix();
- glPushMatrix();{
- glTranslatef(0,0,400);
- drawRectBar(150,20);
- }glPopMatrix();
- glPushMatrix();{
- glTranslatef(0,0,550);
- drawRectBar(100,20);
- }glPopMatrix();
- glPushMatrix();{
- glTranslatef(0,0,650);
- drawRectBar(100,20);
- }glPopMatrix();
- //drawCurvedCylinder(1000, 10, 10);
- glPushMatrix();
- {
- // glTranslatef(-100,170,0);///////////
- // glRotatef(30,1.9,1,1);
- // glRotatef(120,0,0,1);
- // glRotatef(90,1,0,0);
- triangular(1000,70,10,30);//////////////
- }glPopMatrix();
- }
- void drawCircularStrip()
- {
- vector<point> v1,v2,v3,v4;
- double radius1,radius2,width;
- radius1=200;
- radius2=190;
- width=10;
- for(int i=-45;i<50;i++)
- {
- float scale=.45;
- point a;
- a.x=-width/2;
- a.y=scale*6*radius1*sin(pi*i/180);
- a.z=scale*5*radius1*cos(pi*i/180);
- v1.push_back(a);
- a.x=width/2;
- a.y=scale*6*radius1*sin(pi*i/180);
- a.z=scale*5*radius1*cos(pi*i/180);
- v2.push_back(a);
- a.x=-width/2;
- a.y=scale*5.5*radius2*sin(pi*i/180);
- a.z=scale*5*radius2*cos(pi*i/180);
- v3.push_back(a);
- a.x=width/2;
- a.y=scale*5.5*radius2*sin(pi*i/180);
- a.z=scale*5*radius2*cos(pi*i/180);
- v4.push_back(a);
- }
- for(int i=0;i<v1.size()-1;i++)
- {
- glBegin(GL_QUADS);{
- glColor3d(200,200,200);
- glVertex3f(v1[i].x,v1[i].y,v1[i].z);
- glVertex3f(v1[i+1].x,v1[i+1].y,v1[i+1].z);
- glVertex3f(v2[i+1].x,v2[i+1].y,v2[i+1].z);
- glVertex3f(v2[i].x,v2[i].y,v2[i].z);
- }glEnd();
- glBegin(GL_QUADS);{
- glColor3d(200,200,200);
- glVertex3f(v3[i].x,v3[i].y,v3[i].z);
- glVertex3f(v3[i+1].x,v3[i+1].y,v3[i+1].z);
- glVertex3f(v4[i+1].x,v4[i+1].y,v4[i+1].z);
- glVertex3f(v4[i].x,v4[i].y,v4[i].z);
- }glEnd();
- ///right side
- glBegin(GL_QUADS);{
- glColor3d(200,200,200);
- glVertex3f(v1[i].x,v1[i].y,v1[i].z);
- glVertex3f(v1[i+1].x,v1[i+1].y,v1[i+1].z);
- glVertex3f(v3[i+1].x,v3[i+1].y,v3[i+1].z);
- glVertex3f(v3[i].x,v3[i].y,v3[i].z);
- }glEnd();
- ///left side
- glBegin(GL_QUADS);{
- glColor3d(200,200,200);
- glVertex3f(v2[i+1].x,v2[i+1].y,v2[i+1].z);
- glVertex3f(v2[i].x,v2[i].y,v2[i].z);
- glVertex3f(v4[i].x,v4[i].y,v4[i].z);
- glVertex3f(v4[i+1].x,v4[i+1].y,v4[i+1].z);
- }glEnd();
- }
- }
- //void drawColumnStrip(double width=1.25,double radius=22){
- // vector<point> v1,v2;
- // vector<point> v3,v4;
- // double radius2 = radius-1;int i;
- // //repi(i,-77,45)
- // for(i=-77;i<=45;i++){
- // point a,b,c,d;
- // a.x=-width/2;
- // a.y=1.4*radius*sin(PI*i/180);
- // a.z=radius*cos(PI*i/180);
- // v1.pb(a);
- //// v1.pb(point(-width/2,1.4*radius*sin(PI*i/180.),radius*cos(PI*i/180)));
- // b.x=width/2;
- // b.y=1.4*radius*sin(PI*i/180);
- // b.z=radius*cos(PI*i/180);
- //// v2.pb(point(width/2,1.4*radius*sin(PI*i/180.),radius*cos(PI*i/180)));
- // v2.pb(b);
- // c.x=-width/2;
- // c.y=1.32*radius2*sin(PI*i/180);
- // c.z=radius2*cos(PI*i/180);
- // v3.pb(c);
- // //v3.pb(point(-width/2,1.32*radius2*sin(PI*i/180.),radius2*cos(PI*i/180)));
- // d.x=width/2;
- // d.y=1.32*radius2*sin(PI*i/180.);
- // d.z=radius2*cos(PI*i/180);
- //// v4.pb(point(width/2,1.32*radius2*sin(PI*i/180.),radius2*cos(PI*i/180)));
- // //~ cout<<v1.back().x<<" "<<v1.back().y<<" "<<v1.back().z<<endl;
- // }
- // //~ exit(0);
- //
- // glColor3d(1,0,0);
- // glRotated(-90,1,0,0);
- // glBegin(GL_QUADS);{
- // //rep(i,len(v1)-1)
- // for(i=0;i<v1.size()-2;i++){
- // glColor3d(0,1,0);
- // ///outer strip
- // glVertex3f(v1[i].x,v1[i].y,v1[i].z);
- // glVertex3f(v1[i+1].x,v1[i+1].y,v1[i+1].z);
- // glVertex3f(v2[i+1].x,v2[i+1].y,v2[i+1].z);
- // glVertex3f(v2[i].x,v2[i].y,v2[i].z);
- //
- // ///inner strip
- // glVertex3f(v3[i].x,v3[i].y,v3[i].z);
- // glVertex3f(v3[i+1].x,v3[i+1].y,v3[i+1].z);
- // glVertex3f(v4[i+1].x,v4[i+1].y,v4[i+1].z);
- // glVertex3f(v4[i].x,v4[i].y,v4[i].z);
- //
- // ///right side
- // glColor3d(1,0,0);
- // glVertex3f(v1[i].x,v1[i].y,v1[i].z);
- // glVertex3f(v1[i+1].x,v1[i+1].y,v1[i+1].z);
- // glVertex3f(v3[i+1].x,v3[i+1].y,v3[i+1].z);
- // glVertex3f(v3[i].x,v3[i].y,v3[i].z);
- //
- // ///left side
- // glVertex3f(v2[i+1].x,v2[i+1].y,v2[i+1].z);
- // glVertex3f(v2[i].x,v2[i].y,v2[i].z);
- // glVertex3f(v4[i].x,v4[i].y,v4[i].z);
- // glVertex3f(v4[i+1].x,v4[i+1].y,v4[i+1].z);
- // }
- // }glEnd();
- //}
- void drawCurveColumns(){
- double ang = 50;
- glPushMatrix();{
- glTranslated(0.5,0,0);
- glRotated(-ang,0,0,1);
- glPushMatrix();{
- glTranslated(0,-12,13.5);
- glRotated(-37,1,0,0);
- //drawRectBar(1.25,0.4,1.25,15,55);
- };glPopMatrix();
- glTranslated(0,2,82);
- glRotated(-18,1,0,0);
- glTranslated(0,-4.5,-37);
- // drawColumnStrip(1.25,22);
- }glPopMatrix();
- }
- void drawss()
- {
- glPushMatrix();{
- glTranslated(900,0,0);
- drawsphere(20,20,20);}glPopMatrix();
- twoColumn();
- glPushMatrix();{
- glTranslatef(0,0,1014);
- drawHexCap(300,33.13);
- }glPopMatrix();
- }
- //draws half sphere
- void drawsphere(float radius,int slices,int stacks)
- {
- struct point points[100][100];
- int i,j;
- double h,r;
- for(i=0;i<=stacks;i++)
- {
- h=radius*sin(((double)i/(double)stacks)*(pi/2));
- r=sqrt(radius*radius-h*h);
- for(j=0;j<=slices;j++)
- {
- points[i][j].x=r*cos(((double)j/(double)slices)*2*pi);
- points[i][j].y=r*sin(((double)j/(double)slices)*2*pi);
- points[i][j].z=h; ///this creates the upper half
- }
- }
- for(i=0;i<stacks;i++)
- {
- for(j=0;j<slices;j++)
- {
- glColor3f((double)i/(double)stacks,(double)i/(double)stacks,(double)i/(double)stacks);
- glBegin(GL_QUADS);{
- glVertex3f(points[i][j].x,points[i][j].y,points[i][j].z);
- glVertex3f(points[i][j+1].x,points[i][j+1].y,points[i][j+1].z);
- glVertex3f(points[i+1][j+1].x,points[i+1][j+1].y,points[i+1][j+1].z);
- glVertex3f(points[i+1][j].x,points[i+1][j].y,points[i+1][j].z);
- }glEnd();
- }
- }
- for(i=0;i<=stacks;i++)
- {
- h=radius*sin(((double)i/(double)stacks)*(pi/2));
- r=sqrt(radius*radius-h*h);
- for(j=0;j<=slices;j++)
- {
- points[i][j].x=r*cos(((double)j/(double)slices)*2*pi);
- points[i][j].y=r*sin(((double)j/(double)slices)*2*pi);
- points[i][j].z=-h; ///this creates the lower half
- }
- }
- for(i=0;i<stacks;i++)
- {
- for(j=0;j<slices;j++)
- {
- glColor3f((double)i/(double)stacks,(double)i/(double)stacks,(double)i/(double)stacks);
- glBegin(GL_QUADS);{
- glVertex3f(points[i][j].x,points[i][j].y,points[i][j].z);
- glVertex3f(points[i][j+1].x,points[i][j+1].y,points[i][j+1].z);
- glVertex3f(points[i+1][j+1].x,points[i+1][j+1].y,points[i+1][j+1].z);
- glVertex3f(points[i+1][j].x,points[i+1][j].y,points[i+1][j].z);
- }glEnd();
- }
- }
- }
- void keyboardListener(unsigned char key, int x,int y){
- switch(key){
- case '1':
- drawgrid=1-drawgrid;
- break;
- default:
- break;
- }
- }
- void specialKeyListener(int key, int x,int y){
- switch(key){
- case GLUT_KEY_DOWN: //down arrow key
- cameraHeight -= 30.0;
- break;
- case GLUT_KEY_UP: // up arrow key
- cameraHeight += 30.0;
- break;
- case GLUT_KEY_RIGHT:
- cameraAngle += 0.03;
- break;
- case GLUT_KEY_LEFT:
- cameraAngle -= 0.03;
- break;
- case GLUT_KEY_PAGE_UP:
- break;
- case GLUT_KEY_PAGE_DOWN:
- break;
- case GLUT_KEY_INSERT:
- break;
- case GLUT_KEY_HOME:
- break;
- case GLUT_KEY_END:
- break;
- default:
- break;
- }
- }
- void mouseListener(int button, int state, int x, int y){ //x, y is the x-y of the screen (2D)
- switch(button){
- case GLUT_LEFT_BUTTON:
- if(state == GLUT_DOWN){ // 2 times?? in ONE click? -- solution is checking DOWN or UP
- drawaxes=1-drawaxes;
- }
- break;
- case GLUT_RIGHT_BUTTON:
- //........
- break;
- case GLUT_MIDDLE_BUTTON:
- //........
- break;
- default:
- break;
- }
- }
- void display(){
- //clear the display
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- glClearColor(0,0,0,0); //color black
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- /********************
- / set-up camera here
- ********************/
- //load the correct matrix -- MODEL-VIEW matrix
- glMatrixMode(GL_MODELVIEW);
- //initialize the matrix
- glLoadIdentity();
- //now give three info
- //1. where is the camera (viewer)?
- //2. where is the camera looking?
- //3. Which direction is the camera's UP direction?
- //gluLookAt(100,100,100, 0,0,0, 0,0,1);
- gluLookAt(500*cos(cameraAngle), 500*sin(cameraAngle), cameraHeight, 0,0,0, 0,0,1);
- //gluLookAt(0,-1,150, 0,0,0, 0,0,1);
- //again select MODEL-VIEW
- glMatrixMode(GL_MODELVIEW);
- /****************************
- / Add your objects from here
- ****************************/
- //add objects
- drawAxes();
- drawGrid();
- drawss();
- //ADD this line in the end --- if you use double buffer (i.e. GL_DOUBLE)
- glutSwapBuffers();
- }
- void animate(){
- angle+=0.05;
- //codes for any changes in Models, Camera
- glutPostRedisplay();
- }
- void init(){
- //codes for initialization
- drawgrid=0;
- drawaxes=1;
- cameraHeight=1000.0;
- cameraAngle=1.0;
- angle=0;
- //clear the screen
- glClearColor(0,0,0,0);
- /************************
- / set-up projection here
- ************************/
- //load the PROJECTION matrix
- glMatrixMode(GL_PROJECTION);
- //initialize the matrix
- glLoadIdentity();
- //give PERSPECTIVE parameters
- gluPerspective(80, 1, 1, 10000.0);
- //field of view in the Y (vertically)
- //aspect ratio that determines the field of view in the X direction (horizontally)
- //near distance
- //far distance
- }
- int main(int argc, char **argv){
- glutInit(&argc,argv);
- glutInitWindowSize(500, 500);
- glutInitWindowPosition(0, 0);
- glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGB); //Depth, Double buffer, RGB color
- glutCreateWindow("Mega structure, 0905004");
- init();
- glEnable(GL_DEPTH_TEST); //enable Depth Testing
- glutDisplayFunc(display); //display callback function
- glutIdleFunc(animate); //what you want to do in the idle time (when no drawing is occuring)
- glutKeyboardFunc(keyboardListener);
- glutSpecialFunc(specialKeyListener);
- glutMouseFunc(mouseListener);
- glutMainLoop(); //The main loop of OpenGL
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement