Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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