Real Time 3D Week 2 Tutorial

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

Q6. Describe the hidden surface removal algorithm supported by OpenGL.

A6. OpenGL supports the z-buffer algorithm by enabling an extra buffer storing depth information as geometry travels down the pipeline. The typical implementation of thez-buffer algorithm checks the visibility of a fragment by comparing its screen z value to that stored in the z-buffer. The pixel colour is updated if the z-test determines that the new fragment is closer to the viewer (lower value than the stored in the buffer). If that is the case, the value in the z-buffer is updated.

Q1. What is an aspect ratio? How is it related to a view port? Explain how an aspect ratio is specified in OpenGL when creating a window using the SDL library. What happens if we resize a window and the aspect ratio does not match that of the clipping rectangle of the camera view? How can we fix that?

A1. The aspect ratio of a rectangle is the ratio of the rectangle's width to its height. A view port is a rectangular area of the display window. When we create a window using SDL, we implicitly specify the aspect ratio when we define its height and width. Actually, for a given height (h), the width can be obtained as w = A ·h, with A the aspect ratio. The creating statement can be as follows: SDL_CreateWindow(''My Window'', ini_x, ini_y,w, h, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN); For a given window, we can adjust the height and width of the viewport to match the aspect ratio of the clipping rectangle, thus preventing any object distortion in the image.

Q2. Describe how you would adapt the RGB colour model in OpenGL to allow you to work with a subtractive colour model.

A2. The subtractive colors are often called the complementary colors. Suppose each color in the RGB system can be written as the triplet (r,g,b) where each value is between 0 and 1. Then, the complement of the color (r,g,b) is the color in CMY space (c,m,y) = (1-r, 1-g, 1-b). If we want a color C in RGB space, we specify its complement in CMY space. For example, if we want a full red, in RGB it is (1,0,0) and its complement is (0,1,1). In CMY, (0,1,1) is magenta and yellow, which have red in common.

Q3. A fundamental operation in graphics systems is to map a point (x, y) that lies within a clipping rectangle to a point (xs , ys ) that lies in the view port of a window on the screen. Assume that the view port is defined by the (u, v) coordinates for the left-lower corner, and width (w) and height (h) values, and the viewing rectangle is defined as xmin · x · xmax , ymin · y · ymax . Derive the mathematical equations thatmap (x, y) into (xs , ys ).

A3. We can solve this problem separately in the x and y directions. The transformation is linear, that is xs = ax +b, ys = c y +d. We must maintain proportions, so that xs in the same relative position in the viewport as x is in the window, hence x − xmin xs − u x − xmin ----------- = ------- => xs = u+w *( ------------ ) xmax − xmin width xmax−xmin Likewise y − ymin ys − v y − ymin ----------- = ------- => xs = v+h *( ------------ ) ymax − ymin height ymax−ymin

Q4. A certain graphics system with a CRT display is advertised to display any four colours out of 64 colours. What does this statement tell you about the frame buffer and about the quality of the monitor?

A4. It can display four colors, there are 2 bits per pixel in the frame buffer. Because the total number of available colours is 64 = (22)3, we can display only 4 reds, 4 greens and 4 blues which probably indicates a low quality CRT.

Q5. A redisplay of the frame buffer can occur when its contents are still being altered by the application and the viewer will see only a partially drawn display. Devise a solution to this problem.

A5. The most common solution is double buffering. Instead of a single frame buffer, the hardware has two frame buffers. One, called the front buffer, is one that is displayed. The other, called the back buffer, is then available for constructing what we would like to display. Once the drawing is complete, we swap the front and back buffers. We then clear the new back buffer and can start drawing into it.


Kaugnay na mga set ng pag-aaral

Microeconomics- Roger Arnold- Chapter 6-Elasticity

View Set

OG burns, emergency and trauma quiz

View Set

Origin: How Life Began Worksheet

View Set

AP Psych Units 12 & 13 - Abnormal & Treatment Approaches

View Set

PS251 Personality Exam 1 (Shim 2016)

View Set

Week 3 Homework Multiple Choice Question and Answers (Psychology)

View Set

Health- Lesson 3 "Practicing Healthful Behaviors"

View Set