Skip to content
davido262 edited this page Nov 11, 2012 · 8 revisions

Description of the Renderer manager. Uses OpenGL Legacy and Core profiles.

This is responsible for rendering all the RenderableMesh components, which contain a Model each. Currently the only primitive available is a box, although models can be loaded from files.

The OpenGL renderer supports both Legacy and Core profiles. It will the best capabilities available for the OpenGL version supported by the graphics card. It will then try to find if the graphics card supports extensions that offer better capabilities than the ones offered by the official version.

It currently renders all of the RenderableMesh components in the scene, but it is intended to add frustum culling and occlusion culling by planes to limit the amount of rendering done by the graphics card. Also currently shaders are not supported yet.

For more information please refer to the Official OpenGL site.

Initialization

The first thing done is to print the capabilities of the current graphics card. It analyzes the version of OpenGL supported by the graphics card and based on that it assigns the preferred techniques for uploading models to the graphics card and mipmaps generation. It then queries for extension to find any better technique for the current OpenGL version. Finally it enables the required OpenGL states to avoid changing them during runtime. All the RenderableMeshs, Lights and Cameras are added by each Component when created. The OpenGL context is created by the Device.

Shutdown

It iterates over all the stored RenderableMeshs, Lights and Cameras and destroys them. The OpenGL context is destroyed by the Device.

Update

Each frame the scene is rendered through the draw function. The first thing done is to clear the color and depth bits. It then loads the identity matrix, multiplies it by the inverse of the camera's orientation and then by the inverse position. It then sets the lights of the scene. Finally it renders each RenderableMesh component individually. Note that it only needs the absolute position and orientation of each and it does not matter its hierarchy in the scene graph. This is because each time an Entity changes its position or orientation, both the absolute and relative position and orientation are updated.

The rendering process of each RenderableMesh is the following. It first pushes a matrix into the stack and multiply it by the corresponding matrix with the Entity's position and orientation. It then iterates through all the meshes and for each one it sets the material and binds the diffuse texture. It then draws the geometry by either using VBO's or VAO's. Once everything is drawn, it pops the matrix from the stack and continues with the rest of the RenderableMeshs

Rendering Techniques

These are the techniques that can be chosen by the initialization of the Renderer, the first places are the preferred techniques.

Data Upload

  1. Vertex Buffer Object - OpenGL 1.5
  2. Vertex Buffer Object EXT - Extension
  3. Vertex Array Object - OpenGL 1.1

Mipmap Generation

  1. GL_GENERATE_MIPMAP at glTexParameteri() - OpenGL 1.4
  2. GL_GENERATE_MIPMAP_SGIS at glTexParameteri() - Extension
  3. gluBuild2DMipmaps() - OpenGL 1.0
Clone this wiki locally