-
Notifications
You must be signed in to change notification settings - Fork 0
Renderer
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.
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 RenderableMesh
s, Light
s and Camera
s are added by each Component
when created. The OpenGL context is created by the Device
.
It iterates over all the stored RenderableMesh
s, Light
s and Camera
s and destroys them. The OpenGL context is destroyed by the Device
.
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 RenderableMesh
s
These are the techniques that can be chosen by the initialization of the Renderer
, the first places are the preferred techniques.
- Vertex Buffer Object - OpenGL 1.5
- Vertex Buffer Object EXT - Extension
- Vertex Array Object - OpenGL 1.1
- GL_GENERATE_MIPMAP at glTexParameteri() - OpenGL 1.4
- GL_GENERATE_MIPMAP_SGIS at glTexParameteri() - Extension
- gluBuild2DMipmaps() - OpenGL 1.0