Skip to content
This repository has been archived by the owner on Nov 6, 2024. It is now read-only.

Commit

Permalink
metal impl started; cocoa surface creation fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
krisvers committed Aug 1, 2024
1 parent 064e0e7 commit 02b6428
Show file tree
Hide file tree
Showing 8 changed files with 1,072 additions and 212 deletions.
10 changes: 6 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/.vscode/
/.vs/
/build/
/out/
.vscode/
.vs/
build/
out/
xcode/
.DS_Store
56 changes: 23 additions & 33 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,47 +7,37 @@ if ("${CMAKE_SIZEOF_VOID_P}" STREQUAL "4")
endif()

find_package(Vulkan REQUIRED)
set(LIB_PATH "")
if (WIN32)
if (IS_32_BIT)
set(LIB_PATH "tests/vendor/lib/vc-x86")
if (MINGW)
set(LIB_PATH "tests/vendor/lib/mingw-w32")
endif()
else()
set(LIB_PATH "tests/vendor/lib/vc-x64")
if (MINGW)
set(LIB_PATH "tests/vendor/lib/mingw-w64")
endif()
endif()
else()
find_package(glfw3 REQUIRED)
endif()

if (NOT "${LIB_PATH}" STREQUAL "")
link_directories(${LIB_PATH})
set(SOURCES "kgfx/src/kgfx_vk.cpp")
if (APPLE)
list(APPEND SOURCES "kgfx/src/kgfx_vk_cocoa.mm")
endif()

file(GLOB_RECURSE SOURCES "kgfx/src/*.cpp" "tests/*.cpp")
add_executable(kgfx ${SOURCES})
add_library(kgfx_vk SHARED ${SOURCES})

target_link_libraries(kgfx Vulkan::Vulkan)
target_link_libraries(kgfx_vk Vulkan::Vulkan)
include_directories(${Vulkan_INCLUDE_DIRS} "kgfx/include" "tests/vendor/include")

if (WIN32)
target_link_libraries(kgfx glfw3)
else()
target_link_libraries(kgfx glfw)
endif()

include_directories(${GLFW_INCLUDE_DIRS})

if (LINUX)
target_link_libraries(kgfx X11)
target_link_libraries(kgfx_vk X11)
elseif (APPLE)
target_link_libraries(kgfx "-framework Cocoa")
target_link_libraries(kgfx "-framework QuartzCore")
target_link_libraries(kgfx_vk "-framework Cocoa")
target_link_libraries(kgfx_vk "-framework QuartzCore")
endif()

target_compile_definitions(kgfx_vk PRIVATE KGFX_DYNAMIC_BUILD)

set_property(TARGET kgfx_vk PROPERTY CXX_STANDARD 17)

add_library(kgfx_mtl SHARED "kgfx/src/kgfx_mtl.mm")

target_link_libraries(kgfx_mtl "-framework Metal")
target_link_libraries(kgfx_mtl "-framework Cocoa")
target_link_libraries(kgfx_mtl "-framework QuartzCore")
target_link_libraries(kgfx_mtl "-framework Quartz")

include_directories("kgfx/include")

target_compile_definitions(kgfx_vk PRIVATE KGFX_DYNAMIC_BUILD)

set_property(TARGET kgfx PROPERTY CXX_STANDARD 17)
set_property(TARGET kgfx_mtl PROPERTY CXX_STANDARD 17)
15 changes: 1 addition & 14 deletions kgfx/include/kgfx/kgfx.h
Original file line number Diff line number Diff line change
Expand Up @@ -342,11 +342,6 @@ typedef struct KGFXRasterizerState {
KGFXbool clockWiseFrontFace;
} KGFXRasterizerState;

typedef struct KGFXFramebufferDesc {
KGFXTexture* pTextures;
KGFXu32 textureCount;
} KGFXFramebufferDesc;

typedef struct KGFXSwapchainDesc {
KGFXSurface surface;
KGFXFormat imageFormat;
Expand Down Expand Up @@ -614,16 +609,8 @@ KGFX_API KGFXbool kgfxEnumerateSurfaceFormats(
KGFX_API KGFXbool kgfxEnumerateSurfacePresentModes(
KGFXDevice device,
KGFXSurface surface,
KGFXu32 presetModeIndex,
KGFXu32 presentModeIndex,
KGFXPresentMode* pPresentMode);

KGFX_API KGFXu32 kgfxGetSurfaceWidth(
KGFXDevice device,
KGFXSurface surface);

KGFX_API KGFXu32 kgfxGetSurfaceHeight(
KGFXDevice device,
KGFXSurface surface);

#ifdef __cplusplus
}
Expand Down
Loading

0 comments on commit 02b6428

Please sign in to comment.