mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-01-10 06:03:34 +00:00
adding secret bindings
This commit is contained in:
0
in_depth_features/build.sh → in_depth_features/GetProcAddr/build.sh
git.filemode.changed_filemode%!(EXTRA template.HTML=git.filemode.executable_file, template.HTML=git.filemode.normal_file)
0
in_depth_features/build.sh → in_depth_features/GetProcAddr/build.sh
git.filemode.changed_filemode%!(EXTRA template.HTML=git.filemode.executable_file, template.HTML=git.filemode.normal_file)
28
in_depth_features/GetProcAddr/main.c
git.filemode.normal_file
28
in_depth_features/GetProcAddr/main.c
git.filemode.normal_file
@@ -0,0 +1,28 @@
|
||||
#include <stdio.h>
|
||||
#include <stddef.h>
|
||||
#include "../../includes/mlx.h"
|
||||
#include "../../includes/mlx_extended.h"
|
||||
|
||||
#include <vulkan/vulkan_core.h>
|
||||
|
||||
typedef VkInstance (*PFN_mlx_get_vk_instance)(mlx_context mlx);
|
||||
|
||||
int main(void)
|
||||
{
|
||||
mlx_context mlx = mlx_init();
|
||||
|
||||
mlx_window_create_info info = { 0 };
|
||||
info.title = "My window";
|
||||
info.width = 400;
|
||||
info.height = 400;
|
||||
info.is_resizable = true;
|
||||
mlx_window win = mlx_new_window(mlx, &info);
|
||||
|
||||
PFN_mlx_get_vk_instance mlx_get_vk_instance = (PFN_mlx_get_vk_instance)mlx_get_proc_addr(mlx, "mlx_get_vk_instance");
|
||||
printf("%p\n", mlx_get_vk_instance(mlx));
|
||||
|
||||
mlx_destroy_window(mlx, win);
|
||||
mlx_destroy_context(mlx);
|
||||
|
||||
return 0;
|
||||
}
|
||||
11
in_depth_features/RTT/build.sh
git.filemode.executable_file
11
in_depth_features/RTT/build.sh
git.filemode.executable_file
@@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ -e a.out ]; then
|
||||
rm a.out
|
||||
fi
|
||||
|
||||
if [ $(uname -s) = 'Darwin' ]; then
|
||||
clang main.c ../../libmlx.dylib -L /opt/homebrew/lib -lSDL2 -lm -g;
|
||||
else
|
||||
clang main.c ../../libmlx.so -lSDL2 -g -Wall -Wextra -Werror -lm;
|
||||
fi
|
||||
4
in_depth_features/RTT/run.sh
git.filemode.executable_file
4
in_depth_features/RTT/run.sh
git.filemode.executable_file
@@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
bash ./build.sh
|
||||
./a.out
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <contact@kbz8.me> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/10/04 16:56:35 by maldavid #+# #+# */
|
||||
/* Updated: 2025/01/05 22:44:22 by maldavid ### ########.fr */
|
||||
/* Updated: 2025/03/12 22:26:32 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -71,7 +71,7 @@ typedef union mlx_color
|
||||
/**
|
||||
* @brief Initializes the MLX internal application
|
||||
*
|
||||
* @return (mlx_context) An opaque handler to the internal MLX application or NULL (0x0) in case of error
|
||||
* @return (mlx_context) An opaque handler to the internal MLX application or MLX_NULL_HANDLE (0x0) in case of error
|
||||
*/
|
||||
MLX_API mlx_context mlx_init();
|
||||
|
||||
@@ -122,7 +122,7 @@ typedef struct mlx_window_create_info
|
||||
* @param mlx Internal MLX application
|
||||
* @param info Pointer to a descriptor structure
|
||||
*
|
||||
* @return (mlx_widnow) An opaque handler to the internal MLX window or NULL (0x0) in case of error
|
||||
* @return (mlx_window) An opaque handler to the internal MLX window or MLX_NULL_HANDLE (0x0) in case of error
|
||||
*/
|
||||
MLX_API mlx_window mlx_new_window(mlx_context mlx, const mlx_window_create_info* info);
|
||||
|
||||
@@ -328,7 +328,7 @@ MLX_API void mlx_pixel_put(mlx_context mlx, mlx_window win, int x, int y, mlx_co
|
||||
* @param width Width of the image
|
||||
* @param height Height of the image
|
||||
*
|
||||
* @return (mlx_image) An opaque handler to the internal image or NULL (0x0) in case of error
|
||||
* @return (mlx_image) An opaque handler to the internal image or MLX_NULL_HANDLE (0x0) in case of error
|
||||
*/
|
||||
MLX_API mlx_image mlx_new_image(mlx_context mlx, int width, int height);
|
||||
|
||||
@@ -340,7 +340,7 @@ MLX_API mlx_image mlx_new_image(mlx_context mlx, int width, int height);
|
||||
* @param width Get the width of the image
|
||||
* @param heigth Get the height of the image
|
||||
*
|
||||
* @return (mlx_image) An opaque handler to the internal image or NULL (0x0) in case of error
|
||||
* @return (mlx_image) An opaque handler to the internal image or MLX_NULL_HANDLE (0x0) in case of error
|
||||
*/
|
||||
MLX_API mlx_image mlx_new_image_from_file(mlx_context mlx, char* filename, int* width, int* height);
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <contact@kbz8.me> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/12/14 16:17:10 by maldavid #+# #+# */
|
||||
/* Updated: 2025/01/08 12:37:15 by maldavid ### ########.fr */
|
||||
/* Updated: 2025/03/12 22:03:45 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -171,6 +171,15 @@ MLX_API void mlx_set_image_region(mlx_context mlx, mlx_image image, int x, int y
|
||||
*/
|
||||
MLX_API void mlx_put_transformed_image_to_window(mlx_context mlx, mlx_window win, mlx_image image, int x, int y, float scale_x, float scale_y, float angle);
|
||||
|
||||
/**
|
||||
* @brief Get direct pointers to hidden functions
|
||||
*
|
||||
* @param mlx Internal MLX application
|
||||
*
|
||||
* @return (mlx_function) A function pointer or NULL (0x0) in case of error
|
||||
*/
|
||||
MLX_API mlx_function mlx_get_proc_addr(mlx_context mlx, const char* name);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/10 08:49:17 by maldavid #+# #+# */
|
||||
/* Updated: 2025/01/07 00:17:45 by maldavid ### ########.fr */
|
||||
/* Updated: 2025/03/12 22:01:07 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -202,6 +202,9 @@
|
||||
#define MLX_VERSION_PATCH(version) ((uint32_t)(version) & 0xFFFU)
|
||||
|
||||
#define MLX_DEFINE_HANDLE(object) typedef struct object##_handler* object
|
||||
#define MLX_NULL_HANDLE NULL
|
||||
|
||||
typedef void (*mlx_function)(void);
|
||||
|
||||
#define MLX_VERSION MLX_MAKE_VERSION(2, 0, 0)
|
||||
#define MLX_TARGET_VULKAN_API_VERSION MLX_MAKE_VERSION(1, 0, 0)
|
||||
|
||||
@@ -14,6 +14,8 @@ namespace mlx
|
||||
Handle CreateWindow(const mlx_window_create_info* info, std::int32_t& id, bool hidden);
|
||||
void DestroyWindow(Handle window) noexcept;
|
||||
|
||||
SDL_Window* GetRawWindow(Handle window) noexcept;
|
||||
|
||||
void InputsFetcher(std::function<void(mlx_event_type, int, int)> functor);
|
||||
|
||||
VkSurfaceKHR CreateVulkanSurface(Handle window, VkInstance instance) const noexcept;
|
||||
|
||||
@@ -38,6 +38,8 @@ namespace mlx
|
||||
MLX_FORCEINLINE std::vector<const char*> GetRequiredVulkanInstanceExtentions() const noexcept { return SDLManager::Get().GetRequiredVulkanInstanceExtentions(p_window); }
|
||||
MLX_FORCEINLINE Vec2ui GetVulkanDrawableSize() const noexcept { return SDLManager::Get().GetVulkanDrawableSize(p_window); }
|
||||
|
||||
[[nodiscard]] inline Handle GetRawHandle() const noexcept { return p_window; }
|
||||
|
||||
void Destroy() noexcept;
|
||||
|
||||
~Window() { Destroy(); }
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
#include <Core/Application.h>
|
||||
#include <Core/SDLManager.h>
|
||||
#include <Renderer/RenderCore.h>
|
||||
#include <mlx.h>
|
||||
#include <mlx_extended.h>
|
||||
#include <Core/Memory.h>
|
||||
#include <Core/Handles.h>
|
||||
#include <Renderer/RenderCore.h>
|
||||
|
||||
static mlx::Application* __internal_application_ptr = nullptr;
|
||||
|
||||
@@ -427,4 +427,63 @@ extern "C"
|
||||
return;
|
||||
gs->TexturePut(texture, x, y, scale_x, scale_y, angle);
|
||||
}
|
||||
|
||||
// Hidden bindings
|
||||
|
||||
VkInstance mlx_get_vk_instance(mlx_context mlx)
|
||||
{
|
||||
MLX_CHECK_APPLICATION_POINTER(mlx);
|
||||
return mlx::RenderCore::Get().GetInstance();
|
||||
}
|
||||
|
||||
VkPhysicalDevice mlx_get_vk_physical_device(mlx_context mlx)
|
||||
{
|
||||
MLX_CHECK_APPLICATION_POINTER(mlx);
|
||||
return mlx::RenderCore::Get().GetPhysicalDevice();
|
||||
}
|
||||
|
||||
VkDevice mlx_get_vk_device(mlx_context mlx)
|
||||
{
|
||||
MLX_CHECK_APPLICATION_POINTER(mlx);
|
||||
return mlx::RenderCore::Get().GetDevice();
|
||||
}
|
||||
|
||||
mlx_function mlx_get_vk_fn(const char* name)
|
||||
{
|
||||
#define MLX_VULKAN_GLOBAL_FUNCTION(fn) if(std::strcmp(name, #fn) == 0) return reinterpret_cast<mlx_function>(mlx::RenderCore::Get().fn);
|
||||
#define MLX_VULKAN_INSTANCE_FUNCTION(fn) if(std::strcmp(name, #fn) == 0) return reinterpret_cast<mlx_function>(mlx::RenderCore::Get().fn);
|
||||
#define MLX_VULKAN_DEVICE_FUNCTION(fn) if(std::strcmp(name, #fn) == 0) return reinterpret_cast<mlx_function>(mlx::RenderCore::Get().fn);
|
||||
#include <Renderer/Vulkan/VulkanDefs.h>
|
||||
#undef MLX_VULKAN_GLOBAL_FUNCTION
|
||||
#undef MLX_VULKAN_INSTANCE_FUNCTION
|
||||
#undef MLX_VULKAN_DEVICE_FUNCTION
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void* mlx_get_window_handle(mlx_context mlx, mlx_window win)
|
||||
{
|
||||
MLX_CHECK_APPLICATION_POINTER(mlx);
|
||||
mlx::NonOwningPtr<mlx::GraphicsSupport> gs = mlx->app->GetGraphicsSupport(win);
|
||||
if(!gs || !gs->HasWindow())
|
||||
return nullptr;
|
||||
return mlx::SDLManager::Get().GetRawWindow(gs->GetWindow()->GetRawHandle());
|
||||
}
|
||||
|
||||
mlx_function mlx_get_proc_addr(mlx_context mlx, const char* name)
|
||||
{
|
||||
MLX_CHECK_APPLICATION_POINTER(mlx);
|
||||
#define MLX_MAKE_ENTRY(fn) { #fn, reinterpret_cast<mlx_function>(fn) }
|
||||
std::unordered_map<std::string, mlx_function> entries = {
|
||||
MLX_MAKE_ENTRY(mlx_get_vk_instance),
|
||||
MLX_MAKE_ENTRY(mlx_get_vk_physical_device),
|
||||
MLX_MAKE_ENTRY(mlx_get_vk_device),
|
||||
MLX_MAKE_ENTRY(mlx_get_vk_fn),
|
||||
MLX_MAKE_ENTRY(mlx_get_window_handle),
|
||||
};
|
||||
auto it = entries.find(std::string{ name });
|
||||
if(it != entries.end())
|
||||
return it->second;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,8 +21,10 @@ namespace mlx
|
||||
{
|
||||
using namespace std::literals;
|
||||
|
||||
#ifndef DEBUG
|
||||
if(type == LogType::Debug && std::getenv("MLX_DEBUG_LOGS") == nullptr)
|
||||
return;
|
||||
#endif
|
||||
|
||||
std::string code_infos;
|
||||
if((type == LogType::Error || type == LogType::FatalError) && !file.empty() && !function.empty())
|
||||
|
||||
@@ -80,6 +80,12 @@ namespace mlx
|
||||
delete infos;
|
||||
}
|
||||
|
||||
SDL_Window* SDLManager::GetRawWindow(Handle window) noexcept
|
||||
{
|
||||
Internal::WindowInfos* infos = static_cast<Internal::WindowInfos*>(window);
|
||||
return infos->window;
|
||||
}
|
||||
|
||||
VkSurfaceKHR SDLManager::CreateVulkanSurface(Handle window, VkInstance instance) const noexcept
|
||||
{
|
||||
VkSurfaceKHR surface;
|
||||
|
||||
@@ -114,11 +114,11 @@ namespace mlx
|
||||
|
||||
void DescriptorPool::ReturnDescriptorSet(std::shared_ptr<DescriptorSet> set)
|
||||
{
|
||||
std::size_t i = 0;
|
||||
//std::size_t i = 0;
|
||||
auto it = std::find_if(m_used_sets.begin(), m_used_sets.end(), [&](const std::shared_ptr<DescriptorSet>& rhs_set)
|
||||
{
|
||||
i++;
|
||||
std::cout << m_used_sets.size() << " " << i << std::endl;
|
||||
//i++;
|
||||
//std::cout << m_used_sets.size() << " " << i << std::endl;
|
||||
return set == rhs_set;
|
||||
});
|
||||
if(it == m_used_sets.end())
|
||||
|
||||
Reference in New Issue
Block a user