diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml
new file mode 100644
index 0000000..e82f86c
--- /dev/null
+++ b/.github/workflows/windows.yml
@@ -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
diff --git a/.gitignore b/.gitignore
index 50cb388..2911f85 100644
--- a/.gitignore
+++ b/.gitignore
@@ -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
diff --git a/Makefile b/Makefile
index f5c7986..a6d8efe 100644
--- a/Makefile
+++ b/Makefile
@@ -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/**))
diff --git a/README.md b/README.md
index a7fae86..cfdd314 100644
--- a/README.md
+++ b/README.md
@@ -5,6 +5,9 @@
+
+

+
###### 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.
diff --git a/XMAKE_BUILD.md b/XMAKE_BUILD.md
new file mode 100644
index 0000000..b0e5218
--- /dev/null
+++ b/XMAKE_BUILD.md
@@ -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
+
+
+
\ No newline at end of file
diff --git a/includes/mlx.h b/includes/mlx.h
index 7c10776..57dc761 100644
--- a/includes/mlx.h
+++ b/includes/mlx.h
@@ -6,7 +6,7 @@
/* By: maldavid +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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
}
diff --git a/res/screenshot_test_windows.png b/res/screenshot_test_windows.png
new file mode 100644
index 0000000..65f5771
Binary files /dev/null and b/res/screenshot_test_windows.png differ
diff --git a/src/core/application.cpp b/src/core/application.cpp
index ba33ccf..f8ce592 100644
--- a/src/core/application.cpp
+++ b/src/core/application.cpp
@@ -6,7 +6,7 @@
/* By: maldavid +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/04 22:10:52 by maldavid #+# #+# */
-/* Updated: 2023/11/20 07:29:12 by maldavid ### ########.fr */
+/* Updated: 2023/12/08 13:32:18 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
diff --git a/src/core/application.h b/src/core/application.h
index 007e525..a877086 100644
--- a/src/core/application.h
+++ b/src/core/application.h
@@ -6,7 +6,7 @@
/* By: maldavid +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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
#include
+#include
namespace mlx::core
{
diff --git a/src/core/bridge.cpp b/src/core/bridge.cpp
index 9240ddc..854d9f5 100644
--- a/src/core/bridge.cpp
+++ b/src/core/bridge.cpp
@@ -15,6 +15,7 @@
#include "application.h"
#include
#include
+#include
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(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)->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)->loopHook(f, param);
return 0;
}
- int mlx_loop(mlx::core::Application* mlx)
+ int mlx_loop(void* mlx)
{
- mlx->run();
+ static_cast(mlx)->run();
return 0;
}
- int mlx_loop_end(mlx::core::Application* mlx)
+ int mlx_loop_end(void* mlx)
{
- mlx->loopEnd();
+ static_cast(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)->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)->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)->onEvent(win, static_cast(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)->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)->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(color_bits));
+ static_cast(mlx)->setTexturePixel(img, x, y, *reinterpret_cast(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)->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)->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)->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)->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)->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(color_bits));
+ static_cast(mlx)->pixelPut(win, x, y, *reinterpret_cast(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(color_bits), str);
+ static_cast(mlx)->stringPut(win, x, y, *reinterpret_cast(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)->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)->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)->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)->destroyGraphicsSupport(win);
return 0;
}
- int mlx_destroy_display(mlx::core::Application* mlx)
+ int mlx_destroy_display(void* mlx)
{
- delete mlx;
+ delete static_cast(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)->getScreenSize(w, h);
return 0;
}
-}
+}
\ No newline at end of file
diff --git a/src/core/errors.h b/src/core/errors.h
index b11db46..d8f5ba1 100644
--- a/src/core/errors.h
+++ b/src/core/errors.h
@@ -6,7 +6,7 @@
/* By: maldavid +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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
+#include
enum class e_kind
{
diff --git a/src/core/graphics.h b/src/core/graphics.h
index 6c19aaa..2680162 100644
--- a/src/core/graphics.h
+++ b/src/core/graphics.h
@@ -6,7 +6,7 @@
/* By: maldavid +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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
#include
#include
+#include
namespace mlx
{
diff --git a/src/core/memory.h b/src/core/memory.h
index 5e8c3eb..b4649e1 100644
--- a/src/core/memory.h
+++ b/src/core/memory.h
@@ -6,7 +6,7 @@
/* By: maldavid +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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
+#include
#include
namespace mlx
diff --git a/src/core/profile.h b/src/core/profile.h
index c5e45a2..45d6ed7 100644
--- a/src/core/profile.h
+++ b/src/core/profile.h
@@ -6,7 +6,7 @@
/* By: maldavid +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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
#include
diff --git a/src/platform/inputs.h b/src/platform/inputs.h
index 030171c..332d8e0 100644
--- a/src/platform/inputs.h
+++ b/src/platform/inputs.h
@@ -6,7 +6,7 @@
/* By: maldavid +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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
#include
+#include
+
#include "window.h"
namespace mlx
diff --git a/src/platform/window.h b/src/platform/window.h
index fa445ca..8923564 100644
--- a/src/platform/window.h
+++ b/src/platform/window.h
@@ -6,7 +6,7 @@
/* By: maldavid +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/04 21:53:12 by maldavid #+# #+# */
-/* Updated: 2023/11/25 11:33:32 by maldavid ### ########.fr */
+/* Updated: 2023/12/08 19:05:31 by kbz_8 ### ########.fr */
/* */
/* ************************************************************************** */
@@ -15,6 +15,7 @@
#include
#include
+#include
namespace mlx
{
diff --git a/src/renderer/buffers/vk_buffer.h b/src/renderer/buffers/vk_buffer.h
index 3cad686..783c486 100644
--- a/src/renderer/buffers/vk_buffer.h
+++ b/src/renderer/buffers/vk_buffer.h
@@ -6,7 +6,7 @@
/* By: maldavid +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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
#include
+#include
namespace mlx
{
diff --git a/src/renderer/buffers/vk_ibo.h b/src/renderer/buffers/vk_ibo.h
index 92f8c09..ecaa21f 100644
--- a/src/renderer/buffers/vk_ibo.h
+++ b/src/renderer/buffers/vk_ibo.h
@@ -6,7 +6,7 @@
/* By: maldavid +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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
#include "vk_buffer.h"
#include
+#include
namespace mlx
{
diff --git a/src/renderer/buffers/vk_ubo.h b/src/renderer/buffers/vk_ubo.h
index f1ca457..057e24e 100644
--- a/src/renderer/buffers/vk_ubo.h
+++ b/src/renderer/buffers/vk_ubo.h
@@ -6,7 +6,7 @@
/* By: maldavid +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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
#include
+#include
namespace mlx
{
diff --git a/src/renderer/buffers/vk_vbo.h b/src/renderer/buffers/vk_vbo.h
index a8c942c..7b52c76 100644
--- a/src/renderer/buffers/vk_vbo.h
+++ b/src/renderer/buffers/vk_vbo.h
@@ -6,7 +6,7 @@
/* By: maldavid +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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
+#include
namespace mlx
{
diff --git a/src/renderer/command/cmd_manager.h b/src/renderer/command/cmd_manager.h
index 4920d69..e6a13be 100644
--- a/src/renderer/command/cmd_manager.h
+++ b/src/renderer/command/cmd_manager.h
@@ -6,7 +6,7 @@
/* By: maldavid +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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
#include
+#include
#include
#include
#include
diff --git a/src/renderer/command/vk_cmd_buffer.h b/src/renderer/command/vk_cmd_buffer.h
index ee6d8df..0b4e742 100644
--- a/src/renderer/command/vk_cmd_buffer.h
+++ b/src/renderer/command/vk_cmd_buffer.h
@@ -6,7 +6,7 @@
/* By: maldavid +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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
#include
+#include
namespace mlx
{
diff --git a/src/renderer/command/vk_cmd_pool.h b/src/renderer/command/vk_cmd_pool.h
index 5445150..cacc651 100644
--- a/src/renderer/command/vk_cmd_pool.h
+++ b/src/renderer/command/vk_cmd_pool.h
@@ -6,7 +6,7 @@
/* By: maldavid +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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
+#include
namespace mlx
{
diff --git a/src/renderer/core/memory.h b/src/renderer/core/memory.h
index bb3e2b7..671a90b 100644
--- a/src/renderer/core/memory.h
+++ b/src/renderer/core/memory.h
@@ -6,7 +6,7 @@
/* By: maldavid +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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
#include
+#include
namespace mlx
{
diff --git a/src/renderer/core/render_core.cpp b/src/renderer/core/render_core.cpp
index 13e46cc..aa8ec23 100644
--- a/src/renderer/core/render_core.cpp
+++ b/src/renderer/core/render_core.cpp
@@ -24,7 +24,11 @@
#include
#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
diff --git a/src/renderer/core/render_core.h b/src/renderer/core/render_core.h
index 94b8c56..8319cca 100644
--- a/src/renderer/core/render_core.h
+++ b/src/renderer/core/render_core.h
@@ -6,7 +6,7 @@
/* By: maldavid +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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
#include
+#include
namespace mlx
{
diff --git a/src/renderer/core/vk_device.h b/src/renderer/core/vk_device.h
index 4078c96..c2353af 100644
--- a/src/renderer/core/vk_device.h
+++ b/src/renderer/core/vk_device.h
@@ -6,7 +6,7 @@
/* By: maldavid +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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
#include "vk_queues.h"
+#include
namespace mlx
{
diff --git a/src/renderer/core/vk_fence.h b/src/renderer/core/vk_fence.h
index a72cd02..342ce78 100644
--- a/src/renderer/core/vk_fence.h
+++ b/src/renderer/core/vk_fence.h
@@ -6,7 +6,7 @@
/* By: maldavid +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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
+#include
#include
namespace mlx
diff --git a/src/renderer/core/vk_instance.h b/src/renderer/core/vk_instance.h
index dc6e216..d5de82d 100644
--- a/src/renderer/core/vk_instance.h
+++ b/src/renderer/core/vk_instance.h
@@ -6,7 +6,7 @@
/* By: maldavid +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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
#include
+#include
namespace mlx
{
diff --git a/src/renderer/core/vk_queues.h b/src/renderer/core/vk_queues.h
index 5ed1b56..1716999 100644
--- a/src/renderer/core/vk_queues.h
+++ b/src/renderer/core/vk_queues.h
@@ -6,7 +6,7 @@
/* By: maldavid +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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
#include
#include
+#include
namespace mlx
{
diff --git a/src/renderer/core/vk_semaphore.h b/src/renderer/core/vk_semaphore.h
index 8c1371e..9ae964f 100644
--- a/src/renderer/core/vk_semaphore.h
+++ b/src/renderer/core/vk_semaphore.h
@@ -6,7 +6,7 @@
/* By: maldavid +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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
#include
+#include
namespace mlx
{
diff --git a/src/renderer/core/vk_surface.h b/src/renderer/core/vk_surface.h
index a39de21..24dd3ec 100644
--- a/src/renderer/core/vk_surface.h
+++ b/src/renderer/core/vk_surface.h
@@ -6,7 +6,7 @@
/* By: maldavid +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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
#include
+#include
namespace mlx
{
diff --git a/src/renderer/core/vk_validation_layers.h b/src/renderer/core/vk_validation_layers.h
index 8fb08c0..a956674 100644
--- a/src/renderer/core/vk_validation_layers.h
+++ b/src/renderer/core/vk_validation_layers.h
@@ -6,7 +6,7 @@
/* By: maldavid +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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
+#include
namespace mlx
{
diff --git a/src/renderer/descriptors/vk_descriptor_pool.h b/src/renderer/descriptors/vk_descriptor_pool.h
index 115cecb..7a97760 100644
--- a/src/renderer/descriptors/vk_descriptor_pool.h
+++ b/src/renderer/descriptors/vk_descriptor_pool.h
@@ -6,7 +6,7 @@
/* By: maldavid +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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
#include
+#include
namespace mlx
{
diff --git a/src/renderer/descriptors/vk_descriptor_set.h b/src/renderer/descriptors/vk_descriptor_set.h
index 0d39d72..d9c51d3 100644
--- a/src/renderer/descriptors/vk_descriptor_set.h
+++ b/src/renderer/descriptors/vk_descriptor_set.h
@@ -6,7 +6,7 @@
/* By: maldavid +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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
#include
+#include
#include
namespace mlx
diff --git a/src/renderer/descriptors/vk_descriptor_set_layout.h b/src/renderer/descriptors/vk_descriptor_set_layout.h
index 4066a1f..23d2ef2 100644
--- a/src/renderer/descriptors/vk_descriptor_set_layout.h
+++ b/src/renderer/descriptors/vk_descriptor_set_layout.h
@@ -6,7 +6,7 @@
/* By: maldavid +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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
#include
#include