OpenGL Game Development Tutorials

OpenGL Book: A OpenGL Tutorial Reference Book
Easily understand OpenGL and learn how to create 3D worlds and games from scratch.

OpenGL Gems is the authorative guide on OpenGL programming published by Learning Curve / Education for software developers! This book in 3D C++ programming series clearly, and in easy to follow language, explains fundamental principles used behind programming 3D games using the OpenGL cross-platform framework.

Preorder Now in PDF format for Kindle and get a discount.
OpenGL Gems is coming out on April 15th, 2017.
The paperback version will be available via this Amazon page, please bookmark it!

OpenGL Base Code

What you need to get started with OpenGL This tutorial is a little digression from the OpenGL fundamentals. This tutorial needs to be here because I want to explain what my OpenGL base code is turning into.

As it's not contained within a single header and a single cpp files anymore, an explanation is required of how files are linked together. Moreover, you need to know how to add additional modules of code to the current code structure if you decide to append something to the base code by yourself.

So, here is how files are linked together in the fallout openGL base code:

The main include file "glbase.h":
                glbase.h---+- <windows.h>
                +- <gl/gl.h>
                +- <gl/glu.h>
                +- "defined.h"
                +- "log.h"
                +- "winmain.h"
                +- "model.h"
                +- "system.h"
                +- "glmain.h"
                +- "dierr.h"
                +- "directinput.h"
            

Each of the following *.cpp files #includes "glbase.h":

dierr.cpp        :  DirectInput error codes
                directinput.cpp  :  DirectInput implementation
                glmain.cpp       :  the "main()" function
                log.cpp          :  system log
                model.cpp        :  [*.m] format model definition
                system.cpp       :  'system' stuff; SysShutdown, SysSetDisplayMode...
                winmain.cpp      :  WinMain(); and initialization

Whenever you want to add your own module of code, for example a 3D math library, given that your math library is contained within math3d.h and math3d.cpp files, you would go to "glbase.h" and append the line #include "math3d.h" (indicated in red below) at the end of the already included files list:

// glbase.h

        #include <windows.h>		// Windows crap...

        #include <gl/gl.h>		// openGL headers
        #include <gl/glu.h>

        #include "defined.h"		// main defined types
        #include "log.h"		// system log

        #include "winmain.h"		// WinMain(), InitOpenGL()
        #include "model.h"		// model file (filename.m) definition
        #include "system.h"		// SysShutdown(), Sys...
        #include "glmain.h"		// RenderFrame()

        #include "dierr.h"		// DirectInput error codes
        #include "directinput.h"	// DirectInput implementation

        #include "math3d.h"		// your 3D math library

You would then add the line #include "glbase.h" at the beginning of your math3d.cpp file. Recompile the code. Now you can use your math library from within any other file included in glbase.h. That simple.

OpenGL Book: A OpenGL Tutorial Reference Book
OpenGL Book - A OpenGL Tutorial Reference Book

If tutorials on this site are not enough, or you simply like reading from a physical book or a digital device (Kindle, iPad, tablets, etc.) check out OpenGL Book. Written by the author of tutorials on this site.

This book is a OpenGL tutorial and a reference that guides the reader through the process of setting up and initializing OpenGL, drawing 3D primitives and creating 3D computer games.

Preorder Here
© 2017 Copyright OpenGL Tutorials (www.falloutsoftware.com)

All content and graphics on this website are the property of www.falloutsoftware.com - please provide a back link when referencing on other sites.