Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I have a very simple game engine. A GameObjectManager stores a collection of all the GameObjects. When I want to render, I just call GameObjectManager.render() from the rendering context.

This works well for rendering most objects, but now I am looking to add a water shader to the scene where it takes in reflection and refraction textures. The reflection and refraction textures will be computed each frame by re-rendering the scene from a new perspective. Unfortunately, my design choice of having a single GameObjectManager to store all GameObjects just won't work for this - it wouldn't make sense to store a GameObject for the water in the GameObjectManager.

What is a good game engine design pattern to handle re-rendering the scene for an effect such as a reflection?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Your current approach should be fine for this.

All you need to do is to have the reflective object hide itself, before performing the reflection render. This is typically done by having it clear a "IsVisible" flag on itself, before starting the reflection render.

Now, if you wanted to have objects which didn't reflect their surroundings, but instead showed elements from a different scene (say, a television screen showing a part of the next level), at that point it might be worth thinking about not having only a single GameObjectManager, and instead having one per discrete scene. But if all you're considering are reflections within a single scene, then a single GameObjectManager should be able to do everything you need.

share|improve this answer
    
Ok, that put me on the right path. Thanks. –  VigoTheCarpathian Jul 20 '11 at 15:33

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.