Click to choose your tutorial
Tutorial 1: SDK
Tutorial 2: Creating a Window
Tutorial 3: Vulkan Instance
Tutorial 4: Supported Extensions
Tutorial 5: Drawing Points
Tutorial 6: Drawing Lines
Tutorial 7: Drawing Triangles
Tutorial 8: Introduction to Shaders
Tutorial 9: Loading Shaders
Tutorial 10: Using Multiple Shaders
Tutorial 11: Loading 3D Model
Tutorial 12: Displaying 3D Model
Tutorial 13: Vertex Animation
Tutorial 14: Bone Animation
OpenGL Tutorials
site is v0.1a build Sep 11, 2016
Join to be notified of new tutorials

Tutorial 7 - The basic blocks of my OpenGL basecode, free to use for anyone. Have fun.

Written by staff. Contact us to submit your article for review.
Sep 13, 2016
tags Tags keywords
Post #32

The basic blocks of my OpenGL basecode, free to use for anyone. Have fun.

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.

article tab
Follow OpenGL Tutorials
You will only receive important news about OpenGL tutorial updates.
Who is joining?
  • Programmers You want to stay in touch to receive OpenGL tutorial updates.
  • Game Devs You're a game developer, and you also want to learn more about OpenGL!
  • Supporters You have invested interest in supporting OpenGL tutorial site.
Follow OpenGL Tutorials