fix some build errors or something
This commit is contained in:
@@ -1 +1,2 @@
|
|||||||
build/
|
build/
|
||||||
|
glfw
|
||||||
|
|||||||
+6
-1
@@ -2,9 +2,14 @@ cmake_minimum_required(VERSION 3.12)
|
|||||||
project(ChemistryRenderingApp LANGUAGES C CXX OBJCXX) # OBJCXX is required for Metal .mm files
|
project(ChemistryRenderingApp LANGUAGES C CXX OBJCXX) # OBJCXX is required for Metal .mm files
|
||||||
add_executable(ChemistryRenderingApp main.cpp)
|
add_executable(ChemistryRenderingApp main.cpp)
|
||||||
target_include_directories(ChemistryRenderingApp PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
|
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 17)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
add_subdirectory(Gryphn)
|
add_subdirectory(Gryphn)
|
||||||
|
set(BUILD_SHARED_LIBS ON)
|
||||||
|
add_subdirectory(glfw)
|
||||||
|
set(BUILD_SHARED_LIBS OFF)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
|
#include "gryphn_return_code.h"
|
||||||
#include "gryphn_instance.h"
|
#include "gryphn_instance.h"
|
||||||
#include "stdlib.h"
|
#include "stdlib.h"
|
||||||
#include "stdio.h"
|
|
||||||
|
|
||||||
typedef gnReturnCode (*PFN_initBackend)(gnInstance, gnInstanceCreateInfo*);
|
typedef gnReturnCode (*PFN_initBackend)(gnInstance, gnInstanceCreateInfo*);
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
#include "gryphn_handle.h"
|
#include "gryphn_handle.h"
|
||||||
#include "metal_functions.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;
|
if (version != gnCreateVersion(1, 0, 0)) return 0;
|
||||||
id<MTLDevice> testDevice = MTLCreateSystemDefaultDevice();
|
id<MTLDevice> testDevice = MTLCreateSystemDefaultDevice();
|
||||||
if (testDevice == nil)
|
if (testDevice == nil)
|
||||||
@@ -17,7 +17,7 @@ gnReturnCode destroyBackend(gnInstance instance) {
|
|||||||
return GN_SUCCESS;
|
return GN_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" gnReturnCode initBackend(gnInstance instance, gnInstanceCreateInfo* info) {
|
gnReturnCode initBackend(gnInstance instance, gnInstanceCreateInfo* info) {
|
||||||
instance->dispatchTable.destroyInstance = destroyBackend;
|
instance->dispatchTable.destroyInstance = destroyBackend;
|
||||||
instance->dispatchTable.enumeratePhysicalDevices = metalEnumeratePhysicalDevices;
|
instance->dispatchTable.enumeratePhysicalDevices = metalEnumeratePhysicalDevices;
|
||||||
instance->dispatchTable.getPhysicalDeviceProperties = metalGetPhysicalDeviceProperties;
|
instance->dispatchTable.getPhysicalDeviceProperties = metalGetPhysicalDeviceProperties;
|
||||||
|
|||||||
@@ -63,6 +63,6 @@ gnReturnCode metalCreateDevice(gnInstance instance, gnDeviceCreateInfo* createIn
|
|||||||
}
|
}
|
||||||
|
|
||||||
gnReturnCode metalDestroyDevice(gnDevice device) {
|
gnReturnCode metalDestroyDevice(gnDevice device) {
|
||||||
// [device->internalData release];
|
device->internalData = NULL;
|
||||||
return GN_SUCCESS;
|
return GN_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "Gryphn/gryphn.h"
|
#include "Gryphn/gryphn.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "stdlib.h"
|
#include "stdlib.h"
|
||||||
|
#include "glfw/include/GLFW/glfw3.h"
|
||||||
|
|
||||||
#define CONCAT_IMPL(a, b) a##b
|
#define CONCAT_IMPL(a, b) a##b
|
||||||
#define CONCAT(a, b) CONCAT_IMPL(a, b)
|
#define CONCAT(a, b) CONCAT_IMPL(a, b)
|
||||||
@@ -11,6 +12,7 @@
|
|||||||
<< ": " << CONCAT(res, __LINE__) << "\n"; \
|
<< ": " << CONCAT(res, __LINE__) << "\n"; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GLFWwindow* window;
|
||||||
gnVersion version = gnCreateVersion(1, 0, 0);
|
gnVersion version = gnCreateVersion(1, 0, 0);
|
||||||
gnInstance instance;
|
gnInstance instance;
|
||||||
gnDevice device;
|
gnDevice device;
|
||||||
@@ -61,13 +63,28 @@ void createDevice() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
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 {
|
try {
|
||||||
createInstance();
|
createInstance();
|
||||||
createDevice();
|
createDevice();
|
||||||
|
while (!glfwWindowShouldClose(window)) {
|
||||||
|
glfwPollEvents();
|
||||||
|
}
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
std::cerr << "Caught Exception: " << e.what() << "\n";
|
std::cerr << "Caught Exception: " << e.what() << "\n";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
glfwDestroyWindow(window);
|
||||||
gnDestroyDevice(&device);
|
gnDestroyDevice(&device);
|
||||||
gnDestroyInstance(&instance);
|
gnDestroyInstance(&instance);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user