Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: sf::View - why is my minimap transparent  (Read 1138 times)

0 Members and 1 Guest are viewing this topic.

Dajcok

  • Newbie
  • *
  • Posts: 13
    • View Profile
    • Email
sf::View - why is my minimap transparent
« on: April 28, 2020, 12:14:57 pm »
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));
}
 
« Last Edit: April 28, 2020, 12:19:59 pm by Dajcok »

Zakkle

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: sf::View - why is my minimap transparent
« Reply #1 on: May 06, 2020, 04:26:22 pm »
Without being able to see the whole code for the grid, worldCamera, and whatnot, I am going to go out on a limb and say the mini map is transparent because the main view is also transparent and doesn't have a default fill.  Whatever you were hoping to achieve without it being transparent, you could either fill the background of the main view or the mini map.

 

anything