restructured project x2
This commit is contained in:
parent
e137549b2e
commit
49b2ba0ba7
163
CMakeLists.txt
163
CMakeLists.txt
@ -1,31 +1,166 @@
|
|||||||
cmake_minimum_required (VERSION 3.16)
|
cmake_minimum_required (VERSION 3.16)
|
||||||
|
|
||||||
# Dependencies
|
# Extract project version from source
|
||||||
set(CMAKE_CXX_STANDARD 20)
|
file(STRINGS "source/hpr/core/common.hpp"
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
|
hpr_version_defines REGEX "#define HPR_VERSION_(MAJOR|MINOR|PATCH) ")
|
||||||
|
|
||||||
set(USE_SYSTEM_OCCT ON CACHE INTERNAL "")
|
foreach(ver ${hpr_version_defines})
|
||||||
|
if(ver MATCHES [[#define HPR_VERSION_(MAJOR|MINOR|PATCH) +([^ ]+)$]])
|
||||||
|
set(HPR_VERSION_${CMAKE_MATCH_1} "${CMAKE_MATCH_2}")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
if(HPR_VERSION_PATCH MATCHES [[\.([a-zA-Z0-9]+)$]])
|
||||||
|
set(hpr_VERSION_TYPE "${CMAKE_MATCH_1}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
string(REGEX MATCH "^[0-9]+" HPR_VERSION_PATCH "${HPR_VERSION_PATCH}")
|
||||||
|
set(HPR_PROJECT_VERSION "${HPR_VERSION_MAJOR}.${HPR_VERSION_MINOR}.${HPR_VERSION_PATCH}")
|
||||||
|
|
||||||
# Main project
|
# Main project
|
||||||
project(
|
project(
|
||||||
project-hyporo
|
hpr
|
||||||
VERSION 0.10.0
|
VERSION "${HPR_PROJECT_VERSION}"
|
||||||
LANGUAGES CXX
|
LANGUAGES CXX
|
||||||
)
|
)
|
||||||
|
|
||||||
option(WITH_GTESTS "Enable GTest unit testing" ON)
|
# Detect how project is used
|
||||||
|
if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
|
||||||
|
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)
|
||||||
|
set(lines
|
||||||
|
"You are building in-place. If that is not what you intended to "
|
||||||
|
"do, you can clean the source directory with:\n"
|
||||||
|
"rm -r CMakeCache.txt CMakeFiles/ cmake_uninstall.cmake hprConfig.cmake "
|
||||||
|
"hprConfigVersion.cmake\n")
|
||||||
|
message(AUTHOR_WARNING ${lines})
|
||||||
|
endif()
|
||||||
|
|
||||||
enable_testing()
|
set(HPR_MASTER_PROJECT ON)
|
||||||
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
|
|
||||||
if(WITH_GTESTS)
|
message(STATUS ${CMAKE_SOURCE_DIR})
|
||||||
option(INSTALL_GMOCK "" OFF)
|
else()
|
||||||
option(INSTALL_GTEST "" OFF)
|
set(HPR_MASTER_PROJECT OFF)
|
||||||
include(${CMAKE_SOURCE_DIR}/cmake/googletest.cmake)
|
|
||||||
include(GoogleTest)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
add_subdirectory(source)
|
|
||||||
|
# Standard includes
|
||||||
|
include(GNUInstallDirs)
|
||||||
|
include(CPack)
|
||||||
|
|
||||||
|
# Options
|
||||||
|
option(HPR_INSTALL "Install hpr files?" ${HPR_MASTER_PROJECT})
|
||||||
|
option(HPR_TEST "Build hpr tests?" ${HPR_MASTER_PROJECT})
|
||||||
|
|
||||||
|
# Testing
|
||||||
|
if(HPR_TEST)
|
||||||
|
enable_testing()
|
||||||
|
|
||||||
|
option(INSTALL_GMOCK "" OFF)
|
||||||
|
option(INSTALL_GTEST "" OFF)
|
||||||
|
|
||||||
|
include(${CMAKE_SOURCE_DIR}/cmake/external/googletest.cmake)
|
||||||
|
include(GoogleTest)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Modules
|
||||||
|
option(WITH_CONTAINERS "" ON)
|
||||||
|
option(WITH_MATH "" ON)
|
||||||
|
option(WITH_IO "" ON)
|
||||||
|
option(WITH_MESH "" ON)
|
||||||
|
option(WITH_CSG "" ON)
|
||||||
|
option(USE_SYSTEM_OCCT "" ON)
|
||||||
|
option(WITH_GPU "" ON)
|
||||||
|
option(WITH_WINDOW_SYSTEM "" ON)
|
||||||
|
|
||||||
|
set_property(GLOBAL PROPERTY HPR_MODULES "")
|
||||||
|
macro(add_module MODULE)
|
||||||
|
set_property(GLOBAL APPEND PROPERTY HPR_MODULES "${MODULE}")
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
add_subdirectory(source/hpr)
|
||||||
|
|
||||||
|
get_property(hpr_modules GLOBAL PROPERTY HPR_MODULES)
|
||||||
|
foreach(module ${hpr_modules})
|
||||||
|
get_target_property(module_type ${module} TYPE)
|
||||||
|
if(module_type STREQUAL "INTERFACE_LIBRARY")
|
||||||
|
list(APPEND HPR_INTERFACE_LIBS "${PROJECT_NAME}::${module}")
|
||||||
|
else()
|
||||||
|
list(APPEND HPR_PUBLIC_LIBS "${PROJECT_NAME}::${module}")
|
||||||
|
endif()
|
||||||
|
set(hpr_modules_summary "${hpr_modules_summary} ${module}")
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
# Main library
|
||||||
|
add_library(hpr SHARED
|
||||||
|
source/hpr/hpr.cpp)
|
||||||
|
add_library(hpr::hpr ALIAS hpr)
|
||||||
|
|
||||||
|
target_sources(hpr
|
||||||
|
INTERFACE
|
||||||
|
"$<BUILD_INTERFACE:source/hpr/hpr.hpp>"
|
||||||
|
"$<INSTALL_INTERFACE:include/${PROJECT_NAME}>"
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(hpr
|
||||||
|
INTERFACE
|
||||||
|
${HPR_INTERFACE_LIBS}
|
||||||
|
PUBLIC
|
||||||
|
${HPR_PUBLIC_LIBS}
|
||||||
|
)
|
||||||
|
|
||||||
|
include(CMakePackageConfigHelpers)
|
||||||
|
|
||||||
|
configure_package_config_file(
|
||||||
|
"${PROJECT_SOURCE_DIR}/cmake/${PROJECT_NAME}Config.cmake.in"
|
||||||
|
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
|
||||||
|
INSTALL_DESTINATION
|
||||||
|
${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}-${PROJECT_VERSION}
|
||||||
|
)
|
||||||
|
|
||||||
|
write_basic_package_version_file(
|
||||||
|
"${PROJECT_NAME}ConfigVersion.cmake"
|
||||||
|
VERSION ${PROJECT_VERSION}
|
||||||
|
COMPATIBILITY SameMajorVersion
|
||||||
|
)
|
||||||
|
|
||||||
|
install(FILES
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
|
||||||
|
DESTINATION
|
||||||
|
${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}-${PROJECT_VERSION}
|
||||||
|
)
|
||||||
|
install(
|
||||||
|
TARGETS ${PROJECT_NAME}
|
||||||
|
EXPORT ${PROJECT_NAME}Targets
|
||||||
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}
|
||||||
|
NAMELINK_SKIP
|
||||||
|
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||||
|
)
|
||||||
|
install(
|
||||||
|
EXPORT ${PROJECT_NAME}Targets
|
||||||
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME}-${HPR_PROJECT_VERSION}
|
||||||
|
NAMESPACE ${CMAKE_PROJECT_NAME}::
|
||||||
|
)
|
||||||
|
install(
|
||||||
|
TARGETS ${PROJECT_NAME}
|
||||||
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}
|
||||||
|
NAMELINK_ONLY
|
||||||
|
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
# Project summary
|
||||||
|
set(summary
|
||||||
|
"Summary:\n"
|
||||||
|
"Version: ${HPR_PROJECT_VERSION}\n"
|
||||||
|
"Master: ${HPR_MASTER_PROJECT}\n"
|
||||||
|
"Modules: ${hpr_modules_summary}"
|
||||||
|
)
|
||||||
|
message(STATUS ${summary})
|
||||||
|
|
||||||
|
# Documentation
|
||||||
#add_subdirectory(docs)
|
#add_subdirectory(docs)
|
||||||
|
|
||||||
|
# Additional applications
|
||||||
|
add_subdirectory(source/applications)
|
2
cmake/glad.cmake → cmake/external/glad.cmake
vendored
2
cmake/glad.cmake → cmake/external/glad.cmake
vendored
@ -1,4 +1,4 @@
|
|||||||
include(${CMAKE_CURRENT_LIST_DIR}/CPM.cmake)
|
include(${CMAKE_SOURCE_DIR}/cmake/tools/CPM.cmake)
|
||||||
|
|
||||||
CPMAddPackage(
|
CPMAddPackage(
|
||||||
NAME glad
|
NAME glad
|
8
cmake/external/glfw.cmake
vendored
Normal file
8
cmake/external/glfw.cmake
vendored
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
include(${CMAKE_SOURCE_DIR}/cmake/tools/CPM.cmake)
|
||||||
|
|
||||||
|
CPMAddPackage(
|
||||||
|
NAME glfw
|
||||||
|
GIT_REPOSITORY https://github.com/glfw/glfw.git
|
||||||
|
GIT_TAG 3.3.7
|
||||||
|
EXCLUDE_FROM_ALL ON
|
||||||
|
)
|
@ -1,4 +1,4 @@
|
|||||||
include(${CMAKE_CURRENT_LIST_DIR}/CPM.cmake)
|
include(${CMAKE_SOURCE_DIR}/cmake/tools/CPM.cmake)
|
||||||
|
|
||||||
CPMAddPackage(
|
CPMAddPackage(
|
||||||
NAME googletest
|
NAME googletest
|
@ -1,4 +1,4 @@
|
|||||||
include(${CMAKE_CURRENT_LIST_DIR}/CPM.cmake)
|
include(${CMAKE_SOURCE_DIR}/cmake/tools/CPM.cmake)
|
||||||
|
|
||||||
# branch: docking
|
# branch: docking
|
||||||
CPMAddPackage(
|
CPMAddPackage(
|
13
cmake/occt.cmake → cmake/external/occt.cmake
vendored
13
cmake/occt.cmake → cmake/external/occt.cmake
vendored
@ -3,10 +3,13 @@ if(USE_SYSTEM_OCCT)
|
|||||||
find_package(OpenCASCADE REQUIRED)
|
find_package(OpenCASCADE REQUIRED)
|
||||||
|
|
||||||
if(OpenCASCADE_FOUND)
|
if(OpenCASCADE_FOUND)
|
||||||
message(STATUS "Found OCCT")
|
message(STATUS "OCCT: Found")
|
||||||
endif()
|
|
||||||
else()
|
else()
|
||||||
include(${CMAKE_CURRENT_LIST_DIR}/CPM.cmake)
|
message(FATAL "OCCT: Not Found")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
else()
|
||||||
|
include(${CMAKE_SOURCE_DIR}/cmake/tools/CPM.cmake)
|
||||||
|
|
||||||
CPMAddPackage(
|
CPMAddPackage(
|
||||||
NAME occt
|
NAME occt
|
||||||
@ -16,7 +19,7 @@ else()
|
|||||||
)
|
)
|
||||||
|
|
||||||
if(occt_ADDED)
|
if(occt_ADDED)
|
||||||
# Freaks are using CMAKE_SOURCE_DIR and CMAKE_BINARY_DIR for the project root, fix it
|
# They are using CMAKE_SOURCE_DIR and CMAKE_BINARY_DIR for the project root, fix it
|
||||||
file(READ ${occt_SOURCE_DIR}/CMakeLists.txt filedata_)
|
file(READ ${occt_SOURCE_DIR}/CMakeLists.txt filedata_)
|
||||||
string(FIND "${filedata_}" "CMAKE_SOURCE_DIR" need_patch)
|
string(FIND "${filedata_}" "CMAKE_SOURCE_DIR" need_patch)
|
||||||
|
|
||||||
@ -38,7 +41,7 @@ else()
|
|||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
project(OCCT)
|
project(OCCT)
|
||||||
# should be better way to pass build directory
|
# find better way to pass build directory
|
||||||
set(_OCCT_BINARY_DIR ${occt_BINARY_DIR})
|
set(_OCCT_BINARY_DIR ${occt_BINARY_DIR})
|
||||||
set(INSTALL_DIR ${occt_BINARY_DIR} CACHE BOOL "" FORCE)
|
set(INSTALL_DIR ${occt_BINARY_DIR} CACHE BOOL "" FORCE)
|
||||||
|
|
2
cmake/stb.cmake → cmake/external/stb.cmake
vendored
2
cmake/stb.cmake → cmake/external/stb.cmake
vendored
@ -1,4 +1,4 @@
|
|||||||
include(${CMAKE_CURRENT_LIST_DIR}/CPM.cmake)
|
include(${CMAKE_SOURCE_DIR}/cmake/tools/CPM.cmake)
|
||||||
|
|
||||||
CPMAddPackage(
|
CPMAddPackage(
|
||||||
NAME stb_external
|
NAME stb_external
|
7
cmake/hprConfig.cmake.in
Normal file
7
cmake/hprConfig.cmake.in
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
@PACKAGE_INIT@
|
||||||
|
|
||||||
|
include(CMakeFindDependencyMacro)
|
||||||
|
|
||||||
|
include("${CMAKE_CURRENT_LIST_DIR}/hprTargets.cmake")
|
||||||
|
|
||||||
|
check_required_components("@PROJECT_NAME@")
|
@ -1,52 +0,0 @@
|
|||||||
|
|
||||||
macro(add_component_library COMPONENT LIBRARY_TYPE COMPONENT_SOURCES)
|
|
||||||
add_library(${COMPONENT} ${LIBRARY_TYPE} ${COMPONENT_SOURCES})
|
|
||||||
add_library(${PROJECT_NAME}::${COMPONENT} ALIAS ${COMPONENT})
|
|
||||||
endmacro()
|
|
||||||
|
|
||||||
macro(install_component_source COMPONENT)
|
|
||||||
set_target_properties(${COMPONENT}
|
|
||||||
PROPERTIES
|
|
||||||
VERSION ${${PROJECT_NAME}_VERSION}
|
|
||||||
SOVERSION ${${PROJECT_NAME}_VERSION_MAJOR}
|
|
||||||
OUTPUT_NAME ${PROJECT_NAME}-${COMPONENT}
|
|
||||||
)
|
|
||||||
|
|
||||||
install(
|
|
||||||
TARGETS ${COMPONENT}
|
|
||||||
EXPORT ${COMPONENT}Targets
|
|
||||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}
|
|
||||||
)
|
|
||||||
|
|
||||||
install(
|
|
||||||
EXPORT ${COMPONENT}Targets
|
|
||||||
FILE ${COMPONENT}Targets.cmake
|
|
||||||
NAMESPACE ${PROJECT_NAME}::
|
|
||||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
|
|
||||||
)
|
|
||||||
endmacro()
|
|
||||||
|
|
||||||
macro(install_component_headers COMPONENT)
|
|
||||||
|
|
||||||
#target_include_directories(${COMPONENT}
|
|
||||||
# PUBLIC
|
|
||||||
# $<INSTALL_INTERFACE:include>
|
|
||||||
# $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>#/${CMAKE_PROJECT_NAME}>#/include>
|
|
||||||
# )
|
|
||||||
|
|
||||||
install(
|
|
||||||
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}#/${COMPONENT}
|
|
||||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}#/${COMPONENT}
|
|
||||||
COMPONENT devel
|
|
||||||
FILES_MATCHING
|
|
||||||
PATTERN "*.h"
|
|
||||||
PATTERN "*.hpp"
|
|
||||||
)
|
|
||||||
|
|
||||||
install(
|
|
||||||
FILES ${CMAKE_CURRENT_SOURCE_DIR}/../${COMPONENT}.hpp
|
|
||||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}#/${COMPONENT}
|
|
||||||
COMPONENT devel
|
|
||||||
)
|
|
||||||
|
|
||||||
endmacro()
|
|
@ -1,3 +1,3 @@
|
|||||||
add_subdirectory(hpr)
|
add_subdirectory(hpr)
|
||||||
add_subdirectory(creator)
|
#add_subdirectory(creator)
|
||||||
#add_subdirectory(applications)
|
#add_subdirectory(applications)
|
@ -1,10 +1,16 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
|
||||||
|
project(periodic
|
||||||
|
VERSION "0.1.0"
|
||||||
|
LANGUAGES CXX
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
add_executable(periodic
|
add_executable(periodic
|
||||||
periodic.cpp
|
periodic.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(periodic
|
target_link_libraries(periodic
|
||||||
hyporo-hyplib
|
hpr::csg
|
||||||
hyporo-csg
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../../hyporo/hyplib/scalar/scalar.hpp"
|
#include "../../hpr/math.hpp"
|
||||||
#include "../../hyporo/hyplib/vector/vector.hpp"
|
#include "../../hpr/csg.hpp"
|
||||||
#include "../../hyporo/hyplib/array/array.hpp"
|
|
||||||
#include "../../hyporo/hyplib/matrix/matrix.hpp"
|
|
||||||
#include "../../hyporo/csg/csg.hpp"
|
|
||||||
|
|
||||||
|
|
||||||
namespace hpr::csg
|
namespace hpr::csg
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
#include "../../hyporo/hyplib/scalar/scalar.hpp"
|
#include "../../hpr/math.hpp"
|
||||||
#include "../../hyporo/hyplib/vector/vector.hpp"
|
#include "../../hpr/csg.hpp"
|
||||||
#include "../../hyporo/hyplib/array/array.hpp"
|
|
||||||
#include "../../hyporo/csg/csg.hpp"
|
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
@ -7,7 +7,7 @@ project(
|
|||||||
|
|
||||||
# Compiler options
|
# Compiler options
|
||||||
set(CMAKE_CXX_STANDARD 20)
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
|
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
|
||||||
|
|
||||||
# Project options
|
# Project options
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
@ -35,3 +35,18 @@ target_include_directories(${PROJECT_NAME}
|
|||||||
PRIVATE
|
PRIVATE
|
||||||
../
|
../
|
||||||
)
|
)
|
||||||
|
|
||||||
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
|
add_executable(testi
|
||||||
|
test.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(testi
|
||||||
|
PRIVATE
|
||||||
|
../
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(testi
|
||||||
|
hpr::hpr
|
||||||
|
imgui
|
||||||
|
)
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
#ifndef __gl_h_
|
||||||
|
#include <glad/glad.h>
|
||||||
|
#endif
|
||||||
#include "hpr/window_system/window_system.hpp"
|
#include "hpr/window_system/window_system.hpp"
|
||||||
#include "hpr/window_system/glfw/window_system.hpp"
|
#include "hpr/window_system/glfw/window_system.hpp"
|
||||||
#include "hpr/window_system/glfw/window.hpp"
|
#include "hpr/window_system/glfw/window.hpp"
|
||||||
@ -10,6 +13,108 @@
|
|||||||
#include <imgui_impl_opengl3.h>
|
#include <imgui_impl_opengl3.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
void APIENTRY glDebugOutput(
|
||||||
|
GLenum source,
|
||||||
|
GLenum type,
|
||||||
|
unsigned int id,
|
||||||
|
GLenum severity,
|
||||||
|
GLsizei length,
|
||||||
|
const char* message,
|
||||||
|
const void* userParam
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// ignore non-significant error/warning codes
|
||||||
|
if (id == 131169 || id == 131185 || id == 131218 || id == 131204)
|
||||||
|
return;
|
||||||
|
|
||||||
|
std::cout << "Debug::GL[" << id << "]: " << message << std::endl;
|
||||||
|
|
||||||
|
switch (source)
|
||||||
|
{
|
||||||
|
case GL_DEBUG_SOURCE_API:
|
||||||
|
std::cout << "Source: API";
|
||||||
|
break;
|
||||||
|
case GL_DEBUG_SOURCE_WINDOW_SYSTEM:
|
||||||
|
std::cout << "Source: Window System";
|
||||||
|
break;
|
||||||
|
case GL_DEBUG_SOURCE_SHADER_COMPILER:
|
||||||
|
std::cout << "Source: Shader Compiler";
|
||||||
|
break;
|
||||||
|
case GL_DEBUG_SOURCE_THIRD_PARTY:
|
||||||
|
std::cout << "Source: Third Party";
|
||||||
|
break;
|
||||||
|
case GL_DEBUG_SOURCE_APPLICATION:
|
||||||
|
std::cout << "Source: Application";
|
||||||
|
break;
|
||||||
|
case GL_DEBUG_SOURCE_OTHER:
|
||||||
|
std::cout << "Source: Other";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
std::cout << std::endl;
|
||||||
|
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case GL_DEBUG_TYPE_ERROR:
|
||||||
|
std::cout << "Type: Error";
|
||||||
|
break;
|
||||||
|
case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR:
|
||||||
|
std::cout << "Type: Deprecated Behaviour";
|
||||||
|
break;
|
||||||
|
case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR:
|
||||||
|
std::cout << "Type: Undefined Behaviour";
|
||||||
|
break;
|
||||||
|
case GL_DEBUG_TYPE_PORTABILITY:
|
||||||
|
std::cout << "Type: Portability";
|
||||||
|
break;
|
||||||
|
case GL_DEBUG_TYPE_PERFORMANCE:
|
||||||
|
std::cout << "Type: Performance";
|
||||||
|
break;
|
||||||
|
case GL_DEBUG_TYPE_MARKER:
|
||||||
|
std::cout << "Type: Marker";
|
||||||
|
break;
|
||||||
|
case GL_DEBUG_TYPE_PUSH_GROUP:
|
||||||
|
std::cout << "Type: Push Group";
|
||||||
|
break;
|
||||||
|
case GL_DEBUG_TYPE_POP_GROUP:
|
||||||
|
std::cout << "Type: Pop Group";
|
||||||
|
break;
|
||||||
|
case GL_DEBUG_TYPE_OTHER:
|
||||||
|
std::cout << "Type: Other";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
std::cout << std::endl;
|
||||||
|
|
||||||
|
switch (severity)
|
||||||
|
{
|
||||||
|
case GL_DEBUG_SEVERITY_HIGH:
|
||||||
|
std::cout << "Severity: high";
|
||||||
|
break;
|
||||||
|
case GL_DEBUG_SEVERITY_MEDIUM:
|
||||||
|
std::cout << "Severity: medium";
|
||||||
|
break;
|
||||||
|
case GL_DEBUG_SEVERITY_LOW:
|
||||||
|
std::cout << "Severity: low";
|
||||||
|
break;
|
||||||
|
case GL_DEBUG_SEVERITY_NOTIFICATION:
|
||||||
|
std::cout << "Severity: notification";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
std::cout << std::endl;
|
||||||
|
}
|
||||||
|
void debug()
|
||||||
|
{
|
||||||
|
GLint flags;
|
||||||
|
glGetIntegerv(GL_CONTEXT_FLAGS, &flags);
|
||||||
|
|
||||||
|
if (flags & GL_CONTEXT_FLAG_DEBUG_BIT)
|
||||||
|
{
|
||||||
|
glEnable(GL_DEBUG_OUTPUT);
|
||||||
|
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
|
||||||
|
glDebugMessageCallback(glDebugOutput, nullptr);
|
||||||
|
glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, nullptr, GL_TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
struct ConstantBuffer {
|
struct ConstantBuffer {
|
||||||
hpr::mat4 World;
|
hpr::mat4 World;
|
||||||
hpr::mat4 View;
|
hpr::mat4 View;
|
||||||
@ -64,13 +169,14 @@ int main()
|
|||||||
if (gpu::opengl::Device::loadLoader())
|
if (gpu::opengl::Device::loadLoader())
|
||||||
std::cerr << "Load gl loader error" << std::endl;
|
std::cerr << "Load gl loader error" << std::endl;
|
||||||
|
|
||||||
|
//debug();
|
||||||
gpu::Device* device;
|
gpu::Device* device;
|
||||||
gpu::Device::create(&device, gpu::Device::DeviceAPI::OpenGL);
|
gpu::Device::create(&device, gpu::Device::DeviceAPI::OpenGL);
|
||||||
device->initialize();
|
device->initialize();
|
||||||
gpu::Shader* vertexShader;
|
gpu::Shader* vertexShader;
|
||||||
device->createVertexShader(&vertexShader, "shaders/base.vert.glsl", "VS");
|
device->createVertexShader(&vertexShader, "shaders/test.vert.glsl", "VS");
|
||||||
gpu::Shader* fragmentShader;
|
gpu::Shader* fragmentShader;
|
||||||
device->createFragmentShader(&fragmentShader, "shaders/base.frag.glsl", "FS");
|
device->createFragmentShader(&fragmentShader, "shaders/test.frag.glsl", "FS");
|
||||||
gpu::ShaderProgram* shaderProgram;
|
gpu::ShaderProgram* shaderProgram;
|
||||||
device->createShaderProgram(&shaderProgram);
|
device->createShaderProgram(&shaderProgram);
|
||||||
device->attachShader(shaderProgram, vertexShader);
|
device->attachShader(shaderProgram, vertexShader);
|
||||||
@ -96,13 +202,39 @@ int main()
|
|||||||
for (auto k = 0; k < 3; ++k)
|
for (auto k = 0; k < 3; ++k)
|
||||||
data[k + 3 * n] = *(arr[n]->data() + k);
|
data[k + 3 * n] = *(arr[n]->data() + k);
|
||||||
darray<unsigned short> indices (6, 0);
|
darray<unsigned short> indices (6, 0);
|
||||||
for (auto n = 0; n < arr.size(); ++n)
|
indices[0] = 0;
|
||||||
indices[n] = mesh.indexOf(arr[n]);
|
indices[1] = 1;
|
||||||
|
indices[2] = 2;
|
||||||
|
indices[3] = 2;
|
||||||
|
indices[4] = 3;
|
||||||
|
indices[5] = 0;
|
||||||
|
//for (auto n = 0; n < arr.size(); ++n)
|
||||||
|
// indices[n] = mesh.indexOf(arr[n]);
|
||||||
|
|
||||||
|
std::cout << "Data: ";
|
||||||
|
for (auto p : data)
|
||||||
|
std::cout << p << " ";
|
||||||
|
std::cout << std::endl;
|
||||||
|
std::cout << "Indices: ";
|
||||||
|
for (auto p : indices)
|
||||||
|
std::cout << p << " ";
|
||||||
|
std::cout << std::endl;
|
||||||
|
|
||||||
|
darray<float> vertices {
|
||||||
|
0.5f, 0.5f, 0.0f, // top right
|
||||||
|
0.5f, -0.5f, 0.0f, // bottom right
|
||||||
|
-0.5f, -0.5f, 0.0f, // bottom left
|
||||||
|
-0.5f, 0.5f, 0.0f // top left
|
||||||
|
};
|
||||||
|
darray<unsigned int> indices2 { // note that we start from 0!
|
||||||
|
0, 1, 3, // first Triangle
|
||||||
|
1, 2, 3 // second Triangle
|
||||||
|
};
|
||||||
|
|
||||||
gpu::Buffer* vertexBuffer;
|
gpu::Buffer* vertexBuffer;
|
||||||
device->createVertexBuffer(&vertexBuffer, sizeof(float) * data.size(), (char*)data.data());
|
device->createVertexBuffer(&vertexBuffer, sizeof(float) * vertices.size(), (char*)vertices.data());
|
||||||
gpu::Buffer* indexBuffer;
|
gpu::Buffer* indexBuffer;
|
||||||
device->createIndexBuffer(&indexBuffer, sizeof(unsigned short) * indices.size(), (char*)indices.data());
|
device->createIndexBuffer(&indexBuffer, sizeof(unsigned int) * indices2.size(), (char*)indices2.data());
|
||||||
|
|
||||||
gpu::Buffer* constantBuffer;
|
gpu::Buffer* constantBuffer;
|
||||||
device->createUniformBuffer(&constantBuffer, sizeof(ConstantBuffer), nullptr);
|
device->createUniformBuffer(&constantBuffer, sizeof(ConstantBuffer), nullptr);
|
||||||
@ -152,11 +284,17 @@ int main()
|
|||||||
|
|
||||||
while (w->isOpen())
|
while (w->isOpen())
|
||||||
{
|
{
|
||||||
dynamic_cast<gpu::glfw::Window*>(w)->pollEvents();
|
glViewport(0, 0, 600, 400);
|
||||||
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
glClearColor(0.2f, 0.2f, 0.2f, 1.0f);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
device->useShaderProgram(shaderProgram);
|
device->useShaderProgram(shaderProgram);
|
||||||
device->useVertexBuffer(vertexBuffer, 0, 0);
|
device->useVertexBuffer(vertexBuffer, 0, 0);
|
||||||
device->useIndexBuffer(indexBuffer, 0);
|
device->useIndexBuffer(indexBuffer, 0);
|
||||||
dynamic_cast<gpu::opengl::Device*>(device)->Draw(2, 0, 0);
|
//dynamic_cast<gpu::opengl::Device*>(device)->Draw(2, 0, 0);
|
||||||
|
//glDrawArrays(GL_TRIANGLES, 0, 6);
|
||||||
|
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);
|
||||||
|
|
||||||
ImGui_ImplOpenGL3_NewFrame();
|
ImGui_ImplOpenGL3_NewFrame();
|
||||||
ImGui_ImplGlfw_NewFrame();
|
ImGui_ImplGlfw_NewFrame();
|
||||||
ImGui::NewFrame();
|
ImGui::NewFrame();
|
||||||
@ -174,6 +312,7 @@ int main()
|
|||||||
ImGui::Render();
|
ImGui::Render();
|
||||||
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
||||||
dynamic_cast<gpu::glfw::Window*>(w)->swapBuffers();
|
dynamic_cast<gpu::glfw::Window*>(w)->swapBuffers();
|
||||||
|
dynamic_cast<gpu::glfw::Window*>(w)->pollEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui_ImplOpenGL3_Shutdown();
|
ImGui_ImplOpenGL3_Shutdown();
|
||||||
|
252
source/creator/test.cpp
Normal file
252
source/creator/test.cpp
Normal file
@ -0,0 +1,252 @@
|
|||||||
|
#ifndef __gl_h_
|
||||||
|
#include <glad/glad.h>
|
||||||
|
#endif
|
||||||
|
#include "hpr/window_system/window_system.hpp"
|
||||||
|
#include "hpr/window_system/glfw/window_system.hpp"
|
||||||
|
#include "hpr/window_system/glfw/window.hpp"
|
||||||
|
#include "hpr/gpu.hpp"
|
||||||
|
#include "hpr/math.hpp"
|
||||||
|
#include "hpr/mesh.hpp"
|
||||||
|
|
||||||
|
#include <imgui.h>
|
||||||
|
#include <imgui_impl_glfw.h>
|
||||||
|
#include <imgui_impl_opengl3.h>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
const char *vertexShaderSource = "#version 330 core\n"
|
||||||
|
"layout (location = 0) in vec3 aPos;\n"
|
||||||
|
"void main()\n"
|
||||||
|
"{\n"
|
||||||
|
" gl_Position = vec4(aPos.x, aPos.y, aPos.z, 1.0);\n"
|
||||||
|
"}\0";
|
||||||
|
const char *fragmentShaderSource = "#version 330 core\n"
|
||||||
|
"out vec4 FragColor;\n"
|
||||||
|
"void main()\n"
|
||||||
|
"{\n"
|
||||||
|
" FragColor = vec4(1.0f, 0.5f, 0.2f, 1.0f);\n"
|
||||||
|
"}\n\0";
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
using namespace hpr;
|
||||||
|
|
||||||
|
gpu::WindowSystem *ws = gpu::WindowSystem::create(gpu::WindowContext::Provider::GLFW);
|
||||||
|
gpu::Window *w = ws->newWindow();
|
||||||
|
w->init("test", gpu::Window::Style::Windowed, 0, 0, 600, 400, nullptr, nullptr);
|
||||||
|
|
||||||
|
if (gpu::opengl::Device::loadLoader())
|
||||||
|
std::cerr << "Load gl loader error" << std::endl;
|
||||||
|
|
||||||
|
// build and compile our shader program
|
||||||
|
// ------------------------------------
|
||||||
|
// vertex shader
|
||||||
|
/*unsigned int vertexShader = glCreateShader(GL_VERTEX_SHADER);
|
||||||
|
glShaderSource(vertexShader, 1, &vertexShaderSource, NULL);
|
||||||
|
glCompileShader(vertexShader);
|
||||||
|
// check for shader compile errors
|
||||||
|
int success;
|
||||||
|
char infoLog[512];
|
||||||
|
glGetShaderiv(vertexShader, GL_COMPILE_STATUS, &success);
|
||||||
|
if (!success)
|
||||||
|
{
|
||||||
|
glGetShaderInfoLog(vertexShader, 512, NULL, infoLog);
|
||||||
|
std::cout << "ERROR::SHADER::VERTEX::COMPILATION_FAILED\n" << infoLog << std::endl;
|
||||||
|
}
|
||||||
|
// fragment shader
|
||||||
|
unsigned int fragmentShader = glCreateShader(GL_FRAGMENT_SHADER);
|
||||||
|
glShaderSource(fragmentShader, 1, &fragmentShaderSource, NULL);
|
||||||
|
glCompileShader(fragmentShader);
|
||||||
|
// check for shader compile errors
|
||||||
|
glGetShaderiv(fragmentShader, GL_COMPILE_STATUS, &success);
|
||||||
|
if (!success)
|
||||||
|
{
|
||||||
|
glGetShaderInfoLog(fragmentShader, 512, NULL, infoLog);
|
||||||
|
std::cout << "ERROR::SHADER::FRAGMENT::COMPILATION_FAILED\n" << infoLog << std::endl;
|
||||||
|
}
|
||||||
|
// link shaders
|
||||||
|
unsigned int shaderProgram = glCreateProgram();
|
||||||
|
glAttachShader(shaderProgram, vertexShader);
|
||||||
|
glAttachShader(shaderProgram, fragmentShader);
|
||||||
|
glLinkProgram(shaderProgram);
|
||||||
|
// check for linking errors
|
||||||
|
glGetProgramiv(shaderProgram, GL_LINK_STATUS, &success);
|
||||||
|
if (!success) {
|
||||||
|
glGetProgramInfoLog(shaderProgram, 512, NULL, infoLog);
|
||||||
|
std::cout << "ERROR::SHADER::PROGRAM::LINKING_FAILED\n" << infoLog << std::endl;
|
||||||
|
}
|
||||||
|
glDeleteShader(vertexShader);
|
||||||
|
glDeleteShader(fragmentShader);
|
||||||
|
*/
|
||||||
|
mesh::Mesh mesh;
|
||||||
|
mesh.addVertex(-1, 1, 0.5);
|
||||||
|
mesh.addVertex(1, 1, 0.5);
|
||||||
|
mesh.addVertex(1, -1, 0.5);
|
||||||
|
mesh.addVertex(-1, -1, 0.5);
|
||||||
|
mesh.addEdge(mesh.vertex(0), mesh.vertex(1));
|
||||||
|
mesh.addEdge(mesh.vertex(1), mesh.vertex(2));
|
||||||
|
mesh.addEdge(mesh.vertex(2), mesh.vertex(3));
|
||||||
|
mesh.addEdge(mesh.vertex(3), mesh.vertex(0));
|
||||||
|
mesh.addEdge(mesh.vertex(0), mesh.vertex(2));
|
||||||
|
mesh.addFace(mesh.edge(0), mesh.edge(1), mesh.edge(4));
|
||||||
|
mesh.addFace(mesh.edge(2), mesh.edge(3), mesh.edge(4));
|
||||||
|
|
||||||
|
/*darray<float> data (3 * 6, 0.f);
|
||||||
|
auto arr = mesh.face(0)->vertices() + mesh.face(1)->vertices();
|
||||||
|
for (auto n = 0; n < arr.size(); ++n)
|
||||||
|
for (auto k = 0; k < 3; ++k)
|
||||||
|
data[k + 3 * n] = *(arr[n]->data() + k);*/
|
||||||
|
darray<unsigned short> indices (6, 0);
|
||||||
|
darray<float> data;
|
||||||
|
for (auto v : mesh.vertices())
|
||||||
|
for (auto c : *v)
|
||||||
|
data.push(c);
|
||||||
|
|
||||||
|
indices[0] = 3;
|
||||||
|
indices[1] = 1;
|
||||||
|
indices[2] = 0;
|
||||||
|
indices[3] = 1;
|
||||||
|
indices[4] = 2;
|
||||||
|
indices[5] = 3;
|
||||||
|
|
||||||
|
std::cout << "Data: ";
|
||||||
|
for (auto p : data)
|
||||||
|
std::cout << p << " ";
|
||||||
|
std::cout << std::endl;
|
||||||
|
std::cout << "Indices: ";
|
||||||
|
for (auto p : indices)
|
||||||
|
std::cout << p << " ";
|
||||||
|
std::cout << std::endl;
|
||||||
|
|
||||||
|
darray<float> vertices {
|
||||||
|
0.5f, 0.5f, 0.0f, // top right
|
||||||
|
0.5f, -0.5f, 0.0f, // bottom right
|
||||||
|
-0.5f, -0.5f, 0.0f, // bottom left
|
||||||
|
-0.5f, 0.5f, 0.0f // top left
|
||||||
|
};
|
||||||
|
darray<unsigned int> indices2 { // note that we start from 0!
|
||||||
|
0, 1, 3, // first Triangle
|
||||||
|
1, 2, 3 // second Triangle
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
unsigned int VBO, VAO, EBO;
|
||||||
|
glGenVertexArrays(1, &VAO);
|
||||||
|
glGenBuffers(1, &VBO);
|
||||||
|
glGenBuffers(1, &EBO);
|
||||||
|
// bind the Vertex Array Object first, then bind and set vertex buffer(s), and then configure vertex attributes(s).
|
||||||
|
glBindVertexArray(VAO);
|
||||||
|
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, VBO);
|
||||||
|
//glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);//data.size(), data.data(), GL_STATIC_DRAW);
|
||||||
|
glBufferData(GL_ARRAY_BUFFER, sizeof(float) * vertices.size(), vertices.data(), GL_STATIC_DRAW);
|
||||||
|
|
||||||
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO);
|
||||||
|
//glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices2), indices2, GL_STATIC_DRAW);//indices.size(), indices.data(), GL_STATIC_DRAW);
|
||||||
|
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(unsigned int) * indices2.size(), indices2.data(), GL_STATIC_DRAW);
|
||||||
|
|
||||||
|
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), (void*)0);
|
||||||
|
glEnableVertexAttribArray(0);
|
||||||
|
|
||||||
|
// note that this is allowed, the call to glVertexAttribPointer registered VBO as the vertex attribute's bound vertex buffer object so afterwards we can safely unbind
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
|
|
||||||
|
// remember: do NOT unbind the EBO while a VAO is active as the bound element buffer object IS stored in the VAO; keep the EBO bound.
|
||||||
|
//glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||||
|
|
||||||
|
// You can unbind the VAO afterwards so other VAO calls won't accidentally modify this VAO, but this rarely happens. Modifying other
|
||||||
|
// VAOs requires a call to glBindVertexArray anyways so we generally don't unbind VAOs (nor VBOs) when it's not directly necessary.
|
||||||
|
glBindVertexArray(0);
|
||||||
|
*/
|
||||||
|
gpu::Device* device;
|
||||||
|
gpu::Device::create(&device, gpu::Device::DeviceAPI::OpenGL);
|
||||||
|
device->initialize();
|
||||||
|
gpu::Shader* vertexShader;
|
||||||
|
device->createVertexShader(&vertexShader, "shaders/test.vert.glsl", "VS");
|
||||||
|
gpu::Shader* fragmentShader;
|
||||||
|
device->createFragmentShader(&fragmentShader, "shaders/test.frag.glsl", "FS");
|
||||||
|
gpu::ShaderProgram* shaderProgram;
|
||||||
|
device->createShaderProgram(&shaderProgram);
|
||||||
|
device->attachShader(shaderProgram, vertexShader);
|
||||||
|
device->attachShader(shaderProgram, fragmentShader);
|
||||||
|
device->linkProgram(shaderProgram);
|
||||||
|
|
||||||
|
gpu::Buffer* vertexBuffer;
|
||||||
|
device->createVertexBuffer(&vertexBuffer, sizeof(float) * data.size(), (char*)data.data());
|
||||||
|
gpu::Buffer* indexBuffer;
|
||||||
|
device->createIndexBuffer(&indexBuffer, sizeof(unsigned short) * indices.size(), (char*)indices.data());
|
||||||
|
|
||||||
|
|
||||||
|
IMGUI_CHECKVERSION();
|
||||||
|
ImGui::CreateContext();
|
||||||
|
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;
|
||||||
|
|
||||||
|
ImGui::StyleColorsDark();
|
||||||
|
|
||||||
|
ImGui_ImplGlfw_InitForOpenGL(dynamic_cast<gpu::glfw::Window*>(w)->instance(), true);
|
||||||
|
ImGui_ImplOpenGL3_Init("#version 420");
|
||||||
|
|
||||||
|
while (w->isOpen())
|
||||||
|
{
|
||||||
|
glViewport(0, 0, 600, 400);
|
||||||
|
|
||||||
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
glClearColor(0.2f, 0.2f, 0.2f, 1.0f);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
|
// draw our first triangle
|
||||||
|
/*glUseProgram(shaderProgram);
|
||||||
|
glBindVertexArray(VAO); // seeing as we only have a single VAO there's no need to bind it every time, but we'll do so to keep things a bit more organized
|
||||||
|
//glDrawArrays(GL_TRIANGLES, 0, 6);
|
||||||
|
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);*/
|
||||||
|
device->useShaderProgram(shaderProgram);
|
||||||
|
device->useVertexBuffer(vertexBuffer, 0, 0);
|
||||||
|
device->useIndexBuffer(indexBuffer, 0);
|
||||||
|
//dynamic_cast<gpu::opengl::Device*>(device)->Draw(2, 0, 0);
|
||||||
|
glDrawArrays(GL_TRIANGLES, 0, 6);
|
||||||
|
//glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);
|
||||||
|
|
||||||
|
|
||||||
|
ImGui_ImplOpenGL3_NewFrame();
|
||||||
|
ImGui_ImplGlfw_NewFrame();
|
||||||
|
ImGui::NewFrame();
|
||||||
|
|
||||||
|
bool yes = true;
|
||||||
|
ImGui::ShowDemoWindow(&yes);
|
||||||
|
|
||||||
|
ImGui::Begin("Hello, world!");
|
||||||
|
{
|
||||||
|
if (ImGui::Button("Exit"))
|
||||||
|
w->state(gpu::Window::State::Closed);
|
||||||
|
ImGui::End();
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::Render();
|
||||||
|
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
||||||
|
dynamic_cast<gpu::glfw::Window*>(w)->swapBuffers();
|
||||||
|
dynamic_cast<gpu::glfw::Window*>(w)->pollEvents();
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui_ImplOpenGL3_Shutdown();
|
||||||
|
ImGui_ImplGlfw_Shutdown();
|
||||||
|
ImGui::DestroyContext();
|
||||||
|
|
||||||
|
device->destroyShaderProgram(shaderProgram, false);
|
||||||
|
device->destroyShader(vertexShader);
|
||||||
|
device->destroyShader(fragmentShader);
|
||||||
|
device->destroyBuffer(vertexBuffer);
|
||||||
|
device->destroyBuffer(indexBuffer);
|
||||||
|
delete dynamic_cast<gpu::opengl::Device*>(device);
|
||||||
|
|
||||||
|
/*glDeleteVertexArrays(1, &VAO);
|
||||||
|
glDeleteBuffers(1, &VBO);
|
||||||
|
glDeleteBuffers(1, &EBO);
|
||||||
|
glDeleteProgram(shaderProgram);*/
|
||||||
|
|
||||||
|
ws->destroyWindow(w);
|
||||||
|
gpu::WindowSystem::destroy(ws);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
@ -1,131 +1,20 @@
|
|||||||
|
|
||||||
project(
|
# Modules
|
||||||
hpr
|
add_subdirectory(core)
|
||||||
VERSION 0.10.0
|
add_subdirectory(containers)
|
||||||
LANGUAGES CXX
|
add_subdirectory(math)
|
||||||
)
|
add_subdirectory(io)
|
||||||
|
add_subdirectory(mesh)
|
||||||
# Compiler options
|
|
||||||
set(CMAKE_CXX_STANDARD 20)
|
|
||||||
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
|
|
||||||
|
|
||||||
add_definitions(-DPRECISION_DOUBLE)
|
|
||||||
|
|
||||||
# Project options
|
|
||||||
include(GNUInstallDirs)
|
|
||||||
include(${CMAKE_SOURCE_DIR}/cmake/macros.cmake)
|
|
||||||
|
|
||||||
option(WITH_CSG "Build with CSG component" ON)
|
|
||||||
option(WITH_GPU "Build with graphics component" ON)
|
|
||||||
option(WITH_MESH "Build with mesh utils component" ON)
|
|
||||||
option(WITH_WS "Build with window system component" ON)
|
|
||||||
|
|
||||||
# containers
|
|
||||||
file(GLOB containers_hpp "containers.hpp" "containers/*.hpp" "containers/array/*.hpp")
|
|
||||||
file(GLOB containers_cpp "containers/*.cpp" "containers/array/*.cpp")
|
|
||||||
|
|
||||||
# math
|
|
||||||
file(GLOB math_hpp "math.hpp" "math/*.hpp" "math/scalar/*.hpp" "math/vector/*.hpp" "math/matrix/*.hpp")
|
|
||||||
file(GLOB math_cpp "math/*.cpp" "math/scalar/*.cpp" "math/vector/*.cpp" "math/matrix/*.cpp")
|
|
||||||
|
|
||||||
# io
|
|
||||||
file(GLOB io_hpp "io.hpp" "io/*.hpp")
|
|
||||||
file(GLOB io_cpp "io/*.cpp")
|
|
||||||
|
|
||||||
# csg
|
|
||||||
file(GLOB csg_hpp "csg.hpp" "csg/*.hpp")
|
|
||||||
file(GLOB csg_cpp "csg/*.cpp")
|
|
||||||
|
|
||||||
# gpu
|
|
||||||
file(GLOB gpu_hpp "gpu.hpp" "gpu/*.hpp")
|
|
||||||
file(GLOB gpu_cpp "gpu/*.cpp")
|
|
||||||
file(GLOB gpu_opengl_hpp "gpu/opengl/*.hpp")
|
|
||||||
file(GLOB gpu_opengl_cpp "gpu/opengl/*.cpp")
|
|
||||||
|
|
||||||
# mesh
|
|
||||||
file(GLOB mesh_hpp "mesh.hpp" "mesh/*.hpp")
|
|
||||||
file(GLOB mesh_cpp "mesh/*.cpp")
|
|
||||||
|
|
||||||
# window system
|
|
||||||
file(GLOB window_system_hpp "window_system.hpp" "window_system/*.hpp")
|
|
||||||
file(GLOB window_system_cpp "window_system/*.cpp")
|
|
||||||
file(GLOB window_system_glfw_hpp "window_system/glfw/*.hpp")
|
|
||||||
file(GLOB window_system_glfw_cpp "window_system/glfw/*.cpp")
|
|
||||||
|
|
||||||
#
|
|
||||||
list(APPEND hpr_INCLUDE
|
|
||||||
${containers_hpp}
|
|
||||||
${math_hpp}
|
|
||||||
${io_hpp}
|
|
||||||
)
|
|
||||||
list(APPEND hpr_SOURCES
|
|
||||||
${containers_cpp}
|
|
||||||
${math_cpp}
|
|
||||||
${io_cpp}
|
|
||||||
)
|
|
||||||
list(APPEND hpr_LIBRARIES "")
|
|
||||||
list(APPEND hpr_INCLUDE_DIRS "")
|
|
||||||
|
|
||||||
if(WITH_CSG)
|
if(WITH_CSG)
|
||||||
include(${CMAKE_SOURCE_DIR}/cmake/occt.cmake)
|
include(${CMAKE_SOURCE_DIR}/cmake/external/occt.cmake)
|
||||||
|
add_subdirectory(csg)
|
||||||
list(APPEND hpr_INCLUDE ${csg_hpp})
|
|
||||||
list(APPEND hpr_SOURCES ${csg_cpp})
|
|
||||||
list(APPEND hpr_LIBRARIES ${OCCT_LIBRARIES})
|
|
||||||
|
|
||||||
list(APPEND hpr_INCLUDE_DIRS ${OCCT_INCLUDE_DIRS})
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(WITH_GPU)
|
if(WITH_GPU)
|
||||||
include(${CMAKE_SOURCE_DIR}/cmake/glad.cmake)
|
include(${CMAKE_SOURCE_DIR}/cmake/external/glad.cmake)
|
||||||
include(${CMAKE_SOURCE_DIR}/cmake/stb.cmake)
|
include(${CMAKE_SOURCE_DIR}/cmake/external/stb.cmake)
|
||||||
|
add_subdirectory(gpu)
|
||||||
list(APPEND hpr_INCLUDE ${gpu_hpp} ${gpu_opengl_hpp})
|
|
||||||
list(APPEND hpr_SOURCES ${gpu_cpp} ${gpu_opengl_cpp})
|
|
||||||
list(APPEND hpr_LIBRARIES glad stb)
|
|
||||||
endif()
|
endif()
|
||||||
|
if(WITH_WINDOW_SYSTEM)
|
||||||
if (WITH_WS)
|
include(${CMAKE_SOURCE_DIR}/cmake/external/glfw.cmake)
|
||||||
list(APPEND hpr_INCLUDE ${window_system_hpp} ${window_system_glfw_hpp})
|
add_subdirectory(window_system)
|
||||||
list(APPEND hpr_SOURCES ${window_system_cpp} ${window_system_glfw_cpp})
|
|
||||||
list(APPEND hpr_LIBRARIES glfw)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_library(${PROJECT_NAME} SHARED
|
|
||||||
hpr.cpp
|
|
||||||
${hpr_SOURCES}
|
|
||||||
)
|
|
||||||
add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
|
|
||||||
|
|
||||||
target_link_libraries(${PROJECT_NAME}
|
|
||||||
${hpr_LIBRARIES}
|
|
||||||
)
|
|
||||||
|
|
||||||
target_include_directories(${PROJECT_NAME}
|
|
||||||
PUBLIC
|
|
||||||
${hpr_INCLUDE_DIRS}
|
|
||||||
)
|
|
||||||
|
|
||||||
# Install library
|
|
||||||
|
|
||||||
install(
|
|
||||||
TARGETS ${PROJECT_NAME}
|
|
||||||
EXPORT ${PROJECT_NAME}Targets
|
|
||||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}
|
|
||||||
)
|
|
||||||
|
|
||||||
install(
|
|
||||||
EXPORT ${PROJECT_NAME}Targets
|
|
||||||
FILE ${PROJECT_NAME}Targets.cmake
|
|
||||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
|
|
||||||
)
|
|
||||||
|
|
||||||
include(CPack)
|
|
||||||
|
|
||||||
#
|
|
||||||
message(STATUS "Components:")
|
|
||||||
message(STATUS " Core: ON")
|
|
||||||
message(STATUS " CSG: ${WITH_CSG}")
|
|
||||||
message(STATUS " GPU: ${WITH_GPU}")
|
|
||||||
message(STATUS " Mesh: ${WITH_MESH}")
|
|
||||||
message(STATUS " WindowSystem: ${WITH_WS}")
|
|
||||||
|
@ -1,28 +1,62 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
|
||||||
set(COMPONENT_NAME containers)
|
project(containers
|
||||||
|
VERSION "${HPR_PROJECT_VERSION}"
|
||||||
add_component_library(${COMPONENT_NAME} INTERFACE ""
|
LANGUAGES CXX
|
||||||
)
|
)
|
||||||
|
|
||||||
#target_sources(${COMPONENT_NAME} PUBLIC
|
add_library(${PROJECT_NAME} INTERFACE)
|
||||||
# array/dynamic_array.hpp
|
add_library(${CMAKE_PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
|
||||||
# array.hpp
|
add_module(${PROJECT_NAME})
|
||||||
# array/iterator.hpp
|
|
||||||
# array/static_array.hpp
|
|
||||||
#)
|
|
||||||
|
|
||||||
install_component_headers(${COMPONENT_NAME})
|
file(GLOB ${CMAKE_PROJECT_NAME}_${PROJECT_NAME}_HEADERS
|
||||||
install_component_source(${COMPONENT_NAME})
|
"../containers.hpp" "*.hpp" "array/*.hpp"
|
||||||
|
|
||||||
if (WITH_GTEST)
|
|
||||||
add_executable(${COMPONENT_NAME}-test
|
|
||||||
tests/${COMPONENT_NAME}-test.cpp
|
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(${COMPONENT_NAME}-test
|
foreach(_header_path ${${CMAKE_PROJECT_NAME}_${PROJECT_NAME}_HEADERS})
|
||||||
${CMAKE_PROJECT_NAME}::${COMPONENT_NAME}
|
list(APPEND ${CMAKE_PROJECT_NAME}_${PROJECT_NAME}_HEADERS_INTERFACE "$<BUILD_INTERFACE:${_header_path}>")
|
||||||
GTest::gtest_main
|
endforeach()
|
||||||
|
|
||||||
|
target_sources(${PROJECT_NAME}
|
||||||
|
INTERFACE
|
||||||
|
${${CMAKE_PROJECT_NAME}_${PROJECT_NAME}_HEADERS_INTERFACE}
|
||||||
|
$<INSTALL_INTERFACE:include/${CMAKE_PROJECT_NAME}/${PROJECT_NAME}>
|
||||||
)
|
)
|
||||||
|
|
||||||
gtest_add_tests(TARGET ${COMPONENT_NAME}-test)
|
install(
|
||||||
|
TARGETS ${PROJECT_NAME}
|
||||||
|
EXPORT ${PROJECT_NAME}Targets
|
||||||
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}
|
||||||
|
NAMELINK_SKIP
|
||||||
|
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||||
|
)
|
||||||
|
install(
|
||||||
|
EXPORT ${PROJECT_NAME}Targets
|
||||||
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME}-${HPR_PROJECT_VERSION}
|
||||||
|
NAMESPACE ${CMAKE_PROJECT_NAME}::
|
||||||
|
)
|
||||||
|
install(
|
||||||
|
TARGETS ${PROJECT_NAME}
|
||||||
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}
|
||||||
|
NAMELINK_ONLY
|
||||||
|
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||||
|
)
|
||||||
|
install(
|
||||||
|
DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||||
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${CMAKE_PROJECT_NAME}
|
||||||
|
COMPONENT devel
|
||||||
|
FILES_MATCHING
|
||||||
|
PATTERN "*.h"
|
||||||
|
PATTERN "*.hpp"
|
||||||
|
PATTERN "tests" EXCLUDE
|
||||||
|
)
|
||||||
|
install(
|
||||||
|
FILES ../${PROJECT_NAME}.hpp
|
||||||
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${CMAKE_PROJECT_NAME}
|
||||||
|
COMPONENT devel
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
if(HPR_TEST)
|
||||||
|
add_subdirectory(tests)
|
||||||
endif()
|
endif()
|
15
source/hpr/containers/tests/CMakeLists.txt
Normal file
15
source/hpr/containers/tests/CMakeLists.txt
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
|
||||||
|
file(GLOB tests_cpp "*.cpp")
|
||||||
|
|
||||||
|
add_executable(${PROJECT_NAME}-tests
|
||||||
|
${tests_cpp}
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(${PROJECT_NAME}-tests
|
||||||
|
PUBLIC
|
||||||
|
hpr::containers
|
||||||
|
PRIVATE
|
||||||
|
GTest::gtest_main
|
||||||
|
)
|
||||||
|
|
||||||
|
gtest_add_tests(TARGET ${PROJECT_NAME}-tests)
|
0
source/hpr/core.hpp
Normal file
0
source/hpr/core.hpp
Normal file
55
source/hpr/core/CMakeLists.txt
Normal file
55
source/hpr/core/CMakeLists.txt
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
|
||||||
|
project(core
|
||||||
|
VERSION "${HPR_PROJECT_VERSION}"
|
||||||
|
LANGUAGES CXX
|
||||||
|
)
|
||||||
|
|
||||||
|
add_library(${PROJECT_NAME} INTERFACE)
|
||||||
|
add_library(${CMAKE_PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
|
||||||
|
add_module(${PROJECT_NAME})
|
||||||
|
|
||||||
|
file(GLOB ${CMAKE_PROJECT_NAME}_${PROJECT_NAME}_HEADERS "../core.hpp" "*.hpp")
|
||||||
|
|
||||||
|
foreach(_header_path ${${CMAKE_PROJECT_NAME}_${PROJECT_NAME}_HEADERS})
|
||||||
|
list(APPEND ${CMAKE_PROJECT_NAME}_${PROJECT_NAME}_HEADERS_INTERFACE "$<BUILD_INTERFACE:${_header_path}>")
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
target_sources(${PROJECT_NAME}
|
||||||
|
INTERFACE
|
||||||
|
${${CMAKE_PROJECT_NAME}_${PROJECT_NAME}_HEADERS_INTERFACE}
|
||||||
|
$<INSTALL_INTERFACE:include/${CMAKE_PROJECT_NAME}/${PROJECT_NAME}>
|
||||||
|
)
|
||||||
|
|
||||||
|
install(
|
||||||
|
TARGETS ${PROJECT_NAME}
|
||||||
|
EXPORT ${PROJECT_NAME}Targets
|
||||||
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}
|
||||||
|
NAMELINK_SKIP
|
||||||
|
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||||
|
)
|
||||||
|
install(
|
||||||
|
EXPORT ${PROJECT_NAME}Targets
|
||||||
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME}-${HPR_PROJECT_VERSION}
|
||||||
|
NAMESPACE ${CMAKE_PROJECT_NAME}::
|
||||||
|
)
|
||||||
|
install(
|
||||||
|
TARGETS ${PROJECT_NAME}
|
||||||
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}
|
||||||
|
NAMELINK_ONLY
|
||||||
|
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||||
|
)
|
||||||
|
install(
|
||||||
|
DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||||
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${CMAKE_PROJECT_NAME}
|
||||||
|
COMPONENT devel
|
||||||
|
FILES_MATCHING
|
||||||
|
PATTERN "*.h"
|
||||||
|
PATTERN "*.hpp"
|
||||||
|
PATTERN "tests" EXCLUDE
|
||||||
|
)
|
||||||
|
install(
|
||||||
|
FILES ../${PROJECT_NAME}.hpp
|
||||||
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${CMAKE_PROJECT_NAME}
|
||||||
|
COMPONENT devel
|
||||||
|
)
|
5
source/hpr/core/common.hpp
Normal file
5
source/hpr/core/common.hpp
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#define HPR_VERSION_MAJOR 0
|
||||||
|
#define HPR_VERSION_MINOR 10
|
||||||
|
#define HPR_VERSION_PATCH 0
|
@ -1,35 +1,77 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
|
||||||
set(COMPONENT_NAME csg)
|
project(csg
|
||||||
|
VERSION "${HPR_PROJECT_VERSION}"
|
||||||
add_component_library(${COMPONENT_NAME} STATIC
|
LANGUAGES CXX
|
||||||
shape.cpp
|
|
||||||
)
|
)
|
||||||
|
|
||||||
#target_sources(${COMPONENT_NAME} PUBLIC
|
add_library(${PROJECT_NAME})
|
||||||
|
add_library(${CMAKE_PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
|
||||||
|
add_module(${PROJECT_NAME})
|
||||||
|
|
||||||
#)
|
file(GLOB ${CMAKE_PROJECT_NAME}_${PROJECT_NAME}_HEADERS
|
||||||
|
"../csg.hpp" "*.hpp"
|
||||||
|
)
|
||||||
|
|
||||||
target_link_libraries(${COMPONENT_NAME}
|
foreach(_header_path ${${CMAKE_PROJECT_NAME}_${PROJECT_NAME}_HEADERS})
|
||||||
|
list(APPEND ${CMAKE_PROJECT_NAME}_${PROJECT_NAME}_HEADERS_INTERFACE "$<BUILD_INTERFACE:${_header_path}>")
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
file(GLOB ${CMAKE_PROJECT_NAME}_${PROJECT_NAME}_SOURCES
|
||||||
|
"*.cpp"
|
||||||
|
)
|
||||||
|
|
||||||
|
target_sources(${PROJECT_NAME}
|
||||||
|
INTERFACE
|
||||||
|
${${CMAKE_PROJECT_NAME}_${PROJECT_NAME}_HEADERS_INTERFACE}
|
||||||
|
$<INSTALL_INTERFACE:include/${CMAKE_PROJECT_NAME}/${PROJECT_NAME}>
|
||||||
|
PRIVATE
|
||||||
|
${${CMAKE_PROJECT_NAME}_${PROJECT_NAME}_SOURCES}
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(${PROJECT_NAME}
|
||||||
${OCCT_LIBRARIES}
|
${OCCT_LIBRARIES}
|
||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories(${COMPONENT_NAME}
|
target_include_directories(${PROJECT_NAME}
|
||||||
PUBLIC
|
PUBLIC
|
||||||
${OCCT_INCLUDE_DIRS}
|
${OCCT_INCLUDE_DIRS}
|
||||||
)
|
)
|
||||||
|
|
||||||
install_component_headers(${COMPONENT_NAME})
|
install(
|
||||||
install_component_source(${COMPONENT_NAME})
|
TARGETS ${PROJECT_NAME}
|
||||||
|
EXPORT ${PROJECT_NAME}Targets
|
||||||
if (0)
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}
|
||||||
add_executable(${COMPONENT_NAME}-test
|
NAMELINK_SKIP
|
||||||
tests/${COMPONENT_NAME}-test.cpp
|
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||||
|
)
|
||||||
|
install(
|
||||||
|
EXPORT ${PROJECT_NAME}Targets
|
||||||
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME}-${HPR_PROJECT_VERSION}
|
||||||
|
NAMESPACE ${CMAKE_PROJECT_NAME}::
|
||||||
|
)
|
||||||
|
install(
|
||||||
|
TARGETS ${PROJECT_NAME}
|
||||||
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}
|
||||||
|
NAMELINK_ONLY
|
||||||
|
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||||
|
)
|
||||||
|
install(
|
||||||
|
DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||||
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${CMAKE_PROJECT_NAME}
|
||||||
|
COMPONENT devel
|
||||||
|
FILES_MATCHING
|
||||||
|
PATTERN "*.h"
|
||||||
|
PATTERN "*.hpp"
|
||||||
|
PATTERN "tests" EXCLUDE
|
||||||
|
)
|
||||||
|
install(
|
||||||
|
FILES ../${PROJECT_NAME}.hpp
|
||||||
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${CMAKE_PROJECT_NAME}
|
||||||
|
COMPONENT devel
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(${COMPONENT_NAME}-test
|
|
||||||
${PROJECT_NAME}::${COMPONENT_NAME}
|
|
||||||
GTest::gtest_main
|
|
||||||
)
|
|
||||||
|
|
||||||
gtest_add_tests(TARGET ${COMPONENT_NAME}-test)
|
if(HPR_TEST)
|
||||||
|
add_subdirectory(tests)
|
||||||
endif()
|
endif()
|
||||||
|
14
source/hpr/csg/tests/CMakeLists.txt
Normal file
14
source/hpr/csg/tests/CMakeLists.txt
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
file(GLOB tests_cpp "*.cpp")
|
||||||
|
|
||||||
|
add_executable(${PROJECT_NAME}-tests
|
||||||
|
${tests_cpp}
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(${PROJECT_NAME}-tests
|
||||||
|
PUBLIC
|
||||||
|
hpr::${PROJECT_NAME}
|
||||||
|
PRIVATE
|
||||||
|
GTest::gtest_main
|
||||||
|
)
|
||||||
|
|
||||||
|
gtest_add_tests(TARGET ${PROJECT_NAME}-tests)
|
@ -9,7 +9,7 @@ TEST(csgTest, Shape)
|
|||||||
auto sphere = csg::sphere({0, 0, 0}, radius);
|
auto sphere = csg::sphere({0, 0, 0}, radius);
|
||||||
EXPECT_TRUE(equal(sphere.volume(), volume, 1e-6));
|
EXPECT_TRUE(equal(sphere.volume(), volume, 1e-6));
|
||||||
auto box = csg::box({0, 0, 0}, 1, 1, 1);
|
auto box = csg::box({0, 0, 0}, 1, 1, 1);
|
||||||
EXPECT_TRUE(equal(box.volume(), 1));
|
EXPECT_TRUE(equal(box.volume(), 1.));
|
||||||
auto edge = csg::Edge();
|
auto edge = csg::Edge();
|
||||||
int n = 0;
|
int n = 0;
|
||||||
for (auto& face : box.subShapes(csg::Shape::Type::Face))
|
for (auto& face : box.subShapes(csg::Shape::Type::Face))
|
||||||
|
19
source/hpr/geometry/tetrahedron.hpp
Normal file
19
source/hpr/geometry/tetrahedron.hpp
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#include "../math.hpp"
|
||||||
|
|
||||||
|
namespace hpr::geometry
|
||||||
|
{
|
||||||
|
|
||||||
|
vec3 circumCentre(vec3 p1, vec3 p2, vec3 p3, vec3 p4)
|
||||||
|
{
|
||||||
|
vec3 e1 = p2 - p1;
|
||||||
|
vec3 e2 = p3 - p1;
|
||||||
|
vec3 e3 = p4 - p1;
|
||||||
|
mat3 A;
|
||||||
|
A.row(0, e1);
|
||||||
|
A.row(1, e2);
|
||||||
|
A.row(2, e3);
|
||||||
|
vec3 B = 0.5 * vec3(sum(pow(p2, 2)) - sum(pow(p1, 2)), sum(pow(p3, 2)) - sum(pow(p1, 2)), sum(pow(p4, 2)) - sum(pow(p1, 2)));
|
||||||
|
return A.inv() * B;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
15
source/hpr/geometry/triangle.hpp
Normal file
15
source/hpr/geometry/triangle.hpp
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#include "../math.hpp"
|
||||||
|
|
||||||
|
namespace hpr::geometry
|
||||||
|
{
|
||||||
|
|
||||||
|
vec2 circumCentre(vec2 p1, vec2 p2, vec2 p3)
|
||||||
|
{
|
||||||
|
vec2 pb1 {(p1 + p2) * 0.5};
|
||||||
|
vec2 pb2 {(p2 + p3) * 0.5};
|
||||||
|
scalar s1 = (p2[1] - p1[1]) / (p2[0] - p1[0]);
|
||||||
|
scalar s2 = (p3[1] - p2[1]) / (p3[0] - p2[0]);
|
||||||
|
return vec2(pb1[0] + s1 * pb1[1], pb2[0] + s2 * pb2[1]) * mat2(1, s1, 1, s2).inv();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,42 +1,68 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
|
||||||
set(COMPONENT_NAME gpu)
|
project(gpu
|
||||||
|
VERSION "${HPR_PROJECT_VERSION}"
|
||||||
add_component_library(${COMPONENT_NAME} STATIC
|
LANGUAGES CXX
|
||||||
buffer.cpp
|
|
||||||
context.cpp
|
|
||||||
device.cpp
|
|
||||||
shader.cpp
|
|
||||||
shader_program.cpp
|
|
||||||
texture.cpp
|
|
||||||
opengl/buffer.cpp
|
|
||||||
opengl/context.cpp
|
|
||||||
opengl/device.cpp
|
|
||||||
opengl/shader.cpp
|
|
||||||
opengl/shader_program.cpp
|
|
||||||
opengl/texture.cpp
|
|
||||||
)
|
)
|
||||||
|
|
||||||
#target_sources(${COMPONENT_NAME} PUBLIC
|
add_library(${PROJECT_NAME})
|
||||||
|
add_library(${CMAKE_PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
|
||||||
|
add_module(${PROJECT_NAME})
|
||||||
|
|
||||||
#)
|
file(GLOB ${CMAKE_PROJECT_NAME}_${PROJECT_NAME}_HEADERS
|
||||||
|
"../gpu.hpp" "*.hpp" "opengl/*.hpp"
|
||||||
|
)
|
||||||
|
|
||||||
target_link_libraries(${COMPONENT_NAME}
|
foreach(_header_path ${${CMAKE_PROJECT_NAME}_${PROJECT_NAME}_HEADERS})
|
||||||
|
list(APPEND ${CMAKE_PROJECT_NAME}_${PROJECT_NAME}_HEADERS_INTERFACE "$<BUILD_INTERFACE:${_header_path}>")
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
file(GLOB ${CMAKE_PROJECT_NAME}_${PROJECT_NAME}_SOURCES
|
||||||
|
"*.cpp" "opengl/*.cpp"
|
||||||
|
)
|
||||||
|
|
||||||
|
target_sources(${PROJECT_NAME}
|
||||||
|
INTERFACE
|
||||||
|
${${CMAKE_PROJECT_NAME}_${PROJECT_NAME}_HEADERS_INTERFACE}
|
||||||
|
$<INSTALL_INTERFACE:include/${CMAKE_PROJECT_NAME}/${PROJECT_NAME}>
|
||||||
|
PRIVATE
|
||||||
|
${${CMAKE_PROJECT_NAME}_${PROJECT_NAME}_SOURCES}
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(${PROJECT_NAME}
|
||||||
glad
|
glad
|
||||||
stb
|
stb
|
||||||
)
|
)
|
||||||
|
|
||||||
install_component_headers(${COMPONENT_NAME})
|
install(
|
||||||
install_component_source(${COMPONENT_NAME})
|
TARGETS ${PROJECT_NAME}
|
||||||
|
EXPORT ${PROJECT_NAME}Targets
|
||||||
if (0)
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}
|
||||||
add_executable(${COMPONENT_NAME}-test
|
NAMELINK_SKIP
|
||||||
tests/${COMPONENT_NAME}-test.cpp
|
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||||
)
|
)
|
||||||
|
install(
|
||||||
target_link_libraries(${COMPONENT_NAME}-test
|
EXPORT ${PROJECT_NAME}Targets
|
||||||
${PROJECT_NAME}::${COMPONENT_NAME}
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME}-${HPR_PROJECT_VERSION}
|
||||||
GTest::gtest_main
|
NAMESPACE ${CMAKE_PROJECT_NAME}::
|
||||||
|
)
|
||||||
|
install(
|
||||||
|
TARGETS ${PROJECT_NAME}
|
||||||
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}
|
||||||
|
NAMELINK_ONLY
|
||||||
|
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||||
|
)
|
||||||
|
install(
|
||||||
|
DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||||
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${CMAKE_PROJECT_NAME}
|
||||||
|
COMPONENT devel
|
||||||
|
FILES_MATCHING
|
||||||
|
PATTERN "*.h"
|
||||||
|
PATTERN "*.hpp"
|
||||||
|
PATTERN "tests" EXCLUDE
|
||||||
|
)
|
||||||
|
install(
|
||||||
|
FILES ../${PROJECT_NAME}.hpp
|
||||||
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${CMAKE_PROJECT_NAME}
|
||||||
|
COMPONENT devel
|
||||||
)
|
)
|
||||||
|
|
||||||
gtest_add_tests(TARGET ${COMPONENT_NAME}-test)
|
|
||||||
endif()
|
|
@ -65,6 +65,7 @@ void Device::scaleRenderTarget(RenderTarget* target, int width, int height)
|
|||||||
{
|
{
|
||||||
if (target == nullptr)
|
if (target == nullptr)
|
||||||
throw std::invalid_argument("Invalid parameter");
|
throw std::invalid_argument("Invalid parameter");
|
||||||
|
|
||||||
target->p_width = width;
|
target->p_width = width;
|
||||||
target->p_height = height;
|
target->p_height = height;
|
||||||
}
|
}
|
||||||
|
9
source/hpr/gpu/shaders/test.frag.glsl
Normal file
9
source/hpr/gpu/shaders/test.frag.glsl
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#version 330
|
||||||
|
uniform vec3 color;
|
||||||
|
|
||||||
|
out vec4 out_color;
|
||||||
|
|
||||||
|
void main(void)
|
||||||
|
{
|
||||||
|
out_color = vec4(color, 0.5f);
|
||||||
|
}
|
11
source/hpr/gpu/shaders/test.vert.glsl
Normal file
11
source/hpr/gpu/shaders/test.vert.glsl
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#version 330 core
|
||||||
|
layout (location = 0) in vec3 aPos;
|
||||||
|
|
||||||
|
uniform mat4 model;
|
||||||
|
uniform mat4 view;
|
||||||
|
uniform mat4 projection;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_Position = projection * view * model * vec4(aPos, 1.0);
|
||||||
|
}
|
@ -1,27 +1,66 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
|
||||||
set(COMPONENT_NAME io)
|
project(io
|
||||||
|
VERSION "${HPR_PROJECT_VERSION}"
|
||||||
add_component_library(${COMPONENT_NAME} STATIC
|
LANGUAGES CXX
|
||||||
file.cpp
|
|
||||||
)
|
)
|
||||||
|
|
||||||
#target_sources(${COMPONENT_NAME} PUBLIC
|
add_library(${PROJECT_NAME})
|
||||||
# file.hpp
|
add_library(${CMAKE_PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
|
||||||
# logger.hpp
|
add_module(${PROJECT_NAME})
|
||||||
#)
|
|
||||||
|
|
||||||
install_component_headers(${COMPONENT_NAME})
|
file(GLOB ${CMAKE_PROJECT_NAME}_${PROJECT_NAME}_HEADERS
|
||||||
install_component_source(${COMPONENT_NAME})
|
"../io.hpp" "*.hpp"
|
||||||
|
|
||||||
if(0)
|
|
||||||
add_executable(${COMPONENT_NAME}-test
|
|
||||||
tests/${COMPONENT_NAME}-test.cpp
|
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(${COMPONENT_NAME}-test
|
foreach(_header_path ${${CMAKE_PROJECT_NAME}_${PROJECT_NAME}_HEADERS})
|
||||||
${CMAKE_PROJECT_NAME}::${COMPONENT_NAME}
|
list(APPEND ${CMAKE_PROJECT_NAME}_${PROJECT_NAME}_HEADERS_INTERFACE "$<BUILD_INTERFACE:${_header_path}>")
|
||||||
GTest::gtest_main
|
endforeach()
|
||||||
|
|
||||||
|
file(GLOB ${CMAKE_PROJECT_NAME}_${PROJECT_NAME}_SOURCES
|
||||||
|
"*.cpp"
|
||||||
)
|
)
|
||||||
|
|
||||||
gtest_add_tests(TARGET ${COMPONENT_NAME}-test)
|
target_sources(${PROJECT_NAME}
|
||||||
endif()
|
INTERFACE
|
||||||
|
${${CMAKE_PROJECT_NAME}_${PROJECT_NAME}_HEADERS_INTERFACE}
|
||||||
|
$<INSTALL_INTERFACE:include/${CMAKE_PROJECT_NAME}/${PROJECT_NAME}>
|
||||||
|
PRIVATE
|
||||||
|
${${CMAKE_PROJECT_NAME}_${PROJECT_NAME}_SOURCES}
|
||||||
|
)
|
||||||
|
|
||||||
|
install(
|
||||||
|
TARGETS ${PROJECT_NAME}
|
||||||
|
EXPORT ${PROJECT_NAME}Targets
|
||||||
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}
|
||||||
|
NAMELINK_SKIP
|
||||||
|
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||||
|
)
|
||||||
|
install(
|
||||||
|
EXPORT ${PROJECT_NAME}Targets
|
||||||
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME}-${HPR_PROJECT_VERSION}
|
||||||
|
NAMESPACE ${CMAKE_PROJECT_NAME}::
|
||||||
|
)
|
||||||
|
install(
|
||||||
|
TARGETS ${PROJECT_NAME}
|
||||||
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}
|
||||||
|
NAMELINK_ONLY
|
||||||
|
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||||
|
)
|
||||||
|
install(
|
||||||
|
DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||||
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${CMAKE_PROJECT_NAME}
|
||||||
|
COMPONENT devel
|
||||||
|
FILES_MATCHING
|
||||||
|
PATTERN "*.h"
|
||||||
|
PATTERN "*.hpp"
|
||||||
|
PATTERN "tests" EXCLUDE
|
||||||
|
)
|
||||||
|
install(
|
||||||
|
FILES ../${PROJECT_NAME}.hpp
|
||||||
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${CMAKE_PROJECT_NAME}
|
||||||
|
COMPONENT devel
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,34 +1,62 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
|
||||||
set(COMPONENT_NAME math)
|
project(math
|
||||||
|
VERSION "${HPR_PROJECT_VERSION}"
|
||||||
add_component_library(${COMPONENT_NAME} STATIC
|
LANGUAGES CXX
|
||||||
vector/vector_space.cpp
|
|
||||||
matrix/matrix_space.cpp
|
|
||||||
)
|
)
|
||||||
|
|
||||||
#target_sources(${COMPONENT_NAME} PUBLIC
|
add_library(${PROJECT_NAME} INTERFACE)
|
||||||
# matrix/clip_space.hpp
|
add_library(${CMAKE_PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
|
||||||
# matrix.hpp
|
add_module(${PROJECT_NAME})
|
||||||
# matrix/matrix_space.hpp
|
|
||||||
# matrix/transform.hpp
|
|
||||||
# scalar.hpp
|
|
||||||
# scalar/scalar.hpp
|
|
||||||
# vector.hpp
|
|
||||||
# vector/vector_space.hpp
|
|
||||||
#)
|
|
||||||
|
|
||||||
install_component_headers(${COMPONENT_NAME})
|
file(GLOB ${CMAKE_PROJECT_NAME}_${PROJECT_NAME}_HEADERS
|
||||||
install_component_source(${COMPONENT_NAME})
|
"../math.hpp" "*.hpp" "scalar/*.hpp" "vector/*.hpp" "matrix/*.hpp"
|
||||||
|
|
||||||
if(WITH_GTESTS)
|
|
||||||
add_executable(${COMPONENT_NAME}-test
|
|
||||||
tests/${COMPONENT_NAME}-test.cpp
|
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(${COMPONENT_NAME}-test
|
foreach(_header_path ${${CMAKE_PROJECT_NAME}_${PROJECT_NAME}_HEADERS})
|
||||||
${PROJECT_NAME}::${COMPONENT_NAME}
|
list(APPEND ${CMAKE_PROJECT_NAME}_${PROJECT_NAME}_HEADERS_INTERFACE "$<BUILD_INTERFACE:${_header_path}>")
|
||||||
GTest::gtest_main
|
endforeach()
|
||||||
|
|
||||||
|
target_sources(${PROJECT_NAME}
|
||||||
|
INTERFACE
|
||||||
|
${${CMAKE_PROJECT_NAME}_${PROJECT_NAME}_HEADERS_INTERFACE}
|
||||||
|
$<INSTALL_INTERFACE:include/${CMAKE_PROJECT_NAME}/${PROJECT_NAME}>
|
||||||
)
|
)
|
||||||
|
|
||||||
gtest_add_tests(TARGET ${COMPONENT_NAME}-test)
|
install(
|
||||||
|
TARGETS ${PROJECT_NAME}
|
||||||
|
EXPORT ${PROJECT_NAME}Targets
|
||||||
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}
|
||||||
|
NAMELINK_SKIP
|
||||||
|
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||||
|
)
|
||||||
|
install(
|
||||||
|
EXPORT ${PROJECT_NAME}Targets
|
||||||
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME}-${HPR_PROJECT_VERSION}
|
||||||
|
NAMESPACE ${CMAKE_PROJECT_NAME}::
|
||||||
|
)
|
||||||
|
install(
|
||||||
|
TARGETS ${PROJECT_NAME}
|
||||||
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}
|
||||||
|
NAMELINK_ONLY
|
||||||
|
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||||
|
)
|
||||||
|
install(
|
||||||
|
DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||||
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${CMAKE_PROJECT_NAME}
|
||||||
|
COMPONENT devel
|
||||||
|
FILES_MATCHING
|
||||||
|
PATTERN "*.h"
|
||||||
|
PATTERN "*.hpp"
|
||||||
|
PATTERN "tests" EXCLUDE
|
||||||
|
)
|
||||||
|
install(
|
||||||
|
FILES ../${PROJECT_NAME}.hpp
|
||||||
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${CMAKE_PROJECT_NAME}
|
||||||
|
COMPONENT devel
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
if(HPR_TEST)
|
||||||
|
add_subdirectory(tests)
|
||||||
endif()
|
endif()
|
@ -1,9 +0,0 @@
|
|||||||
#include "matrix_space.hpp"
|
|
||||||
#include <cmath>
|
|
||||||
|
|
||||||
namespace hpr
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -253,9 +253,21 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
friend inline
|
friend inline
|
||||||
VectorSpace<Type, Rows> operator*(const VectorSpace<Type, Rows>& vs, const MatrixSpace& ms)
|
VectorSpace<Type, Cols> operator*(const VectorSpace<Type, Cols>& vs, const MatrixSpace& ms)
|
||||||
{
|
{
|
||||||
|
VectorSpace<Type, Cols> res;
|
||||||
|
for (auto n = 0; n < Cols; ++n)
|
||||||
|
res[0] = sum(ms.col(n) * vs);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
friend inline
|
||||||
|
VectorSpace<Type, Rows> operator*(const MatrixSpace& ms, const VectorSpace<Type, Rows>& vs)
|
||||||
|
{
|
||||||
|
VectorSpace<Type, Rows> res;
|
||||||
|
for (auto n = 0; n < Rows; ++n)
|
||||||
|
res[0] = sum(ms.row(n) * vs);
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
MatrixSpace& fill(value_type value)
|
MatrixSpace& fill(value_type value)
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
namespace hpr
|
namespace hpr
|
||||||
{
|
{
|
||||||
|
#define PRECISION_DOUBLE
|
||||||
|
|
||||||
#if defined(PRECISION_FLOAT)
|
#if defined(PRECISION_FLOAT)
|
||||||
|
|
||||||
|
14
source/hpr/math/tests/CMakeLists.txt
Normal file
14
source/hpr/math/tests/CMakeLists.txt
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
file(GLOB tests_cpp "*.cpp")
|
||||||
|
|
||||||
|
add_executable(${PROJECT_NAME}-tests
|
||||||
|
${tests_cpp}
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(${PROJECT_NAME}-tests
|
||||||
|
PUBLIC
|
||||||
|
hpr::${PROJECT_NAME}
|
||||||
|
PRIVATE
|
||||||
|
GTest::gtest_main
|
||||||
|
)
|
||||||
|
|
||||||
|
gtest_add_tests(TARGET ${PROJECT_NAME}-tests)
|
@ -1,26 +1,70 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
|
||||||
set(COMPONENT_NAME mesh)
|
project(mesh
|
||||||
|
VERSION "${HPR_PROJECT_VERSION}"
|
||||||
add_component_library(${COMPONENT_NAME} STATIC
|
LANGUAGES CXX
|
||||||
mesh.cpp
|
|
||||||
)
|
)
|
||||||
|
|
||||||
#target_sources(${COMPONENT_NAME} PUBLIC
|
add_library(${PROJECT_NAME})
|
||||||
|
add_library(${CMAKE_PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
|
||||||
|
add_module(${PROJECT_NAME})
|
||||||
|
|
||||||
#)
|
file(GLOB ${CMAKE_PROJECT_NAME}_${PROJECT_NAME}_HEADERS
|
||||||
|
"../mesh.hpp" "*.hpp"
|
||||||
install_component_headers(${COMPONENT_NAME})
|
|
||||||
install_component_source(${COMPONENT_NAME})
|
|
||||||
|
|
||||||
if (0)
|
|
||||||
add_executable(${COMPONENT_NAME}-test
|
|
||||||
tests/${COMPONENT_NAME}-test.cpp
|
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(${COMPONENT_NAME}-test
|
foreach(_header_path ${${CMAKE_PROJECT_NAME}_${PROJECT_NAME}_HEADERS})
|
||||||
${PROJECT_NAME}::${COMPONENT_NAME}
|
list(APPEND ${CMAKE_PROJECT_NAME}_${PROJECT_NAME}_HEADERS_INTERFACE "$<BUILD_INTERFACE:${_header_path}>")
|
||||||
GTest::gtest_main
|
endforeach()
|
||||||
|
|
||||||
|
file(GLOB ${CMAKE_PROJECT_NAME}_${PROJECT_NAME}_SOURCES
|
||||||
|
"*.cpp"
|
||||||
)
|
)
|
||||||
|
|
||||||
gtest_add_tests(TARGET ${COMPONENT_NAME}-test)
|
target_sources(${PROJECT_NAME}
|
||||||
|
INTERFACE
|
||||||
|
${${CMAKE_PROJECT_NAME}_${PROJECT_NAME}_HEADERS_INTERFACE}
|
||||||
|
$<INSTALL_INTERFACE:include/${CMAKE_PROJECT_NAME}/${PROJECT_NAME}>
|
||||||
|
PRIVATE
|
||||||
|
${${CMAKE_PROJECT_NAME}_${PROJECT_NAME}_SOURCES}
|
||||||
|
)
|
||||||
|
|
||||||
|
install(
|
||||||
|
TARGETS ${PROJECT_NAME}
|
||||||
|
EXPORT ${PROJECT_NAME}Targets
|
||||||
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}
|
||||||
|
NAMELINK_SKIP
|
||||||
|
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||||
|
)
|
||||||
|
install(
|
||||||
|
EXPORT ${PROJECT_NAME}Targets
|
||||||
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME}-${HPR_PROJECT_VERSION}
|
||||||
|
NAMESPACE ${CMAKE_PROJECT_NAME}::
|
||||||
|
)
|
||||||
|
install(
|
||||||
|
TARGETS ${PROJECT_NAME}
|
||||||
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}
|
||||||
|
NAMELINK_ONLY
|
||||||
|
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||||
|
)
|
||||||
|
install(
|
||||||
|
DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||||
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${CMAKE_PROJECT_NAME}
|
||||||
|
COMPONENT devel
|
||||||
|
FILES_MATCHING
|
||||||
|
PATTERN "*.h"
|
||||||
|
PATTERN "*.hpp"
|
||||||
|
PATTERN "tests" EXCLUDE
|
||||||
|
)
|
||||||
|
install(
|
||||||
|
FILES ../${PROJECT_NAME}.hpp
|
||||||
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${CMAKE_PROJECT_NAME}
|
||||||
|
COMPONENT devel
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
if(HPR_TEST)
|
||||||
|
add_subdirectory(tests)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
14
source/hpr/mesh/tests/CMakeLists.txt
Normal file
14
source/hpr/mesh/tests/CMakeLists.txt
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
file(GLOB tests_cpp "*.cpp")
|
||||||
|
|
||||||
|
add_executable(${PROJECT_NAME}-tests
|
||||||
|
${tests_cpp}
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(${PROJECT_NAME}-tests
|
||||||
|
PUBLIC
|
||||||
|
hpr::${PROJECT_NAME}
|
||||||
|
PRIVATE
|
||||||
|
GTest::gtest_main
|
||||||
|
)
|
||||||
|
|
||||||
|
gtest_add_tests(TARGET ${PROJECT_NAME}-tests)
|
@ -1,35 +1,68 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
|
||||||
set(COMPONENT_NAME window_system)
|
project(window-system
|
||||||
|
VERSION "${HPR_PROJECT_VERSION}"
|
||||||
add_component_library(${COMPONENT_NAME} OBJECT
|
LANGUAGES CXX
|
||||||
window_system.cpp
|
|
||||||
monitor.cpp
|
|
||||||
window.cpp
|
|
||||||
glfw/window_system.cpp
|
|
||||||
glfw/monitor.cpp
|
|
||||||
glfw/window.cpp
|
|
||||||
)
|
)
|
||||||
|
|
||||||
#target_sources(${COMPONENT_NAME} PUBLIC
|
add_library(${PROJECT_NAME})
|
||||||
|
add_library(${CMAKE_PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
|
||||||
|
add_module(${PROJECT_NAME})
|
||||||
|
|
||||||
#)
|
file(GLOB ${CMAKE_PROJECT_NAME}_${PROJECT_NAME}_HEADERS
|
||||||
|
"../window_system.hpp" "*.hpp" "glfw/*.hpp"
|
||||||
|
)
|
||||||
|
|
||||||
target_link_libraries(${COMPONENT_NAME}
|
foreach(_header_path ${${CMAKE_PROJECT_NAME}_${PROJECT_NAME}_HEADERS})
|
||||||
|
list(APPEND ${CMAKE_PROJECT_NAME}_${PROJECT_NAME}_HEADERS_INTERFACE "$<BUILD_INTERFACE:${_header_path}>")
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
file(GLOB ${CMAKE_PROJECT_NAME}_${PROJECT_NAME}_SOURCES
|
||||||
|
"*.cpp" "glfw/*.cpp"
|
||||||
|
)
|
||||||
|
|
||||||
|
target_sources(${PROJECT_NAME}
|
||||||
|
INTERFACE
|
||||||
|
${${CMAKE_PROJECT_NAME}_${PROJECT_NAME}_HEADERS_INTERFACE}
|
||||||
|
$<INSTALL_INTERFACE:include/${CMAKE_PROJECT_NAME}/${PROJECT_NAME}>
|
||||||
|
PRIVATE
|
||||||
|
${${CMAKE_PROJECT_NAME}_${PROJECT_NAME}_SOURCES}
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(${PROJECT_NAME}
|
||||||
glfw
|
glfw
|
||||||
)
|
)
|
||||||
|
|
||||||
install_component_headers(${COMPONENT_NAME})
|
|
||||||
install_component_source(${COMPONENT_NAME})
|
|
||||||
|
|
||||||
if (0)
|
install(
|
||||||
add_executable(${COMPONENT_NAME}-test
|
TARGETS ${PROJECT_NAME}
|
||||||
tests/${COMPONENT_NAME}-test.cpp
|
EXPORT ${PROJECT_NAME}Targets
|
||||||
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}
|
||||||
|
NAMELINK_SKIP
|
||||||
|
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||||
)
|
)
|
||||||
|
install(
|
||||||
target_link_libraries(${COMPONENT_NAME}-test
|
EXPORT ${PROJECT_NAME}Targets
|
||||||
${PROJECT_NAME}::${COMPONENT_NAME}
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME}-${HPR_PROJECT_VERSION}
|
||||||
GTest::gtest_main
|
NAMESPACE ${CMAKE_PROJECT_NAME}::
|
||||||
|
)
|
||||||
|
install(
|
||||||
|
TARGETS ${PROJECT_NAME}
|
||||||
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}
|
||||||
|
NAMELINK_ONLY
|
||||||
|
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||||
|
)
|
||||||
|
install(
|
||||||
|
DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||||
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${CMAKE_PROJECT_NAME}
|
||||||
|
COMPONENT devel
|
||||||
|
FILES_MATCHING
|
||||||
|
PATTERN "*.h"
|
||||||
|
PATTERN "*.hpp"
|
||||||
|
PATTERN "tests" EXCLUDE
|
||||||
|
)
|
||||||
|
install(
|
||||||
|
FILES ../${PROJECT_NAME}.hpp
|
||||||
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${CMAKE_PROJECT_NAME}
|
||||||
|
COMPONENT devel
|
||||||
)
|
)
|
||||||
|
|
||||||
gtest_add_tests(TARGET ${COMPONENT_NAME}-test)
|
|
||||||
endif()
|
|
@ -16,6 +16,7 @@ WindowSystem::WindowSystem() :
|
|||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
|
||||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||||
|
glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
WindowSystem::~WindowSystem()
|
WindowSystem::~WindowSystem()
|
||||||
|
Loading…
Reference in New Issue
Block a user