Hello,
I´m making a CAD program and I would like to include minimap which will show me where am I zoomed in etc.
One view shows my enviroment for drawing with current position where am I and the other is minimap which shows 100% of my enviroment. My problem comes when I am drawing stuff to the Views as it for some reason collide with each other as you can see on the screenshot. Even at Red rectangle with 0 transparency. It looks like that I am drawing my background grid to the minimap 2 times but when I try to take it somwhere else in the code so it won´t collide with my camera it doesn´t show up at all. Can you help me solve where I should place my draw for background grid so it won´t collide with my minimap ?
void targetWindow::worldCamera()
{
if (!event)
{
if (setup)// this basically sets up my camera and it run just first time of loop
{
this->camera.setCenter({ 0, 0 }); //camera is private object in targetWindow which
this->camera.setSize({1280, 720});//just creates view
setup = false;
}
this->camera.setView(window);
}
//here is other stuff which handle camera zooming and moving
}
void targetWindow::minimap()
{
if (mSetup)
{
minimapView.setCenter({ 0, 0 }); //minimapView is private object in targetWindow which
minimapView.setSize({ 3842, 2162 });//just creates another view
minimapView.camera.setViewport(sf::FloatRect(0.75f, 0.f, 0.25f, 0.25f));
mMapPosition.setSize({ 1280, 720 });//this is that red rectangle which will show position of main
mMapPosition.setPosition({ 0,0 }); //camera
mMapPosition.setFillColor(sf::Color::Red);
mSetup = false;
}
minimapView.setView(window);
}
void targetWindow::update()
{
minimap();
window.clear(bgColor);//some color for background
window.draw(mMapPosition);//red rectangle
window.draw(backgroundObj);//grid
worldCamera();
window.draw(backgroundObj);//I think that this causes the problem as it should be somewhere else
window.display(); //but I don´t really know where as I´m not very familiar with
//sf::View behavior
sf::sleep(sf::milliseconds(clockVar));
}