c++ - Passing platform-specific data in a platform independent design? -


I have a game engine design written in C ++ where platform-independent game objects are a platform-specific application The object is within

The problem I am trying to solve is the case, where I have to pass from the application to the game from OS-specific data. In this case, I have to use the main HWNDA from Windows for DirectX or an OpenGL theme renderer for other platforms. Unfortunately, I have little control over the renderer, which can expect platform-specific data.

I realized that I can initialize the renderer in the application side, but I have to decide when and where to do it. Generally, I have control over the application side but not towards the game. The sports writer can choose to use a different renderer.

I also have the idea of ​​making some "property manager", where I can cross data through the stars, but I do not like the idea is too much.

Any thoughts?

Remember that you only need to know the timing compilation in the target platform with this information, You can do 'in-out' components for the platform.

In a good design, the game should no need any information about its platform; It should only hold logic and related components.

Your 'engine' orbits should worry about the forum.

Sports classes should be interfaced with engine objects only through public functions, not specific for the forum; You can get several versions of engine objects for each platform, and you can choose what time to use to compile.

For example, you might have a textured 'engine' class that represents the texture in the game. If you support OS X and Windows, then you may have a "texture H" that includes "Windows / Texture HK" or "OSX / Texture H", which you are compiling on. Both headers will define a texture class with the same interface (i.e. they both will do the same public work with the same logic), but their implementation will be platform-specific.

To clarify, the game should tell the application to start the renderer; There should be a strict line between the game logic and the implementation details. Renderer is an implementation description, not part of game logic. Game classes should not know anything about the system and only about the world of sports.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -