Skip to content

Instantly share code, notes, and snippets.

@Bambofy
Last active April 12, 2020 12:46
Show Gist options
  • Save Bambofy/d7387fc8e86c4dd38971a42476c8bbaf to your computer and use it in GitHub Desktop.
Save Bambofy/d7387fc8e86c4dd38971a42476c8bbaf to your computer and use it in GitHub Desktop.
class Texture2DHighDPI
{
public:
Texture2DHighDPI(Texture2D * texture, Vector2 pos, Vector2 size);
void SetPosition(Vector2 pos);
void SetSize(Vector2 size);
void Draw();
private:
Texture2D * m_texture;
Vector2 m_position;
Vector2 m_size;
Vector2 m_origin = Vector2 { 0, 0 };
Rectangle m_sourceRec;
Rectangle m_destRec;
};
Texture2DHighDPI::Texture2DHighDPI(Texture2D * texture, Vector2 pos, Vector2 size) : m_texture(texture), m_position(pos), m_size(size)
{
m_destRec = { m_position.x, m_position.y, m_size.x, m_size.y };
m_sourceRec = { 0, 0, m_texture.width, m_texture.height };
}
void Texture2DHighDPI::SetPosition(Vector2 pos)
{
m_destRec.x = pos.x;
m_destRec.y = pos.y;
}
void Texture2DHighDPI::SetSize(Vector2 size)
{
m_destRec.width = size.x;
m_destRec.height = size.y;
}
void Texture2DHighDPI::Draw()
{
DrawTexturePro(*m_texture, m_sourceRec, m_destRec, m_origin, 0.0f, WHITE);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment