Modified sf::RenderTarget so that it handles views by value rather than by reference

git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1315 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
LaurentGom 2009-12-31 16:43:24 +00:00
parent 54e70a47f0
commit 6d717f3c87
3 changed files with 13 additions and 36 deletions

View file

@ -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;
}