Question: 4. [6 points) Consider the following code that draws a stick-figure face with a triangular hat on top: void draw_face() { glBegin( GL_POLYGON ); glVertex2f


4. [6 points) Consider the following code that draws a stick-figure face with a triangular hat on top: void draw_face() { glBegin( GL_POLYGON ); glVertex2f ( -1, -1); glVertex21( -1, 1); glVertex21( 1, 1); glVertex2(1, -1); glEnd(); glBegin( GL_POINTS ); glVertex2f ( -0.25, 0.25); glVertex2f( 0.25, 0.25); glEnd(); glBegin( GL_LINES ); glVertex2f(-0.5, -0.5); glVertex2f( 0.5, -0.5); glEnd(): void draw_hat() { glBegin( GL_TRIANGLES ); glVertex2f ( 0, 0); glVertex2f( 1, 1); glVertex2f( 2, 0); gl End(); void draw_icon(float x,float y) { glPushMatrix(); gl Translate2(x, y); draw_face(); glPushMatrix(); gl Translate2f(0, 1); draw_hat(); glPopMatrix(); (problem 4 continues on next page] a) continuing problem 4Draw a picture of what gets drawn when draw.icon is called. Don't worry about coordinates, just draw the shapes. b) The hat doesn't appear in the right place when draw icon is called it should be centered directly above the face). Which single line of code should be changed and what should the new line of code be? e) Aller fixing the hal position, the code renders the correct icon, but when called multiple times from within a complicated larger program, this code seems to be causing some strange errors. Why is it causing errors, and what should be changed to fix the errors? 4. [6 points) Consider the following code that draws a stick-figure face with a triangular hat on top: void draw_face() { glBegin( GL_POLYGON ); glVertex2f ( -1, -1); glVertex21( -1, 1); glVertex21( 1, 1); glVertex2(1, -1); glEnd(); glBegin( GL_POINTS ); glVertex2f ( -0.25, 0.25); glVertex2f( 0.25, 0.25); glEnd(); glBegin( GL_LINES ); glVertex2f(-0.5, -0.5); glVertex2f( 0.5, -0.5); glEnd(): void draw_hat() { glBegin( GL_TRIANGLES ); glVertex2f ( 0, 0); glVertex2f( 1, 1); glVertex2f( 2, 0); gl End(); void draw_icon(float x,float y) { glPushMatrix(); gl Translate2(x, y); draw_face(); glPushMatrix(); gl Translate2f(0, 1); draw_hat(); glPopMatrix(); (problem 4 continues on next page] a) continuing problem 4Draw a picture of what gets drawn when draw.icon is called. Don't worry about coordinates, just draw the shapes. b) The hat doesn't appear in the right place when draw icon is called it should be centered directly above the face). Which single line of code should be changed and what should the new line of code be? e) Aller fixing the hal position, the code renders the correct icon, but when called multiple times from within a complicated larger program, this code seems to be causing some strange errors. Why is it causing errors, and what should be changed to fix the errors
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
