Changing the way I think about the renderer...

Started by
3 comments, last by JohnHurt 18 years, 8 months ago
Hey all, I'm working on a 2D engine at the moment. While implementing various GUI widgets, an idea struck me. I currently render the scene directly to the window (a Windows window) then render my GUI elements ontop of that. But what if I allowed sprites to be rendered to various GUI elements themselves? I could have a "desktop" window which takes up the entire screen and various other child rendering windows for things like rear view windows, minimaps, 2D split screens and the like. Any thoughts or ideas? Anyone currently employ this strategy?
Advertisement
what do you mean with child rendering windows? (Windows windows?) or custom gui windows

i would go with the first strategy rendering the map and draw the gui ontop of it

why would you spend more resources to do the same?

hm what you could do is rendering everything to these layers(how do they call it in opengl?)

and merge those when needed
so you render everything that changed its view and merge the pixels without rerendering the scene or the gui elements

http://www.8ung.at/basiror/theironcross.html
You can use texture render-targets so you would basically render to a texture rather than the window. You could have a widget that will allow to render to it. I don't see the need to be able to render to any widget (button or whatever) only those special widgets.

I'm sorry I can't remember more info but its a start, try to look it up on the web :)

Hope that offered some help
I think a common term for the child rendering windows is viewports. It's really easy to do actually, and I can't see it making much of a difference to performance. But I was doing it in 3d, for split screen and the like, so it was a bit different. A mistake I made you might want to be aware of is I cleared the screen before rendering for each viewport out of habit. Not very clever.

EDIT: You don't need to render to texture to do it, you could just mask it with the stencil buffer. I didn't even need to do that because mine were all rectangular and were seperate, not a widgit or anything. I just had to set the glViewport right.
___________________________________________________David OlsenIf I've helped you, please vote for PigeonGrape!
Torque2D does exactly this I beleive. I thought about doing something similar in my 2D engine, but have abandoned the idea as pointless - in a twisted sort of way it makes sense. I've decided instead to use a special widget that can have a "render-to-texture" scene applied to them for minimaps, other camera views etc.

This topic is closed to new replies.

Advertisement