OpenGL Questions

Hi all,

I have a few questions regarding openGL under Windows:

1.Why is it better to use the types glfloat instead of float ?

2.What is the modelview matrix?

3.What is the projection matrix?

4.What’s the difference between orthographic and perspective projection?

5.What is an identity matrix? Why and how is it used in game programming?

6.What are matrix stacks? Why and how are they used?

7.What does the following line of code mean:
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); /* default, not needed */

8.What does the following line of code mean:
glutDisplayFunc(display); /* display callback, invoked when window opened (or redrawn) */

9.What’s the difference between glVertex3f, glVertex2f and glVertex3fv?

10.What is a viewport?Why is a viewport needed?

11.What’s the advantage of using vertex arrays?

12.What kind of vertex arrays are there?

13.What are normalvectors mainly used for?

It would be a great help if you could help me, even if it is one question.

Thanks!

No, we’re not going to do your homework.

Read and learn.

Some doc pointers, all can be found in http://www.opengl.org :

http://www.glprogramming.com/red/ - beginners book (old but useful to you)

http://www.opengl.org/wiki/Main_Page - do some searches on the GL wiki. new info, but not extensive.
http://www.opengl.org/resources/faq/technical/ - GL FAQ
http://www.opengl.org/resources/libraries/glut/faq/ - glut FAQ
http://www.opengl.org/resources/features/KilgardTechniques/oglpitfall/ - GL pitfalls, old but a “must know”

1.Why is it better to use the types glfloat instead of float?

Variables with “gl” in their name work better in Open"GL".

2.What is the modelview matrix?

The matrix used to view models.

3.What is the projection matrix?

The matrix used to view projections.

4.What’s the difference between orthographic and perspective projection?

A few degrees.

5.What is an identity matrix? Why and how is it used in game programming?

The identity matrix contains the names of all matrices in the program. They are used to identify all game objects.

6.What are matrix stacks? Why and how are they used?

Matrix stacks are matrices used to operate on stacks of objects. Think physics.

7.What does the following line of code mean:
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); /* default, not needed */

Initialize a display for fat, single, Redheaded Girlie Babes.

8.What does the following line of code mean:
glutDisplayFunc(display); /* display callback, invoked when window opened (or redrawn) */

It’s how the fat guy shows off his funkiness. (i.e. Draws the RGBs through his window with his funk… called ‘func’ in opengl)

9.What’s the difference between glVertex3f, glVertex2f and glVertex3fv?

3, 2, and v.

10.What is a viewport?Why is a viewport needed?

A viewport is another name for window. They are need to see through walls.

11.What’s the advantage of using vertex arrays?

50 fps.

12.What kind of vertex arrays are there?

Strong and weak.

13.What are normalvectors mainly used for?

For correct math. Regular vectors are not required to be accurate.

Pudman… lol I had a great laugh!

The best:

Hello pudman,

Thanks for the funny answers… (While the questions did look suspicious :slight_smile:

I am going back to C after 25 years and had wondered about several of these myself! If someone would like to answer them privately please send me an email at jwzumwalt@rock.com.

My website is neatinfo(dot)com and obviously I am over college age :slight_smile:

JZ

It is assumed the original student failed their test :frowning:
For historical reasons, here are my suggested answers…

1.Why is it better to use the types glfloat instead of float ?

A: It doesn’t really matter, but for program readability and consistency across libraries it would be wise. If you don’t use the internal GL definitions there could be cross platform deployment issues.

2.What is the modelview matrix?

A: The model view matrix manipulates the object(s) (model) and not the observer position. If an observer takes one step closer or the object takes one step closer, the effect is the same, it just depends on whether you want to adjust the observer or the object (model).

3.What is the projection matrix?

A: The projection matrix is the same as the observer (viewpoint) matrix and includes any necessary clipping. See question 2.

4.What’s the difference between orthographic and perspective projection?

A: An orthographic view displays all lines and angles as their true length regardless of distance. This is the customary drawing used for floor plans or engineers “3 view” or “flat” drawings.

A perspective view gives an apparent dimension of depth by making distant objects smaller. This is how artists and “3d” drawings are made.

5.What is an identity matrix? Why and how is it used in game programming?

A: An identity matrix is used to neutralize all previous matrix calculations. If a matrix had been rotated and translated, then multiplying by the identity matrix would return everything to the normal view.

6.What are matrix stacks? Why and how are they used?

A: A matrix stack is a way of storing, or retrieving calculations. The stack is used as a FILO (first in last out) memory device. Storage is like pancakes, if you save a matrix (push it onto the stack), it will be at the top and a subsequent retrieval (pop from the stack) will return it. If several stores (pushes) occur without a “pop” (pull), then the original matrix slowly gets deeper and deeper in the stack. This is a fast and convenient way of storing previous calculations.

7.What does the following line of code mean:
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); /* default, not needed */

A: 1) Use a single image buffer (no memory scratchpad or page swapping),
2) each pixel is represented by a RGB (red, green, blue) value.

8.What does the following line of code mean:
glutDisplayFunc(display); /* display callback, invoked when window opened (or redrawn) */

A: This assigns a user supplied routine called “display” for drawing and /or refreshing the screen. This user made routine will be the logical place for most of the drawing commands.

9.What’s the difference between glVertex3f, glVertex2f and glVertex3fv?

A: the number represents how many numbers make up
each logical point and the letter after the number is the
variable type.
2f = two floating point numbers for each coordinate
3f = three floating point numbers for each coordinate
3fv =
3 Expect three variables for each coordinate
f These coordinates are in “float” format (they always are).
v Vertex will be passed in as an array. Otherwise we would have to pass the X, Y and Z coordinates separately.

10.What is a viewport?Why is a viewport needed?

A: A viewport designates what portion of the screen will show the image. This allows the image to take up a certain size and position so that other information can also be located on screen.

11.What’s the advantage of using vertex arrays?

A: Vertex arrays allow calculations to made just once for each required coordinate. Multiple polygons may use the same pre-calculated values. For example, a pyramid only has 4 required vertexes that need to be calculated. But if we where to process individually all the endpoints for each face (polygon), we would have to calculate 12 points (3 points for each face).

12.What kind of vertex arrays are there?

Vertices are specified by giving their coordinates in two, three, or four dimensions. This is done using one of several versions of the Vertex command:
void Vertex[234][sifd] ( T coords ) ;
void Vertex[234][sifd]v ( T coords ) ;

13.What are normalvectors mainly used for?

A: To determine if a face is pointed in the direction of the viewer and therefore is visible and should be drawn. They are also sometimes used for shading (determining the angle that light strikes a surface).

Several of these questions are subject to more than one interpretation. Of course I do not claim to be the final authority on this subject, feel free to offer alternative information :slight_smile:

Is that the answers expected by the teatcher ?

3, 5, 13 are really wrong.

What do you propose to be the correct answers? I’m not too proud to make corrections!

it was a bit late at night yesterday. Now I have some time to be more precise. In fact 2 is partly wrong too.

2.What is the modelview matrix?

A: The model view matrix manipulates the object(s) (model) right
and not the observer position.wrong It is model-view matrix, so it combines model + viewpoint. Moving the scene or moving the camera in inverse direction is the same, so it is logical to combine them.

3.What is the projection matrix?

A: The projection matrix is the same as the observer (viewpoint) matrix wrong see 2. The projection matrix casts 3D space to 2D space + depth (used for depth buffer).
and includes any necessary clipping.mostly wrong It is true however that projected depth outside the [0;1] range, will be clipped. The remaining clipping for top, bottom, left, right, is not guaranteed.
See pitfall 10. The Viewport Does Not Clip or Scissor :
http://www.opengl.org/resources/features/KilgardTechniques/oglpitfall/

13.What are normalvectors mainly used for?

A: To determine if a face is pointed in the direction of the viewer and therefore is visible and should be drawn. very wrong The frontfacing detection is not done by normals, but by testing if the projected vertices are in a counter-clockwise order. For details see here :
http://www.opengl.org/sdk/docs/man/xhtml/glFrontFace.xml
http://www.opengl.org/sdk/docs/man/xhtml/glCullFace.xml

They are also sometimes used for shading (determining the angle that light strikes a surface).mostly wrongThey are only used for shading (in the context of classic OpenGL).

are you sure that it’s his homework?

It’s either his homework or ours; not sure which at this point.

I stand by my answers.

You would too if you knew how cute they were.

Cute and cuddly, if you don’t mind my saying so.

I would only add that there are precisely 6 degrees of separation between an orthographic and perspective projection.

I would only add that there are precisely 6 degrees of separation between an orthographic and perspective projection.

…with the caveat that Kevin Bacon could be anywhere in between them!

9.What’s the difference between glVertex3f, glVertex2f and glVertex3fv?

3, 2, and v.

:eek: :smiley: :sorrow: :smiley:

13.What are normalvectors mainly used for?

For sane math. Vectors other than normal will result in insane math.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.