Sign in to follow this  

Creating a platform independent Window Class?

This topic is 4356 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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 :)

Share this post


Link to post
Share on other sites
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();

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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();


Share this post


Link to post
Share on other sites

This topic is 4356 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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