Skip to main content
GameDev.net gamedev.net
🔒 Locked

Window Handling System

Started by Butterman Jun 28, 2007 at 12:05 PM 3 replies 750+ views
Original Post
Butterman
Butterman
Im writing a window handling system for my current project. Right now im deriving any new types of windows i create from a window class. The base class contains all the information to work out the correct sizes of the GUI surrounding the window. This probably is not correct practice, but it works and i like it. However, how do i draw the window that is *on top* first? I cant just loop through the windows and draw the on-top one, because each window is its own different class (Even though it is derived from a base window class). Any idea? [Edited by - Butterman on June 28, 2007 12:39:26 PM]
Game Development Tutorials, a few good game development tutorials located on my site.
Butterman
Butterman
Yes. But each window is a different class. So in each loop i would have to stuff 50 - 100 different draw calls.
Game Development Tutorials, a few good game development tutorials located on my site.
Ravuya
Ravuya
Maybe implement a render queue and do an insertion sort based on Z-value.

Then blow through the queue and render them.

Not entirely sure why you can't just do a loop; can you show the relevant code?
Ravyne
Ravyne
The interface from which you derive should probably contain a virtual Draw() method which all derived classes must inherit and impliment to be "Drawable". Most, if not all, information relevant to the drawing of the window (position, texture, style, etc.) should be encapsulated in the class itself, not parameters.

Alternative to this approach could include a heavily message-driven system, which respond to abstract messages, rather than direct method calls.

There are tons of solid examples on how to impliment a GUI system in C++ since it is essentially the de facto inheritance example. Unfortunately, that also means that there are plenty of bad "This is how to do a GUI in C++" examples from people who have no business writing said example...


Advice:
Find a good GUI in C++ tutorial/example.

Study:
Inheritance (including virtual inheritance)
Virtual methods (pure and non-pure)
Interfaces / Abstract Base Classes
Messaging systems
throw table_exception("(? ???)? ? ???");

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.