OpenGL OpenGL MCQ 3 — Questions and Answers
Question 1: In OpenGL, what is the default front face winding order?
- Clockwise (CW)
- Counter-clockwise (CCW) (Correct answer)
- Alternating CW and CCW
- Determined by vertex normals
Correct answer: Counter-clockwise (CCW)
By default, OpenGL considers triangles with counter-clockwise vertex winding when viewed from the front to be front-facing.
Question 2: Which blending equation in OpenGL produces a standard alpha transparency effect?
- glBlendFunc(GL_ONE, GL_ONE)
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) (Correct answer)
- glBlendFunc(GL_DST_COLOR, GL_ZERO)
- glBlendFunc(GL_SRC_COLOR, GL_DST_COLOR)
Correct answer: glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
GL_SRC_ALPHA for source and GL_ONE_MINUS_SRC_ALPHA for destination produces standard alpha blending where a=1.0 is opaque and a=0.0 is fully transparent.
Question 3: What is the role of the geometry shader stage in the OpenGL pipeline?
- Converts vertices to screen pixels
- Can generate new primitives or discard existing ones (Correct answer)
- Calculates per-fragment lighting
- Decompresses texture data
Correct answer: Can generate new primitives or discard existing ones
The geometry shader receives complete primitives and can emit zero or more new primitives, enabling effects like shadow volumes or particle systems.
Question 4: Which texture wrapping mode causes the texture to repeat in a mirrored pattern?
- GL_REPEAT
- GL_CLAMP_TO_EDGE
- GL_MIRRORED_REPEAT (Correct answer)
- GL_CLAMP_TO_BORDER
Correct answer: GL_MIRRORED_REPEAT
GL_MIRRORED_REPEAT tiles the texture but flips it alternately, creating a mirrored effect at each repetition boundary.
Question 5: What does the GLSL uniform qualifier indicate?
- A variable that changes per vertex
- A constant value set from the CPU that is the same for all shader invocations in a draw call (Correct answer)
- A variable shared between vertex and fragment shaders via interpolation
- A read-only texture sampler
Correct answer: A constant value set from the CPU that is the same for all shader invocations in a draw call
Uniform variables are set once from application code via glUniform*() and remain constant throughout all shader invocations in a single draw call.
Question 6: Which OpenGL function specifies how vertex attribute data is read from a VBO?
- glVertexAttrib4f()
- glVertexAttribPointer() (Correct answer)
- glBindAttribLocation()
- glVertexAttribDivisor()
Correct answer: glVertexAttribPointer()
glVertexAttribPointer() tells OpenGL the size, type, stride, and offset of a vertex attribute within the currently bound VBO.
Question 7: What is a Framebuffer Object (FBO) primarily used for in OpenGL?
- Storing compiled shader programs
- Rendering to off-screen textures or render buffers (Correct answer)
- Managing VBO memory allocation
- Synchronizing GPU and CPU execution
Correct answer: Rendering to off-screen textures or render buffers
An FBO lets you redirect rendering to textures or renderbuffers instead of the default framebuffer, enabling render-to-texture effects.
In OpenGL, what is the default front face winding order?