Code: Select all
...
int yourmap[40][30];
int height=30;
int width=40;
...
video::ITexture* rtmap = 0;
if (driver->queryFeature(video::EVDF_RENDER_TO_TARGET))
{
rtmap = driver->addRenderTargetTexture(core::dimension2d<u32>(1024,680), "rt");
// add fixed camera
fixedCam = smgr->addCameraSceneNode(0, core::vector3df(10,10,-80),
core::vector3df(-10,10,-100));
}
else
{
printf("Your hardware or this renderer is not able to use the\n render to texture feature. RTT Disabled. \n");
}
...
if (rtmap)
{
driver->setRenderTarget(rtmap);
smgr->setActiveCamera(fixedCam);
for (int z = 0; z<height; z++) //here we draw the map to the texture
{
for (int x = 0; x < width; x++)
{
if (yourmap[x][z]==0) //as example water, in my map water is 0
{
driver->draw2DRectangle(video::SColor(255,0,0,255), //blue for water
core::rect<s32>(x*2, z*2, x*2+1, z*2+1); //for example for every map-tile a 2x2 block on the map
//and so on with the other terraintypes or build a colortable for the terraintypes
}
}
//and also you can draw for example a white rect on the map with draw2DRectangle...
}
driver->setRenderTarget(0);
smgr->setActiveCamera(hereinsertyournormalcamera);
}
driver->beginScene(true, true, SColor(0xFF000000));
//here your code
smgr->drawAll();
//minimap
driver->draw2DImage(rtmap, core::position2d<s32>(804,10), //position to draw the minimap on screen
core::rect<s32>(0,0,212,150), 0,
video::SColor(255,255,255,255), false);
driver->endScene();
...