adding logo

This commit is contained in:
Kbz-8
2023-11-25 12:23:57 +01:00
parent 82529d6dc9
commit c7e09f1d8c
8 changed files with 553 additions and 6 deletions

View File

@@ -6,27 +6,44 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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()

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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;