#include<stdio.h>
#include<math.h>
#include<GL/glut.h>
int width=400,height=400;
void myInit()
{
glClearColor(1.0,1.0,1.0,1.0);
glColor3f(1.0,0.0,0.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0,10.0,0.0,10.0);
glMatrixMode(GL_MODELVIEW);
}
void square()
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0,0.0,0.0);
glBegin(GL_POLYGON);
glVertex2i(1,1);
glVertex2i(9,1);
glVertex2i(9,9);
glVertex2i(1,9);
glEnd();
glutSwapBuffers();
glFlush();
}
void triangle()
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0,0.0,1.0);
glBegin(GL_POLYGON);
glVertex2i(1,1);
glVertex2i(5,9);
glVertex2i(9,1);
glEnd();
glutSwapBuffers();
glFlush();
}
void circle()
{
int r=4;
float theta;
glClear(GL_COLOR_BUFFER_BIT);
glPointSize(4.0);
glColor3f(0.0,1.0,1.0);
glBegin(GL_POINTS);
for(theta=0;theta<=360;theta+=
glVertex2f(r*cos(theta*3.142/
}
glEnd();
glutSwapBuffers();
glFlush();
}
void myDisplay()
{
glClear(GL_COLOR_BUFFER_BIT);
glFlush();
}
void myMenu(int id){
printf("MyMenu called with id: %d\n",id);
switch(id){
case 1: triangle(); break;
case 2: circle(); break;
case 3: square(); break;
case 4: exit(0); break;
}
}
void myKey(unsigned char key, int x,int yy){
if(key=='q' || key == 'Q')
exit(0);
}
int main(int argc, char **argv){
int menu_id;
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_
glutInitWindowSize(400,400);
glutInitWindowPosition(100,
glutCreateWindow("Input Interaction");
glutDisplayFunc(myDisplay);
glutKeyboardFunc(myKey);
menu_id=glutCreateMenu(myMenu)
glutAddMenuEntry("Triangle",1)
glutAddMenuEntry("Circle",2);
glutAddMenuEntry("Square",3);
glutAddMenuEntry("exit",4);
glutAttachMenu(GLUT_RIGHT_
myInit();
glutMainLoop();
return 0;
}
This is very interesting content! I have thoroughly enjoyed reading your points and have come to the conclusion that you are right about many of them. You are great. https://igraphicbox.co.nz
ReplyDelete