OpenGL Answers
New to OpenGL? Then this page is for you. This page contains answers to the most popular questions in OpenGL.
Don't forget to subscribe, since new answers are added on a regular basis.
1. What is OpenGL?
OpenGL is an API for drawing graphics. Its purpose is to transfer data from the CPU to the GPU.
2. How is data transferred to the GPU?
Data is transferred to the GPU with objects known as OpenGL Buffers.
3. What is a Buffer?
A buffer is a linear block of untyped data. Think of it as generic memory allocation.
4. Can a buffer store multidimensional data?
No. Data storage used for multidimensional data, such as images, are known as Textures.
5. What is a Vertex Attribute?
The input variable to a Vertex Shader.
6. What is a Vertex Shader?
The Vertex Shader is responsible for computing and passing forward the coordinates of a model to the Fragment shader.
7. How does the Vertex Shader receives data?
The mechanism for getting data in and out of a shader is to declare them as in or out storage qualifiers. When you declare a variable as in, it marks it as an input to the vertex shader. This sets the variable as an input to the graphics pipeline.
8. What is a Fragment Shader?
The basic operation of a fragment shader is to provide a color to each pixel. More specifically, the fragment shader takes the output from the rasterizer and computes the color of the pixel for each fragment.
9. What is the difference between Vertex Attribute vs. Uniform?
A Vertex Attribute can only be received by a Vertex Shader. A Uniform is data that can be received by any shader: Vertex, Tessellation, Geometry and Fragmet.
10. What is a Target?
A target is also known as Binding Points in OpenGL. A target determines the type of an object. Just like int or float determines the memory allocated for a variable in C++, a target determines the behavior of an object.
11. What is a Texture Object?
A Texture Object is an OpenGL object which contains texture data.
12. What is a sampler?
A Sampler represents a texture and sampling parameters in a shader.
13. What is a Sampler Object?
A sampler object stores the Wrapping and Filtering parameters that control a texture.
13. What is a Texture Unit?
A texture unit contains a Texture Object and a Sampler Object.
14. What is Texture Filtering?
It is the process of calculating color fragments from a stretched or shrunken texture map.
15. What is Magnification/Minification?
Stretching a texture is known as Magnification. Shrinking a texture is known as Minification.
16. How do you integrate a Vertex & Fragment Shader into your application?
Before your Vertex and Fragment shader programs can be integrated into your application, you must perform the following steps:
- Create one or more shader objects by using glCreateShader.
- Provide source code for these shaders by calling glShaderSource.
- Compile each of the shaders with glCompileShader.
- Create a program object by calling glCreateProgram.
- Attach the shader objects by calling glAttachShader.
- Link the program object by calling glLinkProgram.
- To use the program object as part of OpenGL’s current state call glUseProgram.