mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-01-12 23:23:34 +00:00
adding std namespace to all libstd provided primitive types
This commit is contained in:
@@ -18,8 +18,8 @@ namespace mlx
|
||||
{
|
||||
static std::random_device random_device;
|
||||
static std::mt19937_64 engine(random_device());
|
||||
static std::uniform_int_distribution<uint64_t> uniform_distribution;
|
||||
static std::uniform_int_distribution<std::uint64_t> uniform_distribution;
|
||||
|
||||
UUID::UUID() : _uuid(uniform_distribution(engine)) {}
|
||||
UUID::UUID(uint64_t uuid) : _uuid(uuid) {}
|
||||
UUID::UUID(std::uint64_t uuid) : _uuid(uuid) {}
|
||||
}
|
||||
|
||||
@@ -21,12 +21,12 @@ namespace mlx
|
||||
{
|
||||
public:
|
||||
UUID();
|
||||
UUID(uint64_t uuid);
|
||||
UUID(std::uint64_t uuid);
|
||||
|
||||
inline operator uint64_t() const { return _uuid; }
|
||||
inline operator std::uint64_t() const { return _uuid; }
|
||||
|
||||
private:
|
||||
uint64_t _uuid;
|
||||
std::uint64_t _uuid;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/10/04 22:10:52 by maldavid #+# #+# */
|
||||
/* Updated: 2024/01/26 11:56:34 by maldavid ### ########.fr */
|
||||
/* Updated: 2024/02/25 07:52:04 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace mlx::core
|
||||
|
||||
void Application::run() noexcept
|
||||
{
|
||||
while(_in->is_running())
|
||||
while(_in->isRunning())
|
||||
{
|
||||
if(!_fps.update())
|
||||
continue;
|
||||
|
||||
@@ -40,20 +40,20 @@ namespace mlx::core
|
||||
|
||||
inline void getScreenSize(void* win, int* w, int* h) noexcept;
|
||||
|
||||
inline void setFPSCap(uint32_t fps) noexcept;
|
||||
inline void setFPSCap(std::uint32_t fps) noexcept;
|
||||
|
||||
inline void* newGraphicsSuport(std::size_t w, std::size_t h, const char* title);
|
||||
inline void clearGraphicsSupport(void* win);
|
||||
inline void destroyGraphicsSupport(void* win);
|
||||
|
||||
inline void pixelPut(void* win, int x, int y, uint32_t color) const noexcept;
|
||||
inline void stringPut(void* win, int x, int y, uint32_t color, char* str);
|
||||
inline void pixelPut(void* win, int x, int y, std::uint32_t color) const noexcept;
|
||||
inline void stringPut(void* win, int x, int y, std::uint32_t color, char* str);
|
||||
|
||||
void* newTexture(int w, int h);
|
||||
void* newStbTexture(char* file, int* w, int* h); // stb textures are format managed by stb image (png, jpg, bpm, ...)
|
||||
inline void texturePut(void* win, void* img, int x, int y);
|
||||
inline int getTexturePixel(void* img, int x, int y);
|
||||
inline void setTexturePixel(void* img, int x, int y, uint32_t color);
|
||||
inline void setTexturePixel(void* img, int x, int y, std::uint32_t color);
|
||||
void destroyTexture(void* ptr);
|
||||
|
||||
inline void loopHook(int (*f)(void*), void* param);
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace mlx::core
|
||||
*h = DM.h;
|
||||
}
|
||||
|
||||
void Application::setFPSCap(uint32_t fps) noexcept
|
||||
void Application::setFPSCap(std::uint32_t fps) noexcept
|
||||
{
|
||||
_fps.setMaxFPS(fps);
|
||||
}
|
||||
@@ -120,14 +120,14 @@ namespace mlx::core
|
||||
_graphics[*static_cast<int*>(win)].reset();
|
||||
}
|
||||
|
||||
void Application::pixelPut(void* win, int x, int y, uint32_t color) const noexcept
|
||||
void Application::pixelPut(void* win, int x, int y, std::uint32_t color) const noexcept
|
||||
{
|
||||
MLX_PROFILE_FUNCTION();
|
||||
CHECK_WINDOW_PTR(win);
|
||||
_graphics[*static_cast<int*>(win)]->pixelPut(x, y, color);
|
||||
}
|
||||
|
||||
void Application::stringPut(void* win, int x, int y, uint32_t color, char* str)
|
||||
void Application::stringPut(void* win, int x, int y, std::uint32_t color, char* str)
|
||||
{
|
||||
MLX_PROFILE_FUNCTION();
|
||||
CHECK_WINDOW_PTR(win);
|
||||
@@ -176,7 +176,7 @@ namespace mlx::core
|
||||
return texture->getPixel(x, y);
|
||||
}
|
||||
|
||||
void Application::setTexturePixel(void* img, int x, int y, uint32_t color)
|
||||
void Application::setTexturePixel(void* img, int x, int y, std::uint32_t color)
|
||||
{
|
||||
MLX_PROFILE_FUNCTION();
|
||||
CHECK_IMAGE_PTR(img, return);
|
||||
|
||||
@@ -300,7 +300,7 @@ extern "C"
|
||||
mlx::core::error::report(e_kind::error, "You cannot set a FPS cap to 0 (nice try)");
|
||||
return 0;
|
||||
}
|
||||
static_cast<mlx::core::Application*>(mlx)->setFPSCap(static_cast<uint32_t>(fps));
|
||||
static_cast<mlx::core::Application*>(mlx)->setFPSCap(static_cast<std::uint32_t>(fps));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,14 +20,14 @@ namespace mlx
|
||||
void FpsManager::init()
|
||||
{
|
||||
_timer = SDL_GetTicks64();
|
||||
_fps_before = static_cast<uint64_t>(std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::high_resolution_clock::now().time_since_epoch()).count());
|
||||
_fps_now = static_cast<uint64_t>(std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::high_resolution_clock::now().time_since_epoch()).count());
|
||||
_fps_before = static_cast<std::uint64_t>(std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::high_resolution_clock::now().time_since_epoch()).count());
|
||||
_fps_now = static_cast<std::uint64_t>(std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::high_resolution_clock::now().time_since_epoch()).count());
|
||||
}
|
||||
|
||||
bool FpsManager::update()
|
||||
{
|
||||
using namespace std::chrono_literals;
|
||||
_fps_now = static_cast<uint64_t>(std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::high_resolution_clock::now().time_since_epoch()).count());
|
||||
_fps_now = static_cast<std::uint64_t>(std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::high_resolution_clock::now().time_since_epoch()).count());
|
||||
|
||||
if(SDL_GetTicks64() - _timer > 1000)
|
||||
_timer += 1000;
|
||||
|
||||
@@ -24,17 +24,17 @@ namespace mlx
|
||||
|
||||
void init();
|
||||
bool update();
|
||||
inline void setMaxFPS(uint32_t fps) noexcept { _max_fps = fps; _ns = 1000000000.0 / fps; }
|
||||
inline void setMaxFPS(std::uint32_t fps) noexcept { _max_fps = fps; _ns = 1000000000.0 / fps; }
|
||||
|
||||
~FpsManager() = default;
|
||||
|
||||
private:
|
||||
double _ns = 1000000000.0 / 1'337'000.0;
|
||||
uint64_t _timer = 0;
|
||||
uint64_t _fps_before = 0;
|
||||
uint64_t _fps_now = 0;
|
||||
uint32_t _max_fps = 1'337'000;
|
||||
uint32_t _fps_elapsed_time = 0;
|
||||
std::uint64_t _timer = 0;
|
||||
std::uint64_t _fps_before = 0;
|
||||
std::uint64_t _fps_now = 0;
|
||||
std::uint32_t _max_fps = 1'337'000;
|
||||
std::uint32_t _fps_elapsed_time = 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace mlx
|
||||
|
||||
#ifdef GRAPHICS_MEMORY_DUMP
|
||||
// dump memory to file every two seconds
|
||||
static uint64_t timer = SDL_GetTicks64();
|
||||
static std::uint64_t timer = SDL_GetTicks64();
|
||||
if(SDL_GetTicks64() - timer > 2000)
|
||||
{
|
||||
Render_Core::get().getAllocator().dumpMemoryToJson();
|
||||
|
||||
@@ -45,8 +45,8 @@ namespace mlx
|
||||
void render() noexcept;
|
||||
|
||||
inline void clearRenderData() noexcept;
|
||||
inline void pixelPut(int x, int y, uint32_t color) noexcept;
|
||||
inline void stringPut(int x, int y, uint32_t color, std::string str);
|
||||
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(Texture* texture, int x, int y);
|
||||
inline void loadFont(const std::filesystem::path& filepath, float scale);
|
||||
|
||||
|
||||
@@ -27,13 +27,13 @@ namespace mlx
|
||||
_texture_manager.clear();
|
||||
}
|
||||
|
||||
void GraphicsSupport::pixelPut(int x, int y, uint32_t color) noexcept
|
||||
void GraphicsSupport::pixelPut(int x, int y, std::uint32_t color) noexcept
|
||||
{
|
||||
MLX_PROFILE_FUNCTION();
|
||||
_pixel_put_pipeline.setPixel(x, y, color);
|
||||
}
|
||||
|
||||
void GraphicsSupport::stringPut(int x, int y, uint32_t color, std::string str)
|
||||
void GraphicsSupport::stringPut(int x, int y, std::uint32_t color, std::string str)
|
||||
{
|
||||
MLX_PROFILE_FUNCTION();
|
||||
std::pair<DrawableResource*, bool> res = _text_manager.registerText(x, y, color, str);
|
||||
|
||||
Reference in New Issue
Block a user