In this lesson we'll get an overview of the modern OpenGL method of passing vertex data from the CPU to the GPU. As of OpenGL version 3, the fix function method of immediate mode where we use GL begin and GL end has been deprecated, as have some of the other functions we took a look at, like GL matrix mode and GL push. Deprecation means these functions are still available and will likely work on your computer, but they are no longer considered best practices by the community. Many of the reasons behind this deprecation are so that us programmers have greater clarity and flexibility in developing programmable pipelines.
It also gives us greater control over how the data is moved around between the CPU and the GPU. Another good reason to learn this programmable pipeline now, is that it greatly facilitates programming on embedded devices, like phones, where immediate mode is usually not supported. The programmable pipeline is a bit trickier to get started with, but far more powerful, and luckily we'll be starting it together. So let's take a look at this graphic. Starting at the top, we make some 3-D calculations in our program running on our CPU.
We then transfer this data to the GPU vertex processor which calculates relevant transformations on this data, so that it will be positioned correctly in our screen. The GPU then assembles the transformed vertices into primitives like triangles and lines, possibly smooths them out in the rasterization step, and finally calculates the actual pixel color as it appears in front of you, perhaps by applying a texture or blending the two colors together. This final color is sent to the frame buffer which is shown on the screen in front of you or if we're rendering to a file, render it off screen.
We'll be taking a look at the vertex processing step and the fragment processing step in a bit more depth. For now consider how much information is actually being handled by the GPU. Modern day GPUs are much faster now, so this is a good thing. So here we've taken a look, the modern OpenGL programmable pipelie, and consider some of the reasons why it's good to learn it.
- What is OpenGL?
- Setting up an OpenGL workflow
- Creating a window with GLFW
- Working with geometric primitives
- Rotating, translating, and scaling
- Understanding matrix transformations
- Creating mesh data structures
- Buffering mesh data
- Getting mouse and keyboard input
Skill Level Intermediate
Q: Why am I getting errors saying I don’t have GLEW installed when I try to create the Xcode projects with Cmake?
1) Download, Install, and Run Xcode
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
brew install glew
./bootstrap && make && make install
brew install cmake
cd Exercise Filesmkdir xcodecd xcodecmake -G "Xcode" ..