Sign in to follow this  

writing an engine

This topic is 4781 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

I can't figure out where to start writing my engine.. I have tried some different places and so but I allways get stuck on something and want to re-write it once again.. I can't really find a good way to start writing the code.. first I want a simple abstract easy renderer interface that I can easy extend later.. I want to use the well-known "Material/shader implementation" but my own version of it (which means the materials will dynamilcy resolve shaders they need) to my problems: whenever I try to load a big file, for exampel parsing a big .ase file exported from 3ds, my engine gets stuck when it is loading.. I have tried to render a logo on a quad that says it is loading but that one never shows up until after the loading is done and then I the engine can proceed to display what it is suppose to do. I then tried to create a thread to load the files in... but how can I know when the loading-thread is done so the main-thread can begin render what it is suppose to do? and how can I handle things like a game menu?

Share this post


Link to post
Share on other sites
I cant help you with the errors that you are getting because I don’t know how your code looks like. What I hopefully can help you with is how to write a engine or any other larger program. The key is planning. You need to have a clear design from start to end. Once you have a clear design you should try it out and make shore that it fits in with the needs that you have.
I also suggest that you look into "Extreme Programming" (XP).

Share this post


Link to post
Share on other sites
Um, how is XP (or better named, Agile development) going to help this guy with his engine? Also, you contradict yourself:

Quote:

You need to have a clear design from start to end.


vs

Quote:

I also suggest that you look into "Extreme Programming" (XP).


Sorry, but XP actually recommends that you do NOT have a full design from start to end. Start with a small design: what objects do you want and how do you want them to interact, then go from there, designing as you code.

To help the poster, I too am in the same predicament. Writing a 3d rendering engine is a huge project. I've been doing lots of research, looking into how other people have designed their engines. Check out Ogre (www.ogre3d.org) and Irrlicht (http://irrlicht.sourceforge.net/) for starters. (side note: Ogre is incredibly complex, so learn what you can from it, but don't try to copy it, though Irrlicht I find a bit to verbose, I'm looking to create a happy medium).

Basically, focus your mind on one aspect of the engine, say the Scene Management, the Renderer, Camera issues, Application layer, and whatnot, and start there. The trick is to break the engine down and only think of those individual pieces. Whenever you think about the engine as a whole, you will quickly get bogged down in details, increasing the chance of never finishing the project.

Last, in an XP manner, design to create a simple working model. Once you've got that working, add to your design. Do not be afraid to refactor (changing code around), as no-one is or will ever be able to design completely and perfectly from start to end.

In short: start small, start simple, and work up from there.

Share this post


Link to post
Share on other sites
Your problem is that you are starting too large. Don't load in models yet. Don't implement a material system yet. You had it right when you said you wanted to write a basic renderer.

I started with a simple interface that would call OpenGL (just basic operations, like pushing and popping matrices). Then I started working on the scene manager. Start working on how your scene is going to be organized. Write a basic scenegraph that loops through some hierarchal objects and renders them. You could also write a basic I/O interface that prints to a console and handles the windows message loop. Create a basic working environment first and work with it. If you code it right, it's not hard to expand and implement certain features.

My engine handles all the VRAM management, and it has a good shader system implemented. This was all just an expansion of a basic (yet modular) rendering system. I haven't implemented any physics, model loading, etc. because those are last on the list.

Of course, Azo is right. Design is key. You have to think about what you want to implement and how so that your code supports it from the beginning (or at least leaves it open for easy implementation). I found it difficult to design an engine without ever writing one, though. If you find it difficult to design one from scratch, I would try coding one first to find out what problems you will face. Then step back and design a new one. It's all about starting simple though, which is very difficult because it takes a while before you start seeing good results.

Edit: James replied before I could :p fixed name too

[Edited by - okonomiyaki on November 15, 2004 4:08:12 PM]

Share this post


Link to post
Share on other sites
well that is the problem... I have a perfect plan in my head (who doesn't :p ) but I can't find a way to write it down, neither as source or just a plan using uml,pen and paper or anything else..

In my engine I come so far that I get an easy setup of the interfaces and the simple structures/classes I need to visually display a simple object like my spaceship I allways use when I rewrite my engine.. but then I allways get stuck on implementing new things as the so verry popular "Material/shader" stuff, altough I want my own more dynamic version.

so I have this:
RenderCore - main api functions
RenderSystem - renderqueue, sorting and enter/exit shaders (loads rendercore from a plugin)
World - keep a list of objects, lights and cameras
FileManager - the file loader

I can handle the simple things as set the material to color blue or mytexture.tga and lights... but when it gets more advanced everything falls apart, even though I plan/think alot before I do anything.

this is how I would like it to work for each object
Load process:
1) mesh is loaded
2) material is loaded
3) resolve shader, renderpass etc.

pre-render process:
1) RenderSystem request visible objects from the world
2) visible objects are pushed into a renderqueue


render proecss:
1a) RenderSystem will start to process the first RenderRequest
1b) set camera view, rendertarget
2) it will recive the first object in the first queue in this request
3) set material properties
3a) disable old shaders no longer needed
3b) enable new shaders needed
4) the mesh is drawn through a call to RenderCore->DrawBuffer()
5) get the next object in list and go back to step 3
6) get the next RenderRequest in list and go back to step 2


altough I don't really know about the Request things.. I have planned that they should determin what to render and where... each request is just a different camera view so a render to texture will be it's own RenderRequest with a target to a texture etc.

I have it working except for the RenderRequest part, the stuff in between is ok shader, changing etc.

EDIT:
I'm going to start again from scratch,

first of is the rendercore part ( so I get the visual stuff working )

then I'll probibly write the File/resource manager so I can load textures/larger scenes ( or should I make the texture loading a part of the RenderCore? )

Share this post


Link to post
Share on other sites

This topic is 4781 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this