OpenGL Functions 2 — Questions and Answers
Question 1: Which function is used to specify the source and destination blending factors in OpenGL?
- glBlendFunc() (Correct answer)
- glBlendEquation()
- glColorMask()
- glAlphaFunc()
Correct answer: glBlendFunc()
glBlendFunc() sets the pixel arithmetic for blending by specifying source and destination factors.
Question 2: What does glDepthMask(GL_FALSE) do?
- Disables depth testing entirely
- Makes the depth buffer read-only (Correct answer)
- Clears the depth buffer
- Inverts depth comparisons
Correct answer: Makes the depth buffer read-only
glDepthMask(GL_FALSE) disables writes to the depth buffer, making it effectively read-only while depth testing can still occur.
Question 3: Which OpenGL function retrieves the location of a uniform variable in a shader program?
- glGetAttribLocation()
- glGetUniformLocation() (Correct answer)
- glUniform1i()
- glBindUniform()
Correct answer: glGetUniformLocation()
glGetUniformLocation() returns the integer location of a named uniform variable within a linked program object.
Question 4: What is the purpose of glGenerateMipmap()?
- Loads a mipmap from disk
- Automatically generates all mipmap levels for a texture (Correct answer)
- Sets the mipmap filter mode
- Binds a specific mipmap level
Correct answer: Automatically generates all mipmap levels for a texture
glGenerateMipmap() automatically computes all mipmap levels for the currently bound texture from the base level image.
Question 5: Which function do you call to attach a renderbuffer to a framebuffer object?
- glFramebufferTexture2D()
- glFramebufferRenderbuffer() (Correct answer)
- glBindRenderbuffer()
- glRenderbufferStorage()
Correct answer: glFramebufferRenderbuffer()
glFramebufferRenderbuffer() attaches a renderbuffer object to a specified attachment point of the currently bound framebuffer.
Question 6: What does glStencilOp() control?
- The stencil test comparison function
- How the stencil buffer is updated based on test results (Correct answer)
- The stencil buffer clear value
- The stencil write mask
Correct answer: How the stencil buffer is updated based on test results
glStencilOp() specifies the actions taken when the stencil test fails, the depth test fails, or both tests pass.
Question 7: Which function is used to map a buffer object's data store into client address space?
- glBufferData()
- glBufferSubData()
- glMapBuffer() (Correct answer)
- glCopyBufferSubData()
Correct answer: glMapBuffer()
glMapBuffer() maps the buffer object's entire data store to a pointer that the CPU can read or write directly.
Which function is used to specify the source and destination blending factors in OpenGL?