Hello, I have a few questions about how views are working.
sf::RenderWindow *mApp;
sf::View *mCamera;
sf::RenderTexture *mRenderTarget;
So first, everything is rendered into mRenderTarget and at the end of the game cycle I draw final image to mApp.
Here is the function which initializes camera and reinitializes it when window is resized:
void DisplayManager::InitializeCamera(const sf::FloatRect &rect)
{
// This is automatically called when window is resized
mCamera->reset(rect);
mApp->setView(*mCamera);
mRenderTarget->create(rect.width, rect.height);
mRenderTarget->setView(*mCamera);
}
And it looks like:
mRenderTarget->display();
mApp->draw(sf::Sprite(mRenderTarget->getTexture()));
mApp->display();
The questions:
Is that code right?
How does views work? When I change some parameters of it I have to reinitialize render target and/or window with same view:
mCamera->zoom(0.96);
//mApp>setView(*mCamera); // Required?
mRenerTarget->setView(*mCamera);
Should I set view to render target only (everything is drawn onto it first)? And why should I setView again and again after any change to the view object? If sf::Window (abstract) takes in arguments address of the view why doesn't it track the changes inside the object?
And the last: when I want to use sf::Window::convertCoords, should I call it from renderTarget (sf::RenderTextuer) or mApp (sf::RenderWindow)?
Thanks