Creating a platform independent Window Class?

Started by
4 comments, last by rip-off 18 years, 3 months ago
I want to implement a class to handle the creation and management of Win32 windows (for now) that will also provide what I need for OpenGL (The hWnd for instance). I was planning on having a function such as CreateNewWindow() and others for returning the various handles and propreties but I'm unsure where to start. I also want to make it extendable so that once I know more Mac/Linux specific c++ I can update the class for those as well. Would it be possible to create it so that the class uses #ifdef to find the platform and runs code accordingly? Or would I need a sperate class for each? (because the mac code return return a hWnd for instance?) Could anyone point me a the right direction for now? Thanks :)
Advertisement
wxWidgets is an open source cross-platform GUI library. I don't know if wxWidgets is good for high-performance apps (Games, etc ) but if you just need GUI stuff it should suffice.

hth,
Joe
moe.ron
Thanks for the reply but I don't mean that.

I want to create my own class that wraps up all of the window work that needs to be done.

So I can do something like:

CWindow myWindow;

myWindow.CreateWindow(800, 600);

hWnd = myWindow.gethWnd();
Quote:Original post by mengha
Thanks for the reply but I don't mean that.

I want to create my own class that wraps up all of the window work that needs to be done.

So I can do something like:

CWindow myWindow;

myWindow.CreateWindow(800, 600);

hWnd = myWindow.gethWnd();


If you want this to be truely cross-platform, then you're going to have to forget about creating getters and setters for things like HWND. HWND is strictly a Windows idea. I suggest you start by designing your interface, being very careful to abstract away from any platform dependent features. That also means that you're going to have to learn to create and manage windows in several environments before you are to get started, so that you have a concept of what ideas you're going to need to create abstractions for.
SDL already does this very well.
Quote:Original post by mengha
Thanks for the reply but I don't mean that.

I want to create my own class that wraps up all of the window work that needs to be done.

So I can do something like:

CWindow myWindow;

myWindow.CreateWindow(800, 600);

hWnd = myWindow.gethWnd();


what about:

window myWindow;window.createWindow(800,600);window.createOpenGLContext();

This topic is closed to new replies.

Advertisement