Temp commit. Textures not working anymor :(

This commit is contained in:
Bram Verhulst
2024-03-27 11:40:44 +01:00
parent 61d1d17795
commit d441222173
43 changed files with 119 additions and 93 deletions

View File

@@ -216,7 +216,7 @@ void Texture::CreateFromSurface( SDL_Surface* pSurface )
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
}
void Texture::Draw( const Point2f& dstBottomLeft, const Rectf& srcRect ) const
void Texture::Draw( const Point2f& dstBottomLeft, const Rectf& srcRect, bool flip) const
{
const float epsilon{ 0.001f };
if ( !m_CreationOk )
@@ -242,7 +242,7 @@ void Texture::Draw( const Point2f& dstBottomLeft, const Rectf& srcRect ) const
}
}
void Texture::Draw( const Rectf& dstRect, const Rectf& srcRect ) const
void Texture::Draw( const Rectf& dstRect, const Rectf& srcRect, bool flip ) const
{
const float epsilon{ 0.001f };
if ( !m_CreationOk )
@@ -296,7 +296,9 @@ void Texture::Draw( const Rectf& dstRect, const Rectf& srcRect ) const
{
vertexRight = vertexLeft + dstRect.width;
vertexTop = vertexBottom + dstRect.height;
}
if(flip) {
std::swap(vertexLeft, vertexRight);
}
// Tell opengl which texture we will use

View File

@@ -13,8 +13,8 @@ public:
Texture& operator=( Texture&& other ) noexcept;
~Texture();
void Draw(const Point2f& dstBottomLeft = {}, const Rectf& srcRect = {}) const;
void Draw( const Rectf& dstRect, const Rectf& srcRect = {} ) const;
void Draw(const Point2f& dstBottomLeft = {}, const Rectf& srcRect = {}, bool flip = false) const;
void Draw( const Rectf& dstRect, const Rectf& srcRect = {}, bool flip = false) const;
float GetWidth() const;
float GetHeight() const;