Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add vulkan renderer to Craft #222

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ log.txt
*.exe
*.dll
*.pyc

*.spv
63 changes: 55 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,63 @@ cmake_minimum_required(VERSION 2.8)

project(craft)

set(VULKANIZE 1)

FILE(GLOB SOURCE_FILES src/*.c)
FILE(GLOB VERTEX_SHADERS shaders/*_vertex.glsl)
FILE(GLOB FRAGMENT_SHADERS shaders/*_fragment.glsl)

if(VULKANIZE)
LIST(REMOVE_ITEM SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/glrenderer.c)
else(VULKANIZE)
LIST(REMOVE_ITEM SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/vkrenderer.c)
endif(VULKANIZE)

foreach(VERT ${VERTEX_SHADERS})
get_filename_component(BASE_NAME ${VERT} NAME_WLE)
set(SPV "shaders/${BASE_NAME}.spv")
add_custom_command(
OUTPUT ${SPV}
COMMAND glslangValidator -V -S vert ${VERT} -o ${SPV}
DEPENDS ${VERT}
)
list(APPEND SPIRS_V ${SPV})
endforeach(VERT)

foreach(FRAG ${FRAGMENT_SHADERS})
get_filename_component(BASE_NAME ${FRAG} NAME_WLE)
set(SPV "shaders/${BASE_NAME}.spv")
add_custom_command(
OUTPUT ${SPV}
COMMAND glslangValidator -V -S frag ${FRAG} -o ${SPV}
DEPENDS ${FRAG}
)
list(APPEND SPIRS_V ${SPV})
endforeach(FRAG)

add_custom_target(
Shaders
DEPENDS ${SPIRS_V}
)

add_executable(
craft
${SOURCE_FILES}
deps/glew/src/glew.c
deps/lodepng/lodepng.c
deps/noise/noise.c
deps/sqlite/sqlite3.c
deps/tinycthread/tinycthread.c)

add_definitions(-std=c99 -O3)
if(VULKANIZE)
add_definitions(-std=c99 -O3 -Wall -DVULKANIZE=1 -DGLFW_INCLUDE_VULKAN)
else(VULKANIZE)
add_definitions(-std=c99 -O3 -Wall -DVULKANIZE=0)
endif(VULKANIZE)

add_dependencies(craft
Shaders
)

add_subdirectory(deps/glfw)
include_directories(deps/glew/include)
include_directories(deps/glfw/include)
include_directories(deps/lodepng)
include_directories(deps/noise)
include_directories(deps/sqlite)
Expand All @@ -33,17 +74,23 @@ endif()
find_package(CURL REQUIRED)
include_directories(${CURL_INCLUDE_DIR})

if(VULKANIZE)
set(GRAPHICS_LIB vulkan)
else(VULKANIZE)
set(GRAPHICS_LIB GLEW)
endif(VULKANIZE)

if(APPLE)
target_link_libraries(craft glfw
target_link_libraries(craft glfw GLEW
${GLFW_LIBRARIES} ${CURL_LIBRARIES})
endif()

if(UNIX)
target_link_libraries(craft dl glfw
target_link_libraries(craft dl glfw ${GRAPHICS_LIB}
${GLFW_LIBRARIES} ${CURL_LIBRARIES})
endif()

if(MINGW)
target_link_libraries(craft ws2_32.lib glfw
target_link_libraries(craft ws2_32.lib glfw ${GRAPHICS_LIB}
${GLFW_LIBRARIES} ${CURL_LIBRARIES})
endif()
73 changes: 0 additions & 73 deletions deps/glew/LICENSE.txt

This file was deleted.

Loading