Created
August 17, 2019 14:37
-
-
Save TanjinAlam/b1c700a0ebb1ae7b5d021a1a5fb33f48 to your computer and use it in GitHub Desktop.
This file contains 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
#include<windows.h> | |
#include <GL/glut.h> | |
#include<math.h> | |
void init2D(float r, float g, float b) | |
{ | |
glClearColor(r,g,b,0.0); | |
glMatrixMode (GL_PROJECTION); | |
gluOrtho2D (-500, 500.0, -500, 500.0); | |
} | |
void display(void) | |
{ | |
glClear(GL_COLOR_BUFFER_BIT); | |
glColor3f(1,0,0); | |
glBegin(GL_POLYGON); | |
float theta; | |
for(int i=0; i<182; i++) | |
{ | |
theta = i*3.1416/180; | |
glVertex2f(0+150*cos(theta),0+150*sin(theta)); | |
} | |
glEnd(); | |
glColor3f(0,0,1); | |
glBegin(GL_POLYGON); | |
float p; | |
for(int i=0; i<190; i++) | |
{ | |
p = i*3.1416/180; | |
glVertex2f(75+75*cos(p),0+75*sin(p)); | |
} | |
glEnd(); | |
glColor3f(0,0,1); | |
glBegin(GL_POLYGON); | |
float t; | |
for(int i=183; i<362; i++) | |
{ | |
t = i*3.1416/180; | |
glVertex2f(0+150*cos(t),0+150*sin(t)); | |
} | |
glEnd(); | |
glColor3f(1,0,0); | |
glBegin(GL_POLYGON); | |
float k; | |
for(int i=180; i<360; i++) | |
{ | |
k = i*3.1416/180; | |
glVertex2f(-75+75*cos(k),0+75*sin(k)); | |
} | |
glEnd(); | |
//second co-ordinate | |
glBegin(GL_POLYGON); | |
glColor3f(0,0,0); | |
//glEnable(GL_); | |
glPointSize(50); | |
glVertex2i(-400,245); | |
glVertex2i(-250,395); | |
glVertex2i(-210,342); | |
glVertex2i(-354,200); | |
//glVertex2i(0,10); | |
//glVertex2i(6,0); | |
glEnd(); | |
glBegin(GL_QUADS); | |
glColor3f(0,0,0); | |
//glEnable(GL_); | |
//glPointSize(50); | |
glVertex2i(-325,165); | |
glVertex2i(-180,310); | |
glVertex2i(-145,260); | |
glVertex2i(-285,125); | |
//glVertex2i(0,10); | |
//glVertex2i(6,0); | |
glEnd(); | |
glBegin(GL_QUADS); | |
glColor3f(0,0,0); | |
//glEnable(GL_); | |
glPointSize(50); | |
glVertex2i(-250,85); | |
glVertex2i(-120,220); | |
glVertex2i(-85,175); | |
glVertex2i(-210,45); | |
//glVertex2i(0,10); | |
//glVertex2i(6,0); | |
glEnd(); | |
//first co-ordinate | |
glBegin(GL_POLYGON); | |
glColor3f(0,0,0); | |
glPointSize(50); | |
glVertex2i(400,250); | |
glVertex2i(350,200); | |
glVertex2i(300,250); | |
glVertex2i(350,300); | |
glEnd(); | |
glBegin(GL_POLYGON); | |
glColor3f(0,0,0); | |
glVertex2i(310,340); | |
glVertex2i(250,395); | |
glVertex2i(210,345); | |
glVertex2i(265,295); | |
glEnd(); | |
glBegin(GL_QUADS); | |
glColor3f(0,0,0); | |
glVertex2i(325,165); | |
glVertex2i(180,310); | |
glVertex2i(145,260); | |
glVertex2i(285,125); | |
glEnd(); | |
glBegin(GL_POLYGON); | |
glColor3f(0,0,0); | |
glPointSize(50); | |
glVertex2i(250,90);//first | |
glVertex2i(200,140); | |
glVertex2i(165,100); | |
glVertex2i(215,50);//last | |
glEnd(); | |
glBegin(GL_POLYGON); | |
glColor3f(0,0,0); | |
glVertex2i(170,175);//first | |
glVertex2i(120,225);//second | |
glVertex2i(85,180);//third | |
glVertex2i(135,135);//last | |
glEnd(); | |
//third co-ordinate | |
glBegin(GL_QUADS); | |
glColor3f(0,0,0); | |
glPointSize(50); | |
glVertex2i(-400,-245); | |
glVertex2i(-250,-395); | |
glVertex2i(-210,-342); | |
glVertex2i(-354,-200); | |
glEnd(); | |
glBegin(GL_POLYGON); | |
glColor3f(0,0,0); | |
glVertex2i(-325,-165); | |
glVertex2i(-270,-220); | |
glVertex2i(-230,-180); | |
glVertex2i(-285,-125); | |
glEnd(); | |
glBegin(GL_POLYGON); | |
glColor3f(0,0,0); | |
glVertex2i(-230,-255); | |
glVertex2i(-180,-310); | |
glVertex2i(-140,-265); | |
glVertex2i(-190,-215); | |
glEnd(); | |
glBegin(GL_QUADS); | |
glColor3f(0,0,0); | |
glPointSize(50); | |
glVertex2i(-250,-85); | |
glVertex2i(-120,-220); | |
glVertex2i(-85,-175); | |
glVertex2i(-210,-45); | |
glEnd(); | |
//forth co-ordinate | |
glBegin(GL_POLYGON); | |
glColor3f(0,0,0); | |
//glEnable(GL_); | |
glPointSize(50); | |
glVertex2i(400,-250); | |
glVertex2i(350,-200); | |
glVertex2i(300,-250); | |
glVertex2i(350,-300); | |
glEnd(); | |
glBegin(GL_POLYGON); | |
glColor3f(0,0,0); | |
glVertex2i(310,-340); | |
glVertex2i(250,-395); | |
glVertex2i(210,-345); | |
glVertex2i(265,-295); | |
glEnd(); | |
glBegin(GL_POLYGON); | |
glColor3f(0,0,0); | |
glVertex2i(325,-165); | |
glVertex2i(270,-220); | |
glVertex2i(230,-180); | |
glVertex2i(285,-125); | |
glEnd(); | |
glBegin(GL_POLYGON); | |
glColor3f(0,0,0); | |
glVertex2i(230,-255); | |
glVertex2i(180,-310); | |
glVertex2i(140,-265); | |
glVertex2i(190,-215); | |
glEnd(); | |
glBegin(GL_POLYGON); | |
glColor3f(0,0,0); | |
glPointSize(50); | |
glVertex2i(250,-90);//first | |
glVertex2i(200,-140); | |
glVertex2i(165,-100); | |
glVertex2i(215,-50);//last | |
glEnd(); | |
glBegin(GL_POLYGON); | |
glColor3f(0,0,0); | |
glVertex2i(170,-175);//first | |
glVertex2i(120,-225);//second | |
glVertex2i(85,-180);//third | |
glVertex2i(135,-135);//last | |
glEnd(); | |
glFlush(); | |
} | |
int main(int argc,char *argv[]) | |
{ | |
glutInit(&argc,argv); | |
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); | |
glutInitWindowSize (500, 500); | |
glutInitWindowPosition (500, 100); | |
glutCreateWindow ("points and lines"); | |
init2D(1,1,1); | |
glutDisplayFunc(display); | |
glutMainLoop(); | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment