OpenGL Programming Test Answers



1. What is usually the best texture format for upload?
Answers:
• GL_UNSIGNED_BYTE
• GL_UNSIGNED_SHORT
• GL_UNSIGNED_INT_8_8_8_8_REV
• GL_INT
• GL_FLOAT

2. What is vsync?
Answers:
• Synchronization with vertex arrays
• Synchronization with the monitor refresh rate
• Synchronization with VBO
• Synchronization with the windows server
• None of the above
3. If the viewport is 1024 by 768, the projection matrix is a 45 degree perspective matrix with the viewport ratio and the modelview matrix is the identity, what will be drawn on the screen when the following drawing code is entered?

void draw (void)
{
    glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
   
    glMatrixMode (GL_MODELVIEW);
    glLoadIdentity ();
   
    glTranslatef (0, 0, -10);
   
    glColor3f (1.0, 1.0, 0.0);
   
    glBegin (GL_QUADS);
    glVertex2i (1, 0);
    glVertex2i (1, 1);
    glVertex2i (-1, 1);
    glVertex2i (-1, 0);
    glEnd ();
    glFlush ();
}
Answers:
• Yellow lines
• Yellow square
• Yellow rectangle
• This code is an invalid drawing function
• None of the above
4. Which of the following is typically applied to the modelview matrix stack?
Answers:
• glFrustrum
• glRotate
• gluPerspective
• glOrtho
• gluOrtho2d
5. What is the difference between glLoadTransposeMatrix and glLoadMatrix?
Answers:
• glLoadTransposeMatrix does not require any argument to transpose the matrix on top of the stack wheras glLoadMatrix does
• glLoadTransposeMatrix transposes the given matrix before loading it wheras glLoadMatrix does not
• glLoadTransposeMatrix loads the matrix in the transpose area of the GPU wheras glLoadMatrix does not
• None of the above
6. Is the following a valid drawing function?

void draw (void)
{
    glClear (GL_COLOR_BUFFER_BIT);

    glMatrixMode (GL_PROJECTION);
    glLoadIdentity ();
    glPushMatrix ();
    gluPerspective (45.0, (float)frame.size.width / (float)frame.size.height,
                    2.0, 1000.0);

    glMatrixMode (GL_MODELVIEW);
    glLoadIdentity ();
    glTranslatef (0, 0, -10);

    glColor3f (1.0, 1.0, 0.0);
   
    glBegin (GL_QUADS);
    glVertex2i (1, 0);
    glVertex2i (1, 1);
    glVertex2i (-1, 1);
    glVertex2i (-1, 0);
    glEnd ();

    glFlush ();
}
Answers:
• Yes
• No
7. What is gl_Vertex in a vertex shader?
Answers:
• An attribute
• An uniform
• A varying
• A constant
• None of the above
8. Which values can be used with glTexParameter and GL_TEXTURE_MAG_FILTER parameter names?
Answers:
• GL_NEAREST
• GL_FAR
• GL_BILINEAR
• GL_LINEAR
• GL_MIPMAP
9. Is the following code correct?

    glBegin (GL_QUADS);
    glVertex2i (1, 0);
    glVertex2i (1, 1);
    glVertex2i (-1, 1);
    glVertex2i (-1, 0);
    glEnd (GL_QUADS);
Answers:
• Yes
• No
10. In which version of OpenGL, GLSL was introduced as a core feature?
Answers:
• 1.1
• 1.2
• 1.3
• 2.0
• 2.1
11. Is gluBeginPolygon the same as glBegin(GL_POLYGON)?
Answers:
• Yes
• No
12. Which of the following might be used to draw VBOs?
Answers:
• glDrawArrays
• glDrawRangeElements
• glDrawElements
• glDrawVBO
• None of the above
13. What is the common size of OpenGL matrices?
Answers:
• 2x2
• 3x3
• 4x4
• 3x4
• 4x3
14. What is true of the following code?

glPushMatrix ();
glLoadIdentity ();
glTranslatef (1.0, 2.0, 4.0);
glPopMatrix ();
Answers:
• After this code has been executed, the matrix stack will be restored to its original state.
• This code has a syntax error.
• Load identity cannot appear after a push matrix.
• None of the above is true
15. Who created OpenGL?
Answers:
• Sun
• Microsoft
• SGI
• Apple
• Dell
16. What is true of OpenGL?
Answers:
• It is a pixel precise specification
• It has numerous implementations
• It can be fully implemented in software
• None of the above is true
17. What is the first argument of glRotate?
Answers:
• The angle in radians
• The angle in degrees
• The center vector
• None of the above
18. What is the difference between statements A and B?

A: gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * gl_Vertex;

B: gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
Answers:
• They are equivalent
• The former has a syntax error whereas the latter has not any
• The former is valid whereas the latter is not
• None of the above
19. Is the following a valid drawing function?

void draw (void)
{
    glClear (GL_COLOR_BUFFER_BIT);

    glBegin (GL_QUADS);
    glVertex2i (1, 0);
    glVertex2i (1, 1);
    glVertex2i (-1, 1);
    glVertex2i (-1, 0);
    glEnd ();

    glFlush ();
}
Answers:
• Yes
• No
20. Which primitives may be used to draw a circle?
Answers:
• Polygon
• Lines
• Quads
• Triangles
• None of the above
21. In Windows, what API will you use to get an OpenGL context?
Answers:
• agl
• wgl
• glX
• None of the above
22. With depth test enabled, will the following drawing code work for depth testing?

void draw (void)
{
    glClear (GL_COLOR_BUFFER_BIT);
    glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
   
    glMatrixMode (GL_MODELVIEW);
    glLoadIdentity ();
    glTranslatef (0, 0, -10);
   
    glColor3f (1.0, 1.0, 0.0);
   
    glBegin (GL_QUADS);
    glVertex2i (1, 0);
    glVertex2i (1, 1);
    glVertex2i (-1, 1);
    glVertex2i (-1, 0);
    glEnd ();
    glFlush ();
}
Answers:
• Yes
• No
23. How do you initialize the name stack?
Answers:
• Using glCreateStack ()
• Using glInitNames ()
• Using glPushMatrix ()
• None of the above
24. What is the purpose of glTexCoord?
Answers:
• To specify the origin and size of a texture
• To associate a texture coordinate with a vertex or raster position
• To generate a UV map from a 3D model
• To generate a coordinate grid for the current texture
• None of the above
25. What is the default parameter qualifier?
Answers:
• none
• in
• out
• inout
• None of the above
26. In Linux, what API will you use to get an OpenGL context?
Answers:
• agl
• wgl
• glX
• None of the above
27. What is the primary language of OpenGL?
Answers:
• C++
• C
• Ruby
• Perl
• Java
28. Which of the following is not an OpenGL primitive?
Answers:
• Point
• Polygon
• Circle
• Quad
• Triangle
29. What is/are the return type/s of glGetx () ?
Answers:
• int
• It/they depend/s on the function
• void
• float
• vector
30. Is glFinish blocking?
Answers:
• Yes
• No
31. After a glRenderMode (GL_SELECT), no fragment are produced.
Answers:
• True
• False
32. Is there any non-structured flow of control like "goto" in GLSL?
Answers:
• Yes
• No
33. What will be drawn by the following code?

    glBegin (GL_QUADS);
    glVertex2i (1, 0);
    glVertex2i (1, 1);
    glVertex2i (-1, 0);
    glEnd ();
Answers:
• A quad
• A polygon
• A line
• This code is invalid
• None of the above
34. Which color is defined by the following call?

    glColor3ub (0, 255, 0);
Answers:
• red
• blue
• green
• gray
• white
35. When glMultMatrix takes a matrix, how should it be ordered?
Answers:
• Row-major
• Column-major
• Mixed mode
• None of the above
36. Consider the following code:

glTranslatef (1.0, 2.0, 3.0);
glRotatef (40, 1.0, 0.0, 0.0);

What will be the first transformation from a geometric point of view?
Answers:
• Translation
• Rotation
37. Which function should be used to upload a 2D texture to OpenGL?
Answers:
• glUploadTex
• glTexCreate2D
• glTexImage2D
• glBuildTexture2D
• glTexture
38. What does glClear do?
Answers:
• It clears all OpenGL buffers
• It clears the OpenGL buffers specified in an argument
• It sets the window color to black
• None of the above
39. Which of the following is not a valid argument to glBegin ()?
Answers:
• GL_POINTS
• GL_LINES
• GL_LINE_STRIP
• GL_TRIANGLES
• GL_QUADS_FAN
40. On what language is GLSL syntax based?
Answers:
• ruby
• C
• python
• Objective-C
• None of the above
41. Can glNormal be called between glBegin and glEnd ?
Answers:
• Yes
• No
42. What will happen if you do the following?
glMatrixMode (GL_PROJECTION);

glRotatef (10, 1, 0, 0);
Answers:
• A bus error will result
• An OpenGL error will result
• A rotation matrix is multiplied with the current projection matrix
• The projection matrix will be filled with garbages
• None of the above
43. When a matrix has been popped from the stack, is it possible to read it again?
Answers:
• Yes, in the backbuffer
• Yes, with the matrix history
• Yes, by pushing an empty matrix
• No
44. What does glGetMinmax do?
Answers:
• It gets minimum and maximum vertex values
• It gets minimum and maximum surface values
• It gets minimum and maximum texture values
• It gets minimum and maximum pixel values
• None of the above
45. OpenGL can draw convex polygons. Can it draw non-convex ones?
Answers:
• Yes
• No
46. What will be the size of the quad drawn by the following code on the screen?

    glBegin (GL_QUADS);
    glVertex2i (1, 0);
    glVertex2i (1, 1);
    glVertex2i (-1, 1);
    glVertex2i (-1, 0);
    glEnd ();
Answers:
• 1 pixel
• 1 cm
• 1 inch
• It depends on the projection and modelview matrices
• None of the above
47. Which of the following functions has an unsigned byte variant? (taking GLubyte as arguments)
Answers:
• glVertex
• glColor
• glNormal
• glTexCoord
• None of the above
48. Does gluProject use the current matrix stack?
Answers:
• Yes
• No
49. What does glPassThrough() do?
Answers:
• It passes polygon through the depth buffer
• It loads the accumulation buffer
• It places a marker in the feedback buffer
• It loads a texture
• None of the above
50. What is a proxy texture?
Answers:
• A server side texture
• A texture without pixel data
• A 3d texture
• None of the above
51. How can you access the current modelview matrix?
Answers:
• With glModelviewMatrix
• With glGetMatrix
• With glReadMatrix
• With glStack
• None of the above
52. What is a display list?
Answers:
• A buffer object
• A list of commands
• A list of vertices
• None of the above
53. Which of the following are valid picking methods?
Answers:
• Back buffers
• Select buffers
• Automatic selection
• Render buffers
• None of the above
54. What image format does OpenGL understand?
Answers:
• png
• bmp
• tiff
• tga
• OpenGL cannot read images directly
55. Which function should be used to specify the coordinates of a point?
Answers:
• glPoint
• glCoord
• glVertex
• glPointCoord
• None of the above
56. glOrtho is used to define a _________ matrix.
Answers:
• modelview
• projection
• texture
• view
• model
57. What does glFrustum do?
Answers:
• It multiplies the current matrix by a translation matrix
• It multiplies the current matrix by a perspective matrix
• It multiplies the current matrix by a texture matrix
• It multiplies the current matrix by a color matrix
• None of the above
58. Which of the following is faster?
Answers:
• glBegin, glVertex, etc.
• Vertex buffer objects
• Vertex arrays
• None of the above
59. What does glActiveTexture do?
Answers:
• It changes the active texture unit
• It queries the active texture unit
• It overrides the current texture unit
• None of the above
60. What should be added to make this drawing function valid?

void draw (void)
{
    glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
   
    glTranslatef (0, 0, -10);
   
    glColor3f (1.0, 1.0, 0.0);
   
    glBegin (GL_QUADS);
    glVertex2i (1, 0);
    glVertex2i (1, 1);
    glVertex2i (-1, 1);
    glVertex2i (-1, 0);
    glEnd ();
   
    glFlush ();
}
Answers:
• It is already valid
• glPushMatrix ()
• glLoadIdentity ()
• glPopMatrix ()
• None of the above
61. Which color is defined by the following call?

    glColor3f (1.0, 0.0, 0.0);
Answers:
• blue
• gray
• white
• red
• green
62. Is the following code valid?

    glMatrixMode (GL_MODELVIEW);
    glLoadIdentity ();
    glTranslatef (0, 0, -10);
Answers:
• Yes
• No
63. Which function should be used to specify the value of a sampler1D?
Answers:
• glSampler1D
• glSamplerUniform
• glUniform1i
• glSetSampler
• None of the above
64. What should be the render mode to use glLoadName ()?
Answers:
• GL_RENDER
• GL_SELECT
• GL_FEEDBACK
• None of the above
65. What does glBitmap do?
Answers:
• It loads a bitmap file
• It loads a png file
• It draws a bitmap
• It creates a texture
• None of the above
66. What is a varying variable?
Answers:
• A variable passed from the C code to the vertex shader
• A variable passed from the C code to the fragment shader
• A variable passed from the vertex shader to the fragment shader
• A variable passed from the fragment shader to the vertex shader
• None of the above
67. What is blending?
Answers:
• Texturing
• Layer composition
• Geometry transformation
• None of the above
68. Which of the following is not a valid argument to glMatrixMode ?
Answers:
• GL_COLOR
• GL_PROJECTION
• GL_TEXTURE
• GL_DEPTH
• GL_MODELVIEW
69. What does gluOrtho2D do?
Answers:
• It sets the eye position
• It defines a projection matrix
• It defines a modelview matrix
• None of the above
70. What will be drawn by the following code?

    glBegin (GL_QUADS);
    glVertex2i (1, 0);
    glVertex2i (1, 1);
    glVertex2i (-1, 0);
    glVertex2i (-1, 1);
    glEnd ();
Answers:
• A quad
• A triangle
• Two lines
• A circle
• None of the above
71. On which matrix stack should gluOrtho2D be used?
Answers:
• Texture
• Color
• Modelview
• Projection
72. Which of the following buffer types is/are supported in OpenGL?
Answers:
• Stencil
• Color
• Depth
• Accumulation
• All of the above
73. The matrix, after the following calls, will be the identity matrix.

    glLoadIdentity ();
   
    glTranslatef (0, 0, -10);
    glRotatef (40, 1, 0, 0);
   
    glTranslatef (0, 0, 10);
    glRotatef (-40, 1, 0, 0);
Answers:
• True
• False
74. What will happen if a null pointer is used with glTexImage2D()? (In OpenGL >1.1)
Answers:
• An error will occur
• Undefined behaviour wil result
• The texture space will be allocated for future use with sub-textures
• None of the above
75. On which matrix stack should gluLookAt be used?
Answers:
• Texture
• Projection
• Modelview
• Color
76. OpenGL has some windows manipulation functions.
Answers:
• True
• False
77. Can you read a uniform value from the C code?
Answers:
• Yes
• No
78. Can "discard" be used in a vertex shader?
Answers:
• Yes
• No