mirror of
https://github.com/SFML/SFML.git
synced 2024-11-28 22:31:09 +08:00
Updated CSFML to properly handle the new way of storing views in render targets
git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1322 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
parent
bc6beac402
commit
4472f81469
@ -168,7 +168,7 @@ CSFML_API const sfView* sfRenderImage_GetView(const sfRenderImage* renderImage);
|
||||
/// \return Default view of the renderimage
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_API sfView* sfRenderImage_GetDefaultView(sfRenderImage* renderImage);
|
||||
CSFML_API const sfView* sfRenderImage_GetDefaultView(const sfRenderImage* renderImage);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the viewport of a view applied to this target
|
||||
|
@ -348,7 +348,7 @@ CSFML_API const sfView* sfRenderWindow_GetView(const sfRenderWindow* renderWindo
|
||||
/// \return Default view of the render window
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_API sfView* sfRenderWindow_GetDefaultView(sfRenderWindow* renderWindow);
|
||||
CSFML_API const sfView* sfRenderWindow_GetDefaultView(const sfRenderWindow* renderWindow);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the viewport of a view applied to this target
|
||||
|
@ -41,9 +41,9 @@ sfRenderImage* sfRenderImage_Create(unsigned int width, unsigned int height, sfB
|
||||
{
|
||||
sfRenderImage* renderImage = new sfRenderImage;
|
||||
renderImage->This.Create(width, height, depthBuffer == sfTrue);
|
||||
renderImage->Target = new sfImage(const_cast<sf::Image*>(&renderImage->This.GetImage()));
|
||||
renderImage->DefaultView = new sfView(const_cast<sf::View*>(&renderImage->This.GetDefaultView()));
|
||||
renderImage->CurrentView = renderImage->DefaultView;
|
||||
renderImage->Target = new sfImage(const_cast<sf::Image*>(&renderImage->This.GetImage()));
|
||||
renderImage->DefaultView.This = renderImage->This.GetDefaultView();
|
||||
renderImage->CurrentView.This = renderImage->This.GetView();
|
||||
|
||||
return renderImage;
|
||||
}
|
||||
@ -54,7 +54,6 @@ sfRenderImage* sfRenderImage_Create(unsigned int width, unsigned int height, sfB
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfRenderImage_Destroy(sfRenderImage* renderImage)
|
||||
{
|
||||
delete renderImage->DefaultView;
|
||||
delete renderImage->Target;
|
||||
delete renderImage;
|
||||
}
|
||||
@ -175,8 +174,8 @@ void sfRenderImage_Clear(sfRenderImage* renderImage, sfColor color)
|
||||
void sfRenderImage_SetView(sfRenderImage* renderImage, const sfView* view)
|
||||
{
|
||||
CSFML_CHECK(view);
|
||||
CSFML_CALL(renderImage, SetView(*view->This));
|
||||
renderImage->CurrentView = view;
|
||||
CSFML_CALL(renderImage, SetView(view->This));
|
||||
renderImage->CurrentView.This = view->This;
|
||||
}
|
||||
|
||||
|
||||
@ -187,18 +186,18 @@ const sfView* sfRenderImage_GetView(const sfRenderImage* renderImage)
|
||||
{
|
||||
CSFML_CHECK_RETURN(renderImage, NULL);
|
||||
|
||||
return renderImage->CurrentView;
|
||||
return &renderImage->CurrentView;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the default view of a renderimage
|
||||
////////////////////////////////////////////////////////////
|
||||
sfView* sfRenderImage_GetDefaultView(sfRenderImage* renderImage)
|
||||
const sfView* sfRenderImage_GetDefaultView(const sfRenderImage* renderImage)
|
||||
{
|
||||
CSFML_CHECK_RETURN(renderImage, NULL);
|
||||
|
||||
return renderImage->DefaultView;
|
||||
return &renderImage->DefaultView;
|
||||
}
|
||||
|
||||
|
||||
@ -211,7 +210,7 @@ sfIntRect sfRenderImage_GetViewport(const sfRenderImage* renderImage, const sfVi
|
||||
CSFML_CHECK_RETURN(view, rect);
|
||||
CSFML_CHECK_RETURN(renderImage, rect);
|
||||
|
||||
sf::IntRect SFMLrect = renderImage->This.GetViewport(*view->This);
|
||||
sf::IntRect SFMLrect = renderImage->This.GetViewport(view->This);
|
||||
rect.Left = SFMLrect.Left;
|
||||
rect.Top = SFMLrect.Top;
|
||||
rect.Right = SFMLrect.Right;
|
||||
@ -230,7 +229,7 @@ void sfRenderImage_ConvertCoords(const sfRenderImage* renderImage, unsigned int
|
||||
|
||||
sf::Vector2f point;
|
||||
if (targetView)
|
||||
point = renderImage->This.ConvertCoords(imageX, imageY, *targetView->This);
|
||||
point = renderImage->This.ConvertCoords(imageX, imageY, targetView->This);
|
||||
else
|
||||
point = renderImage->This.ConvertCoords(imageX, imageY);
|
||||
|
||||
|
@ -41,8 +41,8 @@ struct sfRenderImage
|
||||
{
|
||||
sf::RenderImage This;
|
||||
const sfImage* Target;
|
||||
sfView* DefaultView;
|
||||
const sfView* CurrentView;
|
||||
sfView DefaultView;
|
||||
sfView CurrentView;
|
||||
};
|
||||
|
||||
|
||||
|
@ -58,9 +58,9 @@ sfRenderWindow* sfRenderWindow_Create(sfVideoMode mode, const char* title, unsig
|
||||
// Create the window
|
||||
sfRenderWindow* renderWindow = new sfRenderWindow;
|
||||
renderWindow->This.Create(videoMode, title, style, params);
|
||||
renderWindow->Input.This = &renderWindow->This.GetInput();
|
||||
renderWindow->DefaultView = new sfView(const_cast<sf::View*>(&renderWindow->This.GetDefaultView()));
|
||||
renderWindow->CurrentView = renderWindow->DefaultView;
|
||||
renderWindow->Input.This = &renderWindow->This.GetInput();
|
||||
renderWindow->DefaultView.This = renderWindow->This.GetDefaultView();
|
||||
renderWindow->CurrentView.This = renderWindow->This.GetView();
|
||||
|
||||
return renderWindow;
|
||||
}
|
||||
@ -85,9 +85,9 @@ sfRenderWindow* sfRenderWindow_CreateFromHandle(sfWindowHandle handle, const sfC
|
||||
// Create the window
|
||||
sfRenderWindow* renderWindow = new sfRenderWindow;
|
||||
renderWindow->This.Create(handle, params);
|
||||
renderWindow->Input.This = &renderWindow->This.GetInput();
|
||||
renderWindow->DefaultView = new sfView(const_cast<sf::View*>(&renderWindow->This.GetDefaultView()));
|
||||
renderWindow->CurrentView = renderWindow->DefaultView;
|
||||
renderWindow->Input.This = &renderWindow->This.GetInput();
|
||||
renderWindow->DefaultView.This = renderWindow->This.GetDefaultView();
|
||||
renderWindow->CurrentView.This = renderWindow->This.GetView();
|
||||
|
||||
return renderWindow;
|
||||
}
|
||||
@ -98,7 +98,6 @@ sfRenderWindow* sfRenderWindow_CreateFromHandle(sfWindowHandle handle, const sfC
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfRenderWindow_Destroy(sfRenderWindow* renderWindow)
|
||||
{
|
||||
delete renderWindow->DefaultView;
|
||||
delete renderWindow;
|
||||
}
|
||||
|
||||
@ -413,8 +412,8 @@ void sfRenderWindow_Clear(sfRenderWindow* renderWindow, sfColor color)
|
||||
void sfRenderWindow_SetView(sfRenderWindow* renderWindow, const sfView* view)
|
||||
{
|
||||
CSFML_CHECK(view);
|
||||
CSFML_CALL(renderWindow, SetView(*view->This));
|
||||
renderWindow->CurrentView = view;
|
||||
CSFML_CALL(renderWindow, SetView(view->This));
|
||||
renderWindow->CurrentView.This = view->This;
|
||||
}
|
||||
|
||||
|
||||
@ -425,18 +424,18 @@ const sfView* sfRenderWindow_GetView(const sfRenderWindow* renderWindow)
|
||||
{
|
||||
CSFML_CHECK_RETURN(renderWindow, NULL);
|
||||
|
||||
return renderWindow->CurrentView;
|
||||
return &renderWindow->CurrentView;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Get the default view of a renderwindow
|
||||
////////////////////////////////////////////////////////////
|
||||
sfView* sfRenderWindow_GetDefaultView(sfRenderWindow* renderWindow)
|
||||
const sfView* sfRenderWindow_GetDefaultView(const sfRenderWindow* renderWindow)
|
||||
{
|
||||
CSFML_CHECK_RETURN(renderWindow, NULL);
|
||||
|
||||
return renderWindow->DefaultView;
|
||||
return &renderWindow->DefaultView;
|
||||
}
|
||||
|
||||
|
||||
@ -449,7 +448,7 @@ sfIntRect sfRenderWindow_GetViewport(const sfRenderWindow* renderWindow, const s
|
||||
CSFML_CHECK_RETURN(view, rect);
|
||||
CSFML_CHECK_RETURN(renderWindow, rect);
|
||||
|
||||
sf::IntRect SFMLrect = renderWindow->This.GetViewport(*view->This);
|
||||
sf::IntRect SFMLrect = renderWindow->This.GetViewport(view->This);
|
||||
rect.Left = SFMLrect.Left;
|
||||
rect.Top = SFMLrect.Top;
|
||||
rect.Right = SFMLrect.Right;
|
||||
@ -468,7 +467,7 @@ void sfRenderWindow_ConvertCoords(const sfRenderWindow* renderWindow, unsigned i
|
||||
|
||||
sf::Vector2f point;
|
||||
if (targetView)
|
||||
point = renderWindow->This.ConvertCoords(windowX, windowY, *targetView->This);
|
||||
point = renderWindow->This.ConvertCoords(windowX, windowY, targetView->This);
|
||||
else
|
||||
point = renderWindow->This.ConvertCoords(windowX, windowY);
|
||||
|
||||
|
@ -40,8 +40,8 @@ struct sfRenderWindow
|
||||
{
|
||||
sf::RenderWindow This;
|
||||
sfInput Input;
|
||||
sfView* DefaultView;
|
||||
const sfView* CurrentView;
|
||||
sfView DefaultView;
|
||||
sfView CurrentView;
|
||||
};
|
||||
|
||||
|
||||
|
@ -44,7 +44,10 @@ sfView* sfView_Create()
|
||||
////////////////////////////////////////////////////////////
|
||||
sfView* sfView_CreateFromRect(sfFloatRect rectangle)
|
||||
{
|
||||
return new sfView(rectangle);
|
||||
sfView* view = new sfView;
|
||||
sfView_Reset(view, rectangle);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
|
||||
@ -73,7 +76,7 @@ void sfView_Destroy(sfView* view)
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfView_SetCenter(sfView* view, float x, float y)
|
||||
{
|
||||
CSFML_CALL_PTR(view, SetCenter(x, y));
|
||||
CSFML_CALL(view, SetCenter(x, y));
|
||||
}
|
||||
|
||||
|
||||
@ -82,7 +85,7 @@ void sfView_SetCenter(sfView* view, float x, float y)
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfView_SetSize(sfView* view, float width, float height)
|
||||
{
|
||||
CSFML_CALL_PTR(view, SetSize(width, height));
|
||||
CSFML_CALL(view, SetSize(width, height));
|
||||
}
|
||||
|
||||
|
||||
@ -91,7 +94,7 @@ void sfView_SetSize(sfView* view, float width, float height)
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfView_SetRotation(sfView* view, float angle)
|
||||
{
|
||||
CSFML_CALL_PTR(view, SetRotation(angle));
|
||||
CSFML_CALL(view, SetRotation(angle));
|
||||
}
|
||||
|
||||
|
||||
@ -100,7 +103,7 @@ void sfView_SetRotation(sfView* view, float angle)
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfView_SetViewport(sfView* view, sfFloatRect viewport)
|
||||
{
|
||||
CSFML_CALL_PTR(view, SetViewport(sf::FloatRect(viewport.Left, viewport.Top, viewport.Right, viewport.Bottom)));
|
||||
CSFML_CALL(view, SetViewport(sf::FloatRect(viewport.Left, viewport.Top, viewport.Right, viewport.Bottom)));
|
||||
}
|
||||
|
||||
|
||||
@ -110,7 +113,7 @@ void sfView_SetViewport(sfView* view, sfFloatRect viewport)
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfView_Reset(sfView* view, sfFloatRect rectangle)
|
||||
{
|
||||
CSFML_CALL_PTR(view, Reset(sf::FloatRect(rectangle.Left, rectangle.Top, rectangle.Right, rectangle.Bottom)));
|
||||
CSFML_CALL(view, Reset(sf::FloatRect(rectangle.Left, rectangle.Top, rectangle.Right, rectangle.Bottom)));
|
||||
}
|
||||
|
||||
|
||||
@ -121,7 +124,7 @@ float sfView_GetCenterX(const sfView* view)
|
||||
{
|
||||
CSFML_CHECK_RETURN(view, 0.f);
|
||||
|
||||
return view->This->GetCenter().x;
|
||||
return view->This.GetCenter().x;
|
||||
}
|
||||
|
||||
|
||||
@ -132,7 +135,7 @@ float sfView_GetCenterY(const sfView* view)
|
||||
{
|
||||
CSFML_CHECK_RETURN(view, 0.f);
|
||||
|
||||
return view->This->GetCenter().y;
|
||||
return view->This.GetCenter().y;
|
||||
}
|
||||
|
||||
|
||||
@ -143,7 +146,7 @@ float sfView_GetWidth(const sfView* view)
|
||||
{
|
||||
CSFML_CHECK_RETURN(view, 0.f);
|
||||
|
||||
return view->This->GetSize().x;
|
||||
return view->This.GetSize().x;
|
||||
}
|
||||
|
||||
|
||||
@ -154,7 +157,7 @@ float sfView_GetHeight(const sfView* view)
|
||||
{
|
||||
CSFML_CHECK_RETURN(view, 0.f);
|
||||
|
||||
return view->This->GetSize().y;
|
||||
return view->This.GetSize().y;
|
||||
}
|
||||
|
||||
|
||||
@ -163,7 +166,7 @@ float sfView_GetHeight(const sfView* view)
|
||||
////////////////////////////////////////////////////////////
|
||||
float sfView_GetRotation(const sfView* view)
|
||||
{
|
||||
CSFML_CALL_PTR_RETURN(view, GetRotation(), 0.f);
|
||||
CSFML_CALL_RETURN(view, GetRotation(), 0.f);
|
||||
}
|
||||
|
||||
|
||||
@ -175,7 +178,7 @@ sfFloatRect sfView_GetViewport(const sfView* view)
|
||||
sfFloatRect rect = {0, 0, 0, 0};
|
||||
CSFML_CHECK_RETURN(view, rect);
|
||||
|
||||
sf::FloatRect SFMLRect = view->This->GetViewport();
|
||||
sf::FloatRect SFMLRect = view->This.GetViewport();
|
||||
rect.Left = SFMLRect.Left;
|
||||
rect.Top = SFMLRect.Top;
|
||||
rect.Right = SFMLRect.Right;
|
||||
@ -190,7 +193,7 @@ sfFloatRect sfView_GetViewport(const sfView* view)
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfView_Move(sfView* view, float offsetX, float offsetY)
|
||||
{
|
||||
CSFML_CALL_PTR(view, Move(offsetX, offsetY));
|
||||
CSFML_CALL(view, Move(offsetX, offsetY));
|
||||
}
|
||||
|
||||
|
||||
@ -199,7 +202,7 @@ void sfView_Move(sfView* view, float offsetX, float offsetY)
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfView_Rotate(sfView* view, float angle)
|
||||
{
|
||||
CSFML_CALL_PTR(view, Rotate(angle));
|
||||
CSFML_CALL(view, Rotate(angle));
|
||||
}
|
||||
|
||||
|
||||
@ -208,5 +211,5 @@ void sfView_Rotate(sfView* view, float angle)
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfView_Zoom(sfView* view, float factor)
|
||||
{
|
||||
CSFML_CALL_PTR(view, Zoom(factor));
|
||||
CSFML_CALL(view, Zoom(factor));
|
||||
}
|
||||
|
@ -36,38 +36,7 @@
|
||||
////////////////////////////////////////////////////////////
|
||||
struct sfView
|
||||
{
|
||||
sfView() :
|
||||
This(new sf::View),
|
||||
OwnInstance(true)
|
||||
{
|
||||
}
|
||||
|
||||
sfView(sfFloatRect Rect) :
|
||||
This(new sf::View(sf::FloatRect(Rect.Left, Rect.Top, Rect.Right, Rect.Bottom))),
|
||||
OwnInstance(true)
|
||||
{
|
||||
}
|
||||
|
||||
sfView(sf::View* View) :
|
||||
This(View),
|
||||
OwnInstance(false)
|
||||
{
|
||||
}
|
||||
|
||||
sfView(const sfView& View) :
|
||||
This(View.This ? new sf::View(*View.This) : NULL),
|
||||
OwnInstance(true)
|
||||
{
|
||||
}
|
||||
|
||||
~sfView()
|
||||
{
|
||||
if (OwnInstance)
|
||||
delete This;
|
||||
}
|
||||
|
||||
sf::View* This; // pointer needed for RenderWindow
|
||||
bool OwnInstance;
|
||||
sf::View This;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user