minimap problem

Started by
4 comments, last by Calin 18 years, 10 months ago
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?

My project`s facebook page is “DreamLand Page”

Advertisement
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.
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.
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?

My project`s facebook page is “DreamLand Page”

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. :)
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.

My project`s facebook page is “DreamLand Page”

This topic is closed to new replies.

Advertisement