Be Friendly
Search This Site for Tutorials About...

OpenGL Base Code (Just enough to set you up)

Just for fun: How to Make French Toast

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

Did this article help you learn something new?

I enjoy writing for the Internet audiences because my thoughts are instantly published to the entire world. My work consists of writing educational articles about making websites to help people learn. If you enjoyed reading this article, or learned something new, then I have succeeded.

If the content on this website somehow helped you to learn something new, please let others know about it by sharing it on your website or on your Facebook page with your friends. In addition you can help by making a donation or bookmarking this site.