OpenGL: Relationships between Techniques, Surface Computation, Lighting, and Stencils, Exams of Computer Science

Various opengl-related questions covering the relationships between techniques and concepts such as painter's algorithm and z-buffering, clipping and the viewing frustum, bump mapping and surface normals, bresenham's algorithm and nurbs curves, minkowski sum and morphing, and simplex and icosahedron. Additionally, it involves calculating the value of a surface using de casteljau's algorithm, determining the color and observer position for a lighted sphere, and understanding the functionality of stencils and map2 in opengl.

Typology: Exams

Pre 2010

Uploaded on 09/17/2009

koofers-user-b04
koofers-user-b04 🇺🇸

10 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Sample Test 2
4-digit grading ID:
Name:
IMPORTANT: State any (reasonable) assumption you make to complete the
answer. A yes or no answer without explanation is worth 0 points. You may
use the book(s). Write answers cleanly on the space provided. Use the back of
the previous page if more space is needed. Clear sketches are encouraged.
1 Techniques and Concepts
[6] Describe, in a sentence or two, or using a sketch, the relationship of each of
the following pairs of terms.
(A) Painter’s algorithm and z-buffering.
(B) Clipping and the viewing frustum.
(C) Bump mapping and surface normals.
(D) Bresenham’s algorithm and Nurbs curves.
(E) Minkowski sum and morphing.
(F) Simplex and icosahedron.
1
pf3
pf4

Partial preview of the text

Download OpenGL: Relationships between Techniques, Surface Computation, Lighting, and Stencils and more Exams Computer Science in PDF only on Docsity!

Sample Test 2

4-digit grading ID:

Name:

IMPORTANT: State any (reasonable) assumption you make to complete the answer. A yes or no answer without explanation is worth 0 points. You may use the book(s). Write answers cleanly on the space provided. Use the back of the previous page if more space is needed. Clear sketches are encouraged.

1 Techniques and Concepts

[6] Describe, in a sentence or two, or using a sketch, the relationship of each of the following pairs of terms.

(A) Painter’s algorithm and z-buffering.

(B) Clipping and the viewing frustum.

(C) Bump mapping and surface normals.

(D) Bresenham’s algorithm and Nurbs curves.

(E) Minkowski sum and morphing.

(F) Simplex and icosahedron.

2 glMap2 - Surfaces

Consider the following control points

GLfloat ctrlpoints[2][3][4] = { {{{0.0, 0.0,2.0,2.0}, {0.0, 0.5,0.5,1.0}, {0.0, 1.0,0.0,1.0}}, {{1.0, 0.0,0.0,1.0}, {1.0,0.5,0.5,1.0}, {0.5, 0.5,0.5,0.5}}}};

and the definition of the corresponding B´ezier map

glMap2f(GL_MAP2_VERTEX_4, 0, 1, A, B, 0, 1, C, 2, &ctrlpoints[0][0][0]);

Give appropriate values for A, B and C (with comment). Compute the value of the surface at u = v = 1/2 using de Casteljau’s algorithm.

4 Stencils and Map

[2+2] A stencil application is defined as follows

GLfloat ctrlpoints[333] = { -1,-1,0, 0,-1.5,0, 1,-1,0, -1.5,0,0 , 0,0, 0, 1.5,0,0, -1, 1,0, 0, 1.5,0, 1,1,0 };

In init

glClearStencil(0x0); glEnable(GL_STENCIL_TEST); glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 3, 0, 1, 9, 3, &ctrlpoints[0]); glEnable(GL_MAP2_VERTEX_3); glMapGrid2f(20, 0.0, 1.0, 20, 0.0, 1.0);

In reshape

glClear(GL_STENCIL_BUFFER_BIT); glStencilFunc (GL_ALWAYS, 0x1, 0x1); glStencilOp (GL_REPLACE, GL_REPLACE, GL_REPLACE); glEvalMesh2(GL_FILL, 0, 20, 0, 20);

In display

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glStencilFunc (GL_EQUAL, 0x1, 0x1); glColor3f(1.0,0.0,0.0); glBegin(GL_QUADS); glVertex2f (-0.5, -0.5); glVertex2f ( 0.5, -0.5); glVertex2f ( 0.5, 0.5); glVertex2f (-0.5, 0.5); glEnd(); glStencilFunc (GL_NOTEQUAL, 0x1 , 0x1); glColor3f(0.0,0.0,1.0); glBegin(GL_QUADS); glVertex2f (-1.5, -1.5); glVertex2f ( 1.5, -1.5); glVertex2f ( 1.5, 1.5); glVertex2f (-1.5, 1.5); glEnd();

What is visible on the screen after reshape and display have been called? De- scribe shapes, specify colors!