Skip to content

Commit

Permalink
adding logo
Browse files Browse the repository at this point in the history
  • Loading branch information
Kbz-8 committed Nov 25, 2023
1 parent 82529d6 commit c7e09f1
Show file tree
Hide file tree
Showing 8 changed files with 553 additions and 6 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<p align="center">
<img src="https://raw.githubusercontent.com/420verfl0w/MacroLibX/master/res/logo.png" alt="drawing" width="400"/>
</p>

# MacroLibX [![linux clang workflow][linux-clang_badge]][linux-clang_wf] [![linux gcc workflow][linux-gcc_badge]][linux-gcc_wf] [![macos workflow][macos_badge]][macos_wf]
###### A rewrite of 42 School's MiniLibX using SDL2 and Vulkan.

Expand Down
Binary file added res/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified res/screenshot_test.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 18 additions & 1 deletion src/platform/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion src/platform/window.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
/* */
/* ************************************************************************** */

Expand All @@ -33,6 +33,7 @@ namespace mlx
~MLX_Window();

private:
SDL_Surface* _icon = nullptr;
SDL_Window* _win = nullptr;
int _width = 0;
int _height = 0;
Expand Down
6 changes: 3 additions & 3 deletions src/utils/dogica_ttf.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
525 changes: 525 additions & 0 deletions src/utils/icon_mlx.h

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion test/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
/* */
/* ************************************************************************** */

Expand Down

0 comments on commit c7e09f1

Please sign in to comment.