Jump to content
  • Advertisement
Sign in to follow this  
AspiringDev

OpenGL Roadmap for simple graphics engine

This topic is 618 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

     Hello I'm an undergrad student interested in Computer Graphics. So far I had some experience using SDL creating simple game clones(pong,breakout,tic tac toe). Recently I have been getting into OpenGL using learnopengl in combination with glitter the simple boilerplate code.

     My main goal right now is to use the above resources so I can create a simple graphics engine that will feature a single scene that will go along the lines of containing a terain(island),a player that you can move arround the world(with first person camera) some vegetation models to decorate it,a sun that will light up the scene so items will have shadows too and some other possible models of a house or a fire that maybe will feature some interactivity with the player. At first I want it to be as simple/barebones as possible and then I can work making it pretty and more optimized.

     The thing is I feel kinda lost cause despite the above tutorials and resources being very helpful I can't seem to really understand the basic architecture of my code that will lead me to my goal. So in search for a simple answer I found this article on game states though because of my inexperience I can't know for sure if I'm on the right direction as to what the base of my code should be.

 

   So I'm basically looking for a basic roadmap to follow so I can reach the final goal I described above. I hope I'm not delusional thinking I can create the scene I have in mind with opengl and the tools featured in glitter(bullet,assimp etc).

 

I really hope some of the experienced programmers here will help me clear my thoughts ! Thanks in advance !

Edited by Random2323

Share this post


Link to post
Share on other sites
Advertisement

If you are familiar with SDL I'd advise you to look at SFML.

The basic design concepts of SFML may lead you to a better understanding of how an engine should be written.

There is a lot to know.

Start with reading existing engine's source codes. Like Cryengine, sfml(library), unreal, etc...

There are plenty of open source projects.

Edited by WoopsASword

Share this post


Link to post
Share on other sites

Since it's your first time in 3D and you feel lost (which is normal), then I would suggest you to do things a bit like below (I know some people here might not like this, but to my opinion, this is a good start point):

 

1) have a model class that can draw a full model (your island, each of your trees and so on). You need vertex, normal, texcoord arrays and materials.

2) have a camera class which will act like gluLookAt

3) have a light class which will lit the scene (here directional light)

4) have an engine class that will contain a list of models and a camera and will make all this run altogether

 

You'll also need things to manage the keyboard and mouse which will modify the instance of your camera class.

Then you could add a particle system for your fire

Then you could move to shadowing

Share this post


Link to post
Share on other sites

First I would entrust the Book Game Engine Architecture, Second Edition to you so you could take a look of what a game engine does and what you need for a graphics engine as there are some equalities where each game engine is including a graphics engine too.

 

 

Graphics Engine

 

First you should setup your general rendering pipeline before going anywhere else. First there will be one single step for rendering when you are not using any stencil buffer or alpha blends at the moment, later for example wehn rendering your own UI, you will need different rendering steps for UI because depending on the UI system you will need the stencil buffer too so might have that in mind when designing your first pattern.

 

Secondly you should write a camera class that wraps arround a mat4 type for your view matrix. Anything general transform these days is done by the view matrix in order with the global projection matrix you choose (e.g. for 3D perspective rendering) so you should become familiar with vector math. It is very helpful to check if anything gets rendered correctly by using a camera to move arround.

 

If you have the base of this done I would go for creating a simple Mesh class that will do the basic rendering of one single mesh. This should consist of a mat4 type too for the meshes individual transform in the world and anything you need to render the mesh like VBO, VAO and maybe a Material and a Texture class that refers to a shader and this materials settings for that shader like the texture you use, colors, alpha blend if necessary. This may take a bit more work for getting shaders into OpenGL, loading textures and bring anything together.

 

To get more advanced you might build up your Scene structure by creating a scene graph. In modern game engines you have this scene graph that contains nodes to scene objects that are rendered in the scene and these may contain sub-nodes for child objects that are attached on them like a sword is attached to a warrior model. Scene graph then iterates through the nodes, skipps the nodes out of sight and so for any child node attached to it and otherwise renders that node to screen and any child node attached to it by also keeping root nodes transform to child ndoes (The warrior model is located at point 0,-<its feet to the ground>,0 but the sword itself is also transformed from the warrior models origin to fit into its right or left hand)

 

Particle systems are also some kind of Mesh class but they manage not a single mesh depending on the particle system a point cloud or textured quads with some kind of alpha blending. They also apply transforms to the points depending on mathematical expressions of what the particle system spreads these objects over the space. This may be a curve, a line or even a spherical movement over certain lifetime.

 

At last to get your graphics engine on you need to get into FBOs for the post processing pipeline. Anything else you need for a pure graphics engine is done via shader, lightning, shadows and other effects are applied to the scene in post processing. There are some technics out in the internet worth to take a look into.

 

 

Extending to Game Engine

 

You wrote that you want to have a character walking over a terrain in first person mode so to extend your graphics engine to a game engine there are some more steps to do. First you should inherit a first person camera from you already existing camera because its movement is a bit different from a third person camera. Make your camera a scene object in the graph and attach your character as child or vice versa so moving one moves the other too and your camera should then recognize its parent transform to work.

 

Movement/control input is some kind of system where you might consider first of how you will handle interactions in your game code. Some engines use events to share interactions over the game code, others use a fixed update loop and poll for example any inputs done since last update. Keep in mind to use some kind of delta timing regardless of what interaction system you use, this is important to prevent jumps between frames and updates.

 

 

-----------------------------------

 

I have build up more than once such systems in the past and currently still doing this as part of my job in games industry, using complete systems and also making my own one from scratch using just OS APIs and nothing else, so there are plenty of other things to know and take into account like asset loading/management and hdd optimazations of data packages, multi-thrading, networking up to encryption so since this is a beginner question, anything is written as basic as possible where game engine architecture is a whole engeneering business and needs a lot of research for more general and complex systems.

 

Keep always learning and you will go easily

Share this post


Link to post
Share on other sites

First I would entrust the Book Game Engine Architecture, Second Edition to you so you could take a look of what a game engine does and what you need for a graphics engine as there are some equalities where each game engine is including a graphics engine too.

 

 

Graphics Engine

 

First you should setup your general rendering pipeline before going anywhere else. First there will be one single step for rendering when you are not using any stencil buffer or alpha blends at the moment, later for example wehn rendering your own UI, you will need different rendering steps for UI because depending on the UI system you will need the stencil buffer too so might have that in mind when designing your first pattern.

 

Secondly you should write a camera class that wraps arround a mat4 type for your view matrix. Anything general transform these days is done by the view matrix in order with the global projection matrix you choose (e.g. for 3D perspective rendering) so you should become familiar with vector math. It is very helpful to check if anything gets rendered correctly by using a camera to move arround.

 

If you have the base of this done I would go for creating a simple Mesh class that will do the basic rendering of one single mesh. This should consist of a mat4 type too for the meshes individual transform in the world and anything you need to render the mesh like VBO, VAO and maybe a Material and a Texture class that refers to a shader and this materials settings for that shader like the texture you use, colors, alpha blend if necessary. This may take a bit more work for getting shaders into OpenGL, loading textures and bring anything together.

 

To get more advanced you might build up your Scene structure by creating a scene graph. In modern game engines you have this scene graph that contains nodes to scene objects that are rendered in the scene and these may contain sub-nodes for child objects that are attached on them like a sword is attached to a warrior model. Scene graph then iterates through the nodes, skipps the nodes out of sight and so for any child node attached to it and otherwise renders that node to screen and any child node attached to it by also keeping root nodes transform to child ndoes (The warrior model is located at point 0,-<its feet to the ground>,0 but the sword itself is also transformed from the warrior models origin to fit into its right or left hand)

 

Particle systems are also some kind of Mesh class but they manage not a single mesh depending on the particle system a point cloud or textured quads with some kind of alpha blending. They also apply transforms to the points depending on mathematical expressions of what the particle system spreads these objects over the space. This may be a curve, a line or even a spherical movement over certain lifetime.

 

At last to get your graphics engine on you need to get into FBOs for the post processing pipeline. Anything else you need for a pure graphics engine is done via shader, lightning, shadows and other effects are applied to the scene in post processing. There are some technics out in the internet worth to take a look into.

 

 

Extending to Game Engine

 

You wrote that you want to have a character walking over a terrain in first person mode so to extend your graphics engine to a game engine there are some more steps to do. First you should inherit a first person camera from you already existing camera because its movement is a bit different from a third person camera. Make your camera a scene object in the graph and attach your character as child or vice versa so moving one moves the other too and your camera should then recognize its parent transform to work.

 

Movement/control input is some kind of system where you might consider first of how you will handle interactions in your game code. Some engines use events to share interactions over the game code, others use a fixed update loop and poll for example any inputs done since last update. Keep in mind to use some kind of delta timing regardless of what interaction system you use, this is important to prevent jumps between frames and updates.

 

 

-----------------------------------

 

I have build up more than once such systems in the past and currently still doing this as part of my job in games industry, using complete systems and also making my own one from scratch using just OS APIs and nothing else, so there are plenty of other things to know and take into account like asset loading/management and hdd optimazations of data packages, multi-thrading, networking up to encryption so since this is a beginner question, anything is written as basic as possible where game engine architecture is a whole engeneering business and needs a lot of research for more general and complex systems.

 

Keep always learning and you will go easily

 

 

Thank you so much for this I really need to read Game Engine Architecture and you really helped me get in the right direction. In the following days I have some work to do. Your help and words are invaluable.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!