Introduction to OpenGL

opengl

Computer graphics is an integral part of game and computer simulattion programming. The visual content is the way the application communicates with the user.

Specialized computer hardware, the graphics cards, is used to generate all the complex scenes we see in modern games. This hardware has evolved over the years from drawing simple content used in application user interface, to real powerhouses capable of drawing realistic images of complex scenes and other physical objects.

Developers need a unified way to communicate with these graphics cards and use their power. Modern operating systems fulfill this through the use of device drivers. They provide the basic operations of text display and line drawing.

Our applications though are far more demanding. Complex drawing such as textures, waves, reflections, light and so many other things that make our world so beautiful are required. The graphics cards can perform all these calculations but the effort to develop all the code required would make the development of new applications almost impossible.

The solution was given in 1992 with the introduction of OpenGL. The name stands for Open Graphics Library. This is a cross-language programming interface developed by Silicon Graphics. Their aim was to assist computer aided design software to access the hardware of their high-performance workstations.

It offered a unified interface for two- and three-dimensional drawing and was adopted by all the key vendors of hardware and software. It was ported to all the operating systems and is supported by the device drivers of all the graphics cards in the market.

This success has led to a very robust and mature product upon which we can rely and build our games. Many books were written about it and the amount of documentation and examples we can find online makes learning how it works a lot simpler than it used to be.

In this tutorial, we will cover the basics of OpenGL and we will develop a small graphics engine that will allow us to create games and simulations. We will ilustrate the most fundamental techniques and effects used in game programming.

After you have managed the basics about how to build a simulation application or a simple game you may want to go deeper in OpenGL and enhance the simple techniques we develop in this introductory tutorial. I would recommend two major resources. First the book OpenGL SuperBible which is now in its seventh edition, covering OpenGL up to version 4.5, and second the site https://learnopengl.com/. Here we should also mention the site of the authority behind OpenGL and its successor Vulkan, https://www.khronos.org/.

Once you have mastered the basics and you have an application running you will find a lot of resources to help you improve the graphics layer of your application, and even convert your engine to use the latest 3D specification of Vulkan. the reason we are not going into Vulkan is because it is more demanding in terms of work that needs to be done, and that makes it a little more intimidating for beginners. In any case it is the next industry standard promoted by the same people that brought us OpenGL

You can download the game engine along with all the examples for this tutorial from GitHub. The link to the repository is https://github.com/cosfer65/ogl_tutorial