Merge pull request #5 from 420verfl0w/indev

merge Indev to master
This commit is contained in:
kbz_8
2023-12-09 18:13:55 +01:00
committed by GitHub
53 changed files with 3674 additions and 134 deletions

75
.github/workflows/windows.yml vendored git.filemode.normal_file
View File

@@ -0,0 +1,75 @@
name: Windows (xmake)
on:
pull_request:
push:
paths-ignore:
- '.gitignore'
- 'LICENSE'
- 'README.md'
jobs:
build:
strategy:
fail-fast: false
matrix:
os: [windows-latest]
arch: [x64]
mode: [release]
runs-on: ${{ matrix.os }}
if: "!contains(github.event.head_commit.message, 'ci skip')"
steps:
- name: Get current date as package key
id: cache_key
run: echo "key=$(date +'%W')" >> $GITHUB_OUTPUT
- name: Checkout repository
uses: actions/checkout@v4
# Install system dependencies
- name: Install Vulkan SDK
uses: humbletim/install-vulkan-sdk@v1.1.1
with:
version: 1.3.204.1
cache: true
# Force xmake to a specific folder (for cache)
- name: Set xmake env
run: echo "XMAKE_GLOBALDIR=${{ runner.workspace }}/xmake-global" >> $GITHUB_ENV
# Install xmake
- name: Setup xmake
uses: xmake-io/github-action-setup-xmake@v1
with:
xmake-version: branch@master
actions-cache-folder: .xmake-cache-W${{ steps.cache_key.outputs.key }}
# Update xmake repository (in order to have the file that will be cached)
- name: Update xmake repository
run: xmake repo --update
# Fetch xmake dephash
- name: Retrieve dependencies hash
id: dep_hash
run: echo "hash=$(xmake l utils.ci.packageskey)" >> $GITHUB_OUTPUT
# Cache xmake dependencies
- name: Retrieve cached xmake dependencies
uses: actions/cache@v3
with:
path: ${{ env.XMAKE_GLOBALDIR }}/.xmake/packages
key: Windows-${{ matrix.arch }}-${{ matrix.mode }}-${{ steps.dep_hash.outputs.hash }}-W${{ steps.cache_key.outputs.key }}
# Setup compilation mode and install project dependencies
- name: Configure xmake and install dependencies
run: xmake config --arch=${{ matrix.arch }} --mode=${{ matrix.mode }} --yes
# Build the mlx
- name: Build MacroLibX
run: xmake --yes
# Build the test
- name: Build Test
run: xmake build --yes Test

13
.gitignore vendored
View File

@@ -4,5 +4,18 @@
*.a
*.so
*.out
*.dll
*.lib
*.exp
*.json
*.tmp
*.ilk
*.pdb
*.exe
.vs/
.xmake/
.cache/
objs/
build/
test/.gdb_history
test/Test

View File

@@ -13,6 +13,7 @@
NAME = libmlx.so
SRCS = $(wildcard $(addsuffix /*.cpp, ./src/core))
SRCS += $(wildcard $(addsuffix /*.cpp, ./src/core/**))
SRCS += $(wildcard $(addsuffix /*.cpp, ./src/platform))
SRCS += $(wildcard $(addsuffix /*.cpp, ./src/renderer))
SRCS += $(wildcard $(addsuffix /*.cpp, ./src/renderer/**))

View File

@@ -5,6 +5,9 @@
<a href="https://github.com/420verfl0w/MacroLibX/actions/workflows/linux_gcc.yml"><img src="https://github.com/420verfl0w/MacroLibX/actions/workflows/linux_gcc.yml/badge.svg"></a>
<a href="https://github.com/420verfl0w/MacroLibX/actions/workflows/macos_x86.yml"><img src="https://github.com/420verfl0w/MacroLibX/actions/workflows/macos_x86.yml/badge.svg"></a>
</div>
<div align="center">
<a href="https://github.com/420verfl0w/MacroLibX/actions/workflows/windows.yml"><img src="https://github.com/420verfl0w/MacroLibX/actions/workflows/windows.yml/badge.svg"></a>
</div>
</div>
###### MacroLibX, a rewrite of 42 School's MiniLibX using SDL2 and Vulkan.
@@ -45,6 +48,10 @@ brew install molten-vk
brew install SDL2
```
### 🪟 Windows
To build on Windows you may need to use the [xmake](https://xmake.io) build. [Here's](./XMAKE_BUILD.md) how you can use it.
### Clone and Build
Finally, you can clone the Git repository. When inside it, run the GNU `make` command to compile MacroLibX.

47
XMAKE_BUILD.md git.filemode.normal_file
View File

@@ -0,0 +1,47 @@
# 🏗️ xmake build
To build on Windows (if you don't use [WSL](https://learn.microsoft.com/en-us/windows/wsl/install)) or on other OS, the MacroLibX uses [xmake](https://xmake.io), a build system which will download and compile all dependencies it won't find on your computer.
## 💾 Install xmake
You can find how to install it on your system [here](https://xmake.io/#/guide/installation). Note that you can also download a [portable version](https://github.com/xmake-io/xmake/releases) of xmake if you wish not to install it.
## ⚙️ Configure the MacroLibX build
Just as the Makfile build system, you can configure how xmake should build the MacroLibX. The base command to configure it is `xmake config [opts...]` or `xmake f [opts...]`.
### 📦 Compile mode
You can configure xmake to build the mlx in debug mode or in release mode (release mode is enabled by default). To do so you can use `xmake config --mode=debug` or `xmake config --mode=release`.
### 🛠️ Set the toolchain
To change the compilation toolchain using `xmake config --toolchain=[gcc|clang|...]`
### 🖼️ Image optimisations
If you run into glitches when writing or reading pixels from images you can turn off image optimisations using `xmake config --images_optimized=n`.
### 🖥️ Force the use of the integrated GPU (not recommended)
You can force the mlx to use your integrated GPU using `xmake config --force_integrated_gpu=y`. Note that there are a lot of chances that your application crashes using that.
### 💽 Dump the graphics memory
The mlx can dump it's graphics memory use to json files every two seconds by enabling this option `xmake config --graphics_memory_dump=y`.
### 🪛 A possible build configuration
As a configuration example here's how the command can look like `xmake config --mode=debug --toolchain=clang --graphics_memory_dump=y --images_optimized=n`
## 🚧 Build the lib
### Compile using command-line (first method)
Once you're ready to compile the lib, run `xmake` (or `xmake -jX` if you wish not to use all your computer threads, with X being the number of threads you wish to use) and watch as the lib compiles.
### Generate a project (second method)
xmake can also generate a project file for another tool:
* Visual Studio : `xmake project -k vs`
* CMakeLists.txt (which you can open in CLion and more) : `xmake project -k cmake`
* Makefile : `xmake project -k make`
* Ninja : `xmake project -k ninja`
* XCode : `xmake project -k xcode`
You should now be able to open the project file with the tool of your choice.
## 😋 Enjoy
Enjoy you project built with the mlx
<p align="center">
<img src="./res/screenshot_test_windows.png" alt="drawing" width="400"/>
</p>

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/04 16:56:35 by maldavid #+# #+# */
/* Updated: 2023/12/08 12:14:31 by kbz_8 ### ########.fr */
/* Updated: 2023/12/08 18:07:40 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -15,6 +15,20 @@
#ifndef __MACRO_LIB_X_H__
#define __MACRO_LIB_X_H__
#if defined(_WIN32) || defined(_WIN64)
#define MLX_EXPORT __declspec(dllexport)
#define MLX_IMPORT __declspec(dllimport)
#else
#define MLX_EXPORT
#define MLX_IMPORT
#endif
#ifdef MLX_BUILD
#define MLX_API MLX_EXPORT
#else
#define MLX_API MLX_IMPORT
#endif
#ifdef __cplusplus
extern "C" {
#endif
@@ -34,7 +48,7 @@ typedef enum
*
* @return (void*) An opaque pointer to the internal MLX application or NULL (0x0) in case of error
*/
void* mlx_init();
MLX_API void* mlx_init();
/**
* @brief Creates a new window
@@ -46,7 +60,7 @@ void* mlx_init();
*
* @return (void*) An opaque pointer to the internal MLX window or NULL (0x0) in case of error
*/
void* mlx_new_window(void* mlx, int w, int h, const char* title);
MLX_API void* mlx_new_window(void* mlx, int w, int h, const char* title);
/**
* @brief Gives a function to be executed at each loop turn
@@ -58,7 +72,7 @@ void* mlx_new_window(void* mlx, int w, int h, const char* title);
* @return (int) Always return 0, made this to copy the behaviour of the original MLX
*/
int mlx_loop_hook(void* mlx, int (*f)(), void* param);
MLX_API int mlx_loop_hook(void* mlx, int (*f)(void*), void* param);
/**
* @brief Starts the internal main loop
@@ -67,7 +81,7 @@ int mlx_loop_hook(void* mlx, int (*f)(), void* param);
*
* @return (int) Always return 0, made this to copy the behaviour of the original MLX
*/
int mlx_loop(void* mlx);
MLX_API int mlx_loop(void* mlx);
/**
* @brief Ends the internal main loop
@@ -76,21 +90,21 @@ int mlx_loop(void* mlx);
*
* @return (int) Always return 0, made this to copy the behaviour of the original MLX
*/
int mlx_loop_end(void* mlx);
MLX_API int mlx_loop_end(void* mlx);
/**
* @brief Shows mouse cursor
*
* @return (int) Always return 0, made this to copy the behaviour of the original MLX
*/
int mlx_mouse_show();
MLX_API int mlx_mouse_show();
/**
* @brief Hides mouse cursor
*
* @return (int) Always return 0, made this to copy the behaviour of the original MLX
*/
int mlx_mouse_hide();
MLX_API int mlx_mouse_hide();
/**
* @brief Moves cursor to givent position
@@ -102,7 +116,7 @@ int mlx_mouse_hide();
*
* @return (int) Always return 0, made this to copy the behaviour of the original MLX
*/
int mlx_mouse_move(void* mlx, void* win, int x, int y);
MLX_API int mlx_mouse_move(void* mlx, void* win, int x, int y);
/**
* @brief Get cursor's position
@@ -113,7 +127,7 @@ int mlx_mouse_move(void* mlx, void* win, int x, int y);
*
* @return (int) Always return 0, made this to copy the behaviour of the original MLX
*/
int mlx_mouse_get_pos(void* mlx, int* x, int* y);
MLX_API int mlx_mouse_get_pos(void* mlx, int* x, int* y);
/**
@@ -127,7 +141,7 @@ int mlx_mouse_get_pos(void* mlx, int* x, int* y);
*
* @return (int) Always return 0, made this to copy the behaviour of the original MLX
*/
int mlx_on_event(void* mlx, void* win, mlx_event_type event, int (*f)(), void* param);
MLX_API int mlx_on_event(void* mlx, void* win, mlx_event_type event, int (*f)(int, void*), void* param);
/**
@@ -144,7 +158,7 @@ int mlx_on_event(void* mlx, void* win, mlx_event_type event, int (*f)(), void* p
*
* @return (int) Always return 0, made this to copy the behaviour of the original MLX
*/
int mlx_pixel_put(void* mlx, void* win, int x, int y, int color);
MLX_API int mlx_pixel_put(void* mlx, void* win, int x, int y, int color);
/**
@@ -156,7 +170,7 @@ int mlx_pixel_put(void* mlx, void* win, int x, int y, int color);
*
* @return (void*) An opaque pointer to the internal image or NULL (0x0) in case of error
*/
void* mlx_new_image(void* mlx, int width, int height);
MLX_API void* mlx_new_image(void* mlx, int width, int height);
/**
* @brief Get image pixel data
@@ -176,7 +190,7 @@ void* mlx_new_image(void* mlx, int width, int height);
* ~ make IMAGES_OPTIMIZED=false
* ```
*/
int mlx_get_image_pixel(void* mlx, void* img, int x, int y);
MLX_API int mlx_get_image_pixel(void* mlx, void* img, int x, int y);
/**
* @brief Set image pixel data
@@ -197,7 +211,7 @@ int mlx_get_image_pixel(void* mlx, void* img, int x, int y);
* ~ make IMAGES_OPTIMIZED=false
* ```
*/
void mlx_set_image_pixel(void* mlx, void* img, int x, int y, int color);
MLX_API void mlx_set_image_pixel(void* mlx, void* img, int x, int y, int color);
/**
* @brief Put image to the given window
@@ -210,7 +224,7 @@ void mlx_set_image_pixel(void* mlx, void* img, int x, int y, int color);
*
* @return (int) Always return 0, made this to copy the behaviour of the original MLX
*/
int mlx_put_image_to_window(void* mlx, void* win, void* img, int x, int y);
MLX_API int mlx_put_image_to_window(void* mlx, void* win, void* img, int x, int y);
/**
* @brief Destroys internal image
@@ -220,7 +234,7 @@ int mlx_put_image_to_window(void* mlx, void* win, void* img, int x, int y);
*
* @return (int) Always return 0, made this to copy the behaviour of the original MLX
*/
int mlx_destroy_image(void* mlx, void* img);
MLX_API int mlx_destroy_image(void* mlx, void* img);
/**
@@ -233,7 +247,7 @@ int mlx_destroy_image(void* mlx, void* img);
*
* @return (void*) An opaque pointer to the internal image or NULL (0x0) in case of error
*/
void* mlx_png_file_to_image(void* mlx, char* filename, int* width, int* height);
MLX_API void* mlx_png_file_to_image(void* mlx, char* filename, int* width, int* height);
/**
* @brief Create a new image from a jpg file
@@ -245,7 +259,7 @@ void* mlx_png_file_to_image(void* mlx, char* filename, int* width, int* height);
*
* @return (void*) An opaque pointer to the internal image or NULL (0x0) in case of error
*/
void* mlx_jpg_file_to_image(void* mlx, char* filename, int* width, int* height);
MLX_API void* mlx_jpg_file_to_image(void* mlx, char* filename, int* width, int* height);
/**
* @brief Create a new image from a bmp file
@@ -257,7 +271,7 @@ void* mlx_jpg_file_to_image(void* mlx, char* filename, int* width, int* height);
*
* @return (void*) An opaque pointer to the internal image or NULL (0x0) in case of error
*/
void* mlx_bmp_file_to_image(void* mlx, char* filename, int* width, int* height);
MLX_API void* mlx_bmp_file_to_image(void* mlx, char* filename, int* width, int* height);
/**
@@ -272,7 +286,7 @@ void* mlx_bmp_file_to_image(void* mlx, char* filename, int* width, int* height);
*
* @return (int) Always return 0, made this to copy the behaviour of the original MLX
*/
int mlx_string_put(void* mlx, void* win, int x, int y, int color, char* str);
MLX_API int mlx_string_put(void* mlx, void* win, int x, int y, int color, char* str);
/**
@@ -284,7 +298,7 @@ int mlx_string_put(void* mlx, void* win, int x, int y, int color, char* str);
*
* @return (void)
*/
void mlx_set_font(void* mlx, void* win, char* filepath);
MLX_API void mlx_set_font(void* mlx, void* win, char* filepath);
/**
* @brief Loads a font to be used by `mlx_string_put` and scales it
@@ -296,7 +310,7 @@ void mlx_set_font(void* mlx, void* win, char* filepath);
*
* @return (void)
*/
void mlx_set_font_scale(void* mlx, void* win, char* filepath, float scale);
MLX_API void mlx_set_font_scale(void* mlx, void* win, char* filepath, float scale);
/**
@@ -307,7 +321,7 @@ void mlx_set_font_scale(void* mlx, void* win, char* filepath, float scale);
*
* @return (int) Always return 0, made this to copy the behaviour of the original MLX
*/
int mlx_clear_window(void* mlx, void* win);
MLX_API int mlx_clear_window(void* mlx, void* win);
/**
@@ -318,7 +332,7 @@ int mlx_clear_window(void* mlx, void* win);
*
* @return (int) Always return 0, made this to copy the behaviour of the original MLX
*/
int mlx_destroy_window(void* mlx, void* win);
MLX_API int mlx_destroy_window(void* mlx, void* win);
/**
* @brief Destroy internal MLX application
@@ -327,7 +341,7 @@ int mlx_destroy_window(void* mlx, void* win);
*
* @return (int) Always return 0, made this to copy the behaviour of the original MLX
*/
int mlx_destroy_display(void* mlx);
MLX_API int mlx_destroy_display(void* mlx);
/**
@@ -339,7 +353,7 @@ int mlx_destroy_display(void* mlx);
*
* @return (int) Always return 0, made this to copy the behaviour of the original MLX
*/
int mlx_get_screens_size(void* mlx, int* w, int* h);
MLX_API int mlx_get_screens_size(void* mlx, int* w, int* h);
#ifdef __cplusplus
}

BIN
res/screenshot_test_windows.png git.filemode.normal_file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/04 22:10:52 by maldavid #+# #+# */
/* Updated: 2023/11/20 07:29:12 by maldavid ### ########.fr */
/* Updated: 2023/12/09 17:44:13 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -35,7 +35,7 @@ namespace mlx::core
if(_loop_hook)
_loop_hook(_param);
for(auto& gs : _graphics)
gs->endRender();
}
@@ -66,6 +66,7 @@ namespace mlx::core
Application::~Application()
{
SDL_QuitSubSystem(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_EVENTS);
SDL_Quit();
}
}

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/04 21:49:46 by maldavid #+# #+# */
/* Updated: 2023/11/23 14:25:43 by maldavid ### ########.fr */
/* Updated: 2023/12/08 18:52:47 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -24,6 +24,7 @@
#include <core/graphics.h>
#include <platform/inputs.h>
#include <core/profile.h>
namespace mlx::core
{

View File

@@ -15,6 +15,7 @@
#include "application.h"
#include <renderer/core/render_core.h>
#include <filesystem>
#include <mlx.h>
extern "C"
{
@@ -31,29 +32,29 @@ extern "C"
if(app == nullptr)
mlx::core::error::report(e_kind::fatal_error, "Tout a pété");
init = true;
return app;
return static_cast<void*>(app);
}
void* mlx_new_window(mlx::core::Application* mlx, int w, int h, const char* title)
void* mlx_new_window(void* mlx, int w, int h, const char* title)
{
return mlx->newGraphicsSuport(w, h, title);
return static_cast<mlx::core::Application*>(mlx)->newGraphicsSuport(w, h, title);
}
int mlx_loop_hook(mlx::core::Application* mlx, int (*f)(void*), void* param)
int mlx_loop_hook(void* mlx, int (*f)(void*), void* param)
{
mlx->loopHook(f, param);
static_cast<mlx::core::Application*>(mlx)->loopHook(f, param);
return 0;
}
int mlx_loop(mlx::core::Application* mlx)
int mlx_loop(void* mlx)
{
mlx->run();
static_cast<mlx::core::Application*>(mlx)->run();
return 0;
}
int mlx_loop_end(mlx::core::Application* mlx)
int mlx_loop_end(void* mlx)
{
mlx->loopEnd();
static_cast<mlx::core::Application*>(mlx)->loopEnd();
return 0;
}
@@ -67,57 +68,57 @@ extern "C"
return SDL_ShowCursor(SDL_DISABLE);
}
int mlx_mouse_move(mlx::core::Application* mlx, void* win, int x, int y)
int mlx_mouse_move(void* mlx, void* win, int x, int y)
{
mlx->mouseMove(win, x, y);
static_cast<mlx::core::Application*>(mlx)->mouseMove(win, x, y);
return 0;
}
int mlx_mouse_get_pos(mlx::core::Application* mlx, int* x, int* y)
int mlx_mouse_get_pos(void* mlx, int* x, int* y)
{
mlx->getMousePos(x, y);
static_cast<mlx::core::Application*>(mlx)->getMousePos(x, y);
return 0;
}
int mlx_on_event(mlx::core::Application* mlx, void* win, int event, int (*funct_ptr)(int, void*), void* param)
int mlx_on_event(void* mlx, void* win, mlx_event_type event, int (*funct_ptr)(int, void*), void* param)
{
mlx->onEvent(win, event, funct_ptr, param);
static_cast<mlx::core::Application*>(mlx)->onEvent(win, static_cast<int>(event), funct_ptr, param);
return 0;
}
void* mlx_new_image(mlx::core::Application* mlx, int width, int height)
void* mlx_new_image(void* mlx, int width, int height)
{
return mlx->newTexture(width, height);
return static_cast<mlx::core::Application*>(mlx)->newTexture(width, height);
}
int mlx_get_image_pixel(mlx::core::Application* mlx, void* img, int x, int y)
int mlx_get_image_pixel(void* mlx, void* img, int x, int y)
{
return mlx->getTexturePixel(img, x, y);
return static_cast<mlx::core::Application*>(mlx)->getTexturePixel(img, x, y);
}
void mlx_set_image_pixel(mlx::core::Application* mlx, void* img, int x, int y, int color)
void mlx_set_image_pixel(void* mlx, void* img, int x, int y, int color)
{
unsigned char color_bits[4];
color_bits[0] = (color & 0x00FF0000) >> 16;
color_bits[1] = (color & 0x0000FF00) >> 8;
color_bits[2] = (color & 0x000000FF);
color_bits[3] = (color & 0xFF000000) >> 24;
mlx->setTexturePixel(img, x, y, *reinterpret_cast<unsigned int*>(color_bits));
static_cast<mlx::core::Application*>(mlx)->setTexturePixel(img, x, y, *reinterpret_cast<unsigned int*>(color_bits));
}
int mlx_put_image_to_window(mlx::core::Application* mlx, void* win, void* img, int x, int y)
int mlx_put_image_to_window(void* mlx, void* win, void* img, int x, int y)
{
mlx->texturePut(win, img, x, y);
static_cast<mlx::core::Application*>(mlx)->texturePut(win, img, x, y);
return 0;
}
int mlx_destroy_image(mlx::core::Application* mlx, void* img)
int mlx_destroy_image(void* mlx, void* img)
{
mlx->destroyTexture(img);
static_cast<mlx::core::Application*>(mlx)->destroyTexture(img);
return 0;
}
void* mlx_png_file_to_image(mlx::core::Application* mlx, char* filename, int* width, int* height)
void* mlx_png_file_to_image(void* mlx, char* filename, int* width, int* height)
{
std::filesystem::path file(filename);
if(file.extension() != ".png")
@@ -125,10 +126,10 @@ extern "C"
mlx::core::error::report(e_kind::error, "PNG loader : not a png file '%s'", filename);
return nullptr;
}
return mlx->newStbTexture(filename, width, height);
return static_cast<mlx::core::Application*>(mlx)->newStbTexture(filename, width, height);
}
void* mlx_jpg_file_to_image(mlx::core::Application* mlx, char* filename, int* width, int* height)
void* mlx_jpg_file_to_image(void* mlx, char* filename, int* width, int* height)
{
std::filesystem::path file(filename);
if(file.extension() != ".jpg" && file.extension() != ".jpeg")
@@ -136,10 +137,10 @@ extern "C"
mlx::core::error::report(e_kind::error, "JPG loader : not a jpg file '%s'", filename);
return nullptr;
}
return mlx->newStbTexture(filename, width, height);
return static_cast<mlx::core::Application*>(mlx)->newStbTexture(filename, width, height);
}
void* mlx_bmp_file_to_image(mlx::core::Application* mlx, char* filename, int* width, int* height)
void* mlx_bmp_file_to_image(void* mlx, char* filename, int* width, int* height)
{
std::filesystem::path file(filename);
if(file.extension() != ".bmp" && file.extension() != ".dib")
@@ -147,32 +148,32 @@ extern "C"
mlx::core::error::report(e_kind::error, "BMP loader : not a bmp file '%s'", filename);
return nullptr;
}
return mlx->newStbTexture(filename, width, height);
return static_cast<mlx::core::Application*>(mlx)->newStbTexture(filename, width, height);
}
int mlx_pixel_put(mlx::core::Application* mlx, void* win, int x, int y, int color)
int mlx_pixel_put(void* mlx, void* win, int x, int y, int color)
{
unsigned char color_bits[4];
color_bits[0] = (color & 0x00FF0000) >> 16;
color_bits[1] = (color & 0x0000FF00) >> 8;
color_bits[2] = color & 0x000000FF;
color_bits[3] = 0xFF;
mlx->pixelPut(win, x, y, *reinterpret_cast<unsigned int*>(color_bits));
static_cast<mlx::core::Application*>(mlx)->pixelPut(win, x, y, *reinterpret_cast<unsigned int*>(color_bits));
return 0;
}
int mlx_string_put(mlx::core::Application* mlx, void* win, int x, int y, int color, char* str)
int mlx_string_put(void* mlx, void* win, int x, int y, int color, char* str)
{
unsigned char color_bits[4];
color_bits[0] = (color & 0x00FF0000) >> 16;
color_bits[1] = (color & 0x0000FF00) >> 8;
color_bits[2] = color & 0x000000FF;
color_bits[3] = 0xFF;
mlx->stringPut(win, x, y, *reinterpret_cast<unsigned int*>(color_bits), str);
static_cast<mlx::core::Application*>(mlx)->stringPut(win, x, y, *reinterpret_cast<unsigned int*>(color_bits), str);
return 0;
}
void mlx_set_font(mlx::core::Application* mlx, void* win, char* filepath)
void mlx_set_font(void* mlx, void* win, char* filepath)
{
std::filesystem::path file(filepath);
if(file.extension() != ".ttf" && file.extension() != ".tte")
@@ -180,10 +181,10 @@ extern "C"
mlx::core::error::report(e_kind::error, "TTF loader : not a truetype font file '%s'", filepath);
return;
}
mlx->loadFont(win, file, 16.f);
static_cast<mlx::core::Application*>(mlx)->loadFont(win, file, 16.f);
}
void mlx_set_font_scale(mlx::core::Application* mlx, void* win, char* filepath, float scale)
void mlx_set_font_scale(void* mlx, void* win, char* filepath, float scale)
{
std::filesystem::path file(filepath);
if(file.extension() != ".ttf" && file.extension() != ".tte")
@@ -191,31 +192,31 @@ extern "C"
mlx::core::error::report(e_kind::error, "TTF loader : not a truetype font file '%s'", filepath);
return;
}
mlx->loadFont(win, file, scale);
static_cast<mlx::core::Application*>(mlx)->loadFont(win, file, scale);
}
int mlx_clear_window(mlx::core::Application* mlx, void* win)
int mlx_clear_window(void* mlx, void* win)
{
mlx->clearGraphicsSupport(win);
static_cast<mlx::core::Application*>(mlx)->clearGraphicsSupport(win);
return 0;
}
int mlx_destroy_window(mlx::core::Application* mlx, void* win)
int mlx_destroy_window(void* mlx, void* win)
{
mlx->destroyGraphicsSupport(win);
static_cast<mlx::core::Application*>(mlx)->destroyGraphicsSupport(win);
return 0;
}
int mlx_destroy_display(mlx::core::Application* mlx)
int mlx_destroy_display(void* mlx)
{
delete mlx;
delete static_cast<mlx::core::Application*>(mlx);
mlx::Render_Core::get().destroy();
return 0;
}
int mlx_get_screens_size(mlx::core::Application* mlx, int* w, int* h)
int mlx_get_screens_size(void* mlx, int* w, int* h)
{
mlx->getScreenSize(w, h);
static_cast<mlx::core::Application*>(mlx)->getScreenSize(w, h);
return 0;
}
}
}

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/04 17:42:32 by maldavid #+# #+# */
/* Updated: 2022/10/08 19:06:41 by maldavid ### ########.fr */
/* Updated: 2023/12/08 18:53:11 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -14,6 +14,7 @@
#define __MLX_ERRORS__
#include <string>
#include <core/profile.h>
enum class e_kind
{

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/04/02 15:13:55 by maldavid #+# #+# */
/* Updated: 2023/11/24 20:42:15 by maldavid ### ########.fr */
/* Updated: 2023/12/09 16:52:08 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -77,5 +77,6 @@ namespace mlx
_text_put_pipeline->destroy();
_pixel_put_pipeline.destroy();
_renderer->destroy();
_window->destroy();
}
}

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/04/02 14:49:49 by maldavid #+# #+# */
/* Updated: 2023/11/25 09:59:39 by maldavid ### ########.fr */
/* Updated: 2023/12/08 19:04:59 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -26,6 +26,7 @@
#include <renderer/text_pipeline.h>
#include <utils/non_copyable.h>
#include <renderer/images/texture.h>
#include <core/profile.h>
namespace mlx
{

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/07 16:31:51 by kbz_8 #+# #+# */
/* Updated: 2023/12/08 12:56:21 by kbz_8 ### ########.fr */
/* Updated: 2023/12/08 19:05:15 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -14,6 +14,7 @@
#define __MLX_MEMORY__
#include <utils/singleton.h>
#include <core/profile.h>
#include <list>
namespace mlx

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/10 08:49:17 by maldavid #+# #+# */
/* Updated: 2023/11/10 09:05:56 by maldavid ### ########.fr */
/* Updated: 2023/12/08 18:49:38 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -41,6 +41,19 @@
#warning "This compiler is not fully supported"
#endif
#if defined(_WIN32) || defined(__CYGWIN__)
#define MLX_PLAT_WINDOWS
#elif defined(__linux__)
#define MLX_PLAT_LINUX
#elif defined(__APPLE__) && defined(__MACH__)
#define MLX_PLAT_MACOS
#elif defined(unix) || defined(__unix__) || defined(__unix)
#define MLX_PLAT_UNIX
#else
#error "Unknown environment!"
#endif
// Checking common assumptions
#include <climits>
#include <cstdint>

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/05 16:27:35 by maldavid #+# #+# */
/* Updated: 2023/12/08 12:14:39 by kbz_8 ### ########.fr */
/* Updated: 2023/12/08 18:54:03 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -18,6 +18,8 @@
#include <SDL2/SDL.h>
#include <unordered_map>
#include <core/profile.h>
#include "window.h"
namespace mlx

View File

@@ -6,13 +6,14 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/04 17:36:44 by maldavid #+# #+# */
/* Updated: 2023/11/25 11:48:26 by maldavid ### ########.fr */
/* Updated: 2023/12/09 16:52:29 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
#include <platform/window.h>
#include <core/errors.h>
#include <utils/icon_mlx.h>
#include <iostream>
namespace mlx
{
@@ -40,14 +41,16 @@ namespace mlx
void MLX_Window::destroy() noexcept
{
if(_win)
std::cout << "prout" << std::endl;
if(_win != nullptr)
{
SDL_DestroyWindow(_win);
if(_icon)
_win = nullptr;
}
if(_icon != nullptr)
{
SDL_FreeSurface(_icon);
}
MLX_Window::~MLX_Window()
{
destroy();
_icon = nullptr;
}
}
}

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/25 11:33:32 by maldavid ### ########.fr */
/* Updated: 2023/12/09 16:35:57 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -15,6 +15,7 @@
#include <SDL2/SDL.h>
#include <string>
#include <core/profile.h>
namespace mlx
{
@@ -30,7 +31,7 @@ namespace mlx
void destroy() noexcept;
~MLX_Window();
~MLX_Window() = default;
private:
SDL_Surface* _icon = nullptr;

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/06 23:18:52 by maldavid #+# #+# */
/* Updated: 2023/11/16 13:56:19 by maldavid ### ########.fr */
/* Updated: 2023/12/08 19:05:50 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -15,6 +15,7 @@
#include <volk.h>
#include <renderer/core/render_core.h>
#include <core/profile.h>
namespace mlx
{

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/25 15:05:05 by maldavid #+# #+# */
/* Updated: 2023/11/14 03:25:59 by maldavid ### ########.fr */
/* Updated: 2023/12/08 19:06:07 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -16,6 +16,7 @@
#include <volk.h>
#include "vk_buffer.h"
#include <renderer/renderer.h>
#include <core/profile.h>
namespace mlx
{

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/06 18:45:29 by maldavid #+# #+# */
/* Updated: 2023/11/14 03:26:10 by maldavid ### ########.fr */
/* Updated: 2023/12/08 19:06:28 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -16,6 +16,7 @@
#include "vk_buffer.h"
#include <array>
#include <cstddef>
#include <core/profile.h>
namespace mlx
{

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/06 18:27:38 by maldavid #+# #+# */
/* Updated: 2023/11/14 04:53:36 by maldavid ### ########.fr */
/* Updated: 2023/12/08 19:06:45 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -15,6 +15,7 @@
#include "vk_buffer.h"
#include <renderer/renderer.h>
#include <core/profile.h>
namespace mlx
{

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/04/02 17:48:52 by maldavid #+# #+# */
/* Updated: 2023/04/02 17:50:48 by maldavid ### ########.fr */
/* Updated: 2023/12/08 19:07:00 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -16,6 +16,7 @@
#include <array>
#include <volk.h>
#include <core/profile.h>
#include <renderer/core/render_core.h>
#include <renderer/command/vk_cmd_pool.h>
#include <renderer/command/vk_cmd_buffer.h>

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/06 18:25:42 by maldavid #+# #+# */
/* Updated: 2023/04/21 13:20:49 by maldavid ### ########.fr */
/* Updated: 2023/12/08 19:07:11 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -15,6 +15,7 @@
#include <volk.h>
#include <renderer/core/vk_fence.h>
#include <core/profile.h>
namespace mlx
{

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/06 18:24:12 by maldavid #+# #+# */
/* Updated: 2022/12/18 01:08:31 by maldavid ### ########.fr */
/* Updated: 2023/12/08 19:07:22 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -14,6 +14,7 @@
#define __MLX_VK_CMD_POOL__
#include <volk.h>
#include <core/profile.h>
namespace mlx
{

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/10/20 02:13:03 by maldavid #+# #+# */
/* Updated: 2023/11/14 09:46:32 by maldavid ### ########.fr */
/* Updated: 2023/12/08 19:07:34 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -15,6 +15,7 @@
#include <volk.h>
#include <vma.h>
#include <core/profile.h>
namespace mlx
{

View File

@@ -24,7 +24,11 @@
#include <mutex>
#ifdef DEBUG
#warning "MLX is being compiled in debug mode, this activates Vulkan's validation layers and debug messages which may impact rendering performances"
#ifndef MLX_COMPILER_MSVC
#warning "MLX is being compiled in debug mode, this activates Vulkan's validation layers and debug messages which may impact rendering performances"
#else
#pragma NOTE("MLX is being compiled in debug mode, this activates Vulkan's validation layers and debug messages which may impact rendering performances")
#endif
#endif
namespace mlx

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/08 19:16:32 by maldavid #+# #+# */
/* Updated: 2023/11/20 07:20:43 by maldavid ### ########.fr */
/* Updated: 2023/12/08 18:53:36 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -24,6 +24,7 @@
#include <utils/singleton.h>
#include <core/errors.h>
#include <core/profile.h>
namespace mlx
{

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/08 19:13:42 by maldavid #+# #+# */
/* Updated: 2023/11/11 01:51:26 by maldavid ### ########.fr */
/* Updated: 2023/12/08 19:07:49 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -15,6 +15,7 @@
#include <volk.h>
#include "vk_queues.h"
#include <core/profile.h>
namespace mlx
{

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/04/02 17:52:09 by maldavid #+# #+# */
/* Updated: 2023/04/02 17:52:59 by maldavid ### ########.fr */
/* Updated: 2023/12/08 19:08:01 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -14,6 +14,7 @@
#define __MLX_VK_FENCE__
#include <volk.h>
#include <core/profile.h>
#include <renderer/core/render_core.h>
namespace mlx

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/08 19:03:04 by maldavid #+# #+# */
/* Updated: 2022/12/18 17:42:08 by maldavid ### ########.fr */
/* Updated: 2023/12/08 19:08:14 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -15,6 +15,7 @@
#include <volk.h>
#include <vector>
#include <core/profile.h>
namespace mlx
{

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/08 19:01:49 by maldavid #+# #+# */
/* Updated: 2022/12/18 22:44:37 by maldavid ### ########.fr */
/* Updated: 2023/12/08 19:08:25 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -16,6 +16,7 @@
#include <volk.h>
#include <optional>
#include <cstdint>
#include <core/profile.h>
namespace mlx
{

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/08 18:59:38 by maldavid #+# #+# */
/* Updated: 2023/04/02 17:55:10 by maldavid ### ########.fr */
/* Updated: 2023/12/08 19:08:36 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -15,6 +15,7 @@
#include <volk.h>
#include <vector>
#include <core/profile.h>
namespace mlx
{

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/08 18:57:55 by maldavid #+# #+# */
/* Updated: 2022/12/18 19:34:04 by maldavid ### ########.fr */
/* Updated: 2023/12/08 19:08:49 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -15,6 +15,7 @@
#include <volk.h>
#include <vector>
#include <core/profile.h>
namespace mlx
{

View File

@@ -6,7 +6,7 @@
/* By: maldavid <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/12/19 14:04:25 by maldavid #+# #+# */
/* Updated: 2022/12/19 14:05:19 by maldavid ### ########.fr */
/* Updated: 2023/12/08 19:09:02 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -14,6 +14,7 @@
#define __VK_VALIDATION_LAYERS__
#include <volk.h>
#include <core/profile.h>
namespace mlx
{

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/23 18:32:43 by maldavid #+# #+# */
/* Updated: 2023/01/23 18:44:40 by maldavid ### ########.fr */
/* Updated: 2023/12/08 19:09:20 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -15,6 +15,7 @@
#include <volk.h>
#include <cstddef>
#include <core/profile.h>
namespace mlx
{

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/23 18:39:36 by maldavid #+# #+# */
/* Updated: 2023/12/07 19:47:07 by kbz_8 ### ########.fr */
/* Updated: 2023/12/08 19:09:31 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -15,6 +15,7 @@
#include <volk.h>
#include <array>
#include <core/profile.h>
#include <renderer/core/render_core.h>
namespace mlx

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/23 18:36:22 by maldavid #+# #+# */
/* Updated: 2023/03/31 17:54:03 by maldavid ### ########.fr */
/* Updated: 2023/12/08 19:09:44 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -17,6 +17,7 @@
#include <cstddef>
#include <vector>
#include <map>
#include <core/profile.h>
namespace mlx
{

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/08 02:24:58 by maldavid #+# #+# */
/* Updated: 2023/11/25 10:01:35 by maldavid ### ########.fr */
/* Updated: 2023/12/08 19:10:09 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -21,6 +21,7 @@
#include <renderer/descriptors/vk_descriptor_set.h>
#include <renderer/buffers/vk_ibo.h>
#include <renderer/buffers/vk_vbo.h>
#include <core/profile.h>
namespace mlx
{

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/04/07 16:36:33 by maldavid #+# #+# */
/* Updated: 2023/12/07 18:50:53 by kbz_8 ### ########.fr */
/* Updated: 2023/12/08 19:10:22 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -16,6 +16,7 @@
#include <renderer/images/texture.h>
#include <array>
#include <glm/glm.hpp>
#include <core/profile.h>
namespace mlx
{

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/25 11:54:21 by maldavid #+# #+# */
/* Updated: 2023/11/18 17:10:05 by maldavid ### ########.fr */
/* Updated: 2023/12/08 19:10:38 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -18,6 +18,7 @@
#include <vector>
#include <renderer/command/vk_cmd_buffer.h>
#include <renderer/command/vk_cmd_pool.h>
#include <core/profile.h>
namespace mlx
{

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/12/18 21:23:52 by maldavid #+# #+# */
/* Updated: 2022/12/19 00:27:29 by maldavid ### ########.fr */
/* Updated: 2023/12/08 19:10:51 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -14,6 +14,7 @@
#define __PIPELINE__
#include <volk.h>
#include <core/profile.h>
#include <renderer/command/vk_cmd_buffer.h>
namespace mlx

View File

@@ -6,13 +6,14 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/31 13:18:50 by maldavid #+# #+# */
/* Updated: 2023/08/02 05:27:27 by maldavid ### ########.fr */
/* Updated: 2023/12/08 19:11:43 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef __MLX_PIXEL_PUT__
#define __MLX_PIXEL_PUT__
#include <core/profile.h>
#include <renderer/images/texture.h>
#include <renderer/descriptors/vk_descriptor_set.h>

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/12/18 17:14:45 by maldavid #+# #+# */
/* Updated: 2023/11/20 07:26:12 by maldavid ### ########.fr */
/* Updated: 2023/12/08 19:12:06 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -31,6 +31,7 @@
#include <renderer/descriptors/vk_descriptor_set_layout.h>
#include <core/errors.h>
#include <core/profile.h>
#include <glm/glm.hpp>

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/06 18:19:44 by maldavid #+# #+# */
/* Updated: 2023/11/18 16:44:16 by maldavid ### ########.fr */
/* Updated: 2023/12/08 19:11:04 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -14,6 +14,7 @@
#define __MLX_VK_FRAMEBUFFER__
#include <volk.h>
#include <core/profile.h>
namespace mlx
{

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/06 18:22:00 by maldavid #+# #+# */
/* Updated: 2023/11/20 07:24:48 by maldavid ### ########.fr */
/* Updated: 2023/12/08 19:11:14 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -14,6 +14,7 @@
#define __MLX_VK_RENDER_PASS__
#include <volk.h>
#include <core/profile.h>
namespace mlx
{

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/06 18:23:27 by maldavid #+# #+# */
/* Updated: 2023/11/20 07:25:30 by maldavid ### ########.fr */
/* Updated: 2023/12/08 19:11:30 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -15,6 +15,7 @@
#include <vector>
#include <volk.h>
#include <core/profile.h>
#include <renderer/images/vk_image.h>
namespace mlx

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/04/10 11:52:30 by maldavid #+# #+# */
/* Updated: 2023/04/12 11:38:57 by maldavid ### ########.fr */
/* Updated: 2023/12/08 19:12:24 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -20,6 +20,7 @@
#include <memory>
#include <vector>
#include <cstdint>
#include <core/profile.h>
namespace mlx
{

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/04/06 16:24:11 by maldavid #+# #+# */
/* Updated: 2023/11/24 19:08:04 by maldavid ### ########.fr */
/* Updated: 2023/12/08 19:12:40 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -20,6 +20,7 @@
#include <cstdint>
#include <unordered_set>
#include <renderer/text_library.h>
#include <core/profile.h>
namespace mlx
{

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/04/11 16:20:25 by maldavid #+# #+# */
/* Updated: 2023/11/25 10:47:10 by maldavid ### ########.fr */
/* Updated: 2023/12/08 19:13:00 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/04 17:55:21 by maldavid #+# #+# */
/* Updated: 2023/12/08 12:23:07 by kbz_8 ### ########.fr */
/* Updated: 2023/12/08 18:08:13 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -22,12 +22,14 @@ typedef struct s_mlx
void *img;
} t_mlx;
int update(t_mlx *mlx)
int update(void *param)
{
static int i = 0;
int j;
int k;
t_mlx *mlx;
mlx = (t_mlx *)param;
mlx_put_image_to_window(mlx->mlx, mlx->win, mlx->logo, 100, 100);
mlx_put_image_to_window(mlx->mlx, mlx->win, mlx->img, 150, 60);
mlx_string_put(mlx->mlx, mlx->win, 20, 50, 0xFFFFFFFF, "that's a text");
@@ -41,8 +43,7 @@ int update(t_mlx *mlx)
k++;
j++;
}
i++;
if (i == 5000)
if (++i == 5000)
{
mlx_clear_window(mlx->mlx, mlx->win);
mlx_set_font_scale(mlx->mlx, mlx->win, "font.ttf", 16.f);
@@ -79,17 +80,17 @@ void *create_image(t_mlx *mlx)
return (img);
}
int key_hook(int key, t_mlx *param)
int key_hook(int key, void *param)
{
if (key == 41)
mlx_loop_end(param->mlx);
mlx_loop_end(((t_mlx *)param)->mlx);
return (0);
}
int window_hook(int event, t_mlx *param)
int window_hook(int event, void *param)
{
if (event == 0)
mlx_loop_end(param->mlx);
mlx_loop_end(((t_mlx *)param)->mlx);
return (0);
}

3246
valgrind.supp git.filemode.normal_file

File diff suppressed because it is too large Load Diff

76
xmake.lua git.filemode.normal_file
View File

@@ -0,0 +1,76 @@
--------------------------------------------------------------------------------
-- --
-- ::: :::::::: --
-- xmake.lua :+: :+: :+: --
-- +:+ +:+ +:+ --
-- By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ --
-- +#+#+#+#+#+ +#+ --
-- Created: 2023/12/07 15:21:38 by kbz_8 #+# #+# --
-- Updated: 2023/12/07 15:21:38 by kbz_8 ### ########.fr --
-- --
--------------------------------------------------------------------------------
-- Global settings
add_requires("libsdl", "vulkan-headers")
add_rules("mode.debug", "mode.release")
set_languages("cxx17", "c99")
set_objectdir("objs/xmake/$(os)_$(arch)")
set_targetdir("./")
set_optimize("fastest")
-- Options
option("images_optimized")
set_default(true)
add_defines("IMAGE_OPTIMIZED")
option_end()
option("force_integrated_gpu")
set_default(false)
add_defines("FORCE_INTEGRATED_GPU")
option_end()
option("graphics_memory_dump")
set_default(false)
add_defines("GRAPHICS_MEMORY_DUMP")
option_end()
-- Targets
target("mlx")
set_default(true)
set_license("MIT")
set_kind("shared")
add_options("images_optimized")
add_options("force_integrated_gpu")
add_options("graphics_memory_dump")
add_includedirs("includes", "src", "third_party")
add_defines("MLX_BUILD")
add_files("src/**.cpp")
add_packages("libsdl", "vulkan-headers")
if is_mode("debug") then
add_defines("DEBUG")
end
target_end() -- optional but I think the code is cleaner with this -- optional but I think the code is cleaner with this
target("Test")
set_default(false)
set_kind("binary")
set_targetdir("test")
add_linkdirs("./")
add_deps("mlx")
add_files("test/main.c")
add_packages("libsdl")
target_end()