Created
November 18, 2018 01:24
-
-
Save Svastikkka/e4ab875d9d13d6a57c6c420f30e896d5 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
/* | |
*version 1.0 | |
*/ | |
#include <GL/glut.h> | |
#include <math.h> | |
#include <GL/gl.h> | |
void init(){ | |
glClearColor(0.0,0.0,0.0,0.0); | |
glMatrixMode(GL_PROJECTION); | |
gluOrtho2D(-100.0,100.0,-100.0,100.0); | |
} | |
//alloted for moon | |
void points2(int xc,int yc,int x,int y) | |
{ | |
glColor3f(1.0,1.0,1.0); | |
glVertex2i(xc+x,yc+y); | |
glVertex2i(xc-x,yc+y); | |
glVertex2i(xc+x,yc-y); | |
glVertex2i(xc-x,yc-y); | |
glVertex2i(xc+y,yc+x); | |
glVertex2i(xc-y,yc+x); | |
glVertex2i(xc+y,yc-x); | |
glVertex2i(xc-y,yc-x); | |
} | |
//alloted for windows | |
void points(int xc,int yc,int x,int y) | |
{ | |
glColor3f(0.5,0.5,0.5); | |
glVertex2i(xc+x,yc+y); | |
glColor3f(1.0,0.0,1.0); | |
glVertex2i(xc-x,yc+y); | |
glColor3f(0.0,0.0,1.0); | |
glVertex2i(xc+x,yc-y); | |
glColor3f(0.0,1.0,0.0); | |
glVertex2i(xc-x,yc-y); | |
glColor3f(0.0,1.0,1.0); | |
glVertex2i(xc+y,yc+x); | |
glColor3f(0.0,0.0,0.0); | |
glVertex2i(xc-y,yc+x); | |
glColor3f(1.0,1.0,0.0); | |
glVertex2i(xc+y,yc-x); | |
glColor3f(1.0,0.0,0.0); | |
glVertex2i(xc-y,yc-x); | |
} | |
//alloted for moon circle | |
void circle2(int ra) | |
{ | |
int x=0; | |
int y=ra; | |
int p=1-ra; | |
while(x<=y) | |
{ | |
x++; | |
p=p+2*x+1; | |
if(p>0) | |
{ | |
y--; | |
p=p-2*y; | |
} | |
points2(-60,50,x,y); | |
} | |
} | |
//alloted for window circle | |
void circle(int ra) | |
{ | |
int x=0; | |
int y=ra; | |
int p=1-ra; | |
while(x<=y) | |
{ | |
x++; | |
p=p+2*x+1; | |
if(p>0) | |
{ | |
y--; | |
p=p-2*y; | |
} | |
points(0,20,x,y); | |
} | |
} | |
void setpixel(){ | |
glClear(GL_COLOR_BUFFER_BIT); | |
glLineWidth(1.0); | |
glBegin(GL_LINES); | |
glColor3f(1.0,1.0,1.0); | |
// this is create a vertical line | |
glVertex2i(-99,0); | |
glVertex2i(99,0); | |
// this is create a horizontal line | |
glVertex2i(-99,0); | |
glVertex2i(-99,-99); | |
glVertex2i(99,0); | |
glVertex2i(99,-99); | |
// this is create a vertical line | |
glVertex2i(-99,-99); | |
glVertex2i(99,-99); | |
// this is create a middle vertical line | |
glVertex2i(0,59); | |
glVertex2i(-99,0); | |
glVertex2i(0,59); | |
glVertex2i(99,0); | |
// this is create a door | |
// this is create a vertical line | |
glVertex2i(20,-59); | |
glVertex2i(-20,-59); | |
// this is create a horizontal line | |
glVertex2i(-20,-59); | |
glVertex2i(-20,-99); | |
glVertex2i(20,-59); | |
glVertex2i(20,-99); | |
// this is create a chinni | |
glVertex2i(70,19); | |
glVertex2i(70,70); | |
glVertex2i(70,70); | |
glVertex2i(40,70); | |
glVertex2i(40,36); | |
glVertex2i(40,70); | |
// this is create a left window | |
glVertex2i(-70,-20); | |
glVertex2i(-30,-20); | |
glVertex2i(-70,-20); | |
glVertex2i(-70,-55); | |
glVertex2i(-30,-20); | |
glVertex2i(-30,-55); | |
glVertex2i(-70,-55); | |
glVertex2i(-30,-55); | |
// this is create a right window | |
glVertex2i(70,-20); | |
glVertex2i(30,-20); | |
glVertex2i(70,-20); | |
glVertex2i(70,-55); | |
glVertex2i(30,-20); | |
glVertex2i(30,-55); | |
glVertex2i(70,-55); | |
glVertex2i(30,-55); | |
glClear(GL_COLOR_BUFFER_BIT); | |
glPointSize(2.0); | |
glBegin(GL_POINTS); | |
glColor3f(0.0,1.0,0.0); | |
circle(15); | |
circle2(15); | |
glEnd(); | |
glLineWidth(1.0); | |
glBegin(GL_LINES); | |
glEnd(); | |
glFlush(); | |
} | |
int main(int argc , char**argv){ | |
glutInit(&argc,argv); | |
glutInitWindowPosition(20,20); | |
glutInitWindowSize(512,512); | |
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB); | |
glutCreateWindow("Manshu Sharma 's "); | |
init(); | |
glutDisplayFunc(setpixel); | |
glutMainLoop(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment