diff --git a/include/SFML/Graphics/RenderTarget.hpp b/include/SFML/Graphics/RenderTarget.hpp index 52071bb8..68f1cbcc 100644 --- a/include/SFML/Graphics/RenderTarget.hpp +++ b/include/SFML/Graphics/RenderTarget.hpp @@ -126,12 +126,12 @@ public : const View& GetView() const; //////////////////////////////////////////////////////////// - /// Get the default view of the window for read / write + /// Get the default view of the window /// /// \return Default view /// //////////////////////////////////////////////////////////// - View& GetDefaultView(); + const View& GetDefaultView() const; //////////////////////////////////////////////////////////// /// Get the viewport of a view applied to this target @@ -170,12 +170,6 @@ public : protected : - //////////////////////////////////////////////////////////// - /// Default constructor - /// - //////////////////////////////////////////////////////////// - RenderTarget(); - //////////////////////////////////////////////////////////// /// Called by the derived class when it's ready to be initialized /// @@ -199,7 +193,7 @@ private : //////////////////////////////////////////////////////////// RenderQueue myRenderQueue; ///< Rendering queue storing render commands View myDefaultView; ///< Default view - const View* myCurrentView; ///< Current active view + View myCurrentView; ///< Current active view }; } // namespace sf diff --git a/samples/qt/Main.cpp b/samples/qt/Main.cpp index c256f1ab..8b44ad72 100644 --- a/samples/qt/Main.cpp +++ b/samples/qt/Main.cpp @@ -60,7 +60,7 @@ private : // Adjust the size of the default view when the widget is resized if (event.Type == sf::Event::Resized) { - GetDefaultView().Reset(sf::FloatRect(0, 0, event.Size.Width, event.Size.Height)); + SetView(sf::View(sf::FloatRect(0, 0, event.Size.Width, event.Size.Height))); } } diff --git a/src/SFML/Graphics/RenderTarget.cpp b/src/SFML/Graphics/RenderTarget.cpp index b0b8ab10..cf320eb1 100644 --- a/src/SFML/Graphics/RenderTarget.cpp +++ b/src/SFML/Graphics/RenderTarget.cpp @@ -33,16 +33,6 @@ namespace sf { -//////////////////////////////////////////////////////////// -/// Default constructor -//////////////////////////////////////////////////////////// -RenderTarget::RenderTarget() : -myCurrentView(&myDefaultView) -{ - -} - - //////////////////////////////////////////////////////////// /// Destructor //////////////////////////////////////////////////////////// @@ -79,12 +69,6 @@ void RenderTarget::Draw(const Drawable& object) // Save the current render states myRenderQueue.PushStates(); - // Setup the viewport - myRenderQueue.SetViewport(GetViewport(*myCurrentView)); - - // Setup the projection matrix - myRenderQueue.SetProjection(myCurrentView->GetMatrix()); - // Setup the shader myRenderQueue.SetShader(NULL); @@ -104,12 +88,6 @@ void RenderTarget::Draw(const Drawable& object, const Shader& shader) // Save the current render states myRenderQueue.PushStates(); - // Setup the viewport - myRenderQueue.SetViewport(GetViewport(*myCurrentView)); - - // Setup the projection matrix - myRenderQueue.SetProjection(myCurrentView->GetMatrix()); - // Setup the shader myRenderQueue.SetShader(&shader); @@ -141,7 +119,12 @@ void RenderTarget::Flush() //////////////////////////////////////////////////////////// void RenderTarget::SetView(const View& view) { - myCurrentView = &view; + // Save it + myCurrentView = view; + + // Send the view's viewport and projection matrix to the render queue + myRenderQueue.SetViewport(GetViewport(view)); + myRenderQueue.SetProjection(view.GetMatrix()); } @@ -150,14 +133,14 @@ void RenderTarget::SetView(const View& view) //////////////////////////////////////////////////////////// const View& RenderTarget::GetView() const { - return *myCurrentView; + return myCurrentView; } //////////////////////////////////////////////////////////// -/// Get the default view of the window for read / write +/// Get the default view of the window //////////////////////////////////////////////////////////// -View& RenderTarget::GetDefaultView() +const View& RenderTarget::GetDefaultView() const { return myDefaultView; }