In the world of gaming, SDL provides the entire necessary infrastructure. This would have become clear from previous articles in this series. Infrastructure is to a game what a skeleton is to a human body. But without muscles, no locomotion is possible. So working with the body analogy, SDL provides the skeletal structure to build the game whereas the flesh, blood and skin are provided by 2D and 3D graphics libraries.
The video is initialized to 600x300 resolutions. And the hardware rendering mode is being used. This is done by the SDL_HWSURFACE flag. Hence OpenGL would write on the graphic card's memory instead of mapping it to software memory. After this step, we move into the territory of OpenGL.
To start working with OpenGL, the view port is initialized. Then the screen is cleared or rendered with the specified background color. Since the triangle would be rotating in 3D space, the depth has to be set and depth testing has to be enabled. If smooth shading is not used, then the edges would seem jagged. Hence the smooth shading model is used.
This completes the setting up of OpenGL parameters after SDL video initialization. Drawing and rotation is taken care of by the following code in bold:
That's it. This is how SDL and OpenGL work together. Though this section covers the technical details of OpenGL, the complete steps for using OpenGL are not discussed. That will be the topic of the next discussion.