Jump to content
  • Advertisement
Sign in to follow this  
mengha

Creating a platform independent Window Class?

This topic is 4576 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
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

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!