diff --git a/CMake/Default.cmake b/CMake/Default.cmake new file mode 100644 index 00000000..70bfa903 --- /dev/null +++ b/CMake/Default.cmake @@ -0,0 +1,65 @@ +################################################################################ +# Command for variable_watch. This command issues error message, if a variable +# is changed. If variable PROPERTY_READER_GUARD_DISABLED is TRUE nothing happens +# variable_watch( property_reader_guard) +################################################################################ +function(property_reader_guard VARIABLE ACCESS VALUE CURRENT_LIST_FILE STACK) + if("${PROPERTY_READER_GUARD_DISABLED}") + return() + endif() + + if("${ACCESS}" STREQUAL "MODIFIED_ACCESS") + message(FATAL_ERROR + " Variable ${VARIABLE} is not supposed to be changed.\n" + " It is used only for reading target property ${VARIABLE}.\n" + " Use\n" + " set_target_properties(\"\" PROPERTIES \"${VARIABLE}\" \"\")\n" + " or\n" + " set_target_properties(\"\" PROPERTIES \"${VARIABLE}_\" \"\")\n" + " instead.\n") + endif() +endfunction() + +################################################################################ +# Create variable with generator expression that expands to value of +# target property _. If property is empty or not set then property +# is used instead. Variable has watcher property_reader_guard that +# doesn't allow to edit it. +# create_property_reader() +# Input: +# name - Name of watched property and output variable +################################################################################ +function(create_property_reader NAME) + set(PROPERTY_READER_GUARD_DISABLED TRUE) + set(CONFIG_VALUE "$>>>") + set(IS_CONFIG_VALUE_EMPTY "$") + set(GENERAL_VALUE "$>") + set("${NAME}" "$" PARENT_SCOPE) + variable_watch("${NAME}" property_reader_guard) +endfunction() + +################################################################################ +# Set property $_${PROPS_CONFIG_U} of ${PROPS_TARGET} to +# set_config_specific_property( ) +# Input: +# name - Prefix of property name +# value - New value +################################################################################ +function(set_config_specific_property NAME VALUE) + set_target_properties("${PROPS_TARGET}" PROPERTIES "${NAME}_${PROPS_CONFIG_U}" "${VALUE}") +endfunction() + +################################################################################ + +create_property_reader("TARGET_NAME") +create_property_reader("OUTPUT_DIRECTORY") + +set_config_specific_property("TARGET_NAME" "${PROPS_TARGET}") +set_config_specific_property("OUTPUT_NAME" "${TARGET_NAME}") +set_config_specific_property("ARCHIVE_OUTPUT_NAME" "${TARGET_NAME}") +set_config_specific_property("LIBRARY_OUTPUT_NAME" "${TARGET_NAME}") +set_config_specific_property("RUNTIME_OUTPUT_NAME" "${TARGET_NAME}") + +set_config_specific_property("ARCHIVE_OUTPUT_DIRECTORY" "${OUTPUT_DIRECTORY}") +set_config_specific_property("LIBRARY_OUTPUT_DIRECTORY" "${OUTPUT_DIRECTORY}") +set_config_specific_property("RUNTIME_OUTPUT_DIRECTORY" "${OUTPUT_DIRECTORY}") \ No newline at end of file diff --git a/CMake/DefaultCXX.cmake b/CMake/DefaultCXX.cmake new file mode 100644 index 00000000..eff0e569 --- /dev/null +++ b/CMake/DefaultCXX.cmake @@ -0,0 +1,12 @@ +include("${CMAKE_CURRENT_LIST_DIR}/Default.cmake") + +set_config_specific_property("OUTPUT_DIRECTORY" "${CMAKE_SOURCE_DIR}$<$>:/${CMAKE_VS_PLATFORM_NAME}>/${PROPS_CONFIG}") + +if(MSVC) + create_property_reader("DEFAULT_CXX_EXCEPTION_HANDLING") + create_property_reader("DEFAULT_CXX_DEBUG_INFORMATION_FORMAT") + + set_target_properties("${PROPS_TARGET}" PROPERTIES MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>DLL") + set_config_specific_property("DEFAULT_CXX_EXCEPTION_HANDLING" "/EHsc") + set_config_specific_property("DEFAULT_CXX_DEBUG_INFORMATION_FORMAT" "/Zi") +endif() diff --git a/CMake/DefaultFortran.cmake b/CMake/DefaultFortran.cmake new file mode 100644 index 00000000..3c16740e --- /dev/null +++ b/CMake/DefaultFortran.cmake @@ -0,0 +1,12 @@ +include("${CMAKE_CURRENT_LIST_DIR}/Default.cmake") + +set_config_specific_property("OUTPUT_DIRECTORY" "${CMAKE_CURRENT_SOURCE_DIR}$<$>:/${CMAKE_VS_PLATFORM_NAME}>/${PROPS_CONFIG}") + +get_target_property(${PROPS_TARGET}_BINARY_DIR ${PROPS_TARGET} BINARY_DIR) +set(DEFAULT_FORTRAN_MODULES_DIR "${${PROPS_TARGET}_BINARY_DIR}/${PROPS_TARGET}.Modules.dir") +set_target_properties(${PROPS_TARGET} PROPERTIES Fortran_MODULE_DIRECTORY ${DEFAULT_FORTRAN_MODULES_DIR}) + +if(${CMAKE_GENERATOR} MATCHES "Visual Studio") + # Hack for visual studio generator (https://gitlab.kitware.com/cmake/cmake/issues/19552) + add_custom_command(TARGET ${PROPS_TARGET} PRE_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory $/${CMAKE_CFG_INTDIR}) +endif() \ No newline at end of file diff --git a/CMake/Utils.cmake b/CMake/Utils.cmake new file mode 100644 index 00000000..102963fa --- /dev/null +++ b/CMake/Utils.cmake @@ -0,0 +1,266 @@ +# utils file for projects came from visual studio solution with cmake-converter. + +################################################################################ +# Wrap each token of the command with condition +################################################################################ +cmake_policy(PUSH) +cmake_policy(SET CMP0054 NEW) +macro(prepare_commands) + unset(TOKEN_ROLE) + unset(COMMANDS) + foreach(TOKEN ${ARG_COMMANDS}) + if("${TOKEN}" STREQUAL "COMMAND") + set(TOKEN_ROLE "KEYWORD") + elseif("${TOKEN_ROLE}" STREQUAL "KEYWORD") + set(TOKEN_ROLE "CONDITION") + elseif("${TOKEN_ROLE}" STREQUAL "CONDITION") + set(TOKEN_ROLE "COMMAND") + elseif("${TOKEN_ROLE}" STREQUAL "COMMAND") + set(TOKEN_ROLE "ARG") + endif() + + if("${TOKEN_ROLE}" STREQUAL "KEYWORD") + list(APPEND COMMANDS "${TOKEN}") + elseif("${TOKEN_ROLE}" STREQUAL "CONDITION") + set(CONDITION ${TOKEN}) + elseif("${TOKEN_ROLE}" STREQUAL "COMMAND") + list(APPEND COMMANDS "$<$:${DUMMY}>$<${CONDITION}:${TOKEN}>") + elseif("${TOKEN_ROLE}" STREQUAL "ARG") + list(APPEND COMMANDS "$<${CONDITION}:${TOKEN}>") + endif() + endforeach() +endmacro() +cmake_policy(POP) + +################################################################################ +# Transform all the tokens to absolute paths +################################################################################ +macro(prepare_output) + unset(OUTPUT) + foreach(TOKEN ${ARG_OUTPUT}) + if(IS_ABSOLUTE ${TOKEN}) + list(APPEND OUTPUT "${TOKEN}") + else() + list(APPEND OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/${TOKEN}") + endif() + endforeach() +endmacro() + +################################################################################ +# Parse add_custom_command_if args. +# +# Input: +# PRE_BUILD - Pre build event option +# PRE_LINK - Pre link event option +# POST_BUILD - Post build event option +# TARGET - Target +# OUTPUT - List of output files +# DEPENDS - List of files on which the command depends +# COMMANDS - List of commands(COMMAND condition1 commannd1 args1 COMMAND +# condition2 commannd2 args2 ...) +# Output: +# OUTPUT - Output files +# DEPENDS - Files on which the command depends +# COMMENT - Comment +# PRE_BUILD - TRUE/FALSE +# PRE_LINK - TRUE/FALSE +# POST_BUILD - TRUE/FALSE +# TARGET - Target name +# COMMANDS - Prepared commands(every token is wrapped in CONDITION) +# NAME - Unique name for custom target +# STEP - PRE_BUILD/PRE_LINK/POST_BUILD +################################################################################ +function(add_custom_command_if_parse_arguments) + cmake_parse_arguments("ARG" "PRE_BUILD;PRE_LINK;POST_BUILD" "TARGET;COMMENT" "DEPENDS;OUTPUT;COMMANDS" ${ARGN}) + + if(WIN32) + set(DUMMY "cd.") + elseif(UNIX) + set(DUMMY "true") + endif() + + prepare_commands() + prepare_output() + + set(DEPENDS "${ARG_DEPENDS}") + set(COMMENT "${ARG_COMMENT}") + set(PRE_BUILD "${ARG_PRE_BUILD}") + set(PRE_LINK "${ARG_PRE_LINK}") + set(POST_BUILD "${ARG_POST_BUILD}") + set(TARGET "${ARG_TARGET}") + if(PRE_BUILD) + set(STEP "PRE_BUILD") + elseif(PRE_LINK) + set(STEP "PRE_LINK") + elseif(POST_BUILD) + set(STEP "POST_BUILD") + endif() + set(NAME "${TARGET}_${STEP}") + + set(OUTPUT "${OUTPUT}" PARENT_SCOPE) + set(DEPENDS "${DEPENDS}" PARENT_SCOPE) + set(COMMENT "${COMMENT}" PARENT_SCOPE) + set(PRE_BUILD "${PRE_BUILD}" PARENT_SCOPE) + set(PRE_LINK "${PRE_LINK}" PARENT_SCOPE) + set(POST_BUILD "${POST_BUILD}" PARENT_SCOPE) + set(TARGET "${TARGET}" PARENT_SCOPE) + set(COMMANDS "${COMMANDS}" PARENT_SCOPE) + set(STEP "${STEP}" PARENT_SCOPE) + set(NAME "${NAME}" PARENT_SCOPE) +endfunction() + +################################################################################ +# Add conditional custom command +# +# Generating Files +# The first signature is for adding a custom command to produce an output: +# add_custom_command_if( +# +# +# +# [COMMAND condition command2 [args2...]] +# [DEPENDS [depends...]] +# [COMMENT comment] +# +# Build Events +# add_custom_command_if( +# +# +# +# [COMMAND condition command2 [args2...]] +# [COMMENT comment] +# +# Input: +# output - Output files the command is expected to produce +# condition - Generator expression for wrapping the command +# command - Command-line(s) to execute at build time. +# args - Command`s args +# depends - Files on which the command depends +# comment - Display the given message before the commands are executed at +# build time. +# PRE_BUILD - Run before any other rules are executed within the target +# PRE_LINK - Run after sources have been compiled but before linking the +# binary +# POST_BUILD - Run after all other rules within the target have been +# executed +################################################################################ +function(add_custom_command_if) + add_custom_command_if_parse_arguments(${ARGN}) + + if(OUTPUT AND TARGET) + message(FATAL_ERROR "Wrong syntax. A TARGET and OUTPUT can not both be specified.") + endif() + + if(OUTPUT) + add_custom_command(OUTPUT ${OUTPUT} + ${COMMANDS} + DEPENDS ${DEPENDS} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMENT ${COMMENT}) + elseif(TARGET) + if(PRE_BUILD AND NOT ${CMAKE_GENERATOR} MATCHES "Visual Studio") + add_custom_target( + ${NAME} + ${COMMANDS} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMENT ${COMMENT}) + add_dependencies(${TARGET} ${NAME}) + else() + add_custom_command( + TARGET ${TARGET} + ${STEP} + ${COMMANDS} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMENT ${COMMENT}) + endif() + else() + message(FATAL_ERROR "Wrong syntax. A TARGET or OUTPUT must be specified.") + endif() +endfunction() + +################################################################################ +# Use props file for a target and configs +# use_props( ) +# Inside there are following variables: +# PROPS_TARGET - +# PROPS_CONFIG - One of +# PROPS_CONFIG_U - Uppercase PROPS_CONFIG +# Input: +# target - Target to apply props file +# configs - Build configurations to apply props file +# props_file - CMake script +################################################################################ +macro(use_props TARGET CONFIGS PROPS_FILE) + set(PROPS_TARGET "${TARGET}") + foreach(PROPS_CONFIG ${CONFIGS}) + string(TOUPPER "${PROPS_CONFIG}" PROPS_CONFIG_U) + + get_filename_component(ABSOLUTE_PROPS_FILE "${PROPS_FILE}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_LIST_DIR}") + if(EXISTS "${ABSOLUTE_PROPS_FILE}") + include("${ABSOLUTE_PROPS_FILE}") + else() + message(WARNING "Corresponding cmake file from props \"${ABSOLUTE_PROPS_FILE}\" doesn't exist") + endif() + endforeach() +endmacro() + +################################################################################ +# Function for MSVC precompiled headers +# add_precompiled_header( ) +# Input: +# target - Target to which add precompiled header +# precompiled_header - Name of precompiled header +# precompiled_source - Name of precompiled source file +################################################################################ +function(add_precompiled_header TARGET PRECOMPILED_HEADER PRECOMPILED_SOURCE) + get_target_property(SOURCES "${TARGET}" SOURCES) + list(REMOVE_ITEM SOURCES "${PRECOMPILED_SOURCE}") + + if(MSVC) + set(PRECOMPILED_BINARY "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${PROJECT_NAME}.pch") + + set_source_files_properties( + "${PRECOMPILED_SOURCE}" + PROPERTIES + COMPILE_OPTIONS "/Yc${PRECOMPILED_HEADER};/Fp${PRECOMPILED_BINARY}" + OBJECT_OUTPUTS "${PRECOMPILED_BINARY}") + + set_source_files_properties( + ${SOURCES} + PROPERTIES + COMPILE_OPTIONS "$<$,$>:/Yu${PRECOMPILED_HEADER};/Fp${PRECOMPILED_BINARY}>" + OBJECT_DEPENDS "${PRECOMPILED_BINARY}") + endif() + + list(INSERT SOURCES 0 "${PRECOMPILED_SOURCE}") + set_target_properties("${TARGET}" PROPERTIES SOURCES "${SOURCES}") +endfunction() + +################################################################################ +# Add compile options to source file +# source_file_compile_options( [compile_options...]) +# Input: +# source_file - Source file +# compile_options - Options to add to COMPILE_FLAGS property +################################################################################ +function(source_file_compile_options SOURCE_FILE) + if("${ARGC}" LESS_EQUAL "1") + return() + endif() + + get_source_file_property(COMPILE_OPTIONS "${SOURCE_FILE}" COMPILE_OPTIONS) + + if(COMPILE_OPTIONS) + list(APPEND COMPILE_OPTIONS ${ARGN}) + else() + set(COMPILE_OPTIONS "${ARGN}") + endif() + + set_source_files_properties("${SOURCE_FILE}" PROPERTIES COMPILE_OPTIONS "${COMPILE_OPTIONS}") +endfunction() + +################################################################################ +# Default properties of visual studio projects +################################################################################ +set(DEFAULT_CXX_PROPS "${CMAKE_CURRENT_LIST_DIR}/DefaultCXX.cmake") +set(DEFAULT_Fortran_PROPS "${CMAKE_CURRENT_LIST_DIR}/DefaultFortran.cmake") diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..b7b78c7d --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,93 @@ +cmake_minimum_required(VERSION 3.15.0 FATAL_ERROR) +set(CMAKE_CXX_STANDARD 17) + +set(CMAKE_SYSTEM_VERSION 10.0 CACHE STRING "" FORCE) + +project(OpenGL-Examples C CXX) + +################################################################################ +# Set target arch type if empty. Visual studio solution generator provides it. +################################################################################ +if(NOT CMAKE_VS_PLATFORM_NAME) + set(CMAKE_VS_PLATFORM_NAME "x64") +endif() +message("${CMAKE_VS_PLATFORM_NAME} architecture in use") + +if(NOT ("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64")) + message(FATAL_ERROR "${CMAKE_VS_PLATFORM_NAME} arch is not supported!") +endif() + +################################################################################ +# Global configuration types +################################################################################ +set(CMAKE_CONFIGURATION_TYPES + "Debug" + "Release" + CACHE STRING "" FORCE +) + +################################################################################ +# Global compiler options +################################################################################ +if(MSVC) + # remove default flags provided with CMake for MSVC + set(CMAKE_C_FLAGS "") + set(CMAKE_C_FLAGS_DEBUG "") + set(CMAKE_C_FLAGS_RELEASE "") + set(CMAKE_CXX_FLAGS "") + set(CMAKE_CXX_FLAGS_DEBUG "") + set(CMAKE_CXX_FLAGS_RELEASE "") +endif() + +################################################################################ +# Global linker options +################################################################################ +if(MSVC) + # remove default flags provided with CMake for MSVC + set(CMAKE_EXE_LINKER_FLAGS "") + set(CMAKE_MODULE_LINKER_FLAGS "") + set(CMAKE_SHARED_LINKER_FLAGS "") + set(CMAKE_STATIC_LINKER_FLAGS "") + set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS}") + set(CMAKE_MODULE_LINKER_FLAGS_DEBUG "${CMAKE_MODULE_LINKER_FLAGS}") + set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS}") + set(CMAKE_STATIC_LINKER_FLAGS_DEBUG "${CMAKE_STATIC_LINKER_FLAGS}") + set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS}") + set(CMAKE_MODULE_LINKER_FLAGS_RELEASE "${CMAKE_MODULE_LINKER_FLAGS}") + set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS}") + set(CMAKE_STATIC_LINKER_FLAGS_RELEASE "${CMAKE_STATIC_LINKER_FLAGS}") +endif() + +################################################################################ +# Nuget packages function stub. +################################################################################ +function(use_package TARGET PACKAGE VERSION) + message(WARNING "No implementation of use_package. Create yours. " + "Package \"${PACKAGE}\" with version \"${VERSION}\" " + "for target \"${TARGET}\" is ignored!") +endfunction() + +################################################################################ +# Common utils +################################################################################ +include(CMake/Utils.cmake) + +################################################################################ +# Additional Global Settings(add specific info there) +################################################################################ +include(CMake/GlobalSettingsInclude.cmake OPTIONAL) + +################################################################################ +# Use solution folders feature +################################################################################ +set_property(GLOBAL PROPERTY USE_FOLDERS ON) + +################################################################################ +# Sub-projects +################################################################################ +add_subdirectory(OpenGL-Core) +add_subdirectory(OpenGL-Core/vendor/Glad) +add_subdirectory(OpenGL-Core/vendor/glfw) +add_subdirectory(OpenGL-Core/vendor/imgui) +add_subdirectory(OpenGL-Examples) + diff --git a/OpenGL-Core/CMakeLists.txt b/OpenGL-Core/CMakeLists.txt new file mode 100644 index 00000000..3eddcf5b --- /dev/null +++ b/OpenGL-Core/CMakeLists.txt @@ -0,0 +1,601 @@ +set(PROJECT_NAME OpenGL-Core) + +################################################################################ +# Source groups +################################################################################ +set(src + "src/GLCore.h" + "src/GLCoreUtils.h" + "src/glpch.cpp" + "src/glpch.h" +) +source_group("src" FILES ${src}) + +set(src__GLCore__Core + "src/GLCore/Core/Application.cpp" + "src/GLCore/Core/Application.h" + "src/GLCore/Core/Core.h" + "src/GLCore/Core/Input.h" + "src/GLCore/Core/KeyCodes.h" + "src/GLCore/Core/Layer.cpp" + "src/GLCore/Core/Layer.h" + "src/GLCore/Core/LayerStack.cpp" + "src/GLCore/Core/LayerStack.h" + "src/GLCore/Core/Log.cpp" + "src/GLCore/Core/Log.h" + "src/GLCore/Core/MouseButtonCodes.h" + "src/GLCore/Core/Timestep.h" + "src/GLCore/Core/Window.h" +) +source_group("src\\GLCore\\Core" FILES ${src__GLCore__Core}) + +set(src__GLCore__Events + "src/GLCore/Events/ApplicationEvent.h" + "src/GLCore/Events/Event.h" + "src/GLCore/Events/KeyEvent.h" + "src/GLCore/Events/MouseEvent.h" +) +source_group("src\\GLCore\\Events" FILES ${src__GLCore__Events}) + +set(src__GLCore__ImGui + "src/GLCore/ImGui/ImGuiBuild.cpp" + "src/GLCore/ImGui/ImGuiLayer.cpp" + "src/GLCore/ImGui/ImGuiLayer.h" +) +source_group("src\\GLCore\\ImGui" FILES ${src__GLCore__ImGui}) + +set(src__GLCore__Util + "src/GLCore/Util/OpenGLDebug.cpp" + "src/GLCore/Util/OpenGLDebug.h" + "src/GLCore/Util/OrthographicCamera.cpp" + "src/GLCore/Util/OrthographicCamera.h" + "src/GLCore/Util/OrthographicCameraController.cpp" + "src/GLCore/Util/OrthographicCameraController.h" + "src/GLCore/Util/Shader.cpp" + "src/GLCore/Util/Shader.h" +) +source_group("src\\GLCore\\Util" FILES ${src__GLCore__Util}) + +set(src__Platform__Windows + "src/Platform/Windows/WindowsInput.cpp" + "src/Platform/Windows/WindowsInput.h" + "src/Platform/Windows/WindowsWindow.cpp" + "src/Platform/Windows/WindowsWindow.h" +) +source_group("src\\Platform\\Windows" FILES ${src__Platform__Windows}) + +set(vendor__glm__glm + "vendor/glm/glm/common.hpp" + "vendor/glm/glm/exponential.hpp" + "vendor/glm/glm/ext.hpp" + "vendor/glm/glm/fwd.hpp" + "vendor/glm/glm/geometric.hpp" + "vendor/glm/glm/glm.hpp" + "vendor/glm/glm/integer.hpp" + "vendor/glm/glm/mat2x2.hpp" + "vendor/glm/glm/mat2x3.hpp" + "vendor/glm/glm/mat2x4.hpp" + "vendor/glm/glm/mat3x2.hpp" + "vendor/glm/glm/mat3x3.hpp" + "vendor/glm/glm/mat3x4.hpp" + "vendor/glm/glm/mat4x2.hpp" + "vendor/glm/glm/mat4x3.hpp" + "vendor/glm/glm/mat4x4.hpp" + "vendor/glm/glm/matrix.hpp" + "vendor/glm/glm/packing.hpp" + "vendor/glm/glm/trigonometric.hpp" + "vendor/glm/glm/vec2.hpp" + "vendor/glm/glm/vec3.hpp" + "vendor/glm/glm/vec4.hpp" + "vendor/glm/glm/vector_relational.hpp" +) +source_group("vendor\\glm\\glm" FILES ${vendor__glm__glm}) + +set(vendor__glm__glm__detail + "vendor/glm/glm/detail/_features.hpp" + "vendor/glm/glm/detail/_fixes.hpp" + "vendor/glm/glm/detail/_noise.hpp" + "vendor/glm/glm/detail/_swizzle.hpp" + "vendor/glm/glm/detail/_swizzle_func.hpp" + "vendor/glm/glm/detail/_vectorize.hpp" + "vendor/glm/glm/detail/compute_common.hpp" + "vendor/glm/glm/detail/compute_vector_relational.hpp" + "vendor/glm/glm/detail/func_common.inl" + "vendor/glm/glm/detail/func_common_simd.inl" + "vendor/glm/glm/detail/func_exponential.inl" + "vendor/glm/glm/detail/func_exponential_simd.inl" + "vendor/glm/glm/detail/func_geometric.inl" + "vendor/glm/glm/detail/func_geometric_simd.inl" + "vendor/glm/glm/detail/func_integer.inl" + "vendor/glm/glm/detail/func_integer_simd.inl" + "vendor/glm/glm/detail/func_matrix.inl" + "vendor/glm/glm/detail/func_matrix_simd.inl" + "vendor/glm/glm/detail/func_packing.inl" + "vendor/glm/glm/detail/func_packing_simd.inl" + "vendor/glm/glm/detail/func_trigonometric.inl" + "vendor/glm/glm/detail/func_trigonometric_simd.inl" + "vendor/glm/glm/detail/func_vector_relational.inl" + "vendor/glm/glm/detail/func_vector_relational_simd.inl" + "vendor/glm/glm/detail/qualifier.hpp" + "vendor/glm/glm/detail/setup.hpp" + "vendor/glm/glm/detail/type_float.hpp" + "vendor/glm/glm/detail/type_half.hpp" + "vendor/glm/glm/detail/type_half.inl" + "vendor/glm/glm/detail/type_mat2x2.hpp" + "vendor/glm/glm/detail/type_mat2x2.inl" + "vendor/glm/glm/detail/type_mat2x3.hpp" + "vendor/glm/glm/detail/type_mat2x3.inl" + "vendor/glm/glm/detail/type_mat2x4.hpp" + "vendor/glm/glm/detail/type_mat2x4.inl" + "vendor/glm/glm/detail/type_mat3x2.hpp" + "vendor/glm/glm/detail/type_mat3x2.inl" + "vendor/glm/glm/detail/type_mat3x3.hpp" + "vendor/glm/glm/detail/type_mat3x3.inl" + "vendor/glm/glm/detail/type_mat3x4.hpp" + "vendor/glm/glm/detail/type_mat3x4.inl" + "vendor/glm/glm/detail/type_mat4x2.hpp" + "vendor/glm/glm/detail/type_mat4x2.inl" + "vendor/glm/glm/detail/type_mat4x3.hpp" + "vendor/glm/glm/detail/type_mat4x3.inl" + "vendor/glm/glm/detail/type_mat4x4.hpp" + "vendor/glm/glm/detail/type_mat4x4.inl" + "vendor/glm/glm/detail/type_mat4x4_simd.inl" + "vendor/glm/glm/detail/type_quat.hpp" + "vendor/glm/glm/detail/type_quat.inl" + "vendor/glm/glm/detail/type_quat_simd.inl" + "vendor/glm/glm/detail/type_vec1.hpp" + "vendor/glm/glm/detail/type_vec1.inl" + "vendor/glm/glm/detail/type_vec2.hpp" + "vendor/glm/glm/detail/type_vec2.inl" + "vendor/glm/glm/detail/type_vec3.hpp" + "vendor/glm/glm/detail/type_vec3.inl" + "vendor/glm/glm/detail/type_vec4.hpp" + "vendor/glm/glm/detail/type_vec4.inl" + "vendor/glm/glm/detail/type_vec4_simd.inl" +) +source_group("vendor\\glm\\glm\\detail" FILES ${vendor__glm__glm__detail}) + +set(vendor__glm__glm__ext + "vendor/glm/glm/ext/matrix_clip_space.hpp" + "vendor/glm/glm/ext/matrix_clip_space.inl" + "vendor/glm/glm/ext/matrix_common.hpp" + "vendor/glm/glm/ext/matrix_common.inl" + "vendor/glm/glm/ext/matrix_double2x2.hpp" + "vendor/glm/glm/ext/matrix_double2x2_precision.hpp" + "vendor/glm/glm/ext/matrix_double2x3.hpp" + "vendor/glm/glm/ext/matrix_double2x3_precision.hpp" + "vendor/glm/glm/ext/matrix_double2x4.hpp" + "vendor/glm/glm/ext/matrix_double2x4_precision.hpp" + "vendor/glm/glm/ext/matrix_double3x2.hpp" + "vendor/glm/glm/ext/matrix_double3x2_precision.hpp" + "vendor/glm/glm/ext/matrix_double3x3.hpp" + "vendor/glm/glm/ext/matrix_double3x3_precision.hpp" + "vendor/glm/glm/ext/matrix_double3x4.hpp" + "vendor/glm/glm/ext/matrix_double3x4_precision.hpp" + "vendor/glm/glm/ext/matrix_double4x2.hpp" + "vendor/glm/glm/ext/matrix_double4x2_precision.hpp" + "vendor/glm/glm/ext/matrix_double4x3.hpp" + "vendor/glm/glm/ext/matrix_double4x3_precision.hpp" + "vendor/glm/glm/ext/matrix_double4x4.hpp" + "vendor/glm/glm/ext/matrix_double4x4_precision.hpp" + "vendor/glm/glm/ext/matrix_float2x2.hpp" + "vendor/glm/glm/ext/matrix_float2x2_precision.hpp" + "vendor/glm/glm/ext/matrix_float2x3.hpp" + "vendor/glm/glm/ext/matrix_float2x3_precision.hpp" + "vendor/glm/glm/ext/matrix_float2x4.hpp" + "vendor/glm/glm/ext/matrix_float2x4_precision.hpp" + "vendor/glm/glm/ext/matrix_float3x2.hpp" + "vendor/glm/glm/ext/matrix_float3x2_precision.hpp" + "vendor/glm/glm/ext/matrix_float3x3.hpp" + "vendor/glm/glm/ext/matrix_float3x3_precision.hpp" + "vendor/glm/glm/ext/matrix_float3x4.hpp" + "vendor/glm/glm/ext/matrix_float3x4_precision.hpp" + "vendor/glm/glm/ext/matrix_float4x2.hpp" + "vendor/glm/glm/ext/matrix_float4x2_precision.hpp" + "vendor/glm/glm/ext/matrix_float4x3.hpp" + "vendor/glm/glm/ext/matrix_float4x3_precision.hpp" + "vendor/glm/glm/ext/matrix_float4x4.hpp" + "vendor/glm/glm/ext/matrix_float4x4_precision.hpp" + "vendor/glm/glm/ext/matrix_projection.hpp" + "vendor/glm/glm/ext/matrix_projection.inl" + "vendor/glm/glm/ext/matrix_relational.hpp" + "vendor/glm/glm/ext/matrix_relational.inl" + "vendor/glm/glm/ext/matrix_transform.hpp" + "vendor/glm/glm/ext/matrix_transform.inl" + "vendor/glm/glm/ext/quaternion_common.hpp" + "vendor/glm/glm/ext/quaternion_common.inl" + "vendor/glm/glm/ext/quaternion_common_simd.inl" + "vendor/glm/glm/ext/quaternion_double.hpp" + "vendor/glm/glm/ext/quaternion_double_precision.hpp" + "vendor/glm/glm/ext/quaternion_exponential.hpp" + "vendor/glm/glm/ext/quaternion_exponential.inl" + "vendor/glm/glm/ext/quaternion_float.hpp" + "vendor/glm/glm/ext/quaternion_float_precision.hpp" + "vendor/glm/glm/ext/quaternion_geometric.hpp" + "vendor/glm/glm/ext/quaternion_geometric.inl" + "vendor/glm/glm/ext/quaternion_relational.hpp" + "vendor/glm/glm/ext/quaternion_relational.inl" + "vendor/glm/glm/ext/quaternion_transform.hpp" + "vendor/glm/glm/ext/quaternion_transform.inl" + "vendor/glm/glm/ext/quaternion_trigonometric.hpp" + "vendor/glm/glm/ext/quaternion_trigonometric.inl" + "vendor/glm/glm/ext/scalar_common.hpp" + "vendor/glm/glm/ext/scalar_common.inl" + "vendor/glm/glm/ext/scalar_constants.hpp" + "vendor/glm/glm/ext/scalar_constants.inl" + "vendor/glm/glm/ext/scalar_int_sized.hpp" + "vendor/glm/glm/ext/scalar_integer.hpp" + "vendor/glm/glm/ext/scalar_integer.inl" + "vendor/glm/glm/ext/scalar_relational.hpp" + "vendor/glm/glm/ext/scalar_relational.inl" + "vendor/glm/glm/ext/scalar_uint_sized.hpp" + "vendor/glm/glm/ext/scalar_ulp.hpp" + "vendor/glm/glm/ext/scalar_ulp.inl" + "vendor/glm/glm/ext/vector_bool1.hpp" + "vendor/glm/glm/ext/vector_bool1_precision.hpp" + "vendor/glm/glm/ext/vector_bool2.hpp" + "vendor/glm/glm/ext/vector_bool2_precision.hpp" + "vendor/glm/glm/ext/vector_bool3.hpp" + "vendor/glm/glm/ext/vector_bool3_precision.hpp" + "vendor/glm/glm/ext/vector_bool4.hpp" + "vendor/glm/glm/ext/vector_bool4_precision.hpp" + "vendor/glm/glm/ext/vector_common.hpp" + "vendor/glm/glm/ext/vector_common.inl" + "vendor/glm/glm/ext/vector_double1.hpp" + "vendor/glm/glm/ext/vector_double1_precision.hpp" + "vendor/glm/glm/ext/vector_double2.hpp" + "vendor/glm/glm/ext/vector_double2_precision.hpp" + "vendor/glm/glm/ext/vector_double3.hpp" + "vendor/glm/glm/ext/vector_double3_precision.hpp" + "vendor/glm/glm/ext/vector_double4.hpp" + "vendor/glm/glm/ext/vector_double4_precision.hpp" + "vendor/glm/glm/ext/vector_float1.hpp" + "vendor/glm/glm/ext/vector_float1_precision.hpp" + "vendor/glm/glm/ext/vector_float2.hpp" + "vendor/glm/glm/ext/vector_float2_precision.hpp" + "vendor/glm/glm/ext/vector_float3.hpp" + "vendor/glm/glm/ext/vector_float3_precision.hpp" + "vendor/glm/glm/ext/vector_float4.hpp" + "vendor/glm/glm/ext/vector_float4_precision.hpp" + "vendor/glm/glm/ext/vector_int1.hpp" + "vendor/glm/glm/ext/vector_int1_precision.hpp" + "vendor/glm/glm/ext/vector_int2.hpp" + "vendor/glm/glm/ext/vector_int2_precision.hpp" + "vendor/glm/glm/ext/vector_int3.hpp" + "vendor/glm/glm/ext/vector_int3_precision.hpp" + "vendor/glm/glm/ext/vector_int4.hpp" + "vendor/glm/glm/ext/vector_int4_precision.hpp" + "vendor/glm/glm/ext/vector_integer.hpp" + "vendor/glm/glm/ext/vector_integer.inl" + "vendor/glm/glm/ext/vector_relational.hpp" + "vendor/glm/glm/ext/vector_relational.inl" + "vendor/glm/glm/ext/vector_uint1.hpp" + "vendor/glm/glm/ext/vector_uint1_precision.hpp" + "vendor/glm/glm/ext/vector_uint2.hpp" + "vendor/glm/glm/ext/vector_uint2_precision.hpp" + "vendor/glm/glm/ext/vector_uint3.hpp" + "vendor/glm/glm/ext/vector_uint3_precision.hpp" + "vendor/glm/glm/ext/vector_uint4.hpp" + "vendor/glm/glm/ext/vector_uint4_precision.hpp" + "vendor/glm/glm/ext/vector_ulp.hpp" + "vendor/glm/glm/ext/vector_ulp.inl" +) +source_group("vendor\\glm\\glm\\ext" FILES ${vendor__glm__glm__ext}) + +set(vendor__glm__glm__gtc + "vendor/glm/glm/gtc/bitfield.hpp" + "vendor/glm/glm/gtc/bitfield.inl" + "vendor/glm/glm/gtc/color_space.hpp" + "vendor/glm/glm/gtc/color_space.inl" + "vendor/glm/glm/gtc/constants.hpp" + "vendor/glm/glm/gtc/constants.inl" + "vendor/glm/glm/gtc/epsilon.hpp" + "vendor/glm/glm/gtc/epsilon.inl" + "vendor/glm/glm/gtc/integer.hpp" + "vendor/glm/glm/gtc/integer.inl" + "vendor/glm/glm/gtc/matrix_access.hpp" + "vendor/glm/glm/gtc/matrix_access.inl" + "vendor/glm/glm/gtc/matrix_integer.hpp" + "vendor/glm/glm/gtc/matrix_inverse.hpp" + "vendor/glm/glm/gtc/matrix_inverse.inl" + "vendor/glm/glm/gtc/matrix_transform.hpp" + "vendor/glm/glm/gtc/matrix_transform.inl" + "vendor/glm/glm/gtc/noise.hpp" + "vendor/glm/glm/gtc/noise.inl" + "vendor/glm/glm/gtc/packing.hpp" + "vendor/glm/glm/gtc/packing.inl" + "vendor/glm/glm/gtc/quaternion.hpp" + "vendor/glm/glm/gtc/quaternion.inl" + "vendor/glm/glm/gtc/quaternion_simd.inl" + "vendor/glm/glm/gtc/random.hpp" + "vendor/glm/glm/gtc/random.inl" + "vendor/glm/glm/gtc/reciprocal.hpp" + "vendor/glm/glm/gtc/reciprocal.inl" + "vendor/glm/glm/gtc/round.hpp" + "vendor/glm/glm/gtc/round.inl" + "vendor/glm/glm/gtc/type_aligned.hpp" + "vendor/glm/glm/gtc/type_precision.hpp" + "vendor/glm/glm/gtc/type_precision.inl" + "vendor/glm/glm/gtc/type_ptr.hpp" + "vendor/glm/glm/gtc/type_ptr.inl" + "vendor/glm/glm/gtc/ulp.hpp" + "vendor/glm/glm/gtc/ulp.inl" + "vendor/glm/glm/gtc/vec1.hpp" +) +source_group("vendor\\glm\\glm\\gtc" FILES ${vendor__glm__glm__gtc}) + +set(vendor__glm__glm__gtx + "vendor/glm/glm/gtx/associated_min_max.hpp" + "vendor/glm/glm/gtx/associated_min_max.inl" + "vendor/glm/glm/gtx/bit.hpp" + "vendor/glm/glm/gtx/bit.inl" + "vendor/glm/glm/gtx/closest_point.hpp" + "vendor/glm/glm/gtx/closest_point.inl" + "vendor/glm/glm/gtx/color_encoding.hpp" + "vendor/glm/glm/gtx/color_encoding.inl" + "vendor/glm/glm/gtx/color_space.hpp" + "vendor/glm/glm/gtx/color_space.inl" + "vendor/glm/glm/gtx/color_space_YCoCg.hpp" + "vendor/glm/glm/gtx/color_space_YCoCg.inl" + "vendor/glm/glm/gtx/common.hpp" + "vendor/glm/glm/gtx/common.inl" + "vendor/glm/glm/gtx/compatibility.hpp" + "vendor/glm/glm/gtx/compatibility.inl" + "vendor/glm/glm/gtx/component_wise.hpp" + "vendor/glm/glm/gtx/component_wise.inl" + "vendor/glm/glm/gtx/dual_quaternion.hpp" + "vendor/glm/glm/gtx/dual_quaternion.inl" + "vendor/glm/glm/gtx/easing.hpp" + "vendor/glm/glm/gtx/easing.inl" + "vendor/glm/glm/gtx/euler_angles.hpp" + "vendor/glm/glm/gtx/euler_angles.inl" + "vendor/glm/glm/gtx/extend.hpp" + "vendor/glm/glm/gtx/extend.inl" + "vendor/glm/glm/gtx/extended_min_max.hpp" + "vendor/glm/glm/gtx/extended_min_max.inl" + "vendor/glm/glm/gtx/exterior_product.hpp" + "vendor/glm/glm/gtx/exterior_product.inl" + "vendor/glm/glm/gtx/fast_exponential.hpp" + "vendor/glm/glm/gtx/fast_exponential.inl" + "vendor/glm/glm/gtx/fast_square_root.hpp" + "vendor/glm/glm/gtx/fast_square_root.inl" + "vendor/glm/glm/gtx/fast_trigonometry.hpp" + "vendor/glm/glm/gtx/fast_trigonometry.inl" + "vendor/glm/glm/gtx/float_notmalize.inl" + "vendor/glm/glm/gtx/functions.hpp" + "vendor/glm/glm/gtx/functions.inl" + "vendor/glm/glm/gtx/gradient_paint.hpp" + "vendor/glm/glm/gtx/gradient_paint.inl" + "vendor/glm/glm/gtx/handed_coordinate_space.hpp" + "vendor/glm/glm/gtx/handed_coordinate_space.inl" + "vendor/glm/glm/gtx/hash.hpp" + "vendor/glm/glm/gtx/hash.inl" + "vendor/glm/glm/gtx/integer.hpp" + "vendor/glm/glm/gtx/integer.inl" + "vendor/glm/glm/gtx/intersect.hpp" + "vendor/glm/glm/gtx/intersect.inl" + "vendor/glm/glm/gtx/io.hpp" + "vendor/glm/glm/gtx/io.inl" + "vendor/glm/glm/gtx/log_base.hpp" + "vendor/glm/glm/gtx/log_base.inl" + "vendor/glm/glm/gtx/matrix_cross_product.hpp" + "vendor/glm/glm/gtx/matrix_cross_product.inl" + "vendor/glm/glm/gtx/matrix_decompose.hpp" + "vendor/glm/glm/gtx/matrix_decompose.inl" + "vendor/glm/glm/gtx/matrix_factorisation.hpp" + "vendor/glm/glm/gtx/matrix_factorisation.inl" + "vendor/glm/glm/gtx/matrix_interpolation.hpp" + "vendor/glm/glm/gtx/matrix_interpolation.inl" + "vendor/glm/glm/gtx/matrix_major_storage.hpp" + "vendor/glm/glm/gtx/matrix_major_storage.inl" + "vendor/glm/glm/gtx/matrix_operation.hpp" + "vendor/glm/glm/gtx/matrix_operation.inl" + "vendor/glm/glm/gtx/matrix_query.hpp" + "vendor/glm/glm/gtx/matrix_query.inl" + "vendor/glm/glm/gtx/matrix_transform_2d.hpp" + "vendor/glm/glm/gtx/matrix_transform_2d.inl" + "vendor/glm/glm/gtx/mixed_product.hpp" + "vendor/glm/glm/gtx/mixed_product.inl" + "vendor/glm/glm/gtx/norm.hpp" + "vendor/glm/glm/gtx/norm.inl" + "vendor/glm/glm/gtx/normal.hpp" + "vendor/glm/glm/gtx/normal.inl" + "vendor/glm/glm/gtx/normalize_dot.hpp" + "vendor/glm/glm/gtx/normalize_dot.inl" + "vendor/glm/glm/gtx/number_precision.hpp" + "vendor/glm/glm/gtx/number_precision.inl" + "vendor/glm/glm/gtx/optimum_pow.hpp" + "vendor/glm/glm/gtx/optimum_pow.inl" + "vendor/glm/glm/gtx/orthonormalize.hpp" + "vendor/glm/glm/gtx/orthonormalize.inl" + "vendor/glm/glm/gtx/perpendicular.hpp" + "vendor/glm/glm/gtx/perpendicular.inl" + "vendor/glm/glm/gtx/polar_coordinates.hpp" + "vendor/glm/glm/gtx/polar_coordinates.inl" + "vendor/glm/glm/gtx/projection.hpp" + "vendor/glm/glm/gtx/projection.inl" + "vendor/glm/glm/gtx/quaternion.hpp" + "vendor/glm/glm/gtx/quaternion.inl" + "vendor/glm/glm/gtx/range.hpp" + "vendor/glm/glm/gtx/raw_data.hpp" + "vendor/glm/glm/gtx/raw_data.inl" + "vendor/glm/glm/gtx/rotate_normalized_axis.hpp" + "vendor/glm/glm/gtx/rotate_normalized_axis.inl" + "vendor/glm/glm/gtx/rotate_vector.hpp" + "vendor/glm/glm/gtx/rotate_vector.inl" + "vendor/glm/glm/gtx/scalar_multiplication.hpp" + "vendor/glm/glm/gtx/scalar_relational.hpp" + "vendor/glm/glm/gtx/scalar_relational.inl" + "vendor/glm/glm/gtx/spline.hpp" + "vendor/glm/glm/gtx/spline.inl" + "vendor/glm/glm/gtx/std_based_type.hpp" + "vendor/glm/glm/gtx/std_based_type.inl" + "vendor/glm/glm/gtx/string_cast.hpp" + "vendor/glm/glm/gtx/string_cast.inl" + "vendor/glm/glm/gtx/texture.hpp" + "vendor/glm/glm/gtx/texture.inl" + "vendor/glm/glm/gtx/transform.hpp" + "vendor/glm/glm/gtx/transform.inl" + "vendor/glm/glm/gtx/transform2.hpp" + "vendor/glm/glm/gtx/transform2.inl" + "vendor/glm/glm/gtx/type_aligned.hpp" + "vendor/glm/glm/gtx/type_aligned.inl" + "vendor/glm/glm/gtx/type_trait.hpp" + "vendor/glm/glm/gtx/type_trait.inl" + "vendor/glm/glm/gtx/vec_swizzle.hpp" + "vendor/glm/glm/gtx/vector_angle.hpp" + "vendor/glm/glm/gtx/vector_angle.inl" + "vendor/glm/glm/gtx/vector_query.hpp" + "vendor/glm/glm/gtx/vector_query.inl" + "vendor/glm/glm/gtx/wrap.hpp" + "vendor/glm/glm/gtx/wrap.inl" +) +source_group("vendor\\glm\\glm\\gtx" FILES ${vendor__glm__glm__gtx}) + +set(vendor__stb_image + "vendor/stb_image/stb_image.cpp" + "vendor/stb_image/stb_image.h" +) +source_group("vendor\\stb_image" FILES ${vendor__stb_image}) + +set(ALL_FILES + ${src} + ${src__GLCore__Core} + ${src__GLCore__Events} + ${src__GLCore__ImGui} + ${src__GLCore__Util} + ${src__Platform__Windows} + ${vendor__glm__glm} + ${vendor__glm__glm__detail} + ${vendor__glm__glm__ext} + ${vendor__glm__glm__gtc} + ${vendor__glm__glm__gtx} + ${vendor__stb_image} +) + +################################################################################ +# Target +################################################################################ +add_library(${PROJECT_NAME} STATIC ${ALL_FILES}) + +add_precompiled_header(${PROJECT_NAME} "glpch.h" "src/glpch.cpp") + +use_props(${PROJECT_NAME} "${CMAKE_CONFIGURATION_TYPES}" "${DEFAULT_CXX_PROPS}") +set(ROOT_NAMESPACE OpenGL-Core) + +set_target_properties(${PROJECT_NAME} PROPERTIES + VS_GLOBAL_KEYWORD "Win32Proj" +) +################################################################################ +# Target name +################################################################################ +set_target_properties(${PROJECT_NAME} PROPERTIES + TARGET_NAME_DEBUG "OpenGL-Core" + TARGET_NAME_RELEASE "OpenGL-Core" +) +################################################################################ +# Output directory +################################################################################ +set_target_properties(${PROJECT_NAME} PROPERTIES + OUTPUT_DIRECTORY_DEBUG "${CMAKE_CURRENT_SOURCE_DIR}/../bin/Debug-x86_64/OpenGL-Core/" + OUTPUT_DIRECTORY_RELEASE "${CMAKE_CURRENT_SOURCE_DIR}/../bin/Release-x86_64/OpenGL-Core/" +) +################################################################################ +# MSVC runtime library +################################################################################ +get_property(MSVC_RUNTIME_LIBRARY_DEFAULT TARGET ${PROJECT_NAME} PROPERTY MSVC_RUNTIME_LIBRARY) +string(CONCAT "MSVC_RUNTIME_LIBRARY_STR" + $<$: + MultiThreadedDebug + > + $<$: + MultiThreaded + > + $<$,$>>:${MSVC_RUNTIME_LIBRARY_DEFAULT}> +) +set_target_properties(${PROJECT_NAME} PROPERTIES MSVC_RUNTIME_LIBRARY ${MSVC_RUNTIME_LIBRARY_STR}) + +################################################################################ +# Include directories +################################################################################ +target_include_directories(${PROJECT_NAME} PUBLIC + "${CMAKE_CURRENT_SOURCE_DIR}/src;" + "${CMAKE_CURRENT_SOURCE_DIR}/vendor/spdlog/include;" + "${CMAKE_CURRENT_SOURCE_DIR}/vendor/glfw/include;" + "${CMAKE_CURRENT_SOURCE_DIR}/vendor/Glad/include;" + "${CMAKE_CURRENT_SOURCE_DIR}/vendor/imgui;" + "${CMAKE_CURRENT_SOURCE_DIR}/vendor/glm;" + "${CMAKE_CURRENT_SOURCE_DIR}/vendor/stb_image" +) + +################################################################################ +# Compile definitions +################################################################################ +target_compile_definitions(${PROJECT_NAME} PRIVATE + "$<$:" + "GLCORE_DEBUG" + ">" + "$<$:" + "GLCORE_RELEASE" + ">" + "_CRT_SECURE_NO_WARNINGS;" +# "GLCORE_PLATFORM_WINDOWS;" + "GLFW_INCLUDE_NONE;" + "UNICODE;" + "_UNICODE" +) + +################################################################################ +# Compile and link options +################################################################################ +if(MSVC) + target_compile_options(${PROJECT_NAME} PRIVATE + $<$: + /Od; + /ZI + > + $<$: + /Ox; + /Oi; + /GF; + /Gy; + ${DEFAULT_CXX_DEBUG_INFORMATION_FORMAT} + > + /MP; + /std:c++17; + /Gm-; + /W3; + ${DEFAULT_CXX_EXCEPTION_HANDLING} + ) + target_link_options(${PROJECT_NAME} PRIVATE + $<$: + /OPT:REF; + /OPT:ICF + > + /SUBSYSTEM:WINDOWS + ) +endif() + +################################################################################ +# Dependencies +################################################################################ +#add_dependencies(${PROJECT_NAME} +# GLFW +# Glad +# ImGui +#) + +# Link with other targets. +target_link_libraries(${PROJECT_NAME} PUBLIC + glfw + Glad + ImGui +) + +#set(ADDITIONAL_LIBRARY_DEPENDENCIES +# "opengl32" +#) +#target_link_libraries(${PROJECT_NAME} PUBLIC "${ADDITIONAL_LIBRARY_DEPENDENCIES}") + +find_package(OpenGL REQUIRED) +target_include_directories(${PROJECT_NAME} PUBLIC ${OPENGL_INCLUDE_DIR}) diff --git a/OpenGL-Core/src/GLCore/Core/Core.h b/OpenGL-Core/src/GLCore/Core/Core.h index b59cf72b..53319809 100644 --- a/OpenGL-Core/src/GLCore/Core/Core.h +++ b/OpenGL-Core/src/GLCore/Core/Core.h @@ -8,7 +8,11 @@ #endif #ifdef GLCORE_ENABLE_ASSERTS - #define GLCORE_ASSERT(x, ...) { if(!(x)) { LOG_ERROR("Assertion Failed: {0}", __VA_ARGS__); __debugbreak(); } } + #ifdef __clang__ + #define GLCORE_ASSERT(x, ...) { if(!(x)) { LOG_ERROR("Assertion Failed: {0}", __VA_ARGS__); __builtin_debugtrap(); } } + #else + #define GLCORE_ASSERT(x, ...) { if(!(x)) { LOG_ERROR("Assertion Failed: {0}", __VA_ARGS__); __debugbreak(); } } + #endif #else #define GLCORE_ASSERT(x, ...) #endif diff --git a/OpenGL-Core/src/GLCore/Core/Window.h b/OpenGL-Core/src/GLCore/Core/Window.h index 46ee9a68..e601e647 100644 --- a/OpenGL-Core/src/GLCore/Core/Window.h +++ b/OpenGL-Core/src/GLCore/Core/Window.h @@ -1,6 +1,6 @@ #pragma once -#include "glpch.h" +//#include "glpch.h" #include "GLCore/Core/Core.h" #include "GLCore/Events/Event.h" diff --git a/OpenGL-Core/src/GLCore/Events/Event.h b/OpenGL-Core/src/GLCore/Events/Event.h index 040d98de..8de24c1d 100644 --- a/OpenGL-Core/src/GLCore/Events/Event.h +++ b/OpenGL-Core/src/GLCore/Events/Event.h @@ -29,7 +29,7 @@ namespace GLCore { EventCategoryMouseButton = BIT(4) }; -#define EVENT_CLASS_TYPE(type) static EventType GetStaticType() { return EventType::##type; }\ +#define EVENT_CLASS_TYPE(type) static EventType GetStaticType() { return EventType::type; }\ virtual EventType GetEventType() const override { return GetStaticType(); }\ virtual const char* GetName() const override { return #type; } diff --git a/OpenGL-Core/src/GLCore/ImGui/ImGuiLayer.h b/OpenGL-Core/src/GLCore/ImGui/ImGuiLayer.h index 2b25206e..9cf2e323 100644 --- a/OpenGL-Core/src/GLCore/ImGui/ImGuiLayer.h +++ b/OpenGL-Core/src/GLCore/ImGui/ImGuiLayer.h @@ -20,8 +20,8 @@ namespace GLCore { void Begin(); void End(); - virtual void ImGuiLayer::OnEvent(Event& event); - bool ImGuiLayer::OnMouseButtonPressed(MouseButtonPressedEvent& e); + virtual void OnEvent(Event& event); + bool OnMouseButtonPressed(MouseButtonPressedEvent& e); private: float m_Time = 0.0f; }; diff --git a/OpenGL-Core/src/Platform/Windows/WindowsWindow.cpp b/OpenGL-Core/src/Platform/Windows/WindowsWindow.cpp index 322e4b66..455260e6 100644 --- a/OpenGL-Core/src/Platform/Windows/WindowsWindow.cpp +++ b/OpenGL-Core/src/Platform/Windows/WindowsWindow.cpp @@ -42,6 +42,19 @@ namespace GLCore { { int success = glfwInit(); GLCORE_ASSERT(success, "Could not intialize GLFW!"); + + #ifdef __APPLE__ + // GL 3.3 + GLSL 150 + const char* glsl_version = "#version 150"; + glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4); + glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1); + glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); + glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); + #else + // GLSL 130 + const char* glsl_version = "#version 130"; + #endif + glfwSetErrorCallback(GLFWErrorCallback); s_GLFWInitialized = true; } diff --git a/OpenGL-Core/vendor/Glad/CMakeLists.txt b/OpenGL-Core/vendor/Glad/CMakeLists.txt new file mode 100644 index 00000000..efae55a8 --- /dev/null +++ b/OpenGL-Core/vendor/Glad/CMakeLists.txt @@ -0,0 +1,113 @@ +set(PROJECT_NAME Glad) + +################################################################################ +# Source groups +################################################################################ +set(include__KHR + "include/KHR/khrplatform.h" +) +source_group("include\\KHR" FILES ${include__KHR}) + +set(include__glad + "include/glad/glad.h" +) +source_group("include\\glad" FILES ${include__glad}) + +set(src + "src/glad.c" +) +source_group("src" FILES ${src}) + +set(ALL_FILES + ${include__KHR} + ${include__glad} + ${src} +) + +################################################################################ +# Target +################################################################################ +add_library(${PROJECT_NAME} STATIC ${ALL_FILES}) +set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER "Dependencies") + +use_props(${PROJECT_NAME} "${CMAKE_CONFIGURATION_TYPES}" "${DEFAULT_CXX_PROPS}") +set(ROOT_NAMESPACE Glad) + +set_target_properties(${PROJECT_NAME} PROPERTIES + VS_GLOBAL_KEYWORD "Win32Proj" +) +################################################################################ +# Target name +################################################################################ +set_target_properties(${PROJECT_NAME} PROPERTIES + TARGET_NAME_DEBUG "Glad" + TARGET_NAME_RELEASE "Glad" +) +################################################################################ +# Output directory +################################################################################ +set_target_properties(${PROJECT_NAME} PROPERTIES + OUTPUT_DIRECTORY_DEBUG "${CMAKE_CURRENT_SOURCE_DIR}/bin/Debug-windows-x86_64/Glad/" + OUTPUT_DIRECTORY_RELEASE "${CMAKE_CURRENT_SOURCE_DIR}/bin/Release-windows-x86_64/Glad/" +) +################################################################################ +# MSVC runtime library +################################################################################ +get_property(MSVC_RUNTIME_LIBRARY_DEFAULT TARGET ${PROJECT_NAME} PROPERTY MSVC_RUNTIME_LIBRARY) +string(CONCAT "MSVC_RUNTIME_LIBRARY_STR" + $<$: + MultiThreadedDebug + > + $<$: + MultiThreaded + > + $<$,$>>:${MSVC_RUNTIME_LIBRARY_DEFAULT}> +) +set_target_properties(${PROJECT_NAME} PROPERTIES MSVC_RUNTIME_LIBRARY ${MSVC_RUNTIME_LIBRARY_STR}) + +################################################################################ +# Include directories +################################################################################ +target_include_directories(${PROJECT_NAME} PUBLIC + "${CMAKE_CURRENT_SOURCE_DIR}/include" +) + +################################################################################ +# Compile definitions +################################################################################ +target_compile_definitions(${PROJECT_NAME} PRIVATE + "UNICODE;" + "_UNICODE" +) + +################################################################################ +# Compile and link options +################################################################################ +if(MSVC) + target_compile_options(${PROJECT_NAME} PRIVATE + $<$: + /Od; + /ZI + > + $<$: + /Ox; + /Oi; + /GF; + /Gy; + ${DEFAULT_CXX_DEBUG_INFORMATION_FORMAT} + > + /MP; + /Gm-; + /W3; + ${DEFAULT_CXX_EXCEPTION_HANDLING}; + /Y- + ) + target_link_options(${PROJECT_NAME} PRIVATE + $<$: + /OPT:REF; + /OPT:ICF + > + /SUBSYSTEM:WINDOWS + ) +endif() + diff --git a/OpenGL-Examples/CMakeLists.txt b/OpenGL-Examples/CMakeLists.txt new file mode 100644 index 00000000..d4a28bb5 --- /dev/null +++ b/OpenGL-Examples/CMakeLists.txt @@ -0,0 +1,138 @@ +set(PROJECT_NAME OpenGL-Examples) + +################################################################################ +# Source groups +################################################################################ +set(Headers + "src/ExampleLayer.h" +) +source_group("Headers" FILES ${Headers}) + +set(Sources + "src/ExampleApp.cpp" + "src/ExampleLayer.cpp" +) +source_group("Sources" FILES ${Sources}) + +set(ALL_FILES + ${Headers} + ${Sources} +) + +################################################################################ +# Target +################################################################################ +add_executable(${PROJECT_NAME} ${ALL_FILES}) + +use_props(${PROJECT_NAME} "${CMAKE_CONFIGURATION_TYPES}" "${DEFAULT_CXX_PROPS}") +set(ROOT_NAMESPACE OpenGL-Examples) + +#set_target_properties(${PROJECT_NAME} PROPERTIES +# VS_GLOBAL_KEYWORD "Win32Proj" +#) +################################################################################ +# Target name +################################################################################ +set_target_properties(${PROJECT_NAME} PROPERTIES + TARGET_NAME_DEBUG "OpenGL-Examples" + TARGET_NAME_RELEASE "OpenGL-Examples" +) +################################################################################ +# Output directory +################################################################################ +set_target_properties(${PROJECT_NAME} PROPERTIES + OUTPUT_DIRECTORY_DEBUG "${CMAKE_CURRENT_SOURCE_DIR}/../bin/Debug-x86_64/OpenGL-Examples/" + OUTPUT_DIRECTORY_RELEASE "${CMAKE_CURRENT_SOURCE_DIR}/../bin/Release-x86_64/OpenGL-Examples/" +) +################################################################################ +# MSVC runtime library +################################################################################ +get_property(MSVC_RUNTIME_LIBRARY_DEFAULT TARGET ${PROJECT_NAME} PROPERTY MSVC_RUNTIME_LIBRARY) +string(CONCAT "MSVC_RUNTIME_LIBRARY_STR" + $<$: + MultiThreadedDebug + > + $<$: + MultiThreaded + > + $<$,$>>:${MSVC_RUNTIME_LIBRARY_DEFAULT}> +) +set_target_properties(${PROJECT_NAME} PROPERTIES MSVC_RUNTIME_LIBRARY ${MSVC_RUNTIME_LIBRARY_STR}) + +################################################################################ +# Include directories +################################################################################ +target_include_directories(${PROJECT_NAME} PUBLIC + "${CMAKE_CURRENT_SOURCE_DIR}/../OpenGL-Core/vendor/spdlog/include;" + "${CMAKE_CURRENT_SOURCE_DIR}/../OpenGL-Core/src;" + "${CMAKE_CURRENT_SOURCE_DIR}/../OpenGL-Core/vendor;" + "${CMAKE_CURRENT_SOURCE_DIR}/../OpenGL-Core/vendor/glm;" + "${CMAKE_CURRENT_SOURCE_DIR}/../OpenGL-Core/vendor/Glad/include;" + "${CMAKE_CURRENT_SOURCE_DIR}/../OpenGL-Core/vendor/imgui" +) + +################################################################################ +# Compile definitions +################################################################################ +target_compile_definitions(${PROJECT_NAME} PRIVATE + "$<$:" + "GLCORE_DEBUG" + ">" + "$<$:" + "GLCORE_RELEASE" + ">" + # "GLCORE_PLATFORM_WINDOWS;" + "UNICODE;" + "_UNICODE" +) + +################################################################################ +# Compile and link options +################################################################################ +if(MSVC) + target_compile_options(${PROJECT_NAME} PRIVATE + $<$: + /Od; + /ZI + > + $<$: + /Ox; + /Oi; + /GF; + /Gy; + ${DEFAULT_CXX_DEBUG_INFORMATION_FORMAT} + > + /MP; + /std:c++17; + /Gm-; + /W3; + ${DEFAULT_CXX_EXCEPTION_HANDLING}; + /Y- + ) + target_link_options(${PROJECT_NAME} PRIVATE + $<$: + /DEBUG; + /INCREMENTAL + > + $<$: + /DEBUG:FULL; + /OPT:REF; + /OPT:ICF; + /INCREMENTAL:NO + > + /SUBSYSTEM:CONSOLE + ) +endif() + +################################################################################ +# Dependencies +################################################################################ +add_dependencies(${PROJECT_NAME} + OpenGL-Core +) + +# Link with other targets. +target_link_libraries(${PROJECT_NAME} PRIVATE + OpenGL-Core +) + diff --git a/OpenGL-Examples/assets/shaders/test.frag.glsl b/OpenGL-Examples/assets/shaders/test.frag.glsl index b44294c9..f64238f7 100644 --- a/OpenGL-Examples/assets/shaders/test.frag.glsl +++ b/OpenGL-Examples/assets/shaders/test.frag.glsl @@ -1,4 +1,4 @@ -#version 450 core +#version 410 core layout (location = 0) out vec4 o_Color; diff --git a/OpenGL-Examples/assets/shaders/test.vert.glsl b/OpenGL-Examples/assets/shaders/test.vert.glsl index 261b0fe7..c5f0e49d 100644 --- a/OpenGL-Examples/assets/shaders/test.vert.glsl +++ b/OpenGL-Examples/assets/shaders/test.vert.glsl @@ -1,4 +1,4 @@ -#version 450 core +#version 410 core layout (location = 0) in vec3 a_Position; diff --git a/OpenGL-Examples/src/ExampleLayer.cpp b/OpenGL-Examples/src/ExampleLayer.cpp index 3d0d758f..679aa80b 100644 --- a/OpenGL-Examples/src/ExampleLayer.cpp +++ b/OpenGL-Examples/src/ExampleLayer.cpp @@ -16,7 +16,7 @@ ExampleLayer::~ExampleLayer() void ExampleLayer::OnAttach() { - EnableGLDebugging(); + // EnableGLDebugging(); glEnable(GL_DEPTH_TEST); glEnable(GL_BLEND); @@ -27,7 +27,7 @@ void ExampleLayer::OnAttach() "assets/shaders/test.frag.glsl" ); - glCreateVertexArrays(1, &m_QuadVA); + glGenVertexArrays(1, &m_QuadVA); glBindVertexArray(m_QuadVA); float vertices[] = { @@ -37,7 +37,7 @@ void ExampleLayer::OnAttach() -0.5f, 0.5f, 0.0f }; - glCreateBuffers(1, &m_QuadVB); + glGenBuffers(1, &m_QuadVB); glBindBuffer(GL_ARRAY_BUFFER, m_QuadVB); glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW); @@ -45,7 +45,7 @@ void ExampleLayer::OnAttach() glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(float) * 3, 0); uint32_t indices[] = { 0, 1, 2, 2, 3, 0 }; - glCreateBuffers(1, &m_QuadIB); + glGenBuffers(1, &m_QuadIB); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_QuadIB); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW); } diff --git a/README.md b/README.md index 449cce27..ba0f88b9 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,27 @@ # OpenGL-Core -Work-in-progress OpenGL library that aims to provide a powerful sandbox for you to learn or experiment with OpenGL, and graphics programming in general. +Work-in-progress OpenGL library that aims to provide a powerful sandbox for you to learn or experiment with OpenGL, and graphics programming in general. + +These repo add **macOS support (using CMake)**. The original repo is at https://github.com/TheCherno/OpenGL. ## Usage -Currently only "officially" supports Windows - Mac and Linux support is coming soon. +### Windows ``` git clone --recursive https://github.com/TheCherno/OpenGL ``` Run `scripts/Win-Premake.bat` and open `OpenGL-Sandbox.sln` in Visual Studio 2019. `OpenGL-Sandbox/src/SandboxLayer.cpp` contains the example OpenGL code that's running. + + +### MacOS + +#### Download, Build and Run +``` +git clone --recursive https://github.com/TheCherno/OpenGL +cmake . +make + +cd OpenGL-Examples +./OpenGL-Examples +```