# minimap problem

## Recommended Posts

I am making a RTS. I would like to have a minimap in my game but I dont 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 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 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 on other sites
Quote:
 Original post by MizipzorSetup 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 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 on other sites
Quote:
 Original post by MizipzorWell, 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 dont 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.

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
627731
• Total Posts
2978831

• 10
• 9
• 21
• 14
• 12