OpenGL OpenGL Rendering Pipeline 1 — Questions and Answers
Question 1: What is the correct order of the main stages in the OpenGL rendering pipeline?
- Fragment shader → Vertex shader → Rasterization → Output merger
- Vertex shader → Rasterization → Fragment shader → Output merger (Correct answer)
- Rasterization → Vertex shader → Fragment shader → Depth test
- Vertex shader → Fragment shader → Rasterization → Output
Correct answer: Vertex shader → Rasterization → Fragment shader → Output merger
Vertices are processed first, then assembled into primitives, rasterized into fragments, shaded, and finally merged into the framebuffer.
Question 2: What OpenGL test discards fragments whose alpha value falls below a threshold?
- Depth test
- Scissor test
- Alpha test (via discard in GLSL) (Correct answer)
- Stencil test
Correct answer: Alpha test (via discard in GLSL)
In core OpenGL, alpha testing is implemented manually in the fragment shader by calling discard when alpha is below a threshold.
Question 3: What is back-face culling in OpenGL?
- Removing pixels that fail the depth test
- Discarding primitives whose winding order indicates they face away from the viewer (Correct answer)
- Clipping geometry outside the view frustum
- Removing duplicate vertices from a mesh
Correct answer: Discarding primitives whose winding order indicates they face away from the viewer
Back-face culling discards triangles whose vertices appear in clockwise winding when viewed from the front, saving rasterization work.
Question 4: Which OpenGL function enables a specific rendering capability such as depth testing?
- glSet
- glEnable (Correct answer)
- glActivate
- glToggle
Correct answer: glEnable
glEnable(GL_DEPTH_TEST), for example, turns on depth testing; glDisable reverses it.
Question 5: What does the stencil buffer allow OpenGL to do?
- Store floating-point lighting values per pixel
- Mask rendering to specific screen regions based on per-pixel stencil values (Correct answer)
- Improve texture sampling quality
- Cache vertex shader outputs
Correct answer: Mask rendering to specific screen regions based on per-pixel stencil values
The stencil buffer stores an integer value per pixel and tests can accept or reject fragments based on those values.
Question 6: Which OpenGL primitive type draws a separate triangle for every 3 vertices submitted?
- GL_TRIANGLE_STRIP
- GL_TRIANGLE_FAN
- GL_TRIANGLES (Correct answer)
- GL_QUADS
Correct answer: GL_TRIANGLES
GL_TRIANGLES treats each consecutive group of three vertices as an independent triangle, with no sharing.
What is the correct order of the main stages in the OpenGL rendering pipeline?