Program to Create this Image In Graphics
#include<GL/gl.h>
#include<GL/glut.h>
#include<Math.h>
void disp( )
{
glClearColor(1.0,1.0,1.0,0.0);
glClear(GL_COLOR_BUFFER_BIT);
glLineWidth(2);
int num_segments=90;
int i;
float cx=0.0,cy=0.6, r=0.10;
glColor3f(1.0,0.0,0.0);
glBegin(GL_POLYGON);
for(i=0;i<num_segments;i++)
{
float theta;
theta=(2.0*3.1415962*(i))/(num_segments);
float x=r*cosf(theta);
float y=r*sinf(theta);
glVertex2f(x+cx,y+cy);
}
glEnd();
glColor3f(1.0,0.0,1.0);
glBegin(GL_QUADS);
glVertex2f(0.2,0.2);
glVertex2f(0.2,-0.2);
glVertex2f(-0.2,-0.2);
glVertex2f(-0.2,0.2);
glEnd();
float cx1=0.6,cy1=0.0;
glColor3f(0.0,1.0,0.0);
glBegin(GL_POLYGON);
for(i=0;i<num_segments;i++)
{
float theta;
theta=(2.0*3.1415962*(i))/(num_segments);
float x=r*cosf(theta);
float y=r*sinf(theta);
glVertex2f(x+cx1,y+cy1);
}
glEnd();
float cx2=0.0,cy2=-0.6;
glColor3f(0.0,0.0,1.0);
glBegin(GL_POLYGON);
for(i=0;i<num_segments;i++)
{
float theta;
theta=(2.0*3.1415962*(i))/(num_segments);
float x=r*cosf(theta);
float y=r*sinf(theta);
glVertex2f(x+cx2,y+cy2);
}
glEnd();
float cx4=-0.6,cy4=0.0;
glColor3f(0.0,0.0,0.0);
glBegin(GL_POLYGON);
for(i=0;i<num_segments;i++)
{
float theta;
theta=(2.0*3.1415962*(i))/(num_segments);
float x=r*cosf(theta);
float y=r*sinf(theta);
glVertex2f(x+cx4,y+cy4);
}
glEnd();
glColor3f(0.0,0.0,1.0);
glBegin(GL_TRIANGLES);
glVertex2f(-0.2,0.2);
glVertex2f(0.0,0.5);
glVertex2f(0.2,0.2);
glEnd();
glColor3f(1.0,1.0,0.0);
glBegin(GL_TRIANGLES);
glVertex2f(0.2,0.2);
glVertex2f(0.5,0.0);
glVertex2f(0.2,-0.2);
glEnd();
glColor3f(0.0,1.0,0.0);
glBegin(GL_TRIANGLES);
glVertex2f(0.2,-0.2);
glVertex2f(0.0,-0.5);
glVertex2f(-0.2,-0.2);
glEnd();
glColor3f(0.0,1.0,3.0);
glBegin(GL_TRIANGLES);
glVertex2f(-0.2,-0.2);
glVertex2f(-0.5,0.0);
glVertex2f(-0.2,0.2);
glEnd();
glFlush();
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(800,500);
glutInitWindowPosition(150,150);
glutCreateWindow ("Evaluation");
glutDisplayFunc(disp);
glutMainLoop();
return 0;
}
No comments:
Post a Comment