Jump to content
  • Advertisement
Sign in to follow this  

[Design] Window and Renderer: Where to Put What... If Anywhere!

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

Arg, this design problem has been giving me a headache. With the initial intent of supporting multiple windows in my engine, I included a Window class (abstract). The Renderer class acts as the graphics hardware; it lets a client render VertexBuffers, set the video mode, bind textures and cameras, etc. For awhile, Window sort of fell out of the picture. Renderer's setVideoMode() function returned a new Window and that's about it. The new Window could be used to minimize the window the program was running in, as well as set and get the caption text and show and hide the mouse cursor. In this way, Window just provided a different place for some more "window-ish" functionality (this stuff could just as easily been placed in Renderer). So I decided to bring Window back into the picture. Renderer acts as the primary interface to the graphics sub-system, and it provides a series of make...() functions to make Textures, Images, etc. (i.e., makeTexture()). I added a makeWindow() method to this family of functions, and had Renderers bind a target Window to work with. setVideoMode() became a void function that set the video mode of the currently bound Window. Here's where I'm really not sure what to do. I'm currently implementing the engine using SDL and OpenGL (everything's abstracted so that I can add more implementations later). SDL doesn't support multiple windows in the first place! Now, I could just throw an UnsupportedException when a user tries to create more Windows using an SDL implementation, but... I'm starting to wonder if supporting multiple Windows in a game engine is necessary, especially a small one like what I'm working on. Also, this would require moving tons of data and methods from Renderer to Window, such as video metrics. As it is, Renderer is designed to store things like the width and height of the video, whether it's running in full screen, the color depth, and so on. This would all have to move into Window objects now, since it can differ between them. In SDL, there's just no way to do this in the first place. Really my question is, should I even bother with support for multiple windows? If so, what would be the best way to do this? If the API doesn't support it (SDL), should I just throw some UnsupportedExceptions? If I shouldn't support it, should I continue to use a Window class (for methods mentioned above), or should everything fall into the Renderer class? Any ideas are appreciated; I'm really not sure where to go on this one. Thanks! :-) (Also, what about window resizing? I currently built in support for this, but it makes extensive use of my event system [a Window detects a resize, fires a WindowResizeEvent which is handled by its Renderer by setting the video mode with the new dimensions. This in turn fires VideoModeEvents to let listeners know that the video mode is changing]. I can see it getting messy with multiple windows, but there's no need for all of this if Renderer is the window.)

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!