Changed the type of Vertex::TexCoords from integers to floats, to make it compatible with buggy ATI drivers
This commit is contained in:
parent
5a4e8d58af
commit
b65b19343a
6 changed files with 40 additions and 36 deletions
|
@ -201,7 +201,7 @@ void RenderTarget::Draw(const Vertex* vertices, unsigned int verticesCount,
|
|||
const char* data = reinterpret_cast<const char*>(vertices);
|
||||
GLCheck(glVertexPointer(2, GL_FLOAT, sizeof(Vertex), data + 0));
|
||||
GLCheck(glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(Vertex), data + 8));
|
||||
GLCheck(glTexCoordPointer(2, GL_INT, sizeof(Vertex), data + 12));
|
||||
GLCheck(glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex), data + 12));
|
||||
|
||||
// Find the OpenGL primitive type
|
||||
static const GLenum modes[] = {GL_POINTS, GL_LINES, GL_LINE_STRIP,
|
||||
|
|
|
@ -239,8 +239,8 @@ void Shape::UpdateTexCoords()
|
|||
{
|
||||
float xratio = (myVertices[i].Position.x - myInsideBounds.Left) / myInsideBounds.Width;
|
||||
float yratio = (myVertices[i].Position.y - myInsideBounds.Top) / myInsideBounds.Height;
|
||||
myVertices[i].TexCoords.x = static_cast<int>(myTextureRect.Left + myTextureRect.Width * xratio);
|
||||
myVertices[i].TexCoords.y = static_cast<int>(myTextureRect.Top + myTextureRect.Height * yratio);
|
||||
myVertices[i].TexCoords.x = myTextureRect.Left + myTextureRect.Width * xratio;
|
||||
myVertices[i].TexCoords.y = myTextureRect.Top + myTextureRect.Height * yratio;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -160,15 +160,15 @@ void Sprite::UpdatePositions()
|
|||
////////////////////////////////////////////////////////////
|
||||
void Sprite::UpdateTexCoords()
|
||||
{
|
||||
int left = myTextureRect.Left;
|
||||
int right = myTextureRect.Left + myTextureRect.Width;
|
||||
int top = myTextureRect.Top;
|
||||
int bottom = myTextureRect.Top + myTextureRect.Height;
|
||||
float left = static_cast<float>(myTextureRect.Left);
|
||||
float right = left + myTextureRect.Width;
|
||||
float top = static_cast<float>(myTextureRect.Top);
|
||||
float bottom = top + myTextureRect.Height;
|
||||
|
||||
myVertices[0].TexCoords = Vector2i(left, top);
|
||||
myVertices[1].TexCoords = Vector2i(left, bottom);
|
||||
myVertices[2].TexCoords = Vector2i(right, bottom);
|
||||
myVertices[3].TexCoords = Vector2i(right, top);
|
||||
myVertices[0].TexCoords = Vector2f(left, top);
|
||||
myVertices[1].TexCoords = Vector2f(left, bottom);
|
||||
myVertices[2].TexCoords = Vector2f(right, bottom);
|
||||
myVertices[3].TexCoords = Vector2f(right, top);
|
||||
}
|
||||
|
||||
} // namespace sf
|
||||
|
|
|
@ -260,10 +260,10 @@ void Text::UpdateGeometry()
|
|||
float top = y + underlineOffset;
|
||||
float bottom = top + underlineThickness;
|
||||
|
||||
myVertices.Append(Vertex(Vector2f(0, top), myColor, Vector2i(1, 1)));
|
||||
myVertices.Append(Vertex(Vector2f(x, top), myColor, Vector2i(2, 1)));
|
||||
myVertices.Append(Vertex(Vector2f(x, bottom), myColor, Vector2i(2, 2)));
|
||||
myVertices.Append(Vertex(Vector2f(0, bottom), myColor, Vector2i(1, 2)));
|
||||
myVertices.Append(Vertex(Vector2f(0, top), myColor, Vector2f(1, 1)));
|
||||
myVertices.Append(Vertex(Vector2f(x, top), myColor, Vector2f(2, 1)));
|
||||
myVertices.Append(Vertex(Vector2f(x, bottom), myColor, Vector2f(2, 2)));
|
||||
myVertices.Append(Vertex(Vector2f(0, bottom), myColor, Vector2f(1, 2)));
|
||||
}
|
||||
|
||||
// Handle special characters
|
||||
|
@ -283,16 +283,16 @@ void Text::UpdateGeometry()
|
|||
int right = glyph.Bounds.Left + glyph.Bounds.Width;
|
||||
int bottom = glyph.Bounds.Top + glyph.Bounds.Height;
|
||||
|
||||
int u1 = glyph.TextureRect.Left;
|
||||
int v1 = glyph.TextureRect.Top;
|
||||
int u2 = glyph.TextureRect.Left + glyph.TextureRect.Width;
|
||||
int v2 = glyph.TextureRect.Top + glyph.TextureRect.Height;
|
||||
float u1 = static_cast<float>(glyph.TextureRect.Left);
|
||||
float v1 = static_cast<float>(glyph.TextureRect.Top);
|
||||
float u2 = static_cast<float>(glyph.TextureRect.Left + glyph.TextureRect.Width);
|
||||
float v2 = static_cast<float>(glyph.TextureRect.Top + glyph.TextureRect.Height);
|
||||
|
||||
// Add a quad for the current character
|
||||
myVertices.Append(Vertex(Vector2f(x + left - italic * top, y + top), myColor, Vector2i(u1, v1)));
|
||||
myVertices.Append(Vertex(Vector2f(x + right - italic * top, y + top), myColor, Vector2i(u2, v1)));
|
||||
myVertices.Append(Vertex(Vector2f(x + right - italic * bottom, y + bottom), myColor, Vector2i(u2, v2)));
|
||||
myVertices.Append(Vertex(Vector2f(x + left - italic * bottom, y + bottom), myColor, Vector2i(u1, v2)));
|
||||
myVertices.Append(Vertex(Vector2f(x + left - italic * top, y + top), myColor, Vector2f(u1, v1)));
|
||||
myVertices.Append(Vertex(Vector2f(x + right - italic * top, y + top), myColor, Vector2f(u2, v1)));
|
||||
myVertices.Append(Vertex(Vector2f(x + right - italic * bottom, y + bottom), myColor, Vector2f(u2, v2)));
|
||||
myVertices.Append(Vertex(Vector2f(x + left - italic * bottom, y + bottom), myColor, Vector2f(u1, v2)));
|
||||
|
||||
// Advance to the next character
|
||||
x += glyph.Advance;
|
||||
|
@ -304,10 +304,10 @@ void Text::UpdateGeometry()
|
|||
float top = y + underlineOffset;
|
||||
float bottom = top + underlineThickness;
|
||||
|
||||
myVertices.Append(Vertex(Vector2f(0, top), myColor, Vector2i(1, 1)));
|
||||
myVertices.Append(Vertex(Vector2f(x, top), myColor, Vector2i(2, 1)));
|
||||
myVertices.Append(Vertex(Vector2f(x, bottom), myColor, Vector2i(2, 2)));
|
||||
myVertices.Append(Vertex(Vector2f(0, bottom), myColor, Vector2i(1, 2)));
|
||||
myVertices.Append(Vertex(Vector2f(0, top), myColor, Vector2f(1, 1)));
|
||||
myVertices.Append(Vertex(Vector2f(x, top), myColor, Vector2f(2, 1)));
|
||||
myVertices.Append(Vertex(Vector2f(x, bottom), myColor, Vector2f(2, 2)));
|
||||
myVertices.Append(Vertex(Vector2f(0, bottom), myColor, Vector2f(1, 2)));
|
||||
}
|
||||
|
||||
// Recompute the bounding rectangle
|
||||
|
|
|
@ -58,7 +58,7 @@ TexCoords(0, 0)
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
Vertex::Vertex(const Vector2f& position, const Vector2i& texCoords) :
|
||||
Vertex::Vertex(const Vector2f& position, const Vector2f& texCoords) :
|
||||
Position (position),
|
||||
Color (255, 255, 255),
|
||||
TexCoords(texCoords)
|
||||
|
@ -67,7 +67,7 @@ TexCoords(texCoords)
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
Vertex::Vertex(const Vector2f& position, const sf::Color& color, const Vector2i& texCoords) :
|
||||
Vertex::Vertex(const Vector2f& position, const sf::Color& color, const Vector2f& texCoords) :
|
||||
Position (position),
|
||||
Color (color),
|
||||
TexCoords(texCoords)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue