OpenGL OpenGL MCQ 5 — Questions and Answers
Question 1: What is the difference between glDrawArrays() and glDrawElements()?
- glDrawArrays uses indices; glDrawElements does not
- glDrawElements uses an index buffer to reuse vertices; glDrawArrays reads vertices sequentially (Correct answer)
- glDrawArrays is faster on all hardware; glDrawElements is for legacy use
- glDrawElements draws only points; glDrawArrays draws triangles
Correct answer: glDrawElements uses an index buffer to reuse vertices; glDrawArrays reads vertices sequentially
glDrawElements reads vertex indices from an Element Buffer Object (EBO) allowing vertex reuse, while glDrawArrays reads vertices in order without reuse.
Question 2: Which OpenGL mechanism allows the CPU to read back rendered pixels from the framebuffer?
- glTexImage2D()
- glReadPixels() (Correct answer)
- glGetTexImage()
- glMapBuffer()
Correct answer: glReadPixels()
glReadPixels() copies pixel data from the framebuffer to CPU memory, though it causes a GPU-CPU sync stall and should be avoided in performance-critical paths.
Question 3: In OpenGL, what does the LOD (Level of Detail) bias affect?
- The number of mipmap levels generated
- Which mipmap level is selected during texture sampling (Correct answer)
- The anisotropic filtering sample count
- The maximum texture resolution allowed
Correct answer: Which mipmap level is selected during texture sampling
LOD bias shifts the computed LOD value up or down, causing OpenGL to select a sharper or blurrier mipmap level than it would automatically choose.
Question 4: What is transform feedback in OpenGL used for?
- Sending input events back to the application
- Capturing vertex shader or geometry shader outputs into buffer objects (Correct answer)
- Reading uniform values back from the GPU
- Synchronizing double-buffered swap chains
Correct answer: Capturing vertex shader or geometry shader outputs into buffer objects
Transform feedback captures the output of the vertex or geometry shader into VBOs, enabling GPU-side particle systems and physics simulations.
Question 5: Which OpenGL extension introduced bindless textures to reduce CPU driver overhead?
- GL_ARB_texture_storage
- GL_ARB_bindless_texture (Correct answer)
- GL_EXT_direct_state_access
- GL_ARB_sparse_texture
Correct answer: GL_ARB_bindless_texture
GL_ARB_bindless_texture lets shaders access textures via GPU handles instead of texture units, eliminating bind/unbind overhead for scenes with many textures.
Question 6: What does MSAA (Multisample Anti-Aliasing) in OpenGL do?
- Applies a blur filter in a post-processing pass
- Samples each pixel at multiple sub-pixel positions to smooth triangle edges (Correct answer)
- Increases texture resolution for nearby objects
- Renders the scene at twice the resolution then downscales
Correct answer: Samples each pixel at multiple sub-pixel positions to smooth triangle edges
MSAA tests coverage at multiple sample points per pixel and averages only the edge samples, smoothing jagged triangle edges with minimal fill-rate cost.
Question 7: Which OpenGL function maps a buffer object's data store into client address space for direct CPU access?
- glBufferData()
- glMapBuffer() (Correct answer)
- glGetBufferSubData()
- glCopyBufferSubData()
Correct answer: glMapBuffer()
glMapBuffer() returns a pointer to the GPU buffer's memory, allowing the CPU to read or write buffer contents directly without a separate copy call.
What is the difference between glDrawArrays() and glDrawElements()?