• Inan Evin

#6 Lina Engine: Rendering Engine Part2 - Initialization

Hey there, in the last post we talked about the Window Class for the Rendering Engine to use. In this post, I will be talking about what can the Rendering Engine do so far, and it's initialization.

The rendering system is initialized by our core object, and there would be only one rendering instance that will handle everything we need. For now, we plan to have it's dependency only with the core system, such that the core system will be calling necessary methods and the Rendering system will not even have any up-link connection with the core. Maybe in the future, we would need some messages being delivered from the rendering system, along with "to" it, however we can implement an event interface for those messages and avoid messing up our dependencies.

So far, what rendering system does is, to initialize a window, and set some properties with the OpenGL. Other than that, it clears the buffers and is responsible for calling the Update method on the active window that it had initialized before.

In the snippet above, you can see the initialization process of the rendering system. Discard the event-handler parts for now, since we will be talking about it in the upcoming posts. As you can see, it initializes the main window, and sets some settings for the OpenGL rendering. For now, these settings are about culling and gamma correction. As the OpenGL draws, there it draws vertices and holds a position information about them. So it basically knows the 3D geometry that it's drawing. Culling is basically the process of hiding geometry faces and not rendering them, if they would not be visible already. When we are drawing a cube, depending on our projection, we will not be seeing all the faces of it at the same frame, if there is no transparency involved. So there is no need to pass into the Rasterization and Fragmentation operations on the GPU while still including those faces to be calculated. So we remove the triangles from those faces before running the operations, making sure that we would save up some performance.

Another thing we set is the Depth Test, which enables the functionality to draw various different vertices with a particular order, dependent on the projection and how far those vertices are away from the projected point, so that the closer objects would be processed first.

In the end, that's all our rendering engine does for now. It clears a color, meaning that it renders a particular color for the window, like this:


Then it initializes a window and enables some attributes for the OpenGL. After that, every frame, it clears the color & depth buffers for a new fresh frame drawing. Basically that's it about the rendering engine for now. The coolest stuff about rendering will be done on Meshes and Shaders, as we will come to them later! See you next time.

15 views0 comments