Last update: 2 September 2015

The Framework

This section discuss the framework that is used by all the tutorials. The framework can be found in the engine directory of the zip file. All the framework classes are located in the 'vvision' namespace. The framework Manage all the OpenGL Api Calls via a C++ wrapper classes and can load static/animated meshes into OpenGL arrays. The framewok can be seen as a light and compact graphcis engine that can be easily integrated into your project or application.

The framewok is distributed under the LGPL license.

 The framework contains the following modules:

  • Renderer: manage all OpenGLES API calls and contains the following classes( Shaders, 2D textures, cube maps, vertex buffer objcets, vertex array objects, frame buffer objects, render buffers and off-screen render target) .
      • CShader for loading/comping and enabling/disabling shader.
      • CTexture for loading 2D textures.
      • CTextureCubeMap for loading cube map textures
      • CFrameBufferObject (Fbo) allow to render directly to texture or render buffers. this can be useful if you want to process the output image ( for reflections, shadow mapping and post processing effects)
      • CRenderBuffer used as render target for the Fbo.
      • COffscreenRenderTarget to ease the off screen rendering process and hide its complexity.
      • CGpuVertex this a 'GPU' vertex, a GPU vertex is defined by it s postion in the 3D space, its normal vector, texture coordinate, tanget vector and influenced bones and their corresponding weight ( used for skinning).
      • CVertexBuffer for OpengGL array buffer, this is an array of vertices stored on the GPU device memory (VBO).
      • CMeshBuffer is a container of CMeshGroups and CMaterials. A mesh loaded from disk is composed of a certain number of groups that can share materials. each group holds a pointer to an OpenGL array buffer ( CVertexBuffer). 
      • CMeshGroup holds an an OpenGL array buffer. please note all  VBOs are stored in vertex array objects ( VAO) that encapsulate all state needed to specify the vertex data.
      • CMaterial, a material struct that holds the ambient, diffuse specular materials and different texture types ( diffuse, normal, detail and cubemap). The  material properties are fetched at render time to send the  necessary parameters to the shader.
  • EAGLView.h/m: this is an UIView fully compatible with OpenGL drawing commands, used to render the content of OpenGL, it can support retina display and anti aliasing for best image quality. Check the flags in the EAGLView.h to enable/disable retina display or anti aliasing. The following flags can be activated/desactivated within the EAGLView.h.
        • #define VVISION_ENABLE_SCREEN_RETINA this enable/disable retina screen, keep in mind that if retina display is detected and the scale factor is set to 2.0 the number of rasterized pixels that your pixel shader will have to process is multiplied by 4 this could be very costly.
        • #define VVISION_RETINA_SCALE_FACTOR this will define the scaling factor for retina screens only, this value is between 1.0  ( no retina) and 2.0 ( full screen retina ). try different value and see the impact on the quality/performance of the application
        • #define VVISION_ENABLE_DISCARD_FRAME_BUFFER this will enable discard buffer, this tells the OpenGL driver that we dont need the buffer anymore, its recommended by Apple to use it.
        • #define VVISION_ENABLE_MSAA this flag enable/disable the multi sampling for anti aliasing. if set a multi sample buffer is created that holds the number of samples to store for each pixel.  OpenGL resolves the multi sampled buffer to the final resolve buffer where the the final image is rendered. So in the final you have two frame buffer objects ( multi sampled and resolve buffer), your rendering calls are sent to the multi sampled buffer then its resolved to the resolve buffer, this technique smooth edges and improve image quality but require more memory allocation and mpre fragment processing.
  • MeshLoader: Load mesh from disk and store it in openGL Vertex Arrays. it contains the following classes:
        • IMesh an abstact class that all meshes should implement.
        • CAssimpMesh is an implementation of IMesh, its here where all Assimp stuff is done. The function 'LoadMesh' in the class 'CAssimpMesh' loads the assimp mesh from the disk and store it in an OpenGL compatible format. Each assimp scene is composed of multiple meshes. For each mesh we call the function 'ExtractMeshGroup' that creates a CMeshGroup object that holds all vertices position, normals, texture coordinate, tangent and affected bone weights and indices ( for skeleton animation) in a vertex buffer objects. Next we call 'ExtractMaterials' function to extract all materials used by the groups. A 'CMaterial' is defined by ambient, diffuse, specular, shininess and diffuse texture (there is a lot of materials properties that assimp can load.
        • AssimpSceneAnimator used to control animated model. this is taken from the assimp viewer that was orginially written for directtX. There is a big lake of documetation on how Assimp update bones transformations for a given delta time. This animator class is used for character animation and it takes a timestamp as parameter and updates all bones transtormations for the given delta time. For example, for a given bone the transformation matrix is defined for a discrete timestamp t0...ti, if we wantthe current transformation matrix for a given bone at a timestamp between ti and tj we need to interpolate the transformation between the two instant ti and tj. this is the job of the AssimpSceneAnimator class. Once the bones transformations are calculated and interpolated for the given time wen can send these transfromations to a vertex shader to perfom the skemeton animation.
  • ResourceManager: A singleton object that loads and cache disk resources ( meshes, 2D textures, cube map textures and shaders). When a disk reources is loaded using the CCacheResourceManager class, it will be directly cached, so the next call you try to load it there is no disk access, instead it will be directly loaded from memory.
    For exmaple the following line of code loads and cache the shader called shader.frag and shader.vert.: CCacheResourceManager::Instance().LoadShader("shader"); You can at any moment remove a resource from the cache by calling 'DeleteResource' and give the function the type of the resource to delete and the resource name.
  • Utils: useful  class/routines ( file path, string helpers and png/jpg loader specific for iOS).
  • Math: vectors, matrices and quaternion math lib.