Friday, 9 August 2013

The Interjection #1

Hello, Everyone!

   I know I promised to post source code of my first tech demo created with Graphics Framework - both the post and the demo are under construction right now ;-). Example program is ready for a very long time but I'm updating it to utilise the newest version of my library. And of course I'm adding last minute tweaks to the framework before the very first worldwide presentation.
   As I have mentioned in the previous post, I have removed all Create() functions from the so called resource classes (all classes in my framework that represent some of the 3D graphics concepts, like texture, vertex attribute stream, shader or depth buffer state, derive from abstract cResource class). Previously, constructors and Create() functions behaved identically so one could utilise the same variable more than once: if a variable is already constructed it could be easily given new state through mentioned Create() function not only the constructor and assignment operators which lead to unnecessary copies. But then I realised that this leads to redundancy in signatures of Create() functions and constructors (but only signatures, not implementations) and I have read more about RAII principle. Of course behaviour of Create() functions didn't violate the RAII principle - whole state of an object was cleared before new state was assigned, it wasn't possible to change it in any other way - but for me api provided by the resource classes wasn't coherent enough. And finally, I have found out that r-value references are the solution for my problem - I can avoid unnecessary copies and maintain simple api. So I have implemented move assignment operators to all resource classes.
   Earlier object construction could look like this:
// Constructor
cShader vs( eShaderType::VERTEX_SHADER, "sh.vp" );

// Create() function
cShader fs;
fs.Create( eShaderType::FRAGMENT_SHADER, "sh.fp" );
Right now the second example has to be replaced with this:
// Assignment of new object
fs = cShader( eShaderType::FRAGMENT_SHADER, "sh.fp" );
   There is another reason which caused a delay in posting my first demo's source code and screenshots: I'm preparing a training which I will be conducting during the Saturday and Sunday. The scope of this training is of course 3D graphics concepts. I came up with an idea that I could use my framework during the training. I want to build example programs that can show some specific 3D graphics features like different primitive types, texture filtering modes or lighting calculations. Source code of these programs would also be presented so I wanted it to be simple and easy to understand. Graphics Framework allows to quickly and with very few lines of code create new program, it hides 3D graphics api calls but is based on 3D graphics concepts. So I thought it would allow me to emphasize particular feature both in code and usage without the need to explain what some of the OpenGL or Direct3D functions are used for.
   On more thing. Previously I've written that I don't know if I want to make my project open source. Probably I will but right now I'm still not ready to. BUT I always wanted my library to be used freely for learning purposes. More - I hope it will find its way to universities where students could more easily create 3D applications using Graphics Framework.
   That's all for now. See You (probably) after the weekend.

No comments:

Post a Comment