Game Engineering – II | Assignment – 9

For this assignment, I had to completely overhaul how shaders were read into the game. Instead of being hard coded data paths, I had to create my own custom effect file which would store the paths to the fragment and vertex shader files as well as the render state.

Moreover, at build time this effect file would be read in and converted into a binary file which would then be parsed at run-time for get the required shader information.

Here is the executable MyGame_

Controls :

  • F1 – F2 — Move camera up – down
  • F3 – F4 — Move camera left – right
  • directional keys — move sphere
  • SPACE — remove plane

Here is a screenshot of what my effect file looks like.


To make it easier to read I store the render states as boolean values which are converted into their required format when the file is parsed at build time.

And here is the binary version of the same file.

The blue line highlights the 8bit render state. Red lines highlight ends of string paths.

As can be seen I do not convert the paths to built paths at build time. Instead I do so at run time by prepending “data/” to the shader paths retrieved from the binary files.

Now, converting the shader paths and build time saves us runtime costs at the expense of requiring more storage space. Conversely, in my case, prepending the string at runtime requires more processing but saves us storage space.

Both solutions are valid and one may be better than the other based on the context. If there are space restrictions, my solution would be better. If there are processor restrictions, vice versa.

Here is how I extract the binary data at run time.


Refer to the binary file screenshot, each data path ends with a null character (Hex 00). When assigning to a string, it automatically treats the null character as end of string.

And finally, a screen shot of the game itself (for consistency).


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s