mirror of
https://github.com/4ian/GDevelop.git
synced 2025-10-15 10:19:04 +00:00
Use sf::TrianglesStrip instead of sf::Quads for Android support
This commit is contained in:
@@ -110,64 +110,60 @@ bool RuntimePanelSpriteObject::Draw( sf::RenderTarget& window )
|
|||||||
float imageWidth = texture->texture.getSize().x;
|
float imageWidth = texture->texture.getSize().x;
|
||||||
float imageHeight = texture->texture.getSize().y;
|
float imageHeight = texture->texture.getSize().y;
|
||||||
|
|
||||||
sf::Vertex vertices[] =
|
sf::Vertex centerVertices[] = {
|
||||||
{
|
|
||||||
//Center part (streched)
|
|
||||||
sf::Vertex( sf::Vector2f(-width/2 + leftMargin ,-height/2 + topMargin ), sf::Vector2f(leftMargin ,topMargin )),
|
sf::Vertex( sf::Vector2f(-width/2 + leftMargin ,-height/2 + topMargin ), sf::Vector2f(leftMargin ,topMargin )),
|
||||||
sf::Vertex( sf::Vector2f(+width/2 - rightMargin,-height/2 + topMargin ), sf::Vector2f(imageWidth - rightMargin,topMargin )),
|
sf::Vertex( sf::Vector2f(+width/2 - rightMargin,-height/2 + topMargin ), sf::Vector2f(imageWidth - rightMargin,topMargin )),
|
||||||
sf::Vertex( sf::Vector2f(+width/2 - rightMargin,+height/2 - bottomMargin), sf::Vector2f(imageWidth - rightMargin,imageHeight - bottomMargin)),
|
|
||||||
sf::Vertex( sf::Vector2f(-width/2 + leftMargin ,+height/2 - bottomMargin), sf::Vector2f(leftMargin ,imageHeight - bottomMargin)),
|
sf::Vertex( sf::Vector2f(-width/2 + leftMargin ,+height/2 - bottomMargin), sf::Vector2f(leftMargin ,imageHeight - bottomMargin)),
|
||||||
|
sf::Vertex( sf::Vector2f(+width/2 - rightMargin,+height/2 - bottomMargin), sf::Vector2f(imageWidth - rightMargin,imageHeight - bottomMargin)),
|
||||||
|
};
|
||||||
|
|
||||||
|
sf::Vertex topVertices[] = {
|
||||||
//Top-left
|
//Top-left
|
||||||
sf::Vertex( sf::Vector2f(-width/2 ,-height/2 ), sf::Vector2f(0 ,0 )),
|
sf::Vertex( sf::Vector2f(-width/2 ,-height/2 ), sf::Vector2f(0 ,0 )),
|
||||||
|
sf::Vertex( sf::Vector2f(-width/2 ,-height/2 + topMargin ), sf::Vector2f(0 ,topMargin )),
|
||||||
sf::Vertex( sf::Vector2f(-width/2 + leftMargin ,-height/2 ), sf::Vector2f(leftMargin ,0 )),
|
sf::Vertex( sf::Vector2f(-width/2 + leftMargin ,-height/2 ), sf::Vector2f(leftMargin ,0 )),
|
||||||
sf::Vertex( sf::Vector2f(-width/2 + leftMargin ,-height/2 + topMargin ), sf::Vector2f(leftMargin ,topMargin )),
|
sf::Vertex( sf::Vector2f(-width/2 + leftMargin ,-height/2 + topMargin ), sf::Vector2f(leftMargin ,topMargin )),
|
||||||
sf::Vertex( sf::Vector2f(-width/2 ,-height/2 + topMargin ), sf::Vector2f(0 ,topMargin )),
|
|
||||||
|
|
||||||
//Top
|
//Top
|
||||||
sf::Vertex( sf::Vector2f(-width/2 + leftMargin ,-height/2 ), sf::Vector2f(leftMargin ,0 )),
|
|
||||||
sf::Vertex( sf::Vector2f(+width/2 - rightMargin,-height/2 ), sf::Vector2f(imageWidth - rightMargin,0 )),
|
sf::Vertex( sf::Vector2f(+width/2 - rightMargin,-height/2 ), sf::Vector2f(imageWidth - rightMargin,0 )),
|
||||||
sf::Vertex( sf::Vector2f(+width/2 - rightMargin,-height/2 + topMargin ), sf::Vector2f(imageWidth - rightMargin,topMargin )),
|
sf::Vertex( sf::Vector2f(+width/2 - rightMargin,-height/2 + topMargin ), sf::Vector2f(imageWidth - rightMargin,topMargin )),
|
||||||
sf::Vertex( sf::Vector2f(-width/2 + leftMargin ,-height/2 + topMargin ), sf::Vector2f(leftMargin ,topMargin )),
|
|
||||||
|
|
||||||
//Top-right
|
//Top-right
|
||||||
sf::Vertex( sf::Vector2f(+width/2 - rightMargin,-height/2 ), sf::Vector2f(imageWidth - rightMargin,0 )),
|
|
||||||
sf::Vertex( sf::Vector2f(+width/2 ,-height/2 ), sf::Vector2f(imageWidth ,0 )),
|
sf::Vertex( sf::Vector2f(+width/2 ,-height/2 ), sf::Vector2f(imageWidth ,0 )),
|
||||||
sf::Vertex( sf::Vector2f(+width/2 ,-height/2 + topMargin ), sf::Vector2f(imageWidth ,topMargin )),
|
sf::Vertex( sf::Vector2f(+width/2 ,-height/2 + topMargin ), sf::Vector2f(imageWidth ,topMargin )),
|
||||||
sf::Vertex( sf::Vector2f(+width/2 - rightMargin,-height/2 + topMargin ), sf::Vector2f(imageWidth - rightMargin,topMargin )),
|
};
|
||||||
|
|
||||||
//Right
|
sf::Vertex rightVertices[] = {
|
||||||
sf::Vertex( sf::Vector2f(+width/2 - rightMargin,-height/2 + topMargin ), sf::Vector2f(imageWidth - rightMargin,topMargin )),
|
sf::Vertex( sf::Vector2f(+width/2 - rightMargin,-height/2 + topMargin ), sf::Vector2f(imageWidth - rightMargin,topMargin )),
|
||||||
sf::Vertex( sf::Vector2f(+width/2 ,-height/2 + topMargin ), sf::Vector2f(imageWidth ,topMargin )),
|
sf::Vertex( sf::Vector2f(+width/2 ,-height/2 + topMargin ), sf::Vector2f(imageWidth ,topMargin )),
|
||||||
sf::Vertex( sf::Vector2f(+width/2 ,+height/2 - bottomMargin), sf::Vector2f(imageWidth ,imageHeight - bottomMargin)),
|
|
||||||
sf::Vertex( sf::Vector2f(+width/2 - rightMargin,+height/2 - bottomMargin), sf::Vector2f(imageWidth - rightMargin,imageHeight - bottomMargin)),
|
sf::Vertex( sf::Vector2f(+width/2 - rightMargin,+height/2 - bottomMargin), sf::Vector2f(imageWidth - rightMargin,imageHeight - bottomMargin)),
|
||||||
|
sf::Vertex( sf::Vector2f(+width/2 ,+height/2 - bottomMargin), sf::Vector2f(imageWidth ,imageHeight - bottomMargin))
|
||||||
|
};
|
||||||
|
|
||||||
|
sf::Vertex bottomVertices[] = {
|
||||||
//Bottom-left
|
//Bottom-left
|
||||||
sf::Vertex( sf::Vector2f(-width/2 ,+height/2 - bottomMargin), sf::Vector2f(0 ,imageHeight - bottomMargin)),
|
sf::Vertex( sf::Vector2f(-width/2 ,+height/2 - bottomMargin), sf::Vector2f(0 ,imageHeight - bottomMargin)),
|
||||||
|
sf::Vertex( sf::Vector2f(-width/2 ,+height/2 ), sf::Vector2f(0 ,imageHeight )),
|
||||||
sf::Vertex( sf::Vector2f(-width/2 + leftMargin ,+height/2 - bottomMargin), sf::Vector2f(leftMargin ,imageHeight - bottomMargin)),
|
sf::Vertex( sf::Vector2f(-width/2 + leftMargin ,+height/2 - bottomMargin), sf::Vector2f(leftMargin ,imageHeight - bottomMargin)),
|
||||||
sf::Vertex( sf::Vector2f(-width/2 + leftMargin ,+height/2 ), sf::Vector2f(leftMargin ,imageHeight )),
|
sf::Vertex( sf::Vector2f(-width/2 + leftMargin ,+height/2 ), sf::Vector2f(leftMargin ,imageHeight )),
|
||||||
sf::Vertex( sf::Vector2f(-width/2 ,+height/2 ), sf::Vector2f(0 ,imageHeight )),
|
|
||||||
|
|
||||||
//Bottom
|
//Bottom
|
||||||
sf::Vertex( sf::Vector2f(-width/2 + leftMargin ,+height/2 - bottomMargin), sf::Vector2f(leftMargin ,imageHeight - bottomMargin)),
|
|
||||||
sf::Vertex( sf::Vector2f(+width/2 - rightMargin,+height/2 - bottomMargin), sf::Vector2f(imageWidth - rightMargin,imageHeight - bottomMargin)),
|
sf::Vertex( sf::Vector2f(+width/2 - rightMargin,+height/2 - bottomMargin), sf::Vector2f(imageWidth - rightMargin,imageHeight - bottomMargin)),
|
||||||
sf::Vertex( sf::Vector2f(+width/2 - rightMargin,+height/2 ), sf::Vector2f(imageWidth - rightMargin,imageHeight )),
|
sf::Vertex( sf::Vector2f(+width/2 - rightMargin,+height/2 ), sf::Vector2f(imageWidth - rightMargin,imageHeight )),
|
||||||
sf::Vertex( sf::Vector2f(-width/2 + leftMargin ,+height/2 ), sf::Vector2f(leftMargin ,imageHeight )),
|
|
||||||
|
|
||||||
//Bottom-right
|
//Bottom-right
|
||||||
sf::Vertex( sf::Vector2f(+width/2 - rightMargin,+height/2 - bottomMargin), sf::Vector2f(imageWidth - rightMargin,imageHeight - bottomMargin)),
|
|
||||||
sf::Vertex( sf::Vector2f(+width/2 ,+height/2 - bottomMargin), sf::Vector2f(imageWidth ,imageHeight - bottomMargin)),
|
sf::Vertex( sf::Vector2f(+width/2 ,+height/2 - bottomMargin), sf::Vector2f(imageWidth ,imageHeight - bottomMargin)),
|
||||||
sf::Vertex( sf::Vector2f(+width/2 ,+height/2 ), sf::Vector2f(imageWidth ,imageHeight )),
|
sf::Vertex( sf::Vector2f(+width/2 ,+height/2 ), sf::Vector2f(imageWidth ,imageHeight ))
|
||||||
sf::Vertex( sf::Vector2f(+width/2 - rightMargin,+height/2 ), sf::Vector2f(imageWidth - rightMargin,imageHeight )),
|
};
|
||||||
|
|
||||||
//Left
|
sf::Vertex leftVertices[] = {
|
||||||
sf::Vertex( sf::Vector2f(-width/2 ,-height/2 + topMargin ), sf::Vector2f(0 ,topMargin )),
|
sf::Vertex( sf::Vector2f(-width/2 ,-height/2 + topMargin ), sf::Vector2f(0 ,topMargin )),
|
||||||
sf::Vertex( sf::Vector2f(-width/2 + leftMargin ,-height/2 + topMargin ), sf::Vector2f(leftMargin ,topMargin )),
|
sf::Vertex( sf::Vector2f(-width/2 + leftMargin ,-height/2 + topMargin ), sf::Vector2f(leftMargin ,topMargin )),
|
||||||
sf::Vertex( sf::Vector2f(-width/2 + leftMargin ,+height/2 - bottomMargin), sf::Vector2f(leftMargin ,imageHeight - bottomMargin)),
|
|
||||||
sf::Vertex( sf::Vector2f(-width/2 ,+height/2 - bottomMargin), sf::Vector2f(0 ,imageHeight - bottomMargin)),
|
sf::Vertex( sf::Vector2f(-width/2 ,+height/2 - bottomMargin), sf::Vector2f(0 ,imageHeight - bottomMargin)),
|
||||||
|
sf::Vertex( sf::Vector2f(-width/2 + leftMargin ,+height/2 - bottomMargin), sf::Vector2f(leftMargin ,imageHeight - bottomMargin))
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
sf::Transform matrix;
|
sf::Transform matrix;
|
||||||
matrix.translate(centerPosition);
|
matrix.translate(centerPosition);
|
||||||
matrix.rotate(angle);
|
matrix.rotate(angle);
|
||||||
@@ -176,7 +172,11 @@ bool RuntimePanelSpriteObject::Draw( sf::RenderTarget& window )
|
|||||||
states.transform = matrix;
|
states.transform = matrix;
|
||||||
states.texture = &texture->texture;
|
states.texture = &texture->texture;
|
||||||
|
|
||||||
window.draw(vertices, 36, sf::Quads, states);
|
window.draw(centerVertices, 4, sf::TrianglesStrip, states);
|
||||||
|
window.draw(leftVertices, 4, sf::TrianglesStrip, states);
|
||||||
|
window.draw(rightVertices, 4, sf::TrianglesStrip, states);
|
||||||
|
window.draw(topVertices, 8, sf::TrianglesStrip, states);
|
||||||
|
window.draw(bottomVertices, 8, sf::TrianglesStrip, states);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -199,66 +199,61 @@ void PanelSpriteObject::DrawInitialInstance(gd::InitialInstance & instance, sf::
|
|||||||
float width = instance.HasCustomSize() ? instance.GetCustomWidth() : GetInitialInstanceDefaultSize(instance, project, layout).x;
|
float width = instance.HasCustomSize() ? instance.GetCustomWidth() : GetInitialInstanceDefaultSize(instance, project, layout).x;
|
||||||
float height = instance.HasCustomSize() ? instance.GetCustomHeight() : GetInitialInstanceDefaultSize(instance, project, layout).y;
|
float height = instance.HasCustomSize() ? instance.GetCustomHeight() : GetInitialInstanceDefaultSize(instance, project, layout).y;
|
||||||
|
|
||||||
sf::Vertex vertices[] =
|
sf::Vertex centerVertices[] = {
|
||||||
{
|
|
||||||
//Center part (streched)
|
|
||||||
sf::Vertex( sf::Vector2f(-width/2 + leftMargin ,-height/2 + topMargin ), sf::Vector2f(leftMargin ,topMargin )),
|
sf::Vertex( sf::Vector2f(-width/2 + leftMargin ,-height/2 + topMargin ), sf::Vector2f(leftMargin ,topMargin )),
|
||||||
sf::Vertex( sf::Vector2f(+width/2 - rightMargin,-height/2 + topMargin ), sf::Vector2f(imageWidth - rightMargin,topMargin )),
|
sf::Vertex( sf::Vector2f(+width/2 - rightMargin,-height/2 + topMargin ), sf::Vector2f(imageWidth - rightMargin,topMargin )),
|
||||||
sf::Vertex( sf::Vector2f(+width/2 - rightMargin,+height/2 - bottomMargin), sf::Vector2f(imageWidth - rightMargin,imageHeight - bottomMargin)),
|
|
||||||
sf::Vertex( sf::Vector2f(-width/2 + leftMargin ,+height/2 - bottomMargin), sf::Vector2f(leftMargin ,imageHeight - bottomMargin)),
|
sf::Vertex( sf::Vector2f(-width/2 + leftMargin ,+height/2 - bottomMargin), sf::Vector2f(leftMargin ,imageHeight - bottomMargin)),
|
||||||
|
sf::Vertex( sf::Vector2f(+width/2 - rightMargin,+height/2 - bottomMargin), sf::Vector2f(imageWidth - rightMargin,imageHeight - bottomMargin)),
|
||||||
|
};
|
||||||
|
|
||||||
|
sf::Vertex topVertices[] = {
|
||||||
//Top-left
|
//Top-left
|
||||||
sf::Vertex( sf::Vector2f(-width/2 ,-height/2 ), sf::Vector2f(0 ,0 )),
|
sf::Vertex( sf::Vector2f(-width/2 ,-height/2 ), sf::Vector2f(0 ,0 )),
|
||||||
|
sf::Vertex( sf::Vector2f(-width/2 ,-height/2 + topMargin ), sf::Vector2f(0 ,topMargin )),
|
||||||
sf::Vertex( sf::Vector2f(-width/2 + leftMargin ,-height/2 ), sf::Vector2f(leftMargin ,0 )),
|
sf::Vertex( sf::Vector2f(-width/2 + leftMargin ,-height/2 ), sf::Vector2f(leftMargin ,0 )),
|
||||||
sf::Vertex( sf::Vector2f(-width/2 + leftMargin ,-height/2 + topMargin ), sf::Vector2f(leftMargin ,topMargin )),
|
sf::Vertex( sf::Vector2f(-width/2 + leftMargin ,-height/2 + topMargin ), sf::Vector2f(leftMargin ,topMargin )),
|
||||||
sf::Vertex( sf::Vector2f(-width/2 ,-height/2 + topMargin ), sf::Vector2f(0 ,topMargin )),
|
|
||||||
|
|
||||||
//Top
|
//Top
|
||||||
sf::Vertex( sf::Vector2f(-width/2 + leftMargin ,-height/2 ), sf::Vector2f(leftMargin ,0 )),
|
|
||||||
sf::Vertex( sf::Vector2f(+width/2 - rightMargin,-height/2 ), sf::Vector2f(imageWidth - rightMargin,0 )),
|
sf::Vertex( sf::Vector2f(+width/2 - rightMargin,-height/2 ), sf::Vector2f(imageWidth - rightMargin,0 )),
|
||||||
sf::Vertex( sf::Vector2f(+width/2 - rightMargin,-height/2 + topMargin ), sf::Vector2f(imageWidth - rightMargin,topMargin )),
|
sf::Vertex( sf::Vector2f(+width/2 - rightMargin,-height/2 + topMargin ), sf::Vector2f(imageWidth - rightMargin,topMargin )),
|
||||||
sf::Vertex( sf::Vector2f(-width/2 + leftMargin ,-height/2 + topMargin ), sf::Vector2f(leftMargin ,topMargin )),
|
|
||||||
|
|
||||||
//Top-right
|
//Top-right
|
||||||
sf::Vertex( sf::Vector2f(+width/2 - rightMargin,-height/2 ), sf::Vector2f(imageWidth - rightMargin,0 )),
|
|
||||||
sf::Vertex( sf::Vector2f(+width/2 ,-height/2 ), sf::Vector2f(imageWidth ,0 )),
|
sf::Vertex( sf::Vector2f(+width/2 ,-height/2 ), sf::Vector2f(imageWidth ,0 )),
|
||||||
sf::Vertex( sf::Vector2f(+width/2 ,-height/2 + topMargin ), sf::Vector2f(imageWidth ,topMargin )),
|
sf::Vertex( sf::Vector2f(+width/2 ,-height/2 + topMargin ), sf::Vector2f(imageWidth ,topMargin )),
|
||||||
sf::Vertex( sf::Vector2f(+width/2 - rightMargin,-height/2 + topMargin ), sf::Vector2f(imageWidth - rightMargin,topMargin )),
|
};
|
||||||
|
|
||||||
//Right
|
sf::Vertex rightVertices[] = {
|
||||||
sf::Vertex( sf::Vector2f(+width/2 - rightMargin,-height/2 + topMargin ), sf::Vector2f(imageWidth - rightMargin,topMargin )),
|
sf::Vertex( sf::Vector2f(+width/2 - rightMargin,-height/2 + topMargin ), sf::Vector2f(imageWidth - rightMargin,topMargin )),
|
||||||
sf::Vertex( sf::Vector2f(+width/2 ,-height/2 + topMargin ), sf::Vector2f(imageWidth ,topMargin )),
|
sf::Vertex( sf::Vector2f(+width/2 ,-height/2 + topMargin ), sf::Vector2f(imageWidth ,topMargin )),
|
||||||
sf::Vertex( sf::Vector2f(+width/2 ,+height/2 - bottomMargin), sf::Vector2f(imageWidth ,imageHeight - bottomMargin)),
|
|
||||||
sf::Vertex( sf::Vector2f(+width/2 - rightMargin,+height/2 - bottomMargin), sf::Vector2f(imageWidth - rightMargin,imageHeight - bottomMargin)),
|
sf::Vertex( sf::Vector2f(+width/2 - rightMargin,+height/2 - bottomMargin), sf::Vector2f(imageWidth - rightMargin,imageHeight - bottomMargin)),
|
||||||
|
sf::Vertex( sf::Vector2f(+width/2 ,+height/2 - bottomMargin), sf::Vector2f(imageWidth ,imageHeight - bottomMargin))
|
||||||
|
};
|
||||||
|
|
||||||
|
sf::Vertex bottomVertices[] = {
|
||||||
//Bottom-left
|
//Bottom-left
|
||||||
sf::Vertex( sf::Vector2f(-width/2 ,+height/2 - bottomMargin), sf::Vector2f(0 ,imageHeight - bottomMargin)),
|
sf::Vertex( sf::Vector2f(-width/2 ,+height/2 - bottomMargin), sf::Vector2f(0 ,imageHeight - bottomMargin)),
|
||||||
|
sf::Vertex( sf::Vector2f(-width/2 ,+height/2 ), sf::Vector2f(0 ,imageHeight )),
|
||||||
sf::Vertex( sf::Vector2f(-width/2 + leftMargin ,+height/2 - bottomMargin), sf::Vector2f(leftMargin ,imageHeight - bottomMargin)),
|
sf::Vertex( sf::Vector2f(-width/2 + leftMargin ,+height/2 - bottomMargin), sf::Vector2f(leftMargin ,imageHeight - bottomMargin)),
|
||||||
sf::Vertex( sf::Vector2f(-width/2 + leftMargin ,+height/2 ), sf::Vector2f(leftMargin ,imageHeight )),
|
sf::Vertex( sf::Vector2f(-width/2 + leftMargin ,+height/2 ), sf::Vector2f(leftMargin ,imageHeight )),
|
||||||
sf::Vertex( sf::Vector2f(-width/2 ,+height/2 ), sf::Vector2f(0 ,imageHeight )),
|
|
||||||
|
|
||||||
//Bottom
|
//Bottom
|
||||||
sf::Vertex( sf::Vector2f(-width/2 + leftMargin ,+height/2 - bottomMargin), sf::Vector2f(leftMargin ,imageHeight - bottomMargin)),
|
|
||||||
sf::Vertex( sf::Vector2f(+width/2 - rightMargin,+height/2 - bottomMargin), sf::Vector2f(imageWidth - rightMargin,imageHeight - bottomMargin)),
|
sf::Vertex( sf::Vector2f(+width/2 - rightMargin,+height/2 - bottomMargin), sf::Vector2f(imageWidth - rightMargin,imageHeight - bottomMargin)),
|
||||||
sf::Vertex( sf::Vector2f(+width/2 - rightMargin,+height/2 ), sf::Vector2f(imageWidth - rightMargin,imageHeight )),
|
sf::Vertex( sf::Vector2f(+width/2 - rightMargin,+height/2 ), sf::Vector2f(imageWidth - rightMargin,imageHeight )),
|
||||||
sf::Vertex( sf::Vector2f(-width/2 + leftMargin ,+height/2 ), sf::Vector2f(leftMargin ,imageHeight )),
|
|
||||||
|
|
||||||
//Bottom-right
|
//Bottom-right
|
||||||
sf::Vertex( sf::Vector2f(+width/2 - rightMargin,+height/2 - bottomMargin), sf::Vector2f(imageWidth - rightMargin,imageHeight - bottomMargin)),
|
|
||||||
sf::Vertex( sf::Vector2f(+width/2 ,+height/2 - bottomMargin), sf::Vector2f(imageWidth ,imageHeight - bottomMargin)),
|
sf::Vertex( sf::Vector2f(+width/2 ,+height/2 - bottomMargin), sf::Vector2f(imageWidth ,imageHeight - bottomMargin)),
|
||||||
sf::Vertex( sf::Vector2f(+width/2 ,+height/2 ), sf::Vector2f(imageWidth ,imageHeight )),
|
sf::Vertex( sf::Vector2f(+width/2 ,+height/2 ), sf::Vector2f(imageWidth ,imageHeight ))
|
||||||
sf::Vertex( sf::Vector2f(+width/2 - rightMargin,+height/2 ), sf::Vector2f(imageWidth - rightMargin,imageHeight )),
|
};
|
||||||
|
|
||||||
//Left
|
sf::Vertex leftVertices[] = {
|
||||||
sf::Vertex( sf::Vector2f(-width/2 ,-height/2 + topMargin ), sf::Vector2f(0 ,topMargin )),
|
sf::Vertex( sf::Vector2f(-width/2 ,-height/2 + topMargin ), sf::Vector2f(0 ,topMargin )),
|
||||||
sf::Vertex( sf::Vector2f(-width/2 + leftMargin ,-height/2 + topMargin ), sf::Vector2f(leftMargin ,topMargin )),
|
sf::Vertex( sf::Vector2f(-width/2 + leftMargin ,-height/2 + topMargin ), sf::Vector2f(leftMargin ,topMargin )),
|
||||||
sf::Vertex( sf::Vector2f(-width/2 + leftMargin ,+height/2 - bottomMargin), sf::Vector2f(leftMargin ,imageHeight - bottomMargin)),
|
|
||||||
sf::Vertex( sf::Vector2f(-width/2 ,+height/2 - bottomMargin), sf::Vector2f(0 ,imageHeight - bottomMargin)),
|
sf::Vertex( sf::Vector2f(-width/2 ,+height/2 - bottomMargin), sf::Vector2f(0 ,imageHeight - bottomMargin)),
|
||||||
|
sf::Vertex( sf::Vector2f(-width/2 + leftMargin ,+height/2 - bottomMargin), sf::Vector2f(leftMargin ,imageHeight - bottomMargin))
|
||||||
};
|
};
|
||||||
sf::Vector2f centerPosition = sf::Vector2f(instance.GetX()+width/2, instance.GetY()+height/2);
|
|
||||||
|
|
||||||
sf::Transform matrix;
|
sf::Transform matrix;
|
||||||
|
sf::Vector2f centerPosition = sf::Vector2f(instance.GetX()+width/2, instance.GetY()+height/2);
|
||||||
matrix.translate(centerPosition);
|
matrix.translate(centerPosition);
|
||||||
matrix.rotate(instance.GetAngle());
|
matrix.rotate(instance.GetAngle());
|
||||||
|
|
||||||
@@ -266,9 +261,11 @@ void PanelSpriteObject::DrawInitialInstance(gd::InitialInstance & instance, sf::
|
|||||||
states.transform = matrix;
|
states.transform = matrix;
|
||||||
states.texture = &texture->texture;
|
states.texture = &texture->texture;
|
||||||
|
|
||||||
renderTarget.draw(vertices, 36, sf::Quads, states);
|
renderTarget.draw(centerVertices, 4, sf::TrianglesStrip, states);
|
||||||
|
renderTarget.draw(leftVertices, 4, sf::TrianglesStrip, states);
|
||||||
return;
|
renderTarget.draw(rightVertices, 4, sf::TrianglesStrip, states);
|
||||||
|
renderTarget.draw(topVertices, 8, sf::TrianglesStrip, states);
|
||||||
|
renderTarget.draw(bottomVertices, 8, sf::TrianglesStrip, states);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PanelSpriteObject::ExposeResources(gd::ArbitraryResourceWorker & worker)
|
void PanelSpriteObject::ExposeResources(gd::ArbitraryResourceWorker & worker)
|
||||||
|
@@ -110,12 +110,14 @@ bool RuntimeTiledSpriteObject::Draw( sf::RenderTarget& window )
|
|||||||
sf::Vector2f centerPosition = sf::Vector2f(GetX()+GetCenterX(),GetY()+GetCenterY());
|
sf::Vector2f centerPosition = sf::Vector2f(GetX()+GetCenterX(),GetY()+GetCenterY());
|
||||||
float angleInRad = angle*3.14159/180.0;
|
float angleInRad = angle*3.14159/180.0;
|
||||||
texture->texture.setRepeated(true);
|
texture->texture.setRepeated(true);
|
||||||
sf::Vertex vertices[] = {sf::Vertex( centerPosition+RotatePoint(sf::Vector2f(-width/2,-height/2), angleInRad), sf::Vector2f(0+xOffset,0+yOffset)),
|
sf::Vertex vertices[] = {
|
||||||
sf::Vertex( centerPosition+RotatePoint(sf::Vector2f(+width/2,-height/2), angleInRad), sf::Vector2f(width+xOffset,0+yOffset)),
|
sf::Vertex( centerPosition+RotatePoint(sf::Vector2f(-width/2,-height/2), angleInRad), sf::Vector2f(0+xOffset,0+yOffset)),
|
||||||
sf::Vertex( centerPosition+RotatePoint(sf::Vector2f(+width/2,+height/2), angleInRad), sf::Vector2f(width+xOffset, height+yOffset)),
|
sf::Vertex( centerPosition+RotatePoint(sf::Vector2f(+width/2,-height/2), angleInRad), sf::Vector2f(width+xOffset,0+yOffset)),
|
||||||
sf::Vertex( centerPosition+RotatePoint(sf::Vector2f(-width/2,+height/2), angleInRad), sf::Vector2f(0+xOffset, height+yOffset))};
|
sf::Vertex( centerPosition+RotatePoint(sf::Vector2f(-width/2,+height/2), angleInRad), sf::Vector2f(0+xOffset, height+yOffset)),
|
||||||
|
sf::Vertex( centerPosition+RotatePoint(sf::Vector2f(+width/2,+height/2), angleInRad), sf::Vector2f(width+xOffset, height+yOffset))
|
||||||
|
};
|
||||||
|
|
||||||
window.draw(vertices, 4, sf::Quads, &texture->texture);
|
window.draw(vertices, 4, sf::TrianglesStrip, &texture->texture);
|
||||||
texture->texture.setRepeated(false);
|
texture->texture.setRepeated(false);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -142,12 +144,14 @@ void TiledSpriteObject::DrawInitialInstance(gd::InitialInstance & instance, sf::
|
|||||||
sf::Vector2f centerPosition = sf::Vector2f(instance.GetX()+width/2, instance.GetY()+height/2);
|
sf::Vector2f centerPosition = sf::Vector2f(instance.GetX()+width/2, instance.GetY()+height/2);
|
||||||
float angleInRad = instance.GetAngle()*3.14159/180.0;
|
float angleInRad = instance.GetAngle()*3.14159/180.0;
|
||||||
texture->texture.setRepeated(true);
|
texture->texture.setRepeated(true);
|
||||||
sf::Vertex vertices[] = {sf::Vertex( centerPosition+RotatePoint(sf::Vector2f(-width/2,-height/2), angleInRad), sf::Vector2f(0+xOffset,0+yOffset)),
|
sf::Vertex vertices[] = {
|
||||||
sf::Vertex( centerPosition+RotatePoint(sf::Vector2f(+width/2,-height/2), angleInRad), sf::Vector2f(width+xOffset,0+yOffset)),
|
sf::Vertex( centerPosition+RotatePoint(sf::Vector2f(-width/2,-height/2), angleInRad), sf::Vector2f(0+xOffset,0+yOffset)),
|
||||||
sf::Vertex( centerPosition+RotatePoint(sf::Vector2f(+width/2,+height/2), angleInRad), sf::Vector2f(width+xOffset, height+yOffset)),
|
sf::Vertex( centerPosition+RotatePoint(sf::Vector2f(+width/2,-height/2), angleInRad), sf::Vector2f(width+xOffset,0+yOffset)),
|
||||||
sf::Vertex( centerPosition+RotatePoint(sf::Vector2f(-width/2,+height/2), angleInRad), sf::Vector2f(0+xOffset, height+yOffset))};
|
sf::Vertex( centerPosition+RotatePoint(sf::Vector2f(-width/2,+height/2), angleInRad), sf::Vector2f(0+xOffset, height+yOffset)),
|
||||||
|
sf::Vertex( centerPosition+RotatePoint(sf::Vector2f(+width/2,+height/2), angleInRad), sf::Vector2f(width+xOffset, height+yOffset))
|
||||||
|
};
|
||||||
|
|
||||||
renderTarget.draw(vertices, 4, sf::Quads, &texture->texture);
|
renderTarget.draw(vertices, 4, sf::TrianglesStrip, &texture->texture);
|
||||||
texture->texture.setRepeated(false);
|
texture->texture.setRepeated(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user