OpenGL is a graphics library that can be used to render interactive 2D and 3D graphics applications.
OpenGL has wide range of applications. OpenGL library comes in two flavors.
- Deprecated fixed pipeline based API or legacy OpenGL ( releases before 3.0)
- Shader based API or Modern OpenGL (release 3.0 and onwards)
Modern OpenGL uses GPU instead CPU there by increasing user experience tremendously. legacy OpenGL is still supported for backward compatibility as of latest release 4.6.
In this tutorial we consider shader based approach.
Prerequisites
OpenGL programming is different from normal programming. Following is a check list:
- 3D math such as vectors, planes, rays etc.,
- Matrix arithmetic
- Trigonometry
- Understanding of motion related physics
- Intermediate C++ programming
- GLSL concepts and programming
Tutorial Overview
This tutorials attempts to teach basic to advanced concepts one at a time. The goal is to create an advanced , multifunctional library from scratch. The tutorials will be a set of C++ header (.h) files.
There are plenty of websites with rich documentation on different OpenGL related topics. For various topics, a short description will be provided along with a link for further details.
There are plenty of websites with rich documentation on different OpenGL related topics. For various topics, a short description will be provided along with a link for further details.
Tutorial Directory Structure
The folder structure will be as below.
The folder structure will be as below.
Lessons
contains source code and binaries of the applications using the different OpenGL topics and features discussed in the tutorial.
contains source code and binaries of the applications using the different OpenGL topics and features discussed in the tutorial.
Externals
Contains 3rd party libraries used by the tutorial for loading OpenGL extensions, perform vector math, matrices calculations. loading texture, object model etc.
OpenGL Extensions
The OpenGL header file included as a part of windows SDK supports OpenGL specification 1.1. The Modern OpenGL tutorial uses OpenGL specification 3.3. The extensions will be loaded after the context is created. This will be discussed in detail in the next post.
As the OpenGL specification 3.3 has just too many APIs, the extensions will be supplied by a separate library, GLExtensions. The C++ prototypes of OpenGL specification 3.3 can be downloaded from Galogen web site. In addition, latest WGL extensions should also be included. This can be downloaded from this website. WGL Extensions are also included in GLExtensions.
GLExtensions is located under externals folder and is configured as static library. The debug and release libraries are available as externals\GLExtensions\Lib\GLExtensions_static_x86_d.lib and externals\GLExtensions\Lib\GLExtensions_static_x86.lib.
OpenGL Context Creation and mouse/Keyboard Input
This tutorial is primarily targeted for windows OS, so Wiggle APIs are used for creating OpenGL context. For windowing, mouse and keyboard input etc., ATL and WIN32 APIs are used.
GLM
Rendering 3D context involves lot of vector math, matrix math, trigonometry etc. GLM conveniently provides a math library including all these and more. In addition it also provides APIs for creation of Ortho and Perspective projection matrix, transformations such as translation, rotation and scaling, lookat matrix and much more. GLM can be downloaded from here.
Rendering 3D context involves lot of vector math, matrix math, trigonometry etc. GLM conveniently provides a math library including all these and more. In addition it also provides APIs for creation of Ortho and Perspective projection matrix, transformations such as translation, rotation and scaling, lookat matrix and much more. GLM can be downloaded from here.
GLM files are located at externals\glm folder.
Simple OpenGL Image Library
SOIL2 is used for loading textures. displaying bitmaps etc. SOIL2 can be downloaded from here.
SOIL2 is located under externals folder and is configured as static library. The debug and release libraries are available as externals\SOIL2\projects\VC15\libs\SOIL_static_x86_d.lib and externals\SOIL2\projects\VC15\libs\SOIL_static_x86.lib.
Resources
Contains bitmaps, texture bitmaps, wireframe models used in the tutorial.
Development Environment
VS2015 IDE is used for building externals and tutorials.
Creating tutorial lesson projects
Following steps should be used to create tutorial lesson projects using VS IDE
In the next post we will discuss creation of Creating OpenGL Context, Rendering and Mouse/Keyboard input support.
No comments:
Post a Comment