Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<windows.h>
- #include <GL/glut.h>
- #include <GL/gl.h>
- #include <bits/stdc++.h>
- using namespace std;
- double x1,y11,x2,y2,delx,dely,delm,x,y,pk,r;
- void display(void){
- // DDA Line Drawing
- glClear(GL_COLOR_BUFFER_BIT);
- glColor3f(1,0,0);
- // x=x1,y=y11;
- // delx = x2-x1, dely=y2-y11;
- // delm = (dely/delx);
- //
- // if( abs(delm) <=1 ){
- // while(x < x2){
- // x++, y += delm;
- // glBegin(GL_POINTS);
- // glVertex2i(x,round(y));;
- // glEnd();
- // }
- // }
- // else{
- // while(y < y2 ){
- // y++ , x += (1/delm);
- // glBegin(GL_POINTS);
- // glVertex2i(round(x),y);
- // glEnd();
- // }
- //
- // }
- /// circle line Drawing Algorithm
- // pk = 1-r;
- // x = 0, y= r;
- //
- // while( x <= y ){
- // glBegin(GL_POINTS);
- //
- // glVertex2i(x,y);
- // glVertex2i(x,-y);
- // glVertex2i(-x,-y);
- // glVertex2i(-x,y);
- //
- // glVertex2i(y,x);
- // glVertex2i(y,-x);
- // glVertex2i(-y,-x);
- // glVertex2i(-y,x);
- // glEnd();
- // x++;
- //
- // if( pk < 0 ){
- // pk += (2*x + 1);
- // }
- // else{
- // pk += ( (2*x)-(2*y) + 1 );
- // y--;
- // }
- //
- // }
- /// Brasenhas algorithm
- // m = (y2-y11)/ (x2-x1);
- // y = y11,x = x1;
- //
- // if(m<=1){
- // while(x<x2){
- //
- // x=x+1;
- // if(pk > 0) pk= pk + (2*(dy-dx));
- // else pk=pk + 2*(dy);
- //
- // glBegin(GL_POINTS);
- // glVertex2f(x,y);
- // glEnd();
- // }
- //
- // }
- float angle = 0;
- const double t = glutGet(GLUT_ELAPSED_TIME) / 500.0; //retrieves simple GLUT state represented by integers.
- const double a = t*180.0;
- glPushMatrix();
- glTranslated(0.0,0.0,-6);
- glRotated(0,1,0,0);
- glRotated(a,0,0,1);
- glutSolidCone(1,0.5,160,160);
- glColor3d(1,0.5,0);
- glBegin(GL_POLYGON);
- glVertex3f(1.5, 1.0, -6);
- glVertex3f(5.0, 2.0, -6);
- glVertex3f(5.0, 3.0, -6);
- glVertex3f(0.0, 2.0, -6);
- glEnd();
- glColor3d(0.5,0.5,1);
- glBegin(GL_POLYGON);
- glVertex3f(-1.5, -1.0, -6);
- glVertex3f(-5.0, -2.0, -6);
- glVertex3f(-5.0, -3.0, -6);
- glVertex3f(-0.0, -2.0, -6);
- glEnd();
- glColor3d(0,1,1);
- glBegin(GL_POLYGON);
- glVertex3f(-1.0, 1.5, -6);
- glVertex3f(-2.0, 5.0, -6);
- glVertex3f(-3.0, 5.0, -6);
- glEnd();
- glColor3d(1,0,1);
- glBegin(GL_POLYGON);
- glVertex3f(1.0, -1.5, -6);
- glVertex3f(2.0, -5.0, -6);
- glVertex3f(3.0, -5.0, -6);
- glVertex3f(2.0, 0, -6);
- glEnd();
- glEnd();
- glPopMatrix();
- glutPostRedisplay();
- glFlush();
- }
- void init(void){
- glClearColor(1,1,1,5.0);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glPointSize(5.0);
- glOrtho(-100,100,-100,100,-100,100) ;
- }
- int main(int argc, char **argv)
- {
- glutInit(&argc, argv);
- glutInitDisplayMode(GLUT_RED | GLUT_SINGLE );
- glutInitWindowSize(800,500);
- glutInitWindowPosition(100,100);
- glutCreateWindow("Testing ");
- //cin >> r ;
- init();
- glutDisplayFunc(display);
- glutMainLoop();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement