Coder Social home page Coder Social logo

font-demo's People

Contributors

andystanton avatar jpbruyere avatar kocsis1david avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

font-demo's Issues

Building issues on Linux, and minor issue with layers on windows

On windows I had to change the layers to VK_LAYER_KHRONOS_validation. That was due to a semi-recent change in Vulkan.
then,

On linux I had to add:

Threads
X11
DL_LIB
m (math)

to package, directories and the linking to get the project to make. It runs now.

Maybe I did not install something correctly?
Below is the CMakeLists that worked for me.

CMAKE_MINIMUM_REQUIRED(VERSION 3.9)

PROJECT(font-demo VERSION 0.1.0 DESCRIPTION "SDF font demo")

SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
SET(CMAKE_CXX_FLAGS "-W -Wall")
SET(CMAKE_EXE_LINKER_FLAGS "-lm")

IF(NOT CMAKE_BUILD_TYPE)
  SET(CMAKE_BUILD_TYPE Debug)
ENDIF()
MESSAGE(STATUS "${CMAKE_BUILD_TYPE} build.")

if (CMAKE_BUILD_TYPE STREQUAL "Debug")
	ADD_DEFINITIONS (-DDEBUG)
ENDIF()

set(VULKAN_SDK "$ENV{VULKAN_SDK}" CACHE STRING "LunarG Vulkan SDK path")
if (VULKAN_SDK)
		set(ENV{VULKAN_SDK} ${VULKAN_SDK})
endif ()

MESSAGE(STATUS "VULKAN_SDK = $ENV{VULKAN_SDK}")
MESSAGE(STATUS "VK_LAYER_PATH = $ENV{VK_LAYER_PATH}")

#be aware that system libraries have priority on SDK in the finding.
FIND_PACKAGE(Vulkan REQUIRED)
FIND_PACKAGE(GLFW3)
FIND_PACKAGE(Freetype REQUIRED)
FIND_PACKAGE(Threads REQUIRED)
FIND_PACKAGE(X11 REQUIRED)

# Find glslc shader compiler.
# On Android, the NDK includes the binary, so no external dependency.
if(ANDROID)
	file(GLOB glslc-folders ${ANDROID_NDK}/shader-tools/*)
else()
	file(GLOB glslc-folders ${VULKAN_SDK}/bin)
endif()
FIND_PROGRAM(GLSLC glslc HINTS ${glslc-folders})

SET(SHADER_DIR "shaders")

if(GLSLC)
	SET(SHADER_FILES ${SHADER_DIR}/*.frag ${SHADER_DIR}/*.vert ${SHADER_DIR}/*.geom  ${SHADER_DIR}/*.comp)
	FILE(GLOB_RECURSE SHADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${SHADER_FILES})
	FOREACH(SHADER ${SHADERS})
		SET(shader-input ${CMAKE_CURRENT_SOURCE_DIR}/${SHADER})
		SET(shader-output ${CMAKE_CURRENT_BINARY_DIR}/${SHADER}.spv)
		ADD_CUSTOM_COMMAND (
		  OUTPUT ${shader-output}
		  COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CURRENT_BINARY_DIR}/${SHADER_DIR}"
		  COMMAND ${GLSLC} ${shader-input} -o ${shader-output}
		  COMMENT "Compiling ${shader-input}"
		  DEPENDS ${SHADER}
		  VERBATIM
		)
		SET(SHADER_OUTPUTS ${SHADER_OUTPUTS} ${shader-output})
	ENDFOREACH()
else()
	SET(SHADER_FILES ${SHADER_DIR}/*.spv)
	FILE(GLOB_RECURSE SHADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${SHADER_FILES})
	FOREACH(SHADER ${SHADERS})
		SET(shader-input ${CMAKE_CURRENT_SOURCE_DIR}/${SHADER})
		SET(shader-output ${CMAKE_CURRENT_BINARY_DIR}/${SHADER})
		ADD_CUSTOM_COMMAND(
		   OUTPUT  ${shader-output}
		   COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CURRENT_BINARY_DIR}/${SHADER_DIR}"
		   COMMAND ${CMAKE_COMMAND} -E copy_if_different "${shader-input}" "${shader-output}"
		   COMMENT "Copying ${shader-input} to ${shader-output}"
		   DEPENDS ${SHADER}
		   VERBATIM
		)
		SET(SHADER_OUTPUTS ${SHADER_OUTPUTS} ${shader-output})
	ENDFOREACH()
endif()

ADD_CUSTOM_TARGET("${PROJECT_NAME}_Shaders" ALL DEPENDS ${SHADER_OUTPUTS})

FILE(GLOB SRC *.c)

ADD_EXECUTABLE(${PROJECT_NAME} ${SRC} ${SHADERS})

TARGET_INCLUDE_DIRECTORIES(${PROJECT_NAME} PRIVATE
	${Vulkan_INCLUDE_DIRS}
	${FREETYPE_INCLUDE_DIRS}
	${GLFW3_INCLUDE_DIRS}
	${CMAKE_CURRENT_SOURCE_DIR}
	${X11_INCLUDE_DIR}
)

TARGET_LINK_LIBRARIES(${PROJECT_NAME}
	${Vulkan_LIBRARIES}
	${GLFW3_LIBRARY}
	${FREETYPE_LIBRARY}
	${CMAKE_DL_LIBS}
	${X11_LIBRARIES}
	Threads::Threads
	m
)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.