Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (120)
games submitted by our members
Games in WIP (577)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  C++ game engine programming advice needed  (Read 1375 times)
0 Members and 1 Guest are viewing this topic.
Offline zingbat

Senior Duke




Java games rock!


« Posted 2005-02-02 23:51:36 »

What are you puting this on a java forum ? You may ask.

The answer is if i don't do it in C++ then something i have great pride for will be severely cut from me.

But why are you betraying java ? You may ask again rightfuly.

The answer is that im trying to do an engine in C++ the way im used to program in Java. The problem is that in all the C++ forums i post people are completely cluless of what i intend to do because im thinking in Java.

First limitation i cant use classes dynamicaly in an easy way.

Second limitation i want to do an event dispatcher similar to the one in Java3d but i can't use threads.


Heres a trace of the execution of the engine im planing:


open log file for errors
read config file
....look for os specific info
....look for os layer class to use NOTE: this can be SDL, Allegro, OpenGL, etc
load os layer class at runtime
bind os layer class to os layer independent interface NOTE: use os layer independent interface for now on for everything
initialize game screen
initialize game console
initialize game devices
read config file for extensions to load
load extensions in order they apear in config file
....load modules NOTE: modules are function libaries that obey a certain interface and access only other modules or game functions, so they are os safe
....load resources
....register module ids and module startup status (active|inactive)
....bind module classes to module class interfaces
....register resource ids and memory usage policy (permanent|load-on-demand|volatile)
start event loop
....poll devices
....enqueue events
....preprocess event queue
....if exit event leave
....dispatch events to modules
....repeat
finalize and exit

I must load the os layer code at runtime after reading the config file, possibly checking for the name of a class then load it and initialize it then cast it up to a universal os layer interface and use it that way.

Don't have a clue how to do this in C++.

The modules must be loaded at runtime after the engine check for a list of modules to load. Each module implements (inherits in C++) the universal module interface and must be casted to one of these after being loaded.

Im clueless here too.

Finaly i must implement an event loop similar to the one described in the trace but without using threads.

As you guys can see im in deep shit here.

I may try to convert this stuff yo Java later for my great releave but now i need help doing it in C++.

Any ideas ?
Offline nonnus29

Senior Duke




Giving Java a second chance after ludumdare fiasco


« Reply #1 - Posted 2005-02-03 01:00:16 »

You might try looking at some of the open source game engines out there.  I know the irrlicht engine supports 3 different renderers; dx8, dx9 and opengl plus its cross platform (linux mac and windows).  To my knowledge it does not use a plugin architecture though....

Good luck!
Offline Raghar

Junior Duke




Ue ni taete 'ru hitomi ni kono mi wa dou utsuru


« Reply #2 - Posted 2005-02-04 18:02:38 »

Quote
What are you puting this on a java forum ? You may ask.

The answer is if i don't do it in C++ then something i have great pride for will be severely cut from me.

But why are you betraying java ? You may ask again rightfuly.

The answer is that im trying to do an engine in C++ the way im used to program in Java. The problem is that in all the C++ forums i post people are completely cluless of what i intend to do because im thinking in Java.

First limitation i cant use classes dynamicaly in an easy way.

Second limitation i want to do an event dispatcher similar to the one in Java3d but i can't use threads.


Heres a trace of the execution of the engine im planing:


open log file for errors
read config file

That's easy even C++ has defined file operations in the standard library.
Quote

....look for os specific info
....look for os layer class to use NOTE: this can be SDL, Allegro, OpenGL, etc
load os layer class at runtime
bind os layer class to os layer independent interface NOTE: use os layer independent interface for now on for everything

This could be pretty difficult if you'd like to support all OSs and all libraries.
BTW how would you like to discover on what OS are you?
Quote

initialize game screen
initialize game console
initialize game devices

prepare yourself for errors. Errors called untestable interactions between input library and input devices, on various OSs.
Quote

read config file for extensions to load
load extensions in order they apear in config file
....load modules NOTE: modules are function libaries that obey a certain interface and access only other modules or game functions, so they are os safe

Java programmers start here.

Quote

....load resources
....register module ids and module startup status (active|inactive)
....bind module classes to module class interfaces
....register resource ids and memory usage policy (permanent|load-on-demand|volatile)

And don't forget to protect yourself against all weird memory errors. Could be nice to count allocation and releasing of memory, so you'd at least have some idea about memory leaks.
Quote

start event loop
....poll devices
....enqueue events
....preprocess event queue
....if exit event leave
....dispatch events to modules
....repeat

This is rather straightforward in C++. Simillar to Java.
Quote


finalize and exit

I must load the os layer code at runtime after reading the config file, possibly checking for the name of a class then load it and initialize it then cast it up to a universal os layer interface and use it that way.

Correction. You must start launcher and then choose the right file, or DLL, or something.
Quote

Don't have a clue how to do this in C++.

The modules must be loaded at runtime after the engine check for a list of modules to load. Each module implements (inherits in C++) the universal module interface and must be casted to one of these after being loaded.

Im clueless here too.

It looks like you are.
first you'd save the modules with extension .PDB. You'd write at start of each compiled module pointer to inside for entry point of the module. It would be 8 bytes (one 64 bit pointer).

Then in the loader you'd create table of pointers.

PROTO Pointers{
some_UGLY_module1 DWORD
some_OTHERUGLY_module2 DWORD
}
Then you'd look for a file inside of what would be description of module names and file names, and of course what CPU is supported for module. It might be nice idea to have IA32 and MAC modules in different directories.
You'd look at hash of the file and if it will be correct you'd load module into an array. If it would be incorect you'd post a message: "Module isn't loaded. Module is either corrupt, or some band of retards added hastilly new module into a directory and didn't updated neccessary informations. Try running setup, and choose repair modules."

If it was correct, you'd write into that above table entry point of the module. You know it's in the array, in simillar way as it was in the file, so pointer to array+last 4 bytes of the pointer from PDB file (written as low endian) should be entry point to the module in the memory. Right? (its custom to write that entry point as differece from start of the module not from the start of the file. Ie from start of the file it would be 8, in reality it should be 0.)

BTW PDB is abreviation for portable debilism. If you'd be implementing ones you'd know why.

Of course you could have it somewhat easier, if modules would be just a DLL files with predeffined entry point. This means entry point would be entry and outry point would be outry.
Or something like that. ^_^
That table would stay, you'd just use standard DLL loading mechanisms. If your application would crash you should do every effort to unload that DLLs. I don't recall if on current XP is guaranted it will unload all libraries if application would crash, It could run on some OSs that might be less paranoid.
PDB is easier. If your application would crash it will take PDB with itself.

Look at JNI interface, it could give you some ideas.

Quote

Finaly i must implement an event loop similar to the one described in the trace but without using threads.

Not even by multiplatform thread libraries? BOOST for example is cited as a one of more standard ones.
Quote

As you guys can see im in deep shit here.

I may try to convert this stuff yo Java later for my great releave but now i need help doing it in C++.

Any ideas ?

You would do all of that just by yourself? It's work for at least half year, or so. (more likely 1.5 years, then again we don't need to count all that debug and all bug repairs for various OSs to development... )

What they would like to do with this?

It might be faster to write it in Java then port it to C++.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline zingbat

Senior Duke




Java games rock!


« Reply #3 - Posted 2005-02-05 09:44:59 »

Thanks for the help. I think i will stick to dlls and create a System C++ class with a platform independent loadLibrary(string) method.

At the moment I know how to load dynamic linking libraries in almost all patfs. The only thing i need to find out is out to wrap it in C++ interface. Something that java does easly but it looks like a nigthmare in C++.
Offline Raghar

Junior Duke




Ue ni taete 'ru hitomi ni kono mi wa dou utsuru


« Reply #4 - Posted 2005-02-11 18:46:20 »

PROTO Pointers{
some_UGLY_module1 DWORD
some_OTHERUGLY_module2 DWORD
}

This is a nice pointer table.
The rest of that is easy.
Offline zingbat

Senior Duke




Java games rock!


« Reply #5 - Posted 2005-02-12 10:23:49 »

I have already found a solution, thanks. The trick is we can only export C functions in a dll but the compiler can do some tricks and put a C++ class in it as long as we create an accessory C function to construct an instance and return a pointer to an interface of that instance.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Longarmx (52 views)
2014-10-17 03:59:02

Norakomi (43 views)
2014-10-16 15:22:06

Norakomi (33 views)
2014-10-16 15:20:20

lcass (37 views)
2014-10-15 16:18:58

TehJavaDev (68 views)
2014-10-14 00:39:48

TehJavaDev (66 views)
2014-10-14 00:35:47

TehJavaDev (59 views)
2014-10-14 00:32:37

BurntPizza (73 views)
2014-10-11 23:24:42

BurntPizza (45 views)
2014-10-11 23:10:45

BurntPizza (86 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!