-
Notifications
You must be signed in to change notification settings - Fork 4
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
8 changed files
with
553 additions
and
6 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,27 +6,44 @@ | |
/* By: maldavid <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2022/10/04 17:36:44 by maldavid #+# #+# */ | ||
/* Updated: 2023/11/08 20:24:38 by maldavid ### ########.fr */ | ||
/* Updated: 2023/11/25 11:48:26 by maldavid ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#include <platform/window.h> | ||
#include <core/errors.h> | ||
#include <utils/icon_mlx.h> | ||
|
||
namespace mlx | ||
{ | ||
#if SDL_BYTEORDER == SDL_BIG_ENDIAN | ||
constexpr const uint32_t rmask = 0xff000000; | ||
constexpr const uint32_t gmask = 0x00ff0000; | ||
constexpr const uint32_t bmask = 0x0000ff00; | ||
constexpr const uint32_t amask = 0x000000ff; | ||
#else | ||
constexpr const uint32_t rmask = 0x000000ff; | ||
constexpr const uint32_t gmask = 0x0000ff00; | ||
constexpr const uint32_t bmask = 0x00ff0000; | ||
constexpr const uint32_t amask = 0xff000000; | ||
#endif | ||
|
||
MLX_Window::MLX_Window(std::size_t w, std::size_t h, const std::string& title) : _width(w), _height(h) | ||
{ | ||
_win = SDL_CreateWindow(title.c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, w, h, SDL_WINDOW_VULKAN | SDL_WINDOW_SHOWN); | ||
if(!_win) | ||
core::error::report(e_kind::fatal_error, std::string("unable to open a new window, ") + SDL_GetError()); | ||
_id = SDL_GetWindowID(_win); | ||
_icon = SDL_CreateRGBSurfaceFrom(static_cast<void*>(logo_mlx), logo_mlx_width, logo_mlx_height, 32, 4 * logo_mlx_width, rmask, gmask, bmask, amask); | ||
SDL_SetWindowIcon(_win, _icon); | ||
} | ||
|
||
void MLX_Window::destroy() noexcept | ||
{ | ||
if(_win) | ||
SDL_DestroyWindow(_win); | ||
if(_icon) | ||
SDL_FreeSurface(_icon); | ||
} | ||
|
||
MLX_Window::~MLX_Window() | ||
|
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 21:53:12 by maldavid #+# #+# */ | ||
/* Updated: 2023/11/08 20:24:46 by maldavid ### ########.fr */ | ||
/* Updated: 2023/11/25 11:33:32 by maldavid ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -33,6 +33,7 @@ namespace mlx | |
~MLX_Window(); | ||
|
||
private: | ||
SDL_Surface* _icon = nullptr; | ||
SDL_Window* _win = nullptr; | ||
int _width = 0; | ||
int _height = 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,16 +6,16 @@ | |
/* By: maldavid <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2023/04/11 16:20:25 by maldavid #+# #+# */ | ||
/* Updated: 2023/11/20 07:26:45 by maldavid ### ########.fr */ | ||
/* Updated: 2023/11/25 10:47:10 by maldavid ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#ifndef __MLX_DOGICA_TTF__ | ||
#define __MLX_DOGICA_TTF__ | ||
|
||
inline unsigned int dogica_ttf_len = 33860; | ||
constexpr const unsigned int dogica_ttf_len = 33860; | ||
|
||
inline unsigned char dogica_ttf[] = { | ||
constexpr const unsigned char dogica_ttf[dogica_ttf_len] = { | ||
0x00, 0x01, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x80, 0x00, 0x03, 0x00, 0x60, | ||
0x46, 0x46, 0x54, 0x4d, 0x8f, 0xe1, 0x5b, 0x60, 0x00, 0x00, 0x84, 0x28, | ||
0x00, 0x00, 0x00, 0x1c, 0x47, 0x44, 0x45, 0x46, 0x00, 0x15, 0x00, 0x14, | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
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: 2023/11/25 10:40:28 by maldavid ### ########.fr */ | ||
/* Updated: 2023/11/25 11:57:57 by maldavid ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|