Sign in to follow this  
Calin

minimap problem

Recommended Posts

I am making a RTS. I would like to have a minimap in my game but I don`t know the best way to go. The only thing that comes to my mind is to have two viewports (I am using OpenGL for my game) but I am afraid that this solution will slow down my game. Does anyone have any sugestion?

Share this post


Link to post
Share on other sites
Setup a new viewport and use that one to render a top-down image of the level at startup, then delete the viewport. Then you can use the generated image as a background for the minimap and then just plot the player position and such.

Share this post


Link to post
Share on other sites
The best way would really depend on what other data structures your RTS has lying around. For example, if your map file had a preview bitmap you might just load that and during collision detection (or some other phase where you need to cycle through all your actors) just stick pixels on the preview corresponding to the units and then display that. If you don't have something like that, and since you're using OpenGL you might render to an offscreen surface, once when the map is loaded, to generate the mini-map background and store that somewhere and use copies of that like if you had the preview bitmap.

Of course there are purists who would say that doing this during collision detection would be bad software engineering since you would be doing to logically unconnected things in the same code segment. YMMV.

Share this post


Link to post
Share on other sites
Quote:
Original post by Mizipzor
Setup a new viewport and use that one to render a top-down image of the level at startup, then delete the viewport. Then you can use the generated image as a background for the minimap and then just plot the player position and such.


If I will delete the second viewport the viewport image will remain on the screen?

Share this post


Link to post
Share on other sites
Well, take that open gl camera and place it at the center of the level, then elevate it and point it downwards. Then "take a screenshot", store it as a surface, and then use that surface for the background of the minimap. I dont know opengl all that well but I know the routine you see. :)

Share this post


Link to post
Share on other sites
Quote:
Original post by Mizipzor
Well, take that open gl camera and place it at the center of the level, then elevate it and point it downwards. Then "take a screenshot", store it as a surface, and then use that surface for the background of the minimap. I dont know opengl all that well but I know the routine you see. :)


I am still a newbie so I don`t know how to make a screenshot and how to store it. If you know how to do that I would be thankful if you would explain it.
In any case thanks for your advice.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this