Files
2024-04-17 13:54:48 +02:00

43 lines
1.3 KiB
C++

#pragma once
#include "base.h"
class Texture final
{
public:
explicit Texture( const std::string& imagePath );
explicit Texture( const std::string& text, TTF_Font *pFont, const Color4f& textColor );
explicit Texture( const std::string& text, const std::string& fontPath, int ptSize, const Color4f& textColor );
Texture( const Texture& other ) = delete;
Texture& operator=( const Texture& other ) = delete;
Texture( Texture&& other ) noexcept;
Texture& operator=( Texture&& other ) noexcept;
~Texture();
void Draw(const Vector2f& 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;
bool IsCreationOk( ) const;
Rectf getSrcRect();
static int m_TextureCounter;
private:
//DATA MEMBERS
GLuint m_Id;
float m_Width;
float m_Height;
bool m_CreationOk;
// FUNCTIONS
void CreateFromImage( const std::string& path );
void CreateFromString( const std::string& text, TTF_Font *pFont, const Color4f& textColor );
void CreateFromString( const std::string& text, const std::string& fontPath, int ptSize, const Color4f& textColor );
void CreateFromSurface( SDL_Surface *pSurface );
SDL_Surface * STBImageLoad( const std::string& path );
void DrawFilledRect(const Rectf& dstRect) const;
};