From d5c6aa10aec2ab2f6f8021271bc781d4f9047da7 Mon Sep 17 00:00:00 2001 From: Gregory Wells Date: Fri, 8 May 2026 12:37:23 -0400 Subject: [PATCH] fix some build errors or something --- .gitignore | 1 + CMakeLists.txt | 7 ++++++- .../GryphnLoader/src/instance/gryphn_instance.c | 2 +- Gryphn/apis/GryphnMetal/src/metal.m | 4 ++-- Gryphn/apis/GryphnMetal/src/metal_device.m | 2 +- main.cpp | 17 +++++++++++++++++ 6 files changed, 28 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 567609b..bac7191 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ build/ +glfw diff --git a/CMakeLists.txt b/CMakeLists.txt index 4a180c1..29450d6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,9 +2,14 @@ cmake_minimum_required(VERSION 3.12) project(ChemistryRenderingApp LANGUAGES C CXX OBJCXX) # OBJCXX is required for Metal .mm files add_executable(ChemistryRenderingApp main.cpp) target_include_directories(ChemistryRenderingApp PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}") -target_link_libraries(ChemistryRenderingApp PRIVATE GryphnLoader) +target_include_directories(ChemistryRenderingApp PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/glfw/include/") +target_link_libraries(ChemistryRenderingApp PRIVATE GryphnLoader glfw) +project(ChemistryRenderingApp LANGUAGES C CXX OBJC OBJCXX) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) add_subdirectory(Gryphn) +set(BUILD_SHARED_LIBS ON) +add_subdirectory(glfw) +set(BUILD_SHARED_LIBS OFF) diff --git a/Gryphn/GryphnLoader/src/instance/gryphn_instance.c b/Gryphn/GryphnLoader/src/instance/gryphn_instance.c index 685d21b..c2547c0 100644 --- a/Gryphn/GryphnLoader/src/instance/gryphn_instance.c +++ b/Gryphn/GryphnLoader/src/instance/gryphn_instance.c @@ -1,6 +1,6 @@ +#include "gryphn_return_code.h" #include "gryphn_instance.h" #include "stdlib.h" -#include "stdio.h" typedef gnReturnCode (*PFN_initBackend)(gnInstance, gnInstanceCreateInfo*); diff --git a/Gryphn/apis/GryphnMetal/src/metal.m b/Gryphn/apis/GryphnMetal/src/metal.m index 633ce6d..3b2527e 100644 --- a/Gryphn/apis/GryphnMetal/src/metal.m +++ b/Gryphn/apis/GryphnMetal/src/metal.m @@ -4,7 +4,7 @@ #include "gryphn_handle.h" #include "metal_functions.h" -extern "C" uint32_t gnInternalIsApiSupported(gnVersion version) { +uint32_t gnInternalIsApiSupported(gnVersion version) { if (version != gnCreateVersion(1, 0, 0)) return 0; id testDevice = MTLCreateSystemDefaultDevice(); if (testDevice == nil) @@ -17,7 +17,7 @@ gnReturnCode destroyBackend(gnInstance instance) { return GN_SUCCESS; } -extern "C" gnReturnCode initBackend(gnInstance instance, gnInstanceCreateInfo* info) { +gnReturnCode initBackend(gnInstance instance, gnInstanceCreateInfo* info) { instance->dispatchTable.destroyInstance = destroyBackend; instance->dispatchTable.enumeratePhysicalDevices = metalEnumeratePhysicalDevices; instance->dispatchTable.getPhysicalDeviceProperties = metalGetPhysicalDeviceProperties; diff --git a/Gryphn/apis/GryphnMetal/src/metal_device.m b/Gryphn/apis/GryphnMetal/src/metal_device.m index d1aab41..8b01333 100644 --- a/Gryphn/apis/GryphnMetal/src/metal_device.m +++ b/Gryphn/apis/GryphnMetal/src/metal_device.m @@ -63,6 +63,6 @@ gnReturnCode metalCreateDevice(gnInstance instance, gnDeviceCreateInfo* createIn } gnReturnCode metalDestroyDevice(gnDevice device) { - // [device->internalData release]; + device->internalData = NULL; return GN_SUCCESS; } diff --git a/main.cpp b/main.cpp index b26fd94..d47d3ef 100644 --- a/main.cpp +++ b/main.cpp @@ -1,6 +1,7 @@ #include "Gryphn/gryphn.h" #include #include "stdlib.h" +#include "glfw/include/GLFW/glfw3.h" #define CONCAT_IMPL(a, b) a##b #define CONCAT(a, b) CONCAT_IMPL(a, b) @@ -11,6 +12,7 @@ << ": " << CONCAT(res, __LINE__) << "\n"; \ } +GLFWwindow* window; gnVersion version = gnCreateVersion(1, 0, 0); gnInstance instance; gnDevice device; @@ -61,13 +63,28 @@ void createDevice() { } int main() { + if (!glfwInit()) { + std::cout << "Failed to init GLFW\n"; + return -1; + } + + window = glfwCreateWindow(640, 360, "Chemistry Rendering App", nullptr, nullptr); + if (!window) { + std::cerr << "Failed to create window\n"; + return -1; + } + try { createInstance(); createDevice(); + while (!glfwWindowShouldClose(window)) { + glfwPollEvents(); + } } catch (const std::exception& e) { std::cerr << "Caught Exception: " << e.what() << "\n"; return 0; } + glfwDestroyWindow(window); gnDestroyDevice(&device); gnDestroyInstance(&instance); }