-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
77 changed files
with
4,631 additions
and
920 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: maldavid <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2022/10/04 17:55:21 by maldavid #+# #+# */ | ||
/* Updated: 2024/01/26 11:59:34 by maldavid ### ########.fr */ | ||
/* Updated: 2024/02/24 01:07:56 by maldavid ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: maldavid <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* 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; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: maldavid <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2022/10/04 17:35:20 by maldavid #+# #+# */ | ||
/* Updated: 2024/01/19 05:35:38 by maldavid ### ########.fr */ | ||
/* Updated: 2024/02/23 22:37:24 by maldavid ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -120,7 +120,13 @@ extern "C" | |
int mlx_get_image_pixel(void* mlx, void* img, int x, int y) | ||
{ | ||
MLX_CHECK_APPLICATION_POINTER(mlx); | ||
return static_cast<mlx::core::Application*>(mlx)->getTexturePixel(img, x, y); | ||
int color = static_cast<mlx::core::Application*>(mlx)->getTexturePixel(img, x, y); | ||
unsigned char color_bits[4]; | ||
color_bits[0] = (color & 0x000000FF); | ||
color_bits[1] = (color & 0x0000FF00) >> 8; | ||
color_bits[2] = (color & 0x00FF0000) >> 16; | ||
color_bits[3] = (color & 0xFF000000) >> 24; | ||
return *reinterpret_cast<int*>(color_bits); | ||
} | ||
|
||
void mlx_set_image_pixel(void* mlx, void* img, int x, int y, int color) | ||
|
@@ -294,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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: maldavid <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2022/10/05 16:30:19 by maldavid #+# #+# */ | ||
/* Updated: 2024/01/16 07:59:15 by maldavid ### ########.fr */ | ||
/* Updated: 2024/02/23 22:27:30 by maldavid ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -33,7 +33,7 @@ namespace mlx | |
_yRel = _event.motion.yrel; | ||
} | ||
|
||
uint32_t id = _event.window.windowID; | ||
std::uint32_t id = _event.window.windowID; | ||
if(_events_hooks.find(id) == _events_hooks.end()) | ||
continue; | ||
auto& hooks = _events_hooks[id]; | ||
|
@@ -123,19 +123,19 @@ namespace mlx | |
case SDL_WINDOWEVENT_FOCUS_GAINED: | ||
{ | ||
if(win_hook.hook) | ||
win_hook.hook(4, win_hook.param); | ||
win_hook.hook(5, win_hook.param); | ||
break; | ||
} | ||
case SDL_WINDOWEVENT_LEAVE: | ||
{ | ||
if(win_hook.hook) | ||
win_hook.hook(5, win_hook.param); | ||
win_hook.hook(6, win_hook.param); | ||
break; | ||
} | ||
case SDL_WINDOWEVENT_FOCUS_LOST: | ||
{ | ||
if(win_hook.hook) | ||
win_hook.hook(4, win_hook.param); | ||
win_hook.hook(7, win_hook.param); | ||
break; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: maldavid <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2022/10/05 16:27:35 by maldavid #+# #+# */ | ||
/* Updated: 2024/01/16 07:59:08 by maldavid ### ########.fr */ | ||
/* Updated: 2024/02/25 07:51:55 by maldavid ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -44,7 +44,7 @@ namespace mlx | |
inline int getXRel() const noexcept { return _xRel; } | ||
inline int getYRel() const noexcept { return _yRel; } | ||
|
||
inline bool is_running() const noexcept { return !_end; } | ||
inline bool isRunning() const noexcept { return !_end; } | ||
inline constexpr void finish() noexcept { _end = true; } | ||
|
||
inline void addWindow(std::shared_ptr<MLX_Window> window) | ||
|
@@ -53,7 +53,7 @@ namespace mlx | |
_events_hooks[window->getID()] = {}; | ||
} | ||
|
||
inline void onEvent(uint32_t id, int event, int (*funct_ptr)(int, void*), void* param) noexcept | ||
inline void onEvent(std::uint32_t id, int event, int (*funct_ptr)(int, void*), void* param) noexcept | ||
{ | ||
_events_hooks[id][event].hook = funct_ptr; | ||
_events_hooks[id][event].param = param; | ||
|
@@ -62,8 +62,8 @@ namespace mlx | |
~Input() = default; | ||
|
||
private: | ||
std::unordered_map<uint32_t, std::shared_ptr<MLX_Window>> _windows; | ||
std::unordered_map<uint32_t, std::array<Hook, 6>> _events_hooks; | ||
std::unordered_map<std::uint32_t, std::shared_ptr<MLX_Window>> _windows; | ||
std::unordered_map<std::uint32_t, std::array<Hook, 6>> _events_hooks; | ||
SDL_Event _event; | ||
|
||
int _x = 0; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.