Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/CSFML/Graphics/RenderTexture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ void sfRenderTexture_drawShape(sfRenderTexture* renderTexture, const sfShape* ob
{
assert(renderTexture);
assert(object);
renderTexture->This.draw(object->This, convertRenderStates(states));
renderTexture->This.draw(*object, convertRenderStates(states));
}
void sfRenderTexture_drawCircleShape(sfRenderTexture* renderTexture, const sfCircleShape* object, const sfRenderStates* states)
{
Expand Down
2 changes: 1 addition & 1 deletion src/CSFML/Graphics/RenderWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ void sfRenderWindow_drawShape(sfRenderWindow* renderWindow, const sfShape* objec
{
assert(renderWindow);
assert(object);
renderWindow->This.draw(object->This, convertRenderStates(states));
renderWindow->This.draw(*object, convertRenderStates(states));
}
void sfRenderWindow_drawCircleShape(sfRenderWindow* renderWindow, const sfCircleShape* object, const sfRenderStates* states)
{
Expand Down
54 changes: 27 additions & 27 deletions src/CSFML/Graphics/Shape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,95 +53,95 @@ void sfShape_destroy(const sfShape* shape)
void sfShape_setPosition(sfShape* shape, sfVector2f position)
{
assert(shape);
shape->This.setPosition(convertVector2(position));
shape->setPosition(convertVector2(position));
}


////////////////////////////////////////////////////////////
void sfShape_setRotation(sfShape* shape, float angle)
{
assert(shape);
shape->This.setRotation(sf::degrees(angle));
shape->setRotation(sf::degrees(angle));
}


////////////////////////////////////////////////////////////
void sfShape_setScale(sfShape* shape, sfVector2f scale)
{
assert(shape);
shape->This.setScale(convertVector2(scale));
shape->setScale(convertVector2(scale));
}


////////////////////////////////////////////////////////////
void sfShape_setOrigin(sfShape* shape, sfVector2f origin)
{
assert(shape);
shape->This.setOrigin(convertVector2(origin));
shape->setOrigin(convertVector2(origin));
}


////////////////////////////////////////////////////////////
sfVector2f sfShape_getPosition(const sfShape* shape)
{
assert(shape);
return convertVector2(shape->This.getPosition());
return convertVector2(shape->getPosition());
}


////////////////////////////////////////////////////////////
float sfShape_getRotation(const sfShape* shape)
{
assert(shape);
return shape->This.getRotation().asDegrees();
return shape->getRotation().asDegrees();
}


////////////////////////////////////////////////////////////
sfVector2f sfShape_getScale(const sfShape* shape)
{
assert(shape);
return convertVector2(shape->This.getScale());
return convertVector2(shape->getScale());
}


////////////////////////////////////////////////////////////
sfVector2f sfShape_getOrigin(const sfShape* shape)
{
assert(shape);
return convertVector2(shape->This.getOrigin());
return convertVector2(shape->getOrigin());
}


////////////////////////////////////////////////////////////
void sfShape_move(sfShape* shape, sfVector2f offset)
{
assert(shape);
shape->This.move(convertVector2(offset));
shape->move(convertVector2(offset));
}


////////////////////////////////////////////////////////////
void sfShape_rotate(sfShape* shape, float angle)
{
assert(shape);
shape->This.rotate(sf::degrees(angle));
shape->rotate(sf::degrees(angle));
}


////////////////////////////////////////////////////////////
void sfShape_scale(sfShape* shape, sfVector2f factors)
{
assert(shape);
shape->This.scale(convertVector2(factors));
shape->scale(convertVector2(factors));
}


////////////////////////////////////////////////////////////
sfTransform sfShape_getTransform(const sfShape* shape)
{
assert(shape);
shape->Transform = convertTransform(shape->This.getTransform());
shape->Transform = convertTransform(shape->getTransform());
return shape->Transform;
}

Expand All @@ -150,7 +150,7 @@ sfTransform sfShape_getTransform(const sfShape* shape)
sfTransform sfShape_getInverseTransform(const sfShape* shape)
{
assert(shape);
shape->InverseTransform = convertTransform(shape->This.getInverseTransform());
shape->InverseTransform = convertTransform(shape->getInverseTransform());
return shape->InverseTransform;
}

Expand All @@ -159,7 +159,7 @@ sfTransform sfShape_getInverseTransform(const sfShape* shape)
void sfShape_setTexture(sfShape* shape, const sfTexture* texture, bool resetRect)
{
assert(shape);
shape->This.setTexture(texture ? texture->This : nullptr, resetRect);
shape->setTexture(texture ? texture->This : nullptr, resetRect);
shape->Texture = texture;
}

Expand All @@ -168,31 +168,31 @@ void sfShape_setTexture(sfShape* shape, const sfTexture* texture, bool resetRect
void sfShape_setTextureRect(sfShape* shape, sfIntRect rect)
{
assert(shape);
shape->This.setTextureRect(convertRect(rect));
shape->setTextureRect(convertRect(rect));
}


////////////////////////////////////////////////////////////
void sfShape_setFillColor(sfShape* shape, sfColor color)
{
assert(shape);
shape->This.setFillColor(convertColor(color));
shape->setFillColor(convertColor(color));
}


////////////////////////////////////////////////////////////
void sfShape_setOutlineColor(sfShape* shape, sfColor color)
{
assert(shape);
shape->This.setOutlineColor(convertColor(color));
shape->setOutlineColor(convertColor(color));
}


////////////////////////////////////////////////////////////
void sfShape_setOutlineThickness(sfShape* shape, float thickness)
{
assert(shape);
shape->This.setOutlineThickness(thickness);
shape->setOutlineThickness(thickness);
}


Expand All @@ -208,69 +208,69 @@ const sfTexture* sfShape_getTexture(const sfShape* shape)
sfIntRect sfShape_getTextureRect(const sfShape* shape)
{
assert(shape);
return convertRect(shape->This.getTextureRect());
return convertRect(shape->getTextureRect());
}


////////////////////////////////////////////////////////////
sfColor sfShape_getFillColor(const sfShape* shape)
{
assert(shape);
return convertColor(shape->This.getFillColor());
return convertColor(shape->getFillColor());
}


////////////////////////////////////////////////////////////
sfColor sfShape_getOutlineColor(const sfShape* shape)
{
assert(shape);
return convertColor(shape->This.getOutlineColor());
return convertColor(shape->getOutlineColor());
}


////////////////////////////////////////////////////////////
float sfShape_getOutlineThickness(const sfShape* shape)
{
assert(shape);
return shape->This.getOutlineThickness();
return shape->getOutlineThickness();
}


////////////////////////////////////////////////////////////
size_t sfShape_getPointCount(const sfShape* shape)
{
assert(shape);
return shape->This.getPointCount();
return shape->getPointCount();
}


////////////////////////////////////////////////////////////
sfVector2f sfShape_getPoint(const sfShape* shape, size_t index)
{
assert(shape);
return convertVector2(shape->This.getPoint(index));
return convertVector2(shape->getPoint(index));
}


////////////////////////////////////////////////////////////
sfFloatRect sfShape_getLocalBounds(const sfShape* shape)
{
assert(shape);
return convertRect(shape->This.getLocalBounds());
return convertRect(shape->getLocalBounds());
}


////////////////////////////////////////////////////////////
sfFloatRect sfShape_getGlobalBounds(const sfShape* shape)
{
assert(shape);
return convertRect(shape->This.getGlobalBounds());
return convertRect(shape->getGlobalBounds());
}


////////////////////////////////////////////////////////////
void sfShape_update(sfShape* shape)
{
assert(shape);
shape->This.update();
shape->update();
}
29 changes: 6 additions & 23 deletions src/CSFML/Graphics/ShapeStruct.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,11 @@


////////////////////////////////////////////////////////////
// Helper class implementing the callback forwarding from
// C++ to C in sfShape
// Internal structure of sfShape
////////////////////////////////////////////////////////////
class sfShapeImpl : public sf::Shape
struct sfShape : sf::Shape
{
public:
sfShapeImpl(sfShapeGetPointCountCallback getPointCount, sfShapeGetPointCallback getPoint, void* userData) :
sfShape(sfShapeGetPointCountCallback getPointCount, sfShapeGetPointCallback getPoint, void* userData) :
myGetPointCountCallback(getPointCount),
myGetPointCallback(getPoint),
myUserData(userData)
Expand All @@ -61,25 +59,10 @@ class sfShapeImpl : public sf::Shape

using sf::Shape::update;

private:
sfShapeGetPointCountCallback myGetPointCountCallback;
sfShapeGetPointCallback myGetPointCallback;
void* myUserData;
};


////////////////////////////////////////////////////////////
// Internal structure of sfShape
////////////////////////////////////////////////////////////
struct sfShape
{
sfShape(sfShapeGetPointCountCallback getPointCount, sfShapeGetPointCallback getPoint, void* userData) :
This(getPointCount, getPoint, userData)
{
}

sfShapeImpl This;
const sfTexture* Texture{};
mutable sfTransform Transform{};
mutable sfTransform InverseTransform{};
const sfTexture* Texture{};
mutable sfTransform Transform{};
mutable sfTransform InverseTransform{};
};