If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.
![]() |
|
|
|
|
#1 |
|
Member
Join Date: Feb 2002
Posts: 163
|
Guys, I'm switching over from VB/.Net to VC++ and wanted some general opinions on what most people prefer in terms of general approach for game programming in terms of class usage etc. I've never really enjoyed the OO approach for games as I think it can often limit a design and end up requiring more code. In short how are people splitting the use of classes and general generic functions etc? I appreciate this is a little vague but the whole argument for and against OO is huge but hopefully limiting to what styles people are using for games I'll be able to garner a safe direction. Of course I'll tailor this as I progress but I'm very reluctant to start creating millions of classes and methods etc as opposed to a few well chosen generic gaming functions?
Look forward to the comments? |
|
|
|
|
|
#2 |
|
Senior Member
Join Date: Nov 2002
Location: Edmonton, Alberta, Canada
Posts: 1,765
|
My own framework is almost totally object oriented. I find that it makes it easier to keep the engine versatile. I do have a bunch of stand-alone functions linked through their declarations in header files, but these are for -really- generic things such as text file reading and vector/matrix math.
|
|
|
|
|
|
#3 |
|
Junior Member
|
I'd say it's best to do whatever comes out the best
Good code design can be done using any of the programming techniques, be it OOP, procedural, generic or functional. Good design also comes with experience, so it's better not to try do uber-design when you really don't know what that is... It will all come with time (or won't come)... On ZillionsOfClasses vs. FewGoodFunctions - nothing forces you to do zillions of classes - few good classes are better than zillions |
|
|
|
|
|
#4 |
|
Member
Join Date: Feb 2002
Posts: 163
|
Thanks guys, thats sound advice. I kind of aimed this question in the wrong area really as I should have clearly illistrated as to where the classes would be used. i.e. game entities etc. Anyway, thanks for the responses. OOB is appears fine for the mechanics of the game although the dereferencing is a pain but as for he entities data models etc I think I'll stick with regular data arrays and lists etc.
|
|
|
|
|
|
#5 |
|
Join Date: May 2002
Location: New York, NY
Posts: 12,678
|
Well, if you want an example of how OOP is used in one game engine, you can take a look at the scripting in any of the Unreal-engined games.
__________________
April 20, 1979 - America must never forget. |
|
|
|
|
|
#6 |
|
Senior Member
Join Date: Jul 2002
Location: UK
Posts: 1,758
|
I'd give one definite recommendation: implicit new and delete are the bane of efficient games code. You can read most issues of Game Developer and find 'good memory management' or 'bad memory management' on one of the two sides of the postmortem.
|
|
|
|
|
|
#7 | |
|
Join Date: May 2002
Location: New York, NY
Posts: 12,678
|
Quote:
Do you mean not making proper destructors and constructors? Or using, for example: Vector v1; instead of: Vector* v1 = new Vector();
__________________
April 20, 1979 - America must never forget. |
|
|
|
|
|
|
#8 | ||
|
Senior Member
Join Date: Feb 2002
Posts: 2,636
|
Quote:
ps: of course you can add to the above the necessity to pay tibute to the hw caching mechanisms and stuff. |
||
|
|
|
|
|
#9 |
|
Join Date: May 2002
Location: New York, NY
Posts: 12,678
|
So, are you talking about storing data in byte arrays, using custom memory management techniques?
__________________
April 20, 1979 - America must never forget. |
|
|
|
|
|
#10 | |
|
Senior Member
Join Date: Feb 2002
Posts: 2,636
|
Quote:
maybe first to bring some basis in; data can be generally classified into two categories:
where those two categories are subjects to entirely-different allocation/instantiation tactics. whereas the latter category in the most abstract case can be considerd as exhibiting 'gaussian' distribution from the perspective of a memory allocation scheme, and is best left to the care of the general CRT allocation scheme (which as a rule is tailored exactly for that - to find space on the heap for arbitrary data, which can be carried out only so quick), the former category exhibits 'patternisation', thus is susceptible to 'statistically smart' allocation/instantiation schemes (at design time, that is). the criteria for a 'smart' allocation scheme when targeting performance are: minimal maintenance overhead (i.e. allocation and/or deallocation, depending on what are the needs) and access-friendly placement (i.e. cache- and/or busses-friendly -- here usually pops up the question of array-of-structures vs. structure-or-arrays, when arrays are used, that is) ..doh, i feel i'm drifting away in CS basics. ok, to conlcude with something more on the practical side of things, in OOP one must always think of instantiation as a two-fold process - allocation and initialisation -- both of those are subject to tailoring for each specific class and purpose at hand. |
|
|
|
|
|
|
#11 |
|
Member
Join Date: Feb 2002
Location: Vienna, Austria
Posts: 582
|
This probably won't apply to something as "low-level" as 3D programming (especially because the shown examples will mainly use non-uniform data, I guess), but renowned German computer magazine c't has started an interesting article series about performance comparison between C++ and managed languages (Java and C#) in their latest issue. While the first part only compared simple constructs and programs (and showed that Java and C# lose by a surprisingly low margin), they promised a surprise for the next issue when they will compare a more complex piece of software (using lots of dynamic allocation, complex object hierarchy etc. etc.).
Sorry if this is offtopic. |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| 3dfx Rampage ;) | Ante P | 3D Architectures & Chips | 219 | 26-Feb-2012 19:48 |
| Doom3 Object shadows | dizietsma | PC Games | 12 | 14-Aug-2004 19:04 |
| Illumination "sticking" to the object? | Mr. Blue | 3D Technology & Algorithms | 36 | 17-Oct-2003 18:23 |
| Predicting the Xbox-2 | qwerty2000 | Console Technology | 200 | 20-Jun-2003 00:37 |
| Next generation graphics engine | Reverend | 3D Architectures & Chips | 49 | 22-Feb-2002 21:35 |