Sign in to follow this  
klayAlloy

Window / App Classes

Recommended Posts

klayAlloy    150
I'm building a Window class and then a GameApp class. Is it better to write a GameApp class that has a Window member or to combine both Window functionality and Application functionality into one class?

Share this post


Link to post
Share on other sites
Dave Hunt    4872
This is a question of "an application has a window" vs "an application is a window". I would say use the window-as-member option. However, it probably makes little difference to the user of the class - either way, the user will call methods that interact with the window. The implementation doesn't matter. In the end, do whatever makes the most sense to you.

Share this post


Link to post
Share on other sites
dmatter    4844
Im currently redesigning the base of my engine which was previously built on an application class that included windowing functionality so it followed the 'an application is a window' mentality.

My thoughts at the moment are that an application is not a window, in-fact an application could have several windows, each separately renderable to (this i believe is a more correct/accurate approach).

I have also thought about how this might fit with my GraphicsDevice class (the wrapper to the underlying graphics API), I have decided that the graphics module need not know about the concept of 'a window' at all since this is a highly OS specific concept (this is a different approach taken by other engines, just take a look at the Ogre RenderSystem class to see that windowing functionality is built right into their graphics system).

I believe this is more portable, I mean XBOX and PlayStation dont offer windowing capabilities anyway plus OpenGL has no concept of a window and D3D has minimal support for them really - you still have to use the windows API to create a window for DX to use.

However for things to function there still must be interaction between the graphics API and the operating systems 'canvas' concept (a canvas is my generic term for the final rendered surface.. be it a window, or the entire display) so i thought that I would have a Win32Window class which supports the basic functionality to create a Win32 window (the class is completely separate from the graphics module at this point) and then from this derive API specific window classes,
For example: WGLWindow (for OpenGL - this is where 'wiggle' calls are made) and also a D3D9Window.
These window classes will also need to inherit from a RenderSurface class so that the graphics module can use this interface to interact with the window through polymorphism, without actually knowing its a window.

It would be up to the application (which will probably be a factory for creating windows etc) as to which type of window is created, it would also be responsible for managing the different windows (dispatching messages etc)

Im still working out kinks in this system but my initial outlay looks like its a clean way to separate out the different APIs (both the gfx and OS APIs) and still allow them to interact and at the same time provide the flexibility to allow multiple windows per application rather than the application being just a single window (or worse an application that is always a fullscreen app)

I seem to have gone off-topic slightly [grin] into the realm of API independance but I'm sure theres relevant info too [smile]. At least someone might get some ideas.

Happy coding

Share this post


Link to post
Share on other sites
Aiursrage2k    320
I have an app class, a gameApp class (public: app), and a wrapper windows class which is owned by the app class.

The window class can be reused for all my window applications. The application class is the base class for all applications. I can derive the editorApp, gameApp, particleApp, etc from the same app class.

Share this post


Link to post
Share on other sites

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