take a bulldozer to some code

This commit is contained in:
Greg Wells
2025-05-20 17:39:40 -04:00
parent 43c6f88d18
commit a4166ae5c2
30 changed files with 495 additions and 503 deletions

View File

@@ -1,27 +1,32 @@
#pragma once
#include <gryphn/gryphn_utils.h>
#include <platform/gryphn_platform_include.h>
#include <core/init/gryphn_init.h>
#include <core/instance/gryphn_instance.h>
#include <core/presentation_queue/gryphn_presentation_queue.h>
#include <core/buffers/vertex_descriptions/gryphn_vertex_description.h>
#include <core/buffers/gryphn_buffer.h>
#include <core/textures/gryphn_texture.h>
#include <core/uniform_descriptor/gryphn_uniform_layout_binding.h>
#include <core/uniform_descriptor/gryphn_uniform_layout.h>
#include <core/graphics_pipeline/gryphn_render_pass.h>
#include <core/sync_objects/gryphn_sync_semaphore.h>
#include <core/sync_objects/gryphn_fence.h>
#include <core/commands/gryphn_command_buffer.h>
#include <core/commands/gryphn_command.h>
#include <core/commands/present_command/gryphn_command_present.h>
#include <core/commands/submit_command/gryphn_command_submit.h>
#include <core/buffers/gryphn_buffer.h>
#include <core/uniform_descriptor/gryphn_uniform.h>
#include <core/uniform_descriptor/uniform_buffer/gryphn_uniform_buffer.h>
#include <core/uniform_descriptor/sampler/gryphn_sampler.h>
#include <core/push_constant/gryphn_push_constant.h>
#include <core/graphics_pipeline/gryphn_graphics_pipeline.h>
#include <core/gryphn_support.h>
#include <core/framebuffers/gryphn_framebuffer.h>
// #pragma once
// #include <gryphn/gryphn_utils.h>
// #include <platform/gryphn_platform_include.h>
// #include <core/init/gryphn_init.h>
// #include <core/instance/gryphn_instance.h>
// #include <core/presentation_queue/gryphn_presentation_queue.h>
// #include <core/buffers/vertex_descriptions/gryphn_vertex_description.h>
// #include <core/buffers/gryphn_buffer.h>
// #include <core/textures/gryphn_texture.h>
// #include <core/uniform_descriptor/gryphn_uniform_layout_binding.h>
// #include <core/uniform_descriptor/gryphn_uniform_layout.h>
// #include <core/graphics_pipeline/gryphn_render_pass.h>
// #include <core/sync_objects/gryphn_sync_semaphore.h>
// #include <core/sync_objects/gryphn_fence.h>
// #include <core/commands/gryphn_command_buffer.h>
// #include <core/commands/gryphn_command.h>
// #include <core/commands/present_command/gryphn_command_present.h>
// #include <core/commands/submit_command/gryphn_command_submit.h>
// #include <core/buffers/gryphn_buffer.h>
// #include <core/uniform_descriptor/gryphn_uniform.h>
// #include <core/uniform_descriptor/uniform_buffer/gryphn_uniform_buffer.h>
// #include <core/uniform_descriptor/sampler/gryphn_sampler.h>
// #include <core/push_constant/gryphn_push_constant.h>
// #include <core/graphics_pipeline/gryphn_graphics_pipeline.h>
// #include <core/gryphn_support.h>
// #include <core/framebuffers/gryphn_framebuffer.h>

View File

@@ -1,23 +1,20 @@
#pragma once
#include <utils/gryphn_bool.h>
#include <utils/lists/gryphn_list.h>
// #include <utils/gryphn_bool.h>
#include <utils/gryphn_error_code.h>
#include <utils/version/gryphn_version.h>
#include <utils/math/gryphn_vec2.h>
#include <utils/math/gryphn_vec3.h>
#include <utils/math/gryphn_vec4.h>
#include <utils/types/gryphn_color.h>
#include <utils/types/gryphn_color_format.h>
#include <utils/types/gryphn_image_format.h>
#include <utils/gryphn_access_level.h>
#include <utils/strings/gryphn_string.h>
// #include <utils/math/gryphn_vec2.h>
// #include <utils/math/gryphn_vec3.h>
// #include <utils/math/gryphn_vec4.h>
// #include <utils/types/gryphn_color.h>
// #include <utils/types/gryphn_color_format.h>
// #include <utils/types/gryphn_image_format.h>
// #include <utils/strings/gryphn_string.h>
#include <cstdint>
typedef uint32_t gnUInt;
typedef gnChar gnByte;
typedef unsigned char gnUByte;
typedef int gnInt;
typedef float gnFloat;
typedef size_t gnSize;
// typedef uint32_t gnUInt;
// typedef gnChar gnByte;
// typedef unsigned char gnUByte;
// typedef int gnInt;
// typedef float gnFloat;
// typedef size_t gnSize;
#define GN_EXPORT extern "C"
// #define GN_EXPORT extern "C"

View File

@@ -0,0 +1,17 @@
#undef GN_UTILS_CPP
#include "gryphn_debugger.h"
static gnReturnCode (*_gnCreateDebugger)(gnDebugger* debugger, const struct gnDebuggerInfo_t info);
static void (*_gnDestroyDebugger)(gnDebugger* debugger);
void gn_load_functions() {
}
// void gnAddDebugLayer(gnDebugger& debugger, const gnString& layer) {
// gnListAdd(debugger.debug_layers, layer);
// }
// const gnList<gnString>& gnDebuggerGetDebugLayers(gnDebugger& debugger) {
// return debugger.debug_layers;
// }

View File

@@ -1,9 +0,0 @@
#include "gryphn_debugger.h"
void gnAddDebugLayer(gnDebugger& debugger, const gnString& layer) {
gnListAdd(debugger.debug_layers, layer);
}
const gnList<gnString>& gnDebuggerGetDebugLayers(gnDebugger& debugger) {
return debugger.debug_layers;
}

View File

@@ -1,28 +1,17 @@
#pragma once
#include <gryphn/gryphn_utils.h>
#include <iostream>
#include "gryphn_layers.h"
#include "utils/strings/gryphn_string.h"
#include "utils/gryphn_error_code.h"
struct gnPlatformDebugger;
struct gnDebugger;
static gnDebugger* gnDebuggerInstance = nullptr;
inline void gnDebugError(gnString error);
typedef struct gnDebuggerInfo_t {
int layerCount;
gnString* layerNames;
} gnDebuggerInfo;
struct gnDebugger {
ACCESS_LEVEL:
gnPlatformDebugger* debugger;
gnList<gnString> debug_layers = gnCreateList<gnString>();
public:
gnDebugger() {
if (debugger) gnDebugError(gnCreateString("Debugger instance already created (you can only have one debugger)"));
gnDebuggerInstance = this;
}
};
typedef struct gnDebugger_t {
struct gnPlatformDebugger* debugger;
} gnDebugger;
inline void gnDebugError(gnString error) { std::cout << gnToCString(error) << "\n"; }
void gnAddDebugLayer(gnDebugger& debugger, const gnString& layer);
const gnList<gnString>& gnDebuggerGetDebugLayers(gnDebugger& debugger);
inline gnReturnCode (*gnCreateDebugger)(gnDebugger* instance);
inline void (*gnDestroyDebugger)(gnDebugger& instance);
gnReturnCode gnCreateDebugger(gnDebugger* debugger, const struct gnDebuggerInfo_t info);
gnReturnCode gnDestroyDebugger(gnDebugger* debugger);

View File

@@ -1,6 +0,0 @@
#pragma once
#include <gryphn/gryphn_utils.h>
inline gnString (*gnGetPlatformLayerName)(const gnString& gnName);
#define GN_DEFAULT_DEBUG_LAYER gnGetPlatformLayerName("GN_DEFAULT_DEBUG_LAYER")

View File

@@ -0,0 +1,10 @@
#pragma once
// theoretically you could have multible gryphn instances running in one application,
// why I dont know
#include "utils/gryphn_error_code.h"
#include "instance/gryphn_instance.h"
typedef struct gnFunctions_t {
gnReturnCode (*_gnCreateInstance)(gnInstance* instance, struct gnInstanceInfo_t info);
void (*_gnDestroyInstance)(gnInstance* instance);
} gnFunctions;

View File

@@ -1,7 +1,7 @@
#pragma once
#include "gryphn/gryphn_utils.h"
#include "utils/strings/gryphn_string.h"
enum gnRenderingAPI {
typedef enum gnRenderingAPI_t {
GN_RENDERINGAPI_NONE, // idk why im putting this
GN_RENDERINGAPI_SOFTWARE, // i kinda wanna write a software renderer
@@ -9,9 +9,9 @@ enum gnRenderingAPI {
GN_RENDERINGAPI_VULKAN,
GN_RENDERINGAPI_DIRECTX11, GN_RENDERINGAPI_DIRECTX12,
GN_RENDERINGAPI_METAL
};
} gnRenderingAPI;
inline gnString gnRenderingAPIName(gnRenderingAPI api) {
static gnString gnRenderingAPIName(gnRenderingAPI api) {
switch (api) {
case GN_RENDERINGAPI_NONE: return gnCreateString("GN_RENDERINGAPI_NONE");
case GN_RENDERINGAPI_SOFTWARE: return gnCreateString("GN_RENDERINGAPI_SOFTWARE");

View File

@@ -1,174 +0,0 @@
#include <core/init/gryphn_init.h>
#include <dlfcn.h>
#include <platform/gryphn_platform_include.h>
#include <algorithm>
#include <gryphn/gryphn.h>
bool RenderingAPISupported(gnRenderingAPI api) {
std::vector<gnRenderingAPI> supportedRenderingAPIS = gnGetSupportedRenderingAPIS();
return std::find(supportedRenderingAPIS.begin(), supportedRenderingAPIS.end(), api) != supportedRenderingAPIS.end();
}
static void* gnRenderingAPILIB;
//#define LOAD_FUNC(dll, func) gnPlatformLoadDLLFunction(dll, func, gnString(#func) + "Fn")
#define gnLoadDLLFunction(dll, func, func_name) \
gnPlatformLoadDLLFunction(dll, func, func_name); \
if (func == nullptr) return gnReturnError(GN_FUNCTION_NOT_FOUND, gnString("GN_FUNC_(") + gnString(#func) + ")_NOT_LOADED")
gnReturnCode gnInit(gnRenderingAPI RenderingAPI) {
gnString libName = "";
switch (RenderingAPI) {
case GN_RENDERINGAPI_NONE: {
return gnReturnError(GN_UNSUPPORTED_RENDERING_API, "rendering api_none unsupported");
}
case GN_RENDERINGAPI_SOFTWARE: {
return gnReturnError(GN_UNSUPPORTED_RENDERING_API, "rendering api_software unsupported");
}
case GN_RENDERINGAPI_OPENGL: {
return gnReturnError(GN_UNSUPPORTED_RENDERING_API, "rendering api_opengl unsupported");
}
case GN_RENDERINGAPI_VULKAN: {
if (!RenderingAPISupported(GN_RENDERINGAPI_VULKAN)) return gnReturnError(GN_UNSUPPORTED_RENDERING_API, "rendering api vulkan unsupported");
libName = "GryphnVulkanImpl";
break;
}
case GN_RENDERINGAPI_DIRECTX11: {
return gnReturnError(GN_UNSUPPORTED_RENDERING_API, "rendering api directx11 unsupported");
}
case GN_RENDERINGAPI_DIRECTX12: {
return gnReturnError(GN_UNSUPPORTED_RENDERING_API, "rendering api directx12 unsupported");
}
case GN_RENDERINGAPI_METAL: {
if (!RenderingAPISupported(GN_RENDERINGAPI_METAL)) return gnReturnError(GN_UNSUPPORTED_RENDERING_API, "rendering api metal unsupported");
libName = "GryphnMetalImpl";
break;
}
}
gnRenderingAPILIB = gnPlatformLoadDLL(gnString("gryphn/rendering_apis/") + libName);
if (!gnRenderingAPILIB) { return gnReturnError(GN_UNABLE_TO_LOAD_DLL, "GN_ERROR_UNABLE_TO_LOAD_DLL"); }
gnLoadDLLFunction(gnRenderingAPILIB, gnCreateInstance, "gnCreateInstanceFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnDestroyInstance, "gnDestroyInstanceFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnGetPlatformLayerName, "gnGetPlatformLayerNameFn");
// LOAD THE SET WINDOW FUNCTIONS
#ifdef GN_PLATFORM_LINUX
#ifdef GN_WINDOW_X11
gnLoadDLLFunction(gnRenderingAPILIB, gnCreateX11WindowSurface, "gnCreateX11WindowSurfaceFn");
#endif
#ifdef GN_WINDOW_WAYLAND
gnLoadDLLFunction(gnRenderingAPILIB, gnCreateWaylandWindowSurface, "gnCreateWaylandWindowSurfaceFn");
#endif
#endif
#ifdef GN_PLATFORM_WIN32
gnLoadDLLFunction(gnRenderingAPILIB, gnCreateWindowsWindowSurface, "gnCreateWindowsWindowSurfaceFn");
#endif
#ifdef GN_PLATFORM_MACOS
gnLoadDLLFunction(gnRenderingAPILIB, gnCreateMacOSWindowSurface, "gnCreateMacOSWindowSurfaceFn");
#endif
// This is stupid
gnLoadDLLFunction(gnRenderingAPILIB, gnCreateDebugger, "gnCreateDebuggerFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnDestroyDebugger, "gnDestroyDebuggerFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnGetPhysicalOutputDevices, "gnGetPhysicalOutputDevicesFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnDeviceSupportsAPI, "gnDeviceSupportsAPIFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnRegisterOutputDevice, "gnRegisterOutputDeviceFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnWaitForDevice, "gnWaitForDeviceFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnDestroyOutputDevice, "gnDestroyOutputDeviceFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnGetDevicePresentationDetails, "gnGetDevicePresentationDetailsFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnPresentationQueueGetNextImageAsync, "gnPresentationQueueGetNextImageAsyncFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnPresentationQueueGetState, "gnPresentationQueueGetStateFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnCreatePresentationQueue, "gnCreatePresentationQueueFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnDestroyPresentationQueue, "gnDestroyPresentationQueueFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnVertexDescriptionSetBindingDescription, "gnVertexDescriptionSetBindingDescriptionFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnVertexDescriptionSetPropertiesCount, "gnVertexDescriptionSetPropertiesCountFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnVertexDescriptionSetProperty, "gnVertexDescriptionSetPropertyFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnCreateBuffer, "gnCreateBufferFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnBufferData, "gnBufferDataFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnBufferMapData, "gnBufferMapDataFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnDestroyBuffer, "gnDestroyBufferFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnBufferSubData, "gnBufferSubDataFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnBufferClearData, "gnBufferClearDataFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnTextureData, "gnTextureDataFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnTextureCubeMapData, "gnTextureCubeMapDataFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnCreateTexture, "gnCreateTextureFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnDestroyTexture, "gnDestroyTextureFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnCreateUniformLayout, "gnCreateUniformLayoutFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnDestroyUniformLayout, "gnDestroyUniformLayoutFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnCreateRenderPass, "gnCreateRenderPassFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnDestroyRenderPass, "gnDestroyRenderPassFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnCreateFence, "gnCreateFenceFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnWaitForFence, "gnWaitForFenceFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnResetFence, "gnResetFenceFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnDestroyFence, "gnDestroyFenceFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnCreateCommandBuffer, "gnCreateCommandBufferFn");
gnLoadDLLFunction(gnRenderingAPILIB, _gnCreateCommandBuffers, "_gnCreateCommandBuffersFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnCommandBufferReset, "gnCommandBufferResetFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnDestroyCommandBuffer, "gnDestroyCommandBufferFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnBuildShaderModule, "gnBuildShaderModuleFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnDestroyShaderModule, "gnDestroyShaderModuleFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnBuildShader, "gnBuildShaderFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnCreateUniform, "gnCreateUniformFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnDestroyUniform, "gnDestroyUniformFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnUpdateSamplerUniform, "gnUpdateSamplerUniformFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnUpdateBufferUniform, "gnUpdateBufferUniformFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnAPISupports, "gnAPISupportsFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineSetPrimative, "gnGraphicsPipelineSetPrimativeFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineEnableDynamicStates, "gnGraphicsPipelineEnableDynamicStatesFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineEnableDynamicState, "gnGraphicsPipelineEnableDynamicStateFn");
gnLoadDLLFunction(gnRenderingAPILIB, _gnGraphicsPipelineSetViewport, "_gnGraphicsPipelineSetViewportFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineSetCrop, "gnGraphicsPipelineSetCropFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineSetDepthClamp, "gnGraphicsPipelineSetDepthClampFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineSetFillMode, "gnGraphicsPipelineSetFillModeFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineSetLineWidth, "gnGraphicsPipelineSetLineWidthFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineSetCullMode, "gnGraphicsPipelineSetCullModeFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineSetMultisampling, "gnGraphicsPipelineSetMultisamplingFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineEnableDepthTest, "gnGraphicsPipelineEnableDepthTestFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineSetColorBlend, "gnGraphicsPipelineSetColorBlendFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineSetVertexDescription, "gnGraphicsPipelineSetVertexDescriptionFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineBindShader, "gnGraphicsPipelineBindShaderFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineSetRenderPass, "gnGraphicsPipelineSetRenderPassFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineAddUniformLayout, "gnGraphicsPipelineAddUniformLayoutFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineAddPushConstant, "gnGraphicsPipelineAddPushConstantFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnCreateGraphicsPipeline, "gnCreateGraphicsPipelineFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnDestroyGraphicsPipeline, "gnDestroyGraphicsPipelineFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnCreateFramebuffer, "gnCreateFramebufferFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnDestroyFramebuffer, "gnDestroyFramebufferFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnCreateFramebufferAttachment, "gnCreateFramebufferAttachmentFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnCreateSyncSemaphore, "gnCreateSyncSemaphoreFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnDestroySyncSemaphore, "gnDestroySyncSemaphoreFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnCommandBufferStart, "gnCommandBufferStartFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnCommandBufferEnd, "gnCommandBufferEndFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnCommandBeginRenderPass, "gnCommandBeginRenderPassFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnCommandSetGraphicsPipeline, "gnCommandSetGraphicsPipelineFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnCommandBindSamplerUniform, "gnCommandBindSamplerUniformFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnCommandBindBuffer, "gnCommandBindBufferFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnCommandBindBufferUniform, "gnCommandBindBufferUniformFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnCommandPushConstant, "gnCommandPushConstantFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnCommandDrawIndexed, "gnCommandDrawIndexedFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnCommandSetViewport, "gnCommandSetViewportFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnCommandSetScissor, "gnCommandSetScissorFn");
gnLoadDLLFunction(gnRenderingAPILIB, _gnCommandDraw, "gnCommandDrawFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnCommandEndRenderPass, "gnCommandEndRenderPassFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnCommandSubmitGetValidPresentationQueue, "gnCommandSubmitGetValidPresentationQueueFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnCommandSubmit, "gnCommandSubmitFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnCommandPresentGetValidPresentationQueue, "gnCommandPresentGetValidPresentationQueueFn");
gnLoadDLLFunction(gnRenderingAPILIB, gnCommandPresent, "gnCommandPresentFn");
// fucking hell I just realized that I do have to load in all the commands
// I hate the way I chose to do this
return GN_SUCCESS;
}
void gnDestroy() {
dlclose(gnRenderingAPILIB);
}

View File

@@ -1,10 +0,0 @@
#pragma once
#include <gryphn/gryphn_utils.h>
#include <core/gryphn_rendering_api.h>
gnErrorCode gnInit(gnRenderingAPI RenderingAPI);
void gnDestroy();
inline gnString cachePath;
static void gnSetCachePath(const gnString& path) { cachePath = path; }
static const gnString& gnGetCachePath() { return cachePath; }

View File

@@ -1,9 +0,0 @@
#pragma once
#include <gryphn/gryphn_utils.h>
struct gnAppInfo {
gnString ApplicationName;
gnString EngineName;
gnVersion ApplicationVersion;
gnVersion EngineVersion;
};

View File

@@ -0,0 +1,15 @@
#include "gryphn_instance.h"
#include "init/gryphn_init.h"
#include <core/gryphn_platform_functions.h>
gnReturnCode gnCreateInstance(gnInstance* instance, struct gnInstanceInfo_t info) {
if (!gnIsAPISupported(info.renderingAPI)) return GN_UNSUPPORTED_RENDERING_API;
instance->dynamicLib = gnLoadRenderingDLL(info.renderingAPI);
if (instance->dynamicLib == NULL) return GN_UNABLE_TO_LOAD_DYNAMIC_LIBARRY;
gnLoadFunctions(instance->dynamicLib, instance->functions);
return instance->functions->_gnCreateInstance(instance, info);
}
void gnDestroyInstance(gnInstance* instance) {
instance->functions->_gnDestroyInstance(instance);
}

View File

@@ -1,9 +0,0 @@
#include "gryphn_instance.h"
void gnInstanceSetDebugger(gnInstance& instance, gnDebugger& debugger) {
instance.debugger = &debugger;
}
void gnInstanceSetAppInfo(gnInstance& instance, const gnAppInfo info) {
instance.AppInfo = info;
}

View File

@@ -1,47 +1,51 @@
#pragma once
#include <gryphn/gryphn_utils.h>
#include "application_information/gryphn_app_info.h"
#include "core/debugger/gryphn_debugger.h"
#include <core/output_device/gryphn_output_device.h>
#include <platform/gryphn_platform_include.h>
#include "core/gryphn_rendering_api.h"
struct gnPlatformInstanceData;
struct gnPlatformInstance;
struct gnFunctions_t;
struct gnDynamicLibrary_t;
struct gnInstance {
ACCESS_LEVEL:
bool valid = false;
gnPlatformInstanceData* instance = nullptr;
gnAppInfo AppInfo;
gnDebugger* debugger;
public:
gnInstance() {}
};
typedef struct gnInstanceInfo_t {
gnString applicationName;
gnVersion applicationVersion;
void gnInstanceSetAppInfo(gnInstance& instance, const gnAppInfo info);
void gnInstanceSetDebugger(gnInstance& instance, gnDebugger& debugger);
gnString engineName;
gnVersion engineVersion;
inline gnReturnCode (*gnCreateInstance)(gnInstance* instance);
inline void (*gnDestroyInstance)(gnInstance& instance);
// inline gnReturnCode (*gnInstanceSetWindow)(gnInstance& instance, GLFWwindow* window);
gnRenderingAPI renderingAPI;
} gnInstanceInfo;
#ifdef GN_PLATFORM_LINUX
#ifdef GN_WINDOW_X11
inline gnReturnCode (*gnCreateX11WindowSurface)(gnInstance& instance, Display* display, Window* window);
#endif
#ifdef GN_WINDOW_WAYLAND
inline gnReturnCode (*gnCreateWaylandWindowSurface)(gnInstance& instance, wl_display* display, wl_surface* surface);
#endif
#endif
typedef struct gnInstance_t {
struct gnPlatformInstance* instance;
gnBool valid;
struct gnFunctions_t* functions;
struct gnDynamicLibrary_t* dynamicLib;
} gnInstance;
gnReturnCode gnCreateInstance(gnInstance* instance, struct gnInstanceInfo_t info);
void gnDestroyInstance(gnInstance* instance);
// // inline gnReturnCode (*gnInstanceSetWindow)(gnInstance& instance, GLFWwindow* window);
// #ifdef GN_PLATFORM_LINUX
// #ifdef GN_WINDOW_X11
// inline gnReturnCode (*gnCreateX11WindowSurface)(gnInstance& instance, Display* display, Window* window);
// #endif
// #ifdef GN_WINDOW_WAYLAND
// inline gnReturnCode (*gnCreateWaylandWindowSurface)(gnInstance& instance, wl_display* display, wl_surface* surface);
// #endif
// #endif
#ifdef GN_PLATFORM_WIN32
inline gnReturnCode (*gnCreateWindowsWindowSurface)(gnInstance& instance, HWND* window, HINSTANCE* instance);
#endif
// #ifdef GN_PLATFORM_WIN32
// inline gnReturnCode (*gnCreateWindowsWindowSurface)(gnInstance& instance, HWND* window, HINSTANCE* instance);
// #endif
#ifdef GN_PLATFORM_MACOS
inline gnReturnCode (*gnCreateMacOSWindowSurface)(gnInstance& instance, NS::Window* window, NS::View* view);
#endif
// #ifdef GN_PLATFORM_MACOS
// typedef void* NSWindow;
// typedef void* NSView;
// TODO: if instance creation fails add in a query to why the instance creation failed
// Lowkey thats a lot of work tho and I dont really want to do alllllll that
// inline gnReturnCode (*gnCreateMacOSWindowSurface)(gnInstance& instance, NSWindow window, NSView view);
// #endif

View File

@@ -0,0 +1,14 @@
#pragma once
#include "utils/strings/gryphn_string.h"
#include "utils/gryphn_bool.h"
typedef struct gnDynamicLibrary_t {
void* dllPtr;
gnBool isValid;
} gnDynamicLibrary;
struct gnDynamicLibrary_t* gnLoadDynamicLibrary(const gnString path);
void gnUnloadDynamicLibrary(struct gnDynamicLibrary_t* dll);
void* gnLoadFunctionPtr(struct gnDynamicLibrary_t* dll, const char* name);
#define gnLoadDLLFunction(dll, function, name) function = (typeof(function))gnLoadFunctionPtr(dll, name)

View File

@@ -0,0 +1,168 @@
// #undef GN_UTILS_CPP
#include "gryphn_init.h"
#include <platform/gryphn_platform_include.h>
#include "gryphn_dynamic_library.h"
// #include <dlfcn.h>
gnBool gnIsAPISupported(gnRenderingAPI api) {
int renderingAPICount = 0;
gnRenderingAPI* supportedRenderingAPIS = gnGetSupportedRenderingAPIs(&renderingAPICount);
for (int i = 0; i < renderingAPICount; i++) if (supportedRenderingAPIS[i] == api) return true;
return false;
}
struct gnDynamicLibrary_t* gnLoadRenderingDLL(gnRenderingAPI renderingAPI) {
gnString libName = gnCreateEmptyString();
switch (renderingAPI) {
case GN_RENDERINGAPI_NONE: return NULL;
case GN_RENDERINGAPI_SOFTWARE: return NULL;
case GN_RENDERINGAPI_OPENGL: return NULL;
case GN_RENDERINGAPI_VULKAN: {
if (!gnIsAPISupported(GN_RENDERINGAPI_VULKAN)) return NULL;
libName = gnCreateString("GryphnVulkanImpl");
break;
}
case GN_RENDERINGAPI_DIRECTX11: return NULL;
case GN_RENDERINGAPI_DIRECTX12: return NULL;
case GN_RENDERINGAPI_METAL: {
if (!gnIsAPISupported(GN_RENDERINGAPI_METAL)) return NULL;
libName = gnCreateString("GryphnMetalImpl");
break;
}
}
return gnLoadDynamicLibrary(gnCombineStrings(gnCreateString("gryphn/rendering_apis/"), libName));
}
void gnLoadFunctions(struct gnDynamicLibrary_t* lib, struct gnFunctions_t* functions) {
gnLoadDLLFunction(lib, functions->_gnCreateInstance, "gnCreateInstanceFn");
gnLoadDLLFunction(lib, functions->_gnDestroyInstance, "gnDestroyInstanceFn");
}
// gnReturnCode gnInit(gnRenderingAPI RenderingAPI) {
// gnRenderingAPILIB = gnLoadDLL(gnCombineStrings(gnCreateString("gryphn/rendering_apis/"), libName));
// if (!gnRenderingAPILIB.isValid) { return GN_UNABLE_TO_LOAD_DLL; }
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCreateInstance, "gnCreateInstanceFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnDestroyInstance, "gnDestroyInstanceFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnGetPlatformLayerName, "gnGetPlatformLayerNameFn");
// // LOAD THE SET WINDOW FUNCTIONS
// // #ifdef GN_PLATFORM_LINUX
// // #ifdef GN_WINDOW_X11
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCreateX11WindowSurface, "gnCreateX11WindowSurfaceFn");
// // #endif
// // #ifdef GN_WINDOW_WAYLAND
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCreateWaylandWindowSurface, "gnCreateWaylandWindowSurfaceFn");
// // #endif
// // #endif
// // #ifdef GN_PLATFORM_WIN32
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCreateWindowsWindowSurface, "gnCreateWindowsWindowSurfaceFn");
// // #endif
// // #ifdef GN_PLATFORM_MACOS
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCreateMacOSWindowSurface, "gnCreateMacOSWindowSurfaceFn");
// // #endif
// // This is stupid
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCreateDebugger, "gnCreateDebuggerFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnDestroyDebugger, "gnDestroyDebuggerFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnGetPhysicalOutputDevices, "gnGetPhysicalOutputDevicesFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnDeviceSupportsAPI, "gnDeviceSupportsAPIFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnRegisterOutputDevice, "gnRegisterOutputDeviceFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnWaitForDevice, "gnWaitForDeviceFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnDestroyOutputDevice, "gnDestroyOutputDeviceFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnGetDevicePresentationDetails, "gnGetDevicePresentationDetailsFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnPresentationQueueGetNextImageAsync, "gnPresentationQueueGetNextImageAsyncFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnPresentationQueueGetState, "gnPresentationQueueGetStateFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCreatePresentationQueue, "gnCreatePresentationQueueFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnDestroyPresentationQueue, "gnDestroyPresentationQueueFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnVertexDescriptionSetBindingDescription, "gnVertexDescriptionSetBindingDescriptionFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnVertexDescriptionSetPropertiesCount, "gnVertexDescriptionSetPropertiesCountFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnVertexDescriptionSetProperty, "gnVertexDescriptionSetPropertyFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCreateBuffer, "gnCreateBufferFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnBufferData, "gnBufferDataFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnBufferMapData, "gnBufferMapDataFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnDestroyBuffer, "gnDestroyBufferFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnBufferSubData, "gnBufferSubDataFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnBufferClearData, "gnBufferClearDataFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnTextureData, "gnTextureDataFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnTextureCubeMapData, "gnTextureCubeMapDataFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCreateTexture, "gnCreateTextureFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnDestroyTexture, "gnDestroyTextureFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCreateUniformLayout, "gnCreateUniformLayoutFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnDestroyUniformLayout, "gnDestroyUniformLayoutFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCreateRenderPass, "gnCreateRenderPassFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnDestroyRenderPass, "gnDestroyRenderPassFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCreateFence, "gnCreateFenceFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnWaitForFence, "gnWaitForFenceFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnResetFence, "gnResetFenceFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnDestroyFence, "gnDestroyFenceFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCreateCommandBuffer, "gnCreateCommandBufferFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, _gnCreateCommandBuffers, "_gnCreateCommandBuffersFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCommandBufferReset, "gnCommandBufferResetFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnDestroyCommandBuffer, "gnDestroyCommandBufferFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnBuildShaderModule, "gnBuildShaderModuleFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnDestroyShaderModule, "gnDestroyShaderModuleFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnBuildShader, "gnBuildShaderFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCreateUniform, "gnCreateUniformFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnDestroyUniform, "gnDestroyUniformFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnUpdateSamplerUniform, "gnUpdateSamplerUniformFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnUpdateBufferUniform, "gnUpdateBufferUniformFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnAPISupports, "gnAPISupportsFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineSetPrimative, "gnGraphicsPipelineSetPrimativeFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineEnableDynamicStates, "gnGraphicsPipelineEnableDynamicStatesFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineEnableDynamicState, "gnGraphicsPipelineEnableDynamicStateFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, _gnGraphicsPipelineSetViewport, "_gnGraphicsPipelineSetViewportFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineSetCrop, "gnGraphicsPipelineSetCropFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineSetDepthClamp, "gnGraphicsPipelineSetDepthClampFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineSetFillMode, "gnGraphicsPipelineSetFillModeFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineSetLineWidth, "gnGraphicsPipelineSetLineWidthFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineSetCullMode, "gnGraphicsPipelineSetCullModeFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineSetMultisampling, "gnGraphicsPipelineSetMultisamplingFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineEnableDepthTest, "gnGraphicsPipelineEnableDepthTestFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineSetColorBlend, "gnGraphicsPipelineSetColorBlendFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineSetVertexDescription, "gnGraphicsPipelineSetVertexDescriptionFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineBindShader, "gnGraphicsPipelineBindShaderFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineSetRenderPass, "gnGraphicsPipelineSetRenderPassFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineAddUniformLayout, "gnGraphicsPipelineAddUniformLayoutFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnGraphicsPipelineAddPushConstant, "gnGraphicsPipelineAddPushConstantFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCreateGraphicsPipeline, "gnCreateGraphicsPipelineFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnDestroyGraphicsPipeline, "gnDestroyGraphicsPipelineFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCreateFramebuffer, "gnCreateFramebufferFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnDestroyFramebuffer, "gnDestroyFramebufferFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCreateFramebufferAttachment, "gnCreateFramebufferAttachmentFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCreateSyncSemaphore, "gnCreateSyncSemaphoreFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnDestroySyncSemaphore, "gnDestroySyncSemaphoreFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCommandBufferStart, "gnCommandBufferStartFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCommandBufferEnd, "gnCommandBufferEndFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCommandBeginRenderPass, "gnCommandBeginRenderPassFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCommandSetGraphicsPipeline, "gnCommandSetGraphicsPipelineFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCommandBindSamplerUniform, "gnCommandBindSamplerUniformFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCommandBindBuffer, "gnCommandBindBufferFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCommandBindBufferUniform, "gnCommandBindBufferUniformFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCommandPushConstant, "gnCommandPushConstantFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCommandDrawIndexed, "gnCommandDrawIndexedFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCommandSetViewport, "gnCommandSetViewportFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCommandSetScissor, "gnCommandSetScissorFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, _gnCommandDraw, "gnCommandDrawFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCommandEndRenderPass, "gnCommandEndRenderPassFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCommandSubmitGetValidPresentationQueue, "gnCommandSubmitGetValidPresentationQueueFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCommandSubmit, "gnCommandSubmitFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCommandPresentGetValidPresentationQueue, "gnCommandPresentGetValidPresentationQueueFn");
// // gnLoadDLLFunction(gnRenderingAPILIB, gnCommandPresent, "gnCommandPresentFn");
// return GN_SUCCESS;
// }
// void* gnLoadFunction(gnString name) {
// return gnLoadFunctionPtr(gnRenderingAPILIB, name);
// }
// void gnDestroy() {
// gnUnloadDLL(&gnRenderingAPILIB);
// }

View File

@@ -0,0 +1,15 @@
#pragma once
#include <gryphn/gryphn_utils.h>
#include <core/gryphn_rendering_api.h>
#include "core/gryphn_platform_functions.h"
// #include "utils/gryphn_error_code.h"
gnBool gnIsAPISupported(gnRenderingAPI RenderingAPI);
struct gnDynamicLibrary_t* gnLoadRenderingDLL(gnRenderingAPI RenderingAPI);
void gnLoadFunctions(struct gnDynamicLibrary_t* lib, struct gnFunctions_t* functions);
// #ifdef GN_REVEAL_IMPL
// gnErrorCode gnInit(gnRenderingAPI RenderingAPI);
// void gnDestroy();
// void* gnLoadFunction(gnString name);
// #endif

View File

@@ -24,7 +24,7 @@ inline gnReturnCode (*gnCreatePresentationQueue)(gnPresentationQueue* presentati
inline void (*gnDestroyPresentationQueue)(gnPresentationQueue& queue);
inline gnImageFormat (*_gnPresentationQueueGetImageFormat)(gnPresentationQueue& presentationQueue);
inline gnImageFormat gnPresentationQueueGetImageFormat(gnPresentationQueue& presentationQueue) {
std::cout << "gnPresentationQueueGetImageFormat should lowkey become supported\n";
// std::cout << "gnPresentationQueueGetImageFormat should lowkey become supported\n";
return _gnPresentationQueueGetImageFormat(presentationQueue);
}
inline gnPresentationQueueState (*gnPresentationQueueGetState)(gnPresentationQueue& presentationQueue);

View File

@@ -1,8 +1,8 @@
#pragma once
#include "core/gryphn_rendering_api.h"
#ifdef GN_PLATFORM_LINUX
#include <platform/platform_linux/gryphn_platform_linux.h>
#include "platform_linux/gryphn_platform_linux.h"
#endif
#ifdef GN_PLATFORM_MACOS
@@ -10,16 +10,14 @@
#endif
#ifdef GN_PLATFORM_WINDOWS
#include <platform/platform_windows/gryphn_platform_windows.h>
#include "platform_windows/gryphn_platform_windows.h"
#endif
#include <core/gryphn_rendering_api.h>
gnRenderingAPI* gnGetSupportedRenderingAPIs(int* count);
std::vector<gnRenderingAPI> gnGetSupportedRenderingAPIS();
void* gnPlatformLoadDLL(gnString name);
void* gnLoadFunctionPtr(void* dll, gnString name);
template <typename function>
void gnPlatformLoadDLLFunction(void *dll, function& func, gnString name) {
func = (function)gnLoadFunctionPtr(dll, name);
}
// #ifdef __cplusplus
// template <typename function>
// void gnPlatformLoadDLLFunction(void *dll, function& func, gnString name) {
// func = (function)gnLoadFunctionPtr(dll, name);
// }
// #endif

View File

@@ -0,0 +1,33 @@
#ifdef GN_PLATFORM_MACOS
#undef GN_UTILS_CPP
#include "core/gryphn_rendering_api.h"
#include "core/instance/init/gryphn_dynamic_library.h"
#include "dlfcn.h"
gnRenderingAPI renderingAPIs[3] = {
GN_RENDERINGAPI_METAL,
GN_RENDERINGAPI_VULKAN,
GN_RENDERINGAPI_SOFTWARE
};
gnRenderingAPI* gnGetSupportedRenderingAPIs(int* count) {
*count = 3;
return renderingAPIs;
}
struct gnDynamicLibrary_t* gnLoadDynamicLibrary(const gnString path) {
struct gnDynamicLibrary_t* dll = malloc(sizeof(struct gnDynamicLibrary_t));
dll->dllPtr = dlopen(gnToCString(gnCombineStrings(path, ".dylib")), RTLD_LAZY),
dll->isValid = true
if (dll->dllPtr == NULL) dll->isValid = false;
return dll;
}
void* gnLoadFunctionPtr(struct gnDynamicLibrary_t* dll, const char* name) {
if (dll->isValid == false) return NULL;
return dlsym(dll->dllPtr, name);
}
void gnUnloadDynamicLibrary(struct gnDynamicLibrary_t* dll) {
if (dll->isValid) dlclose(dll->dllPtr);
}
#endif

View File

@@ -1,17 +0,0 @@
#ifdef GN_PLATFORM_MACOS
#include <platform/platform_macos/gryphn_platform_macos.h>
#include <dlfcn.h>
std::vector<gnRenderingAPI> gnGetSupportedRenderingAPIS() {
return { GN_RENDERINGAPI_METAL, GN_RENDERINGAPI_VULKAN };
}
void* gnPlatformLoadDLL(gnString name) {
return dlopen(gnToCString(name + ".dylib"), RTLD_LAZY);
}
void* gnLoadFunctionPtr(void *dll, gnString name) {
return dlsym(dll, gnToCString(name));
}
#endif

View File

@@ -1,11 +1,3 @@
#pragma once
#include <core/gryphn_rendering_api.h>
#include <utils/strings/gryphn_string.h>
#include <vector>
#include <dlfcn.h>
namespace NS {
struct Window;
struct View;
}
// #include "AppKit/NSView.hpp"

View File

@@ -1,29 +1,27 @@
#pragma once
typedef enum gnReturnCode {
GN_SUCCESS, GN_WARNING, GN_FAILED,
GN_ERROR = GN_FAILED
typedef enum gnReturnCode_t {
GN_SUCCESS,
GN_UNKNOWN_RENDERINGAPI,
GN_UNSUPPORTED_RENDERING_API,
GN_UNABLE_TO_LOAD_DYNAMIC_LIBARRY
// GN_UNKNOWN_ERROR,
// GN_UNKNOWN_FRAMEBUFFER_ATTACHMENT,
// GN_UNKNOWN_SHADER_MODULE,
// GN_UNKNOWN_FUNCTION,
// GN_SHADER_FAILED_TO_COMPILE,
// GN_UNSUPPORTED_COLOR_FORMAT,
// GN_UNKNOWN_COLOR_FORMAT,
// GN_FUNCTION_NOT_FOUND,
// GN_FAILED_CREATE_DEVICE,
// GN_FAILED_CREATE_GRAPHICS_PIPELINE,
// GN_FAILED_CREATE_PRESENTATION_QUEUE,
// GN_FAILED_TO_CREATE_FRAMEBUFFER,
// GN_FAILED_CREATE_RENDERPASS,
// GN_FAILED_CREATE_INSTANCE,
// GN_FAILED_TO_ATTACH_WINDOW,
// GN_FAILED_TO_CREATE_IMAGE
} gnReturnCode;
typedef enum gnReturnMessage {
GN_UNKNOWN_ERROR,
GN_UNKNOWN_FRAMEBUFFER_ATTACHMENT,
GN_UNKNOWN_SHADER_MODULE,
GN_SHADER_FAILED_TO_COMPILE,
GN_UNSUPPORTED_COLOR_FORMAT,
GN_UNKNOWN_COLOR_FORMAT,
GN_UNSUPPORTED_RENDERING_API,
GN_FUNCTION_NOT_FOUND,
GN_UNABLE_TO_LOAD_DLL,
GN_FAILED_CREATE_DEVICE,
GN_FAILED_CREATE_GRAPHICS_PIPELINE,
GN_FAILED_CREATE_PRESENTATION_QUEUE,
GN_FAILED_TO_CREATE_FRAMEBUFFER,
GN_FAILED_CREATE_RENDERPASS,
GN_FAILED_CREATE_INSTANCE,
GN_FAILED_TO_ATTACH_WINDOW,
GN_FAILED_TO_CREATE_IMAGE
} gnReturnMessage;
typedef gnReturnCode gnErrorCode;
typedef gnReturnMessage gnErrorMessage;

View File

@@ -1,16 +1,16 @@
#pragma once
#include "stdlib.h"
typedef struct gnCList {
typedef struct gnArrayList {
int count;
int maxCount;
void* data;
} gnCList;
} gnArrayList;
const int GROWTH_RATE = 2; // i heard somewhere that 1.5 is better but imma use 2 because I also heard that its better somewhere else
inline gnCList gnCreateCList(int count) {
gnCList newList;
inline gnArrayList gnCreateArrayList(int count) {
gnArrayList newList;
if (count == 0) {
@@ -23,7 +23,7 @@ inline gnCList gnCreateCList(int count) {
return newList;
}
inline void gnCListResize(gnCList* cList, int count) {
inline void gnArrayListResize(gnArrayList* cList, int count) {
cList->count = count;
while (cList->count > cList->maxCount) {
int oldMaxCount = cList->maxCount;
@@ -36,7 +36,7 @@ inline void gnCListResize(gnCList* cList, int count) {
cList->data = realloc(cList->data, cList->maxCount);
}
inline void gnCListReserve(gnCList* cList, int count) {
inline void gnArrayListReserve(gnArrayList* cList, int count) {
while (cList->count > cList->maxCount) {
int oldMaxCount = cList->maxCount;
cList->maxCount *= GROWTH_RATE;

View File

@@ -0,0 +1,22 @@
#pragma once
#include "stdlib.h"
// why would one use a linked list
typedef struct gnLinkedList {
void* data;
gnLinkedList* nextNode;
} gnLinkedList;
static gnLinkedList gnCreateLinkedList(int count) {
gnLinkedList list;
gnLinkedList* currentNode = &list;
for (int i = 0; i < count; i++) {
if ((i + 1) < count) {
currentNode->nextNode = (gnLinkedList*)malloc(sizeof(gnLinkedList));
currentNode = currentNode->nextNode;
}
}
return list;
}

View File

@@ -1,85 +0,0 @@
#pragma once
#include "math.h"
#include "stdio.h"
// TODO: Wack ass list class, needs some serious refactoring, buttttt it works for what I need it to do
// Imma touch this later cuz like I dont like working with C code cuz its wierd but like its also fun
// who needs std::vector when you've got malloc, calloc, and free
// shit just forgot that I dont clean any of this up, imma do this later cuz like its boring
// ive decided to do it now, I hate this, I hate coding, C is fun, this is a Cpp file, what am I doing with life
// I never did it id be super easy just like one anitconstructor????? i dont remeber what is called its the one with the squigly bracked
// TODO: future me rewirte these comments to be less stupid
// TODO: Add insert function, also remove function, orrrrrr i could have people copy lists whever they wanna remove stuff, nah thats gunna piss me off too
#define GRYPHN_LIST_GROWTH_RATE 2 // number straight from my ass I wanted to use 1.5f cuz thats what STL does but like it complained
// im in an abbusive relationship with the compiler, I need to get out of this
// but like I also kinda like it imma pick of drinking (not actually imma just play minecraft)
template <typename Type> // fuck templates
struct gnList {
protected:
Type* items = nullptr;
int size = 0, max_size = 0;
public:
gnList() {}
// why did I make shit protected
// theres gotta be a better way to do this with compiler macros but like that sounds hard
// im never touching this wack ass code ever again
template <typename T>
friend gnList<T> gnCreateList(int size);
template <typename T>
friend void gnListAdd(gnList<T>& list, T item);
template <typename T>
friend int gnListLength(const gnList<T>& list);
template <typename T>
friend T& gnListGet(const gnList<T>& list, int index);
template <typename T>
friend T* gnListGetPtr(const gnList<T>& list, int index);
template <typename T>
friend void gnListSet(const gnList<T>& list, int index, T item);
template <typename T>
friend T* gnListData(const gnList<T>& list);
public:
Type operator[](int index) const { return items[index]; } // idfk what that const is doin there but the compiler complained I was tryna change a const value
// .... I was not, I really am in an abusive relationship
Type& operator[](int index) { return items[index]; }
};
template <typename T>
gnList<T> gnCreateList(int size = 0) {
gnList<T> new_list = gnList<T>();
new_list.size = size;
if (size == 0) size = round(GRYPHN_LIST_GROWTH_RATE);
new_list.items = (T*)malloc(sizeof(T) * size);
new_list.max_size = size;
return new_list;
}
template <typename T>
void gnListAdd(gnList<T>& list, T item) {
if (gnListLength(list) == list.max_size) {
list.max_size = list.max_size * GRYPHN_LIST_GROWTH_RATE;
list.items = (T*)realloc(list.items, sizeof(T) * list.max_size);
}
list.items[list.size] = item;
list.size++;
}
template <typename T>
int gnListLength(const gnList<T>& list) { return list.size; }
template <typename T>
T& gnListGet(const gnList<T>& list, int index) { return list.items[index]; }
template <typename T>
T* gnListGetPtr(const gnList<T>& list, int index) { return &list.items[index]; }
template <typename T>
void gnListSet(const gnList<T>& list, int index, T item) { list.items[index] = item; }
template <typename T>
T* gnListData(const gnList<T>& list) { return list.items; } // wack ass function for binary shit
// if this ever breaks change it to return &list.items[0] cuz that might work
// I have zero clue what any of this shit does

View File

@@ -1,44 +1,77 @@
#pragma once
#include <unordered_map>
#include <string>
// very shitty vec2 class
#include "stdint.h"
template <typename T>
struct gnType2 {
typedef struct gnVec2 {
union {
struct { T a, b; };
struct { T x, y; };
struct { float a, b; };
struct { float x, y; };
};
public:
gnType2(T a, T b) { this->a = a; this->b = b; }
gnType2() {};
gnType2 operator-(const gnType2& other) {
gnType2 returnGnVec2;
#ifdef GN_UTILS_CPP
gnVec2(float x, float y) { this->x = x; this->y = y; }
gnVec2(float s) { this->x = s; this->y = s; }
gnVec2() {};
gnVec2 operator-(const gnVec2& other) {
gnVec2 returnGnVec2;
returnGnVec2.x = this->x - other.x;
returnGnVec2.y = this->y - other.y;
return returnGnVec2;
}
bool operator==(const gnType2& other) const {
bool operator==(const gnVec2& other) const {
return this->a == other.a && this->b == other.b;
}
#endif
} gnVec2;
typedef gnVec2 gnFVec2;
typedef gnVec2 gnFloat2;
typedef struct gnUInt2 {
union {
struct { uint32_t a, b; };
struct { uint32_t x, y; };
};
#ifdef GN_UTILS_CPP
gnUInt2(uint32_t x, uint32_t y) { this->x = x; this->y = y; }
gnUInt2(uint32_t s) { this->x = s; this->y = s; }
gnUInt2() {};
typedef gnType2<float> gnVec2;
typedef gnType2<float> gnFloat2;
typedef gnType2<uint32_t> gnUInt2;
typedef gnType2<int32_t> gnInt2;
namespace std {
template<>
struct hash<gnUInt2> {
std::size_t operator()(const gnUInt2& k) const {
return std::hash<uint32_t>()(k.x) ^ (std::hash<uint32_t>()(k.y) << 1);
gnUInt2 operator-(const gnUInt2& other) {
gnUInt2 returnGnVec2;
returnGnVec2.x = this->x - other.x;
returnGnVec2.y = this->y - other.y;
return returnGnVec2;
}
bool operator==(const gnUInt2& other) const {
return this->a == other.a && this->b == other.b;
}
#endif
} gnUInt2;
typedef struct gnInt2 {
union {
struct { int a, b; };
struct { int x, y; };
};
#ifdef GN_UTILS_CPP
gnInt2(int x, int y) { this->x = x; this->y = y; }
gnInt2(int s) { this->x = s; this->y = s; }
gnInt2() {};
gnInt2 operator-(const gnInt2& other) {
gnInt2 returnGnVec2;
returnGnVec2.x = this->x - other.x;
returnGnVec2.y = this->y - other.y;
return returnGnVec2;
}
bool operator==(const gnInt2& other) const {
return this->a == other.a && this->b == other.b;
}
#endif
} gnInt2;

View File

@@ -36,7 +36,7 @@ typedef struct gnUInt3 {
};
#ifdef GN_UTILS_CPP
gnUInt3(uint32_t x, uint32_t y) { this->x = x; this->y = y; this->z = z; }
gnUInt3(uint32_t x, uint32_t y, uint32_t z) { this->x = x; this->y = y; this->z = z; }
gnUInt3(uint32_t s) { this->x = s; this->y = s; this->z = s; }
gnUInt3() {};

View File

@@ -25,7 +25,7 @@ typedef char gnChar;
typedef struct gnString {
gnChar* value;
#ifdef GN_UTILS_CPP
#ifdef __cplusplus
gnString(const gnChar* input) {
this->value = new gnChar[strlen(input) + 1]; // so like my dumbass forgot to put this earlier and some shit was broken but now it fixed
// I was wondering why one specific string crashed my program, it was my fault

View File

@@ -1,3 +1,4 @@
#pragma once
typedef struct gnColor {
union {
struct {