A Graphical Programming learning experience - utilizing OpenGL and FreeGLUT to start understanding the basics of Graphical Programming.
This Project expands on the initial work done in the S2D
Framework Project by introducing us to what happens under the hood, as the S2D Framework is a 2D
OpenGL Framework.
Initially we were given the task of drawing a shape onto the screen manually, using screen-space
coordinates, by manually creating vertices and converting them into a polygon through OpenGL's
functions.
After this, I started to create Classes that can store Object data, such as Transform
, which
contains two Vector3
s, of which describe Position and Rotation.
Once this was completed I wrote a 2D N-gon generator and gave the data from this into Object Classes
- which formed the basis of future work with 3D models and loading in from .obj files.
Next for this was a Parent-Child relationship, which required researching how OpenGL handles its
matrices internally. The solution for this was Popping and Pushing matrices in order of how they
would be seen in something like Unity's Scene Viewer.
You Pop the Parent's matrix
, so the parent's transformations, then you Pop any
children's matrices and calculate the transformations and one the way back up you Push them back.
This is a recursive process and as such I wrote recursive function to handle this.
LinkedList
s instead of std::vector
s -
which improves memory efficiency as vectors may or may not free memory until it goes out of
scope.
std::shared_ptr
s so that Heap data is managed for
me through Smart Pointers.
v 0.4 0.1 1.0
describes a Vertex and its position relative to the centre of the
object in 3D coordinates.
Material
contains 4 values, 3 float4
s for Ambient, Specular and Diffuse
and also a float
for Shininess.
Material
s in the rendering is made very simple by using
glMaterialfv()
and glMaterialf()
.
float4
s.
Then using glLightfv()
you light the scene that frame.
GameObject
, as such the Text
class
derives
from GameObject
.
std::string
, Transform
and Vector3
of colour.
SceneGraph
works, the Text
would be Sliced, if it was not a
pointer - this is because of how C++ handles memory.
If it was declared on the stack, the memory allocated would be exactly for the base type, and not the
derived class - thus losing data.