Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribedimage text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Spatial And Temporal Databases 11th International Symposium Sstd 2009 Aalborg Denmark July 8 10 2009 Proceedings Lncs 5644

Authors: Nikos Mamoulis ,Thomas Seidl ,Kristian Torp ,Ira Assent

2009th Edition

3642029817, 978-3642029813

More Books

Students also viewed these Databases questions

Question

What is the preferred personality?

Answered: 1 week ago