Archived

This topic is now archived and is closed to further replies.

Oculus_Malus

OO / Class Game engine or not ...

Recommended Posts

Oculus_Malus    123
I, I''m currently working on a game engine (started out as a 3D DOS software renderer long ago..) and i''m wondering if it is worthly to put everything as classes and make it object oriented (renderer class and mesh subclass and stuff). In fact I don''t think that multiple instance of an engine has to be created in a program or game ... Also, there must be a performance impact if all those header and abstract stuff is used Otherwise I could just dump all the stuff in a unit (library) and it should be faster. Thnx --- At The Edge Of Time

Share this post


Link to post
Share on other sites
dcosborn    674
Sounds to me like you already know what you should do.

Edit: To add substance, the performance impact of a properly designed OO system is negligible. If you're still worried it, go ahead and implement a procedural interface if you find that more comfortable. Object-oriented and procedural approaches each have their own benefits and shortcomings - only experience will enable you to choose the best one. Since the choice is yours to make, choose whichever makes you happy for now.

[edited by - dcosborn on May 26, 2004 3:16:39 AM]

Share this post


Link to post
Share on other sites
quorn    145
You''re making a number of strange comments which don''t make sense or aren''t explained.

quote:
i''m wondering if it is worthly to put everything as classes and make it object oriented

Why do you want to change from what you are doing already? What is disatisying? Is it to do with speed?

quote:
I don''t think that multiple instance of an engine has to be created in a program or game

Not really sure what you mean or why this is part of your overall question.

quote:
there must be a performance impact if all those header and abstract stuff is used

Do you mean how long it takes to compile a program with more headers? Or how fast the program will actually run. The headers won''t make any difference to the compiled program. Abstractions of ideas in code aren''t just an object-oriented thing. A function is an abstraction.

quote:
I could just dump all the stuff in a unit (library) and it should be faster.

Putting things into libraries doesn''t (on the whole) affect anything.

Can you be more specific and make less assumptions?

Share this post


Link to post
Share on other sites
Oculus_Malus    123
Humm sorry about this post written under the influence of alcool and stress

The actual engine (renderer) is a class, and the mesh, heightmap, bsp map, weapon system, are other classes which need an engine to work properly (seeking state var in it, sending stuff to the renderer)

The good thing is that they all contain their own var and functions. They are easier to manipulate too.

Now here''s the question

-Since the engine is only created once, is it better to just make it procedural in a library (so it can be re-used later) in terms of in-game performances?

and, the other question that have been answered, is a procedural engine faster (in-game) than an OO one.

Share this post


Link to post
Share on other sites
quorn    145
quote:
Original post by Oculus_Malus
and, the other question that have been answered, is a procedural engine faster (in-game) than an OO one.


Depends who''s written it.

You can write fast code in C and C++. You can write slow code in C and C++.

The ''overhead'' of virtual functions has to be weighed up with the abilities it gives you. You can do things with your design that
if you wanted to approximate something similar in C you''d have to make tables of function pointers yourself anyway.

C++ is made for efficiency. It is one of the most important criteria for its design.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster

Quorn :
"
The ''overhead'' of virtual functions has to be weighed up with the abilities it gives you. You can do things with your design that
if you wanted to approximate something similar in C you''d have to make tables of function pointers yourself anyway.
"

Please note that virtual functions need two indirections, and if in C you store function pointers in your object, you only have one ( but the object is bigger, and more flexible, you can change one pointer at one time ).
If you ever had programming on PS2, it''s important to know that. PS2 hardware is that bad that two indirections can be too much for the cache...

Share this post


Link to post
Share on other sites