mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-01-11 22:53:34 +00:00
adding transformations
This commit is contained in:
@@ -36,7 +36,7 @@ namespace mlx
|
||||
|
||||
Handle NewTexture(int w, int h);
|
||||
Handle NewStbTexture(char* file, int* w, int* h); // stb textures are image files (png, jpg, bpm, ...)
|
||||
inline void TexturePut(Handle win, Handle img, int x, int y);
|
||||
inline void TexturePut(Handle win, Handle img, int x, int y, float scale, float angle);
|
||||
inline int GetTexturePixel(Handle img, int x, int y);
|
||||
inline void SetTexturePixel(Handle img, int x, int y, std::uint32_t color);
|
||||
void DestroyTexture(Handle ptr);
|
||||
|
||||
@@ -169,7 +169,7 @@ namespace mlx
|
||||
}
|
||||
}
|
||||
|
||||
void Application::TexturePut(Handle win, Handle img, int x, int y)
|
||||
void Application::TexturePut(Handle win, Handle img, int x, int y, float scale, float angle)
|
||||
{
|
||||
MLX_PROFILE_FUNCTION();
|
||||
CHECK_WINDOW_PTR(win);
|
||||
@@ -178,7 +178,7 @@ namespace mlx
|
||||
if(!texture->IsInit())
|
||||
Error("trying to put a texture that has been destroyed");
|
||||
else
|
||||
m_graphics[*static_cast<int*>(win)]->TexturePut(texture, x, y);
|
||||
m_graphics[*static_cast<int*>(win)]->TexturePut(texture, x, y, scale, angle);
|
||||
}
|
||||
|
||||
int Application::GetTexturePixel(Handle img, int x, int y)
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace mlx
|
||||
|
||||
inline void PixelPut(int x, int y, std::uint32_t color) noexcept;
|
||||
inline void StringPut(int x, int y, std::uint32_t color, std::string str);
|
||||
inline void TexturePut(NonOwningPtr<class Texture> texture, int x, int y);
|
||||
inline void TexturePut(NonOwningPtr<class Texture> texture, int x, int y, float scale, float angle);
|
||||
|
||||
inline void TryEraseSpritesInScene(NonOwningPtr<Texture> texture) noexcept;
|
||||
|
||||
|
||||
@@ -54,15 +54,16 @@ namespace mlx
|
||||
Text& new_text = p_scene->CreateText(str);
|
||||
new_text.SetPosition(Vec2f{ static_cast<float>(x), static_cast<float>(y) });
|
||||
new_text.SetColor(std::move(vec_color));
|
||||
new_text.SetCenter(Vec2f{ 0.0f, 0.0f });
|
||||
}
|
||||
else if(!p_scene->IsTextAtGivenDrawLayer(str, m_draw_layer))
|
||||
p_scene->BringToDrawLayer(text.Get(), m_draw_layer);
|
||||
}
|
||||
|
||||
void GraphicsSupport::TexturePut(NonOwningPtr<Texture> texture, int x, int y)
|
||||
void GraphicsSupport::TexturePut(NonOwningPtr<Texture> texture, int x, int y, float scale, float angle)
|
||||
{
|
||||
MLX_PROFILE_FUNCTION();
|
||||
NonOwningPtr<Sprite> sprite = p_scene->GetSpriteFromTextureAndPosition(texture, Vec2f{ static_cast<float>(x), static_cast<float>(y) });
|
||||
NonOwningPtr<Sprite> sprite = p_scene->GetSpriteFromTexturePositionScaleRotation(texture, Vec2f{ static_cast<float>(x), static_cast<float>(y) }, scale, angle);
|
||||
if(!sprite)
|
||||
{
|
||||
if(m_pixelput_called)
|
||||
@@ -72,7 +73,9 @@ namespace mlx
|
||||
}
|
||||
Sprite& new_sprite = p_scene->CreateSprite(texture);
|
||||
new_sprite.SetPosition(Vec2f{ static_cast<float>(x), static_cast<float>(y) });
|
||||
|
||||
new_sprite.SetScale(Vec2f{ scale, scale });
|
||||
new_sprite.SetRotation(angle);
|
||||
new_sprite.SetCenter(Vec2f{ texture->GetWidth() / 2.0f, texture->GetHeight() / 2.0f });
|
||||
}
|
||||
else if(!p_scene->IsTextureAtGivenDrawLayer(texture, m_draw_layer))
|
||||
p_scene->BringToDrawLayer(sprite.Get(), m_draw_layer);
|
||||
|
||||
@@ -30,13 +30,8 @@ namespace mlx
|
||||
|
||||
static void Report(LogType type, std::string message);
|
||||
static void Report(LogType type, unsigned int line, std::string_view file, std::string_view function, std::string message);
|
||||
static void BeginSection();
|
||||
static void EndSection();
|
||||
|
||||
~Logs() = delete;
|
||||
|
||||
private:
|
||||
static std::uint32_t s_nesting;
|
||||
};
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
Reference in New Issue
Block a user