Answered step by step
Verified Expert Solution
Question
1 Approved Answer
#include GLfloat angle = 0 . 0 f; GLfloat scale = 1 . 0 f; GLfloat xTrans = 0 . 0 f; GLfloat yTrans =
#include
GLfloat angle f;
GLfloat scale f;
GLfloat xTrans f;
GLfloat yTrans f;
void init
glClearColor;
glMatrixModeGLPROJECTION;
glLoadIdentity;
gluPerspective;
glMatrixModeGLMODELVIEW;
glEnableGLDEPTHTEST;
void display
glClearGLCOLORBUFFERBIT GLDEPTHBUFFERBIT;
glLoadIdentity;
glTranslateffff;
glTranslatefxTrans yTrans, f;
glRotatefanglefff;
glScalefscale scale, scale;
glBeginGLQUADS;
glColorf;
glVertexf;
glVertexf;
glVertexf;
glVertexf;
glColorf;
glVertexf;
glVertexf;
glVertexf;
glVertexf;
glColorf;
glVertexf;
glVertexf;
glVertexf;
glVertexf;
glColorf;
glVertexf;
glVertexf;
glVertexf;
glVertexf;
glColorf;
glVertexf;
glVertexf;
glVertexf;
glVertexf;
glColorf;
glVertexf;
glVertexf;
glVertexf;
glVertexf;
glEnd;
glutSwapBuffers;
void updateint value
angle f;
if angle
angle ;
glutPostRedisplay;
glutTimerFunc update, ;
void specialKeysint key, int x int y
switch key
case GLUTKEYUP:
yTrans f;
break;
case GLUTKEYDOWN:
yTrans f;
break;
case GLUTKEYLEFT:
xTrans f;
break;
case GLUTKEYRIGHT:
xTrans f;
break;
glutPostRedisplay;
void keyboardunsigned char key, int x int y
switch key
case w:
case W:
yTrans f;
break;
case s:
case S:
yTrans f;
break;
case a:
case A:
xTrans f;
break;
case d:
case D:
xTrans f;
break;
case :
scale f;
break;
case :
scale f;
if scale f scale f;
break;
glutPostRedisplay;
int mainint argc, char argv
glutInit&argc, argv;
glutInitDisplayModeGLUTDOUBLE GLUTRGB GLUTDEPTH;
glutInitWindowSize;
glutCreateWindowLAB;
glutDisplayFuncdisplay;
glutSpecialFuncspecialKeys;
glutKeyboardFunckeyboard;
init;
glutTimerFunc update, ;
glutMainLoop;
return ;
Using your code from, implement a mouse click function. When the left mouse button is clicked, another shape with the same one you created is added to the clicked location and does the same animations as the original. For every click, create another shape.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started