init commit
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
project(polypartiCL LANGUAGES CXX)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
find_package(IntelSYCL REQUIRED)
|
||||
|
||||
file(GLOB_RECURSE PROJECT_SOURCES CONFIGURE_DEPENDS "${CMAKE_CURRENT_LIST_DIR}/*.cpp")
|
||||
set(PROJECT_INCLUDE "${CMAKE_CURRENT_LIST_DIR/include/}")
|
||||
|
||||
add_executable(${PROJECT_NAME})
|
||||
target_sources(${PROJECT_NAME} PRIVATE ${PROJECT_SOURCES})
|
||||
target_include_directories(${PROJECT_NAME} PRIVATE ${PROJECT_INCLUDE})
|
||||
add_sycl_to_target(TARGET ${PROJECT_NAME} SOURCES polypartiCL.hpp)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE raylib)
|
||||
|
||||
|
||||
@@ -0,0 +1,379 @@
|
||||
# This is the CMakeCache file.
|
||||
# For build in directory: /home/alardner/cl_polyparti/build
|
||||
# It was generated by CMake: /usr/bin/cmake
|
||||
# You can edit this file to change values found and used by cmake.
|
||||
# If you do not want to change any of the values, simply exit the editor.
|
||||
# If you do want to change a value, simply edit, save, and exit the editor.
|
||||
# The syntax for the file is as follows:
|
||||
# KEY:TYPE=VALUE
|
||||
# KEY is the name of a variable in the cache.
|
||||
# TYPE is a hint to GUIs for the type of VALUE, DO NOT EDIT TYPE!.
|
||||
# VALUE is the current value for the KEY.
|
||||
|
||||
########################
|
||||
# EXTERNAL cache entries
|
||||
########################
|
||||
|
||||
//Path to a program.
|
||||
CMAKE_ADDR2LINE:FILEPATH=/usr/bin/llvm-addr2line
|
||||
|
||||
//Path to a program.
|
||||
CMAKE_AR:FILEPATH=/usr/bin/llvm-ar
|
||||
|
||||
//Choose the type of build, options are: None Debug Release RelWithDebInfo
|
||||
// MinSizeRel ...
|
||||
CMAKE_BUILD_TYPE:STRING=
|
||||
|
||||
//Enable/Disable color output during build.
|
||||
CMAKE_COLOR_MAKEFILE:BOOL=ON
|
||||
|
||||
//CXX compiler
|
||||
CMAKE_CXX_COMPILER:STRING=/opt/intel/oneapi/compiler/2026.0/bin/icpx
|
||||
|
||||
//LLVM archiver
|
||||
CMAKE_CXX_COMPILER_AR:FILEPATH=/opt/intel/oneapi/compiler/2026.0/bin/compiler/llvm-ar
|
||||
|
||||
//Generate index for LLVM archive
|
||||
CMAKE_CXX_COMPILER_RANLIB:FILEPATH=/opt/intel/oneapi/compiler/2026.0/bin/compiler/llvm-ranlib
|
||||
|
||||
//Flags used by the CXX compiler during all build types.
|
||||
CMAKE_CXX_FLAGS:STRING=
|
||||
|
||||
//Flags used by the CXX compiler during DEBUG builds.
|
||||
CMAKE_CXX_FLAGS_DEBUG:STRING=-g -Rno-debug-disables-optimization
|
||||
|
||||
//Flags used by the CXX compiler during MINSIZEREL builds.
|
||||
CMAKE_CXX_FLAGS_MINSIZEREL:STRING=-Os -DNDEBUG
|
||||
|
||||
//Flags used by the CXX compiler during RELEASE builds.
|
||||
CMAKE_CXX_FLAGS_RELEASE:STRING=-O3 -DNDEBUG
|
||||
|
||||
//Flags used by the CXX compiler during RELWITHDEBINFO builds.
|
||||
CMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING=-O2 -g -DNDEBUG
|
||||
|
||||
//Path to a program.
|
||||
CMAKE_DLLTOOL:FILEPATH=/usr/bin/llvm-dlltool
|
||||
|
||||
//Flags used by the linker during all build types.
|
||||
CMAKE_EXE_LINKER_FLAGS:STRING=
|
||||
|
||||
//Flags used by the linker during DEBUG builds.
|
||||
CMAKE_EXE_LINKER_FLAGS_DEBUG:STRING=
|
||||
|
||||
//Flags used by the linker during MINSIZEREL builds.
|
||||
CMAKE_EXE_LINKER_FLAGS_MINSIZEREL:STRING=
|
||||
|
||||
//Flags used by the linker during RELEASE builds.
|
||||
CMAKE_EXE_LINKER_FLAGS_RELEASE:STRING=
|
||||
|
||||
//Flags used by the linker during RELWITHDEBINFO builds.
|
||||
CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO:STRING=
|
||||
|
||||
//Enable/Disable output of compile commands during generation.
|
||||
CMAKE_EXPORT_COMPILE_COMMANDS:BOOL=
|
||||
|
||||
//Value Computed by CMake.
|
||||
CMAKE_FIND_PACKAGE_REDIRECTS_DIR:STATIC=/home/alardner/cl_polyparti/build/CMakeFiles/pkgRedirects
|
||||
|
||||
//Install path prefix, prepended onto install directories.
|
||||
CMAKE_INSTALL_PREFIX:PATH=/usr/local
|
||||
|
||||
//Path to a program.
|
||||
CMAKE_LINKER:FILEPATH=/usr/bin/ld.lld
|
||||
|
||||
//Path to a program.
|
||||
CMAKE_MAKE_PROGRAM:FILEPATH=/usr/bin/gmake
|
||||
|
||||
//Flags used by the linker during the creation of modules during
|
||||
// all build types.
|
||||
CMAKE_MODULE_LINKER_FLAGS:STRING=
|
||||
|
||||
//Flags used by the linker during the creation of modules during
|
||||
// DEBUG builds.
|
||||
CMAKE_MODULE_LINKER_FLAGS_DEBUG:STRING=
|
||||
|
||||
//Flags used by the linker during the creation of modules during
|
||||
// MINSIZEREL builds.
|
||||
CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL:STRING=
|
||||
|
||||
//Flags used by the linker during the creation of modules during
|
||||
// RELEASE builds.
|
||||
CMAKE_MODULE_LINKER_FLAGS_RELEASE:STRING=
|
||||
|
||||
//Flags used by the linker during the creation of modules during
|
||||
// RELWITHDEBINFO builds.
|
||||
CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO:STRING=
|
||||
|
||||
//Path to a program.
|
||||
CMAKE_NM:FILEPATH=/usr/bin/llvm-nm
|
||||
|
||||
//Path to a program.
|
||||
CMAKE_OBJCOPY:FILEPATH=/usr/bin/llvm-objcopy
|
||||
|
||||
//Path to a program.
|
||||
CMAKE_OBJDUMP:FILEPATH=/usr/bin/llvm-objdump
|
||||
|
||||
//Value Computed by CMake
|
||||
CMAKE_PROJECT_COMPAT_VERSION:STATIC=
|
||||
|
||||
//Value Computed by CMake
|
||||
CMAKE_PROJECT_DESCRIPTION:STATIC=
|
||||
|
||||
//Value Computed by CMake
|
||||
CMAKE_PROJECT_HOMEPAGE_URL:STATIC=
|
||||
|
||||
//Value Computed by CMake
|
||||
CMAKE_PROJECT_NAME:STATIC=cl_polyparti
|
||||
|
||||
//Value Computed by CMake
|
||||
CMAKE_PROJECT_SPDX_LICENSE:STATIC=
|
||||
|
||||
//Path to a program.
|
||||
CMAKE_RANLIB:FILEPATH=/usr/bin/llvm-ranlib
|
||||
|
||||
//Path to a program.
|
||||
CMAKE_READELF:FILEPATH=/usr/bin/llvm-readelf
|
||||
|
||||
//Flags used by the linker during the creation of shared libraries
|
||||
// during all build types.
|
||||
CMAKE_SHARED_LINKER_FLAGS:STRING=
|
||||
|
||||
//Flags used by the linker during the creation of shared libraries
|
||||
// during DEBUG builds.
|
||||
CMAKE_SHARED_LINKER_FLAGS_DEBUG:STRING=
|
||||
|
||||
//Flags used by the linker during the creation of shared libraries
|
||||
// during MINSIZEREL builds.
|
||||
CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL:STRING=
|
||||
|
||||
//Flags used by the linker during the creation of shared libraries
|
||||
// during RELEASE builds.
|
||||
CMAKE_SHARED_LINKER_FLAGS_RELEASE:STRING=
|
||||
|
||||
//Flags used by the linker during the creation of shared libraries
|
||||
// during RELWITHDEBINFO builds.
|
||||
CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO:STRING=
|
||||
|
||||
//If set, runtime paths are not added when installing shared libraries,
|
||||
// but are added when building.
|
||||
CMAKE_SKIP_INSTALL_RPATH:BOOL=NO
|
||||
|
||||
//If set, runtime paths are not added when using shared libraries.
|
||||
CMAKE_SKIP_RPATH:BOOL=NO
|
||||
|
||||
//Flags used by the archiver during the creation of static libraries
|
||||
// during all build types.
|
||||
CMAKE_STATIC_LINKER_FLAGS:STRING=
|
||||
|
||||
//Flags used by the archiver during the creation of static libraries
|
||||
// during DEBUG builds.
|
||||
CMAKE_STATIC_LINKER_FLAGS_DEBUG:STRING=
|
||||
|
||||
//Flags used by the archiver during the creation of static libraries
|
||||
// during MINSIZEREL builds.
|
||||
CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL:STRING=
|
||||
|
||||
//Flags used by the archiver during the creation of static libraries
|
||||
// during RELEASE builds.
|
||||
CMAKE_STATIC_LINKER_FLAGS_RELEASE:STRING=
|
||||
|
||||
//Flags used by the archiver during the creation of static libraries
|
||||
// during RELWITHDEBINFO builds.
|
||||
CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO:STRING=
|
||||
|
||||
//Path to a program.
|
||||
CMAKE_STRIP:FILEPATH=/usr/bin/llvm-strip
|
||||
|
||||
//Path to a program.
|
||||
CMAKE_TAPI:FILEPATH=CMAKE_TAPI-NOTFOUND
|
||||
|
||||
//If this value is on, makefiles will be generated without the
|
||||
// .SILENT directive, and all commands will be echoed to the console
|
||||
// during the make. This is useful for debugging only. With Visual
|
||||
// Studio IDE projects all commands are done without /nologo.
|
||||
CMAKE_VERBOSE_MAKEFILE:BOOL=FALSE
|
||||
|
||||
//The directory containing a CMake configuration file for IntelSYCL.
|
||||
IntelSYCL_DIR:PATH=/opt/intel/oneapi/compiler/2026.0/lib/cmake/IntelSYCL
|
||||
|
||||
//Arguments to supply to pkg-config
|
||||
PKG_CONFIG_ARGN:STRING=
|
||||
|
||||
//pkg-config executable
|
||||
PKG_CONFIG_EXECUTABLE:FILEPATH=/usr/bin/pkg-config
|
||||
|
||||
//SYCL Compiler
|
||||
SYCL_COMPILER:STRING=/opt/intel/oneapi/compiler/2026.0/bin/icpx
|
||||
|
||||
//SYCL Compiler version
|
||||
SYCL_COMPILER_VERSION:STRING=20260000
|
||||
|
||||
//Path to a file.
|
||||
SYCL_INCLUDE_DIR:FILEPATH=/opt/intel/oneapi/compiler/2026.0/include
|
||||
|
||||
//Path to a file.
|
||||
SYCL_INCLUDE_SYCL_DIR:FILEPATH=/opt/intel/oneapi/compiler/2026.0/include/sycl
|
||||
|
||||
//SYCL Language version
|
||||
SYCL_LANGUAGE_VERSION:STRING=202012
|
||||
|
||||
//Path to a library.
|
||||
SYCL_LIBRARY:FILEPATH=/opt/intel/oneapi/compiler/2026.0/lib/libsycl.so
|
||||
|
||||
//Path to a file.
|
||||
SYCL_LIBRARY_DIR:FILEPATH=/opt/intel/oneapi/compiler/2026.0/lib
|
||||
|
||||
SYCL_PACKAGE_DIR:STRING=/opt/intel/oneapi/compiler/2026.0
|
||||
|
||||
//Value Computed by CMake
|
||||
cl_polyparti_BINARY_DIR:STATIC=/home/alardner/cl_polyparti/build
|
||||
|
||||
//Value Computed by CMake
|
||||
cl_polyparti_IS_TOP_LEVEL:STATIC=ON
|
||||
|
||||
//Value Computed by CMake
|
||||
cl_polyparti_SOURCE_DIR:STATIC=/home/alardner/cl_polyparti
|
||||
|
||||
|
||||
########################
|
||||
# INTERNAL cache entries
|
||||
########################
|
||||
|
||||
//ADVANCED property for variable: CMAKE_ADDR2LINE
|
||||
CMAKE_ADDR2LINE-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_AR
|
||||
CMAKE_AR-ADVANCED:INTERNAL=1
|
||||
//This is the directory where this CMakeCache.txt was created
|
||||
CMAKE_CACHEFILE_DIR:INTERNAL=/home/alardner/cl_polyparti/build
|
||||
//Major version of cmake used to create the current loaded cache
|
||||
CMAKE_CACHE_MAJOR_VERSION:INTERNAL=4
|
||||
//Minor version of cmake used to create the current loaded cache
|
||||
CMAKE_CACHE_MINOR_VERSION:INTERNAL=3
|
||||
//Patch version of cmake used to create the current loaded cache
|
||||
CMAKE_CACHE_PATCH_VERSION:INTERNAL=3
|
||||
//ADVANCED property for variable: CMAKE_COLOR_MAKEFILE
|
||||
CMAKE_COLOR_MAKEFILE-ADVANCED:INTERNAL=1
|
||||
//Path to CMake executable.
|
||||
CMAKE_COMMAND:INTERNAL=/usr/bin/cmake
|
||||
//Path to cpack program executable.
|
||||
CMAKE_CPACK_COMMAND:INTERNAL=/usr/bin/cpack
|
||||
//Path to ctest program executable.
|
||||
CMAKE_CTEST_COMMAND:INTERNAL=/usr/bin/ctest
|
||||
//ADVANCED property for variable: CMAKE_CXX_COMPILER
|
||||
CMAKE_CXX_COMPILER-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_CXX_COMPILER_AR
|
||||
CMAKE_CXX_COMPILER_AR-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_CXX_COMPILER_RANLIB
|
||||
CMAKE_CXX_COMPILER_RANLIB-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_CXX_FLAGS
|
||||
CMAKE_CXX_FLAGS-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_CXX_FLAGS_DEBUG
|
||||
CMAKE_CXX_FLAGS_DEBUG-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_CXX_FLAGS_MINSIZEREL
|
||||
CMAKE_CXX_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_CXX_FLAGS_RELEASE
|
||||
CMAKE_CXX_FLAGS_RELEASE-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_CXX_FLAGS_RELWITHDEBINFO
|
||||
CMAKE_CXX_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_DLLTOOL
|
||||
CMAKE_DLLTOOL-ADVANCED:INTERNAL=1
|
||||
//Executable file format
|
||||
CMAKE_EXECUTABLE_FORMAT:INTERNAL=ELF
|
||||
//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS
|
||||
CMAKE_EXE_LINKER_FLAGS-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_DEBUG
|
||||
CMAKE_EXE_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_MINSIZEREL
|
||||
CMAKE_EXE_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_RELEASE
|
||||
CMAKE_EXE_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO
|
||||
CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_EXPORT_COMPILE_COMMANDS
|
||||
CMAKE_EXPORT_COMPILE_COMMANDS-ADVANCED:INTERNAL=1
|
||||
//Name of external makefile project generator.
|
||||
CMAKE_EXTRA_GENERATOR:INTERNAL=
|
||||
//Name of generator.
|
||||
CMAKE_GENERATOR:INTERNAL=Unix Makefiles
|
||||
//Generator instance identifier.
|
||||
CMAKE_GENERATOR_INSTANCE:INTERNAL=
|
||||
//Name of generator platform.
|
||||
CMAKE_GENERATOR_PLATFORM:INTERNAL=
|
||||
//Name of generator toolset.
|
||||
CMAKE_GENERATOR_TOOLSET:INTERNAL=
|
||||
//Source directory with the top level CMakeLists.txt file for this
|
||||
// project
|
||||
CMAKE_HOME_DIRECTORY:INTERNAL=/home/alardner/cl_polyparti
|
||||
//Install .so files without execute permission.
|
||||
CMAKE_INSTALL_SO_NO_EXE:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_LINKER
|
||||
CMAKE_LINKER-ADVANCED:INTERNAL=1
|
||||
//Name of CMakeLists files to read
|
||||
CMAKE_LIST_FILE_NAME:INTERNAL=CMakeLists.txt
|
||||
//ADVANCED property for variable: CMAKE_MAKE_PROGRAM
|
||||
CMAKE_MAKE_PROGRAM-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS
|
||||
CMAKE_MODULE_LINKER_FLAGS-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_DEBUG
|
||||
CMAKE_MODULE_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL
|
||||
CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_RELEASE
|
||||
CMAKE_MODULE_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO
|
||||
CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_NM
|
||||
CMAKE_NM-ADVANCED:INTERNAL=1
|
||||
//number of local generators
|
||||
CMAKE_NUMBER_OF_MAKEFILES:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_OBJCOPY
|
||||
CMAKE_OBJCOPY-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_OBJDUMP
|
||||
CMAKE_OBJDUMP-ADVANCED:INTERNAL=1
|
||||
//Platform information initialized
|
||||
CMAKE_PLATFORM_INFO_INITIALIZED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_RANLIB
|
||||
CMAKE_RANLIB-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_READELF
|
||||
CMAKE_READELF-ADVANCED:INTERNAL=1
|
||||
//Path to CMake installation.
|
||||
CMAKE_ROOT:INTERNAL=/usr/share/cmake-4.3
|
||||
//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS
|
||||
CMAKE_SHARED_LINKER_FLAGS-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_DEBUG
|
||||
CMAKE_SHARED_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL
|
||||
CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_RELEASE
|
||||
CMAKE_SHARED_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO
|
||||
CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_SKIP_INSTALL_RPATH
|
||||
CMAKE_SKIP_INSTALL_RPATH-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_SKIP_RPATH
|
||||
CMAKE_SKIP_RPATH-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS
|
||||
CMAKE_STATIC_LINKER_FLAGS-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_DEBUG
|
||||
CMAKE_STATIC_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL
|
||||
CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_RELEASE
|
||||
CMAKE_STATIC_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO
|
||||
CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_STRIP
|
||||
CMAKE_STRIP-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_TAPI
|
||||
CMAKE_TAPI-ADVANCED:INTERNAL=1
|
||||
//uname command
|
||||
CMAKE_UNAME:INTERNAL=/usr/bin/uname
|
||||
//ADVANCED property for variable: CMAKE_VERBOSE_MAKEFILE
|
||||
CMAKE_VERBOSE_MAKEFILE-ADVANCED:INTERNAL=1
|
||||
//Details about finding IntelSYCL
|
||||
FIND_PACKAGE_MESSAGE_DETAILS_IntelSYCL:INTERNAL=[/opt/intel/oneapi/compiler/2026.0/include][/opt/intel/oneapi/compiler/2026.0/lib][-fsycl][20260000][/opt/intel/oneapi/compiler/2026.0/bin/icpx][/opt/intel/oneapi/compiler/2026.0/lib/libsycl.so][v202012()]
|
||||
//ADVANCED property for variable: PKG_CONFIG_ARGN
|
||||
PKG_CONFIG_ARGN-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: PKG_CONFIG_EXECUTABLE
|
||||
PKG_CONFIG_EXECUTABLE-ADVANCED:INTERNAL=1
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
set(CMAKE_CXX_COMPILER "/opt/intel/oneapi/compiler/2026.0/bin/icpx")
|
||||
set(CMAKE_CXX_COMPILER_ARG1 "")
|
||||
set(CMAKE_CXX_COMPILER_ID "IntelLLVM")
|
||||
set(CMAKE_CXX_COMPILER_VERSION "2026.0.0")
|
||||
set(CMAKE_CXX_COMPILER_VERSION_INTERNAL "")
|
||||
set(CMAKE_CXX_COMPILER_WRAPPER "")
|
||||
set(CMAKE_CXX_STANDARD_COMPUTED_DEFAULT "17")
|
||||
set(CMAKE_CXX_EXTENSIONS_COMPUTED_DEFAULT "ON")
|
||||
set(CMAKE_CXX_STANDARD_LATEST "26")
|
||||
set(CMAKE_CXX_COMPILE_FEATURES "cxx_std_98;cxx_template_template_parameters;cxx_std_11;cxx_alias_templates;cxx_alignas;cxx_alignof;cxx_attributes;cxx_auto_type;cxx_constexpr;cxx_decltype;cxx_decltype_incomplete_return_types;cxx_default_function_template_args;cxx_defaulted_functions;cxx_defaulted_move_initializers;cxx_delegating_constructors;cxx_deleted_functions;cxx_enum_forward_declarations;cxx_explicit_conversions;cxx_extended_friend_declarations;cxx_extern_templates;cxx_final;cxx_func_identifier;cxx_generalized_initializers;cxx_inheriting_constructors;cxx_inline_namespaces;cxx_lambdas;cxx_local_type_template_args;cxx_long_long_type;cxx_noexcept;cxx_nonstatic_member_init;cxx_nullptr;cxx_override;cxx_range_for;cxx_raw_string_literals;cxx_reference_qualified_functions;cxx_right_angle_brackets;cxx_rvalue_references;cxx_sizeof_member;cxx_static_assert;cxx_strong_enums;cxx_thread_local;cxx_trailing_return_types;cxx_unicode_literals;cxx_uniform_initialization;cxx_unrestricted_unions;cxx_user_literals;cxx_variadic_macros;cxx_variadic_templates;cxx_std_14;cxx_aggregate_default_initializers;cxx_attribute_deprecated;cxx_binary_literals;cxx_contextual_conversions;cxx_decltype_auto;cxx_digit_separators;cxx_generic_lambdas;cxx_lambda_init_captures;cxx_relaxed_constexpr;cxx_return_type_deduction;cxx_variable_templates;cxx_std_17;cxx_std_20;cxx_std_23;cxx_std_26")
|
||||
set(CMAKE_CXX98_COMPILE_FEATURES "cxx_std_98;cxx_template_template_parameters")
|
||||
set(CMAKE_CXX11_COMPILE_FEATURES "cxx_std_11;cxx_alias_templates;cxx_alignas;cxx_alignof;cxx_attributes;cxx_auto_type;cxx_constexpr;cxx_decltype;cxx_decltype_incomplete_return_types;cxx_default_function_template_args;cxx_defaulted_functions;cxx_defaulted_move_initializers;cxx_delegating_constructors;cxx_deleted_functions;cxx_enum_forward_declarations;cxx_explicit_conversions;cxx_extended_friend_declarations;cxx_extern_templates;cxx_final;cxx_func_identifier;cxx_generalized_initializers;cxx_inheriting_constructors;cxx_inline_namespaces;cxx_lambdas;cxx_local_type_template_args;cxx_long_long_type;cxx_noexcept;cxx_nonstatic_member_init;cxx_nullptr;cxx_override;cxx_range_for;cxx_raw_string_literals;cxx_reference_qualified_functions;cxx_right_angle_brackets;cxx_rvalue_references;cxx_sizeof_member;cxx_static_assert;cxx_strong_enums;cxx_thread_local;cxx_trailing_return_types;cxx_unicode_literals;cxx_uniform_initialization;cxx_unrestricted_unions;cxx_user_literals;cxx_variadic_macros;cxx_variadic_templates")
|
||||
set(CMAKE_CXX14_COMPILE_FEATURES "cxx_std_14;cxx_aggregate_default_initializers;cxx_attribute_deprecated;cxx_binary_literals;cxx_contextual_conversions;cxx_decltype_auto;cxx_digit_separators;cxx_generic_lambdas;cxx_lambda_init_captures;cxx_relaxed_constexpr;cxx_return_type_deduction;cxx_variable_templates")
|
||||
set(CMAKE_CXX17_COMPILE_FEATURES "cxx_std_17")
|
||||
set(CMAKE_CXX20_COMPILE_FEATURES "cxx_std_20")
|
||||
set(CMAKE_CXX23_COMPILE_FEATURES "cxx_std_23")
|
||||
set(CMAKE_CXX26_COMPILE_FEATURES "cxx_std_26")
|
||||
|
||||
set(CMAKE_CXX_PLATFORM_ID "Linux")
|
||||
set(CMAKE_CXX_SIMULATE_ID "GNU")
|
||||
set(CMAKE_CXX_COMPILER_FRONTEND_VARIANT "GNU")
|
||||
set(CMAKE_CXX_COMPILER_APPLE_SYSROOT "")
|
||||
set(CMAKE_CXX_SIMULATE_VERSION "4.2.1")
|
||||
set(CMAKE_CXX_COMPILER_ARCHITECTURE_ID "x86_64")
|
||||
|
||||
|
||||
|
||||
|
||||
set(CMAKE_AR "/usr/bin/llvm-ar")
|
||||
set(CMAKE_CXX_COMPILER_AR "/opt/intel/oneapi/compiler/2026.0/bin/compiler/llvm-ar")
|
||||
set(CMAKE_RANLIB "/usr/bin/llvm-ranlib")
|
||||
set(CMAKE_CXX_COMPILER_RANLIB "/opt/intel/oneapi/compiler/2026.0/bin/compiler/llvm-ranlib")
|
||||
set(CMAKE_LINKER "/usr/bin/ld.lld")
|
||||
set(CMAKE_LINKER_LINK "")
|
||||
set(CMAKE_LINKER_LLD "")
|
||||
set(CMAKE_CXX_COMPILER_LINKER "/usr/bin/ld")
|
||||
set(CMAKE_CXX_COMPILER_LINKER_ID "GNU")
|
||||
set(CMAKE_CXX_COMPILER_LINKER_VERSION 2.46.50.20260608)
|
||||
set(CMAKE_CXX_COMPILER_LINKER_FRONTEND_VARIANT GNU)
|
||||
set(CMAKE_MT "")
|
||||
set(CMAKE_TAPI "CMAKE_TAPI-NOTFOUND")
|
||||
set(CMAKE_COMPILER_IS_GNUCXX )
|
||||
set(CMAKE_CXX_COMPILER_LOADED 1)
|
||||
set(CMAKE_CXX_COMPILER_WORKS TRUE)
|
||||
set(CMAKE_CXX_ABI_COMPILED TRUE)
|
||||
|
||||
set(CMAKE_CXX_COMPILER_ENV_VAR "CXX")
|
||||
|
||||
set(CMAKE_CXX_COMPILER_ID_RUN 1)
|
||||
set(CMAKE_CXX_SOURCE_FILE_EXTENSIONS C;M;c++;cc;cpp;cxx;m;mm;mpp;CPP;ixx;cppm;ccm;cxxm;c++m)
|
||||
set(CMAKE_CXX_IGNORE_EXTENSIONS inl;h;hpp;HPP;H;o;O;obj;OBJ;def;DEF;rc;RC)
|
||||
|
||||
foreach (lang IN ITEMS C OBJC OBJCXX)
|
||||
if (CMAKE_${lang}_COMPILER_ID_RUN)
|
||||
foreach(extension IN LISTS CMAKE_${lang}_SOURCE_FILE_EXTENSIONS)
|
||||
list(REMOVE_ITEM CMAKE_CXX_SOURCE_FILE_EXTENSIONS ${extension})
|
||||
endforeach()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
set(CMAKE_CXX_LINKER_PREFERENCE 30)
|
||||
set(CMAKE_CXX_LINKER_PREFERENCE_PROPAGATES 1)
|
||||
set(CMAKE_CXX_LINKER_DEPFILE_SUPPORTED TRUE)
|
||||
set(CMAKE_LINKER_PUSHPOP_STATE_SUPPORTED TRUE)
|
||||
set(CMAKE_CXX_LINKER_PUSHPOP_STATE_SUPPORTED TRUE)
|
||||
|
||||
# Save compiler ABI information.
|
||||
set(CMAKE_CXX_SIZEOF_DATA_PTR "8")
|
||||
set(CMAKE_CXX_COMPILER_ABI "ELF")
|
||||
set(CMAKE_CXX_BYTE_ORDER "LITTLE_ENDIAN")
|
||||
set(CMAKE_CXX_LIBRARY_ARCHITECTURE "x86_64-linux-gnu")
|
||||
|
||||
if(CMAKE_CXX_SIZEOF_DATA_PTR)
|
||||
set(CMAKE_SIZEOF_VOID_P "${CMAKE_CXX_SIZEOF_DATA_PTR}")
|
||||
endif()
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ABI)
|
||||
set(CMAKE_INTERNAL_PLATFORM_ABI "${CMAKE_CXX_COMPILER_ABI}")
|
||||
endif()
|
||||
|
||||
if(CMAKE_CXX_LIBRARY_ARCHITECTURE)
|
||||
set(CMAKE_LIBRARY_ARCHITECTURE "x86_64-linux-gnu")
|
||||
endif()
|
||||
|
||||
set(CMAKE_CXX_CL_SHOWINCLUDES_PREFIX "")
|
||||
if(CMAKE_CXX_CL_SHOWINCLUDES_PREFIX)
|
||||
set(CMAKE_CL_SHOWINCLUDES_PREFIX "${CMAKE_CXX_CL_SHOWINCLUDES_PREFIX}")
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
set(CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES "/opt/intel/oneapi/dev-utilities/2026.0/include;/opt/intel/oneapi/umf/1.1/include;/opt/intel/oneapi/tbb/2023.0/include;/opt/intel/oneapi/compiler/2026.0/opt/compiler/include;/usr/include/c++/15;/usr/include/x86_64-linux-gnu/c++/15;/usr/include/c++/15/backward;/opt/intel/oneapi/compiler/2026.0/lib/clang/22/include;/usr/local/include;/usr/include/x86_64-linux-gnu;/usr/include")
|
||||
set(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "svml;irng;stdc++;imf;m;gcc_s;gcc;irc;dl;gcc_s;gcc;c;gcc_s;gcc;irc_s")
|
||||
set(CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES "/opt/intel/oneapi/compiler/2026.0/lib;/opt/intel/oneapi/compiler/2026.0/lib/clang/22/lib/x86_64-unknown-linux-gnu;/usr/lib/gcc/x86_64-linux-gnu/15;/usr/lib64;/lib/x86_64-linux-gnu;/lib64;/usr/lib/x86_64-linux-gnu;/opt/intel/oneapi/compiler/2026.0/opt/compiler/lib;/lib;/usr/lib;/opt/intel/oneapi/tcm/1.5/lib;/opt/intel/oneapi/umf/1.1/lib;/opt/intel/oneapi/tbb/2023.0/lib/intel64/gcc4.8")
|
||||
set(CMAKE_CXX_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "")
|
||||
set(CMAKE_CXX_COMPILER_CLANG_RESOURCE_DIR "")
|
||||
|
||||
set(CMAKE_CXX_COMPILER_IMPORT_STD "")
|
||||
set(CMAKE_CXX_COMPILER_IMPORT_STD_ERROR_MESSAGE "Unsupported generator: Unix Makefiles")
|
||||
set(CMAKE_CXX_STDLIB_MODULES_JSON "")
|
||||
Binary file not shown.
@@ -0,0 +1,15 @@
|
||||
set(CMAKE_HOST_SYSTEM "Linux-7.0.12+deb14.1-amd64")
|
||||
set(CMAKE_HOST_SYSTEM_NAME "Linux")
|
||||
set(CMAKE_HOST_SYSTEM_VERSION "7.0.12+deb14.1-amd64")
|
||||
set(CMAKE_HOST_SYSTEM_PROCESSOR "x86_64")
|
||||
|
||||
|
||||
|
||||
set(CMAKE_SYSTEM "Linux-7.0.12+deb14.1-amd64")
|
||||
set(CMAKE_SYSTEM_NAME "Linux")
|
||||
set(CMAKE_SYSTEM_VERSION "7.0.12+deb14.1-amd64")
|
||||
set(CMAKE_SYSTEM_PROCESSOR "x86_64")
|
||||
|
||||
set(CMAKE_CROSSCOMPILING "FALSE")
|
||||
|
||||
set(CMAKE_SYSTEM_LOADED 1)
|
||||
@@ -0,0 +1,949 @@
|
||||
/* This source file must have a .cpp extension so that all C++ compilers
|
||||
recognize the extension without flags. Borland does not know .cxx for
|
||||
example. */
|
||||
#ifndef __cplusplus
|
||||
# error "A C compiler has been selected for C++."
|
||||
#endif
|
||||
|
||||
#if !defined(__has_include)
|
||||
/* If the compiler does not have __has_include, pretend the answer is
|
||||
always no. */
|
||||
# define __has_include(x) 0
|
||||
#endif
|
||||
|
||||
|
||||
/* Version number components: V=Version, R=Revision, P=Patch
|
||||
Version date components: YYYY=Year, MM=Month, DD=Day */
|
||||
|
||||
#if defined(__INTEL_COMPILER) || defined(__ICC)
|
||||
# define COMPILER_ID "Intel"
|
||||
# if defined(_MSC_VER)
|
||||
# define SIMULATE_ID "MSVC"
|
||||
# endif
|
||||
# if defined(__GNUC__)
|
||||
# define SIMULATE_ID "GNU"
|
||||
# endif
|
||||
/* __INTEL_COMPILER = VRP prior to 2021, and then VVVV for 2021 and later,
|
||||
except that a few beta releases use the old format with V=2021. */
|
||||
# if __INTEL_COMPILER < 2021 || __INTEL_COMPILER == 202110 || __INTEL_COMPILER == 202111
|
||||
# define COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER/100)
|
||||
# define COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER/10 % 10)
|
||||
# if defined(__INTEL_COMPILER_UPDATE)
|
||||
# define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER_UPDATE)
|
||||
# else
|
||||
# define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER % 10)
|
||||
# endif
|
||||
# else
|
||||
# define COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER)
|
||||
# define COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER_UPDATE)
|
||||
/* The third version component from --version is an update index,
|
||||
but no macro is provided for it. */
|
||||
# define COMPILER_VERSION_PATCH DEC(0)
|
||||
# endif
|
||||
# if defined(__INTEL_COMPILER_BUILD_DATE)
|
||||
/* __INTEL_COMPILER_BUILD_DATE = YYYYMMDD */
|
||||
# define COMPILER_VERSION_TWEAK DEC(__INTEL_COMPILER_BUILD_DATE)
|
||||
# endif
|
||||
# if defined(_MSC_VER)
|
||||
/* _MSC_VER = VVRR */
|
||||
# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
|
||||
# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
|
||||
# endif
|
||||
# if defined(__GNUC__)
|
||||
# define SIMULATE_VERSION_MAJOR DEC(__GNUC__)
|
||||
# elif defined(__GNUG__)
|
||||
# define SIMULATE_VERSION_MAJOR DEC(__GNUG__)
|
||||
# endif
|
||||
# if defined(__GNUC_MINOR__)
|
||||
# define SIMULATE_VERSION_MINOR DEC(__GNUC_MINOR__)
|
||||
# endif
|
||||
# if defined(__GNUC_PATCHLEVEL__)
|
||||
# define SIMULATE_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__)
|
||||
# endif
|
||||
|
||||
#elif (defined(__clang__) && defined(__INTEL_CLANG_COMPILER)) || defined(__INTEL_LLVM_COMPILER)
|
||||
# define COMPILER_ID "IntelLLVM"
|
||||
#if defined(_MSC_VER)
|
||||
# define SIMULATE_ID "MSVC"
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
# define SIMULATE_ID "GNU"
|
||||
#endif
|
||||
/* __INTEL_LLVM_COMPILER = VVVVRP prior to 2021.2.0, VVVVRRPP for 2021.2.0 and
|
||||
* later. Look for 6 digit vs. 8 digit version number to decide encoding.
|
||||
* VVVV is no smaller than the current year when a version is released.
|
||||
*/
|
||||
#if __INTEL_LLVM_COMPILER < 1000000L
|
||||
# define COMPILER_VERSION_MAJOR DEC(__INTEL_LLVM_COMPILER/100)
|
||||
# define COMPILER_VERSION_MINOR DEC(__INTEL_LLVM_COMPILER/10 % 10)
|
||||
# define COMPILER_VERSION_PATCH DEC(__INTEL_LLVM_COMPILER % 10)
|
||||
#else
|
||||
# define COMPILER_VERSION_MAJOR DEC(__INTEL_LLVM_COMPILER/10000)
|
||||
# define COMPILER_VERSION_MINOR DEC(__INTEL_LLVM_COMPILER/100 % 100)
|
||||
# define COMPILER_VERSION_PATCH DEC(__INTEL_LLVM_COMPILER % 100)
|
||||
#endif
|
||||
#if defined(_MSC_VER)
|
||||
/* _MSC_VER = VVRR */
|
||||
# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
|
||||
# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
# define SIMULATE_VERSION_MAJOR DEC(__GNUC__)
|
||||
#elif defined(__GNUG__)
|
||||
# define SIMULATE_VERSION_MAJOR DEC(__GNUG__)
|
||||
#endif
|
||||
#if defined(__GNUC_MINOR__)
|
||||
# define SIMULATE_VERSION_MINOR DEC(__GNUC_MINOR__)
|
||||
#endif
|
||||
#if defined(__GNUC_PATCHLEVEL__)
|
||||
# define SIMULATE_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__)
|
||||
#endif
|
||||
|
||||
#elif defined(__PATHCC__)
|
||||
# define COMPILER_ID "PathScale"
|
||||
# define COMPILER_VERSION_MAJOR DEC(__PATHCC__)
|
||||
# define COMPILER_VERSION_MINOR DEC(__PATHCC_MINOR__)
|
||||
# if defined(__PATHCC_PATCHLEVEL__)
|
||||
# define COMPILER_VERSION_PATCH DEC(__PATHCC_PATCHLEVEL__)
|
||||
# endif
|
||||
|
||||
#elif defined(__BORLANDC__) && defined(__CODEGEARC_VERSION__)
|
||||
# define COMPILER_ID "Embarcadero"
|
||||
# define COMPILER_VERSION_MAJOR HEX(__CODEGEARC_VERSION__>>24 & 0x00FF)
|
||||
# define COMPILER_VERSION_MINOR HEX(__CODEGEARC_VERSION__>>16 & 0x00FF)
|
||||
# define COMPILER_VERSION_PATCH DEC(__CODEGEARC_VERSION__ & 0xFFFF)
|
||||
|
||||
#elif defined(__BORLANDC__)
|
||||
# define COMPILER_ID "Borland"
|
||||
/* __BORLANDC__ = 0xVRR */
|
||||
# define COMPILER_VERSION_MAJOR HEX(__BORLANDC__>>8)
|
||||
# define COMPILER_VERSION_MINOR HEX(__BORLANDC__ & 0xFF)
|
||||
|
||||
#elif defined(__WATCOMC__) && __WATCOMC__ < 1200
|
||||
# define COMPILER_ID "Watcom"
|
||||
/* __WATCOMC__ = VVRR */
|
||||
# define COMPILER_VERSION_MAJOR DEC(__WATCOMC__ / 100)
|
||||
# define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10)
|
||||
# if (__WATCOMC__ % 10) > 0
|
||||
# define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10)
|
||||
# endif
|
||||
|
||||
#elif defined(__WATCOMC__)
|
||||
# define COMPILER_ID "OpenWatcom"
|
||||
/* __WATCOMC__ = VVRP + 1100 */
|
||||
# define COMPILER_VERSION_MAJOR DEC((__WATCOMC__ - 1100) / 100)
|
||||
# define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10)
|
||||
# if (__WATCOMC__ % 10) > 0
|
||||
# define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10)
|
||||
# endif
|
||||
|
||||
#elif defined(__SUNPRO_CC)
|
||||
# define COMPILER_ID "SunPro"
|
||||
# if __SUNPRO_CC >= 0x5100
|
||||
/* __SUNPRO_CC = 0xVRRP */
|
||||
# define COMPILER_VERSION_MAJOR HEX(__SUNPRO_CC>>12)
|
||||
# define COMPILER_VERSION_MINOR HEX(__SUNPRO_CC>>4 & 0xFF)
|
||||
# define COMPILER_VERSION_PATCH HEX(__SUNPRO_CC & 0xF)
|
||||
# else
|
||||
/* __SUNPRO_CC = 0xVRP */
|
||||
# define COMPILER_VERSION_MAJOR HEX(__SUNPRO_CC>>8)
|
||||
# define COMPILER_VERSION_MINOR HEX(__SUNPRO_CC>>4 & 0xF)
|
||||
# define COMPILER_VERSION_PATCH HEX(__SUNPRO_CC & 0xF)
|
||||
# endif
|
||||
|
||||
#elif defined(__HP_aCC)
|
||||
# define COMPILER_ID "HP"
|
||||
/* __HP_aCC = VVRRPP */
|
||||
# define COMPILER_VERSION_MAJOR DEC(__HP_aCC/10000)
|
||||
# define COMPILER_VERSION_MINOR DEC(__HP_aCC/100 % 100)
|
||||
# define COMPILER_VERSION_PATCH DEC(__HP_aCC % 100)
|
||||
|
||||
#elif defined(__DECCXX)
|
||||
# define COMPILER_ID "Compaq"
|
||||
/* __DECCXX_VER = VVRRTPPPP */
|
||||
# define COMPILER_VERSION_MAJOR DEC(__DECCXX_VER/10000000)
|
||||
# define COMPILER_VERSION_MINOR DEC(__DECCXX_VER/100000 % 100)
|
||||
# define COMPILER_VERSION_PATCH DEC(__DECCXX_VER % 10000)
|
||||
|
||||
#elif defined(__IBMCPP__) && defined(__COMPILER_VER__)
|
||||
# define COMPILER_ID "zOS"
|
||||
/* __IBMCPP__ = VRP */
|
||||
# define COMPILER_VERSION_MAJOR DEC(__IBMCPP__/100)
|
||||
# define COMPILER_VERSION_MINOR DEC(__IBMCPP__/10 % 10)
|
||||
# define COMPILER_VERSION_PATCH DEC(__IBMCPP__ % 10)
|
||||
|
||||
#elif defined(__open_xl__) && defined(__clang__)
|
||||
# define COMPILER_ID "IBMClang"
|
||||
# define COMPILER_VERSION_MAJOR DEC(__open_xl_version__)
|
||||
# define COMPILER_VERSION_MINOR DEC(__open_xl_release__)
|
||||
# define COMPILER_VERSION_PATCH DEC(__open_xl_modification__)
|
||||
# define COMPILER_VERSION_TWEAK DEC(__open_xl_ptf_fix_level__)
|
||||
# define COMPILER_VERSION_INTERNAL_STR __clang_version__
|
||||
|
||||
|
||||
#elif defined(__ibmxl__) && defined(__clang__)
|
||||
# define COMPILER_ID "XLClang"
|
||||
# define COMPILER_VERSION_MAJOR DEC(__ibmxl_version__)
|
||||
# define COMPILER_VERSION_MINOR DEC(__ibmxl_release__)
|
||||
# define COMPILER_VERSION_PATCH DEC(__ibmxl_modification__)
|
||||
# define COMPILER_VERSION_TWEAK DEC(__ibmxl_ptf_fix_level__)
|
||||
|
||||
|
||||
#elif defined(__IBMCPP__) && !defined(__COMPILER_VER__) && __IBMCPP__ >= 800
|
||||
# define COMPILER_ID "XL"
|
||||
/* __IBMCPP__ = VRP */
|
||||
# define COMPILER_VERSION_MAJOR DEC(__IBMCPP__/100)
|
||||
# define COMPILER_VERSION_MINOR DEC(__IBMCPP__/10 % 10)
|
||||
# define COMPILER_VERSION_PATCH DEC(__IBMCPP__ % 10)
|
||||
|
||||
#elif defined(__IBMCPP__) && !defined(__COMPILER_VER__) && __IBMCPP__ < 800
|
||||
# define COMPILER_ID "VisualAge"
|
||||
/* __IBMCPP__ = VRP */
|
||||
# define COMPILER_VERSION_MAJOR DEC(__IBMCPP__/100)
|
||||
# define COMPILER_VERSION_MINOR DEC(__IBMCPP__/10 % 10)
|
||||
# define COMPILER_VERSION_PATCH DEC(__IBMCPP__ % 10)
|
||||
|
||||
#elif defined(__NVCOMPILER)
|
||||
# define COMPILER_ID "NVHPC"
|
||||
# define COMPILER_VERSION_MAJOR DEC(__NVCOMPILER_MAJOR__)
|
||||
# define COMPILER_VERSION_MINOR DEC(__NVCOMPILER_MINOR__)
|
||||
# if defined(__NVCOMPILER_PATCHLEVEL__)
|
||||
# define COMPILER_VERSION_PATCH DEC(__NVCOMPILER_PATCHLEVEL__)
|
||||
# endif
|
||||
|
||||
#elif defined(__PGI)
|
||||
# define COMPILER_ID "PGI"
|
||||
# define COMPILER_VERSION_MAJOR DEC(__PGIC__)
|
||||
# define COMPILER_VERSION_MINOR DEC(__PGIC_MINOR__)
|
||||
# if defined(__PGIC_PATCHLEVEL__)
|
||||
# define COMPILER_VERSION_PATCH DEC(__PGIC_PATCHLEVEL__)
|
||||
# endif
|
||||
|
||||
#elif defined(__clang__) && defined(__cray__)
|
||||
# define COMPILER_ID "CrayClang"
|
||||
# define COMPILER_VERSION_MAJOR DEC(__cray_major__)
|
||||
# define COMPILER_VERSION_MINOR DEC(__cray_minor__)
|
||||
# define COMPILER_VERSION_PATCH DEC(__cray_patchlevel__)
|
||||
# define COMPILER_VERSION_INTERNAL_STR __clang_version__
|
||||
|
||||
|
||||
#elif defined(_CRAYC)
|
||||
# define COMPILER_ID "Cray"
|
||||
# define COMPILER_VERSION_MAJOR DEC(_RELEASE_MAJOR)
|
||||
# define COMPILER_VERSION_MINOR DEC(_RELEASE_MINOR)
|
||||
|
||||
#elif defined(__TI_COMPILER_VERSION__)
|
||||
# define COMPILER_ID "TI"
|
||||
/* __TI_COMPILER_VERSION__ = VVVRRRPPP */
|
||||
# define COMPILER_VERSION_MAJOR DEC(__TI_COMPILER_VERSION__/1000000)
|
||||
# define COMPILER_VERSION_MINOR DEC(__TI_COMPILER_VERSION__/1000 % 1000)
|
||||
# define COMPILER_VERSION_PATCH DEC(__TI_COMPILER_VERSION__ % 1000)
|
||||
|
||||
#elif defined(__CLANG_FUJITSU)
|
||||
# define COMPILER_ID "FujitsuClang"
|
||||
# define COMPILER_VERSION_MAJOR DEC(__FCC_major__)
|
||||
# define COMPILER_VERSION_MINOR DEC(__FCC_minor__)
|
||||
# define COMPILER_VERSION_PATCH DEC(__FCC_patchlevel__)
|
||||
# define COMPILER_VERSION_INTERNAL_STR __clang_version__
|
||||
|
||||
|
||||
#elif defined(__FUJITSU)
|
||||
# define COMPILER_ID "Fujitsu"
|
||||
# if defined(__FCC_version__)
|
||||
# define COMPILER_VERSION __FCC_version__
|
||||
# elif defined(__FCC_major__)
|
||||
# define COMPILER_VERSION_MAJOR DEC(__FCC_major__)
|
||||
# define COMPILER_VERSION_MINOR DEC(__FCC_minor__)
|
||||
# define COMPILER_VERSION_PATCH DEC(__FCC_patchlevel__)
|
||||
# endif
|
||||
# if defined(__fcc_version)
|
||||
# define COMPILER_VERSION_INTERNAL DEC(__fcc_version)
|
||||
# elif defined(__FCC_VERSION)
|
||||
# define COMPILER_VERSION_INTERNAL DEC(__FCC_VERSION)
|
||||
# endif
|
||||
|
||||
|
||||
#elif defined(__ghs__)
|
||||
# define COMPILER_ID "GHS"
|
||||
/* __GHS_VERSION_NUMBER = VVVVRP */
|
||||
# ifdef __GHS_VERSION_NUMBER
|
||||
# define COMPILER_VERSION_MAJOR DEC(__GHS_VERSION_NUMBER / 100)
|
||||
# define COMPILER_VERSION_MINOR DEC(__GHS_VERSION_NUMBER / 10 % 10)
|
||||
# define COMPILER_VERSION_PATCH DEC(__GHS_VERSION_NUMBER % 10)
|
||||
# endif
|
||||
|
||||
#elif defined(__TASKING__)
|
||||
# define COMPILER_ID "Tasking"
|
||||
# define COMPILER_VERSION_MAJOR DEC(__VERSION__/1000)
|
||||
# define COMPILER_VERSION_MINOR DEC(__VERSION__ % 100)
|
||||
# define COMPILER_VERSION_INTERNAL DEC(__VERSION__)
|
||||
|
||||
#elif defined(__ORANGEC__)
|
||||
# define COMPILER_ID "OrangeC"
|
||||
# define COMPILER_VERSION_MAJOR DEC(__ORANGEC_MAJOR__)
|
||||
# define COMPILER_VERSION_MINOR DEC(__ORANGEC_MINOR__)
|
||||
# define COMPILER_VERSION_PATCH DEC(__ORANGEC_PATCHLEVEL__)
|
||||
|
||||
#elif defined(__RENESAS__)
|
||||
# define COMPILER_ID "Renesas"
|
||||
/* __RENESAS_VERSION__ = 0xVVRRPP00 */
|
||||
# define COMPILER_VERSION_MAJOR HEX(__RENESAS_VERSION__ >> 24 & 0xFF)
|
||||
# define COMPILER_VERSION_MINOR HEX(__RENESAS_VERSION__ >> 16 & 0xFF)
|
||||
# define COMPILER_VERSION_PATCH HEX(__RENESAS_VERSION__ >> 8 & 0xFF)
|
||||
|
||||
#elif defined(__SCO_VERSION__)
|
||||
# define COMPILER_ID "SCO"
|
||||
|
||||
#elif defined(__ARMCC_VERSION) && !defined(__clang__)
|
||||
# define COMPILER_ID "ARMCC"
|
||||
#if __ARMCC_VERSION >= 1000000
|
||||
/* __ARMCC_VERSION = VRRPPPP */
|
||||
# define COMPILER_VERSION_MAJOR DEC(__ARMCC_VERSION/1000000)
|
||||
# define COMPILER_VERSION_MINOR DEC(__ARMCC_VERSION/10000 % 100)
|
||||
# define COMPILER_VERSION_PATCH DEC(__ARMCC_VERSION % 10000)
|
||||
#else
|
||||
/* __ARMCC_VERSION = VRPPPP */
|
||||
# define COMPILER_VERSION_MAJOR DEC(__ARMCC_VERSION/100000)
|
||||
# define COMPILER_VERSION_MINOR DEC(__ARMCC_VERSION/10000 % 10)
|
||||
# define COMPILER_VERSION_PATCH DEC(__ARMCC_VERSION % 10000)
|
||||
#endif
|
||||
|
||||
|
||||
#elif defined(__clang__) && defined(__apple_build_version__)
|
||||
# define COMPILER_ID "AppleClang"
|
||||
# if defined(_MSC_VER)
|
||||
# define SIMULATE_ID "MSVC"
|
||||
# endif
|
||||
# define COMPILER_VERSION_MAJOR DEC(__clang_major__)
|
||||
# define COMPILER_VERSION_MINOR DEC(__clang_minor__)
|
||||
# define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__)
|
||||
# if defined(_MSC_VER)
|
||||
/* _MSC_VER = VVRR */
|
||||
# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
|
||||
# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
|
||||
# endif
|
||||
# define COMPILER_VERSION_TWEAK DEC(__apple_build_version__)
|
||||
|
||||
#elif defined(__clang__) && defined(__ARMCOMPILER_VERSION)
|
||||
# define COMPILER_ID "ARMClang"
|
||||
# define COMPILER_VERSION_MAJOR DEC(__ARMCOMPILER_VERSION/1000000)
|
||||
# define COMPILER_VERSION_MINOR DEC(__ARMCOMPILER_VERSION/10000 % 100)
|
||||
# define COMPILER_VERSION_PATCH DEC(__ARMCOMPILER_VERSION/100 % 100)
|
||||
# define COMPILER_VERSION_INTERNAL DEC(__ARMCOMPILER_VERSION)
|
||||
|
||||
#elif defined(__clang__) && defined(__ti__)
|
||||
# define COMPILER_ID "TIClang"
|
||||
# define COMPILER_VERSION_MAJOR DEC(__ti_major__)
|
||||
# define COMPILER_VERSION_MINOR DEC(__ti_minor__)
|
||||
# define COMPILER_VERSION_PATCH DEC(__ti_patchlevel__)
|
||||
# define COMPILER_VERSION_INTERNAL DEC(__ti_version__)
|
||||
|
||||
#elif defined(__clang__)
|
||||
# define COMPILER_ID "Clang"
|
||||
# if defined(_MSC_VER)
|
||||
# define SIMULATE_ID "MSVC"
|
||||
# endif
|
||||
# define COMPILER_VERSION_MAJOR DEC(__clang_major__)
|
||||
# define COMPILER_VERSION_MINOR DEC(__clang_minor__)
|
||||
# define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__)
|
||||
# if defined(_MSC_VER)
|
||||
/* _MSC_VER = VVRR */
|
||||
# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
|
||||
# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
|
||||
# endif
|
||||
|
||||
#elif defined(__LCC__) && (defined(__GNUC__) || defined(__GNUG__) || defined(__MCST__))
|
||||
# define COMPILER_ID "LCC"
|
||||
# define COMPILER_VERSION_MAJOR DEC(__LCC__ / 100)
|
||||
# define COMPILER_VERSION_MINOR DEC(__LCC__ % 100)
|
||||
# if defined(__LCC_MINOR__)
|
||||
# define COMPILER_VERSION_PATCH DEC(__LCC_MINOR__)
|
||||
# endif
|
||||
# if defined(__GNUC__) && defined(__GNUC_MINOR__)
|
||||
# define SIMULATE_ID "GNU"
|
||||
# define SIMULATE_VERSION_MAJOR DEC(__GNUC__)
|
||||
# define SIMULATE_VERSION_MINOR DEC(__GNUC_MINOR__)
|
||||
# if defined(__GNUC_PATCHLEVEL__)
|
||||
# define SIMULATE_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__)
|
||||
# endif
|
||||
# endif
|
||||
|
||||
#elif defined(__GNUC__) || defined(__GNUG__)
|
||||
# define COMPILER_ID "GNU"
|
||||
# if defined(__GNUC__)
|
||||
# define COMPILER_VERSION_MAJOR DEC(__GNUC__)
|
||||
# else
|
||||
# define COMPILER_VERSION_MAJOR DEC(__GNUG__)
|
||||
# endif
|
||||
# if defined(__GNUC_MINOR__)
|
||||
# define COMPILER_VERSION_MINOR DEC(__GNUC_MINOR__)
|
||||
# endif
|
||||
# if defined(__GNUC_PATCHLEVEL__)
|
||||
# define COMPILER_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__)
|
||||
# endif
|
||||
|
||||
#elif defined(_MSC_VER)
|
||||
# define COMPILER_ID "MSVC"
|
||||
/* _MSC_VER = VVRR */
|
||||
# define COMPILER_VERSION_MAJOR DEC(_MSC_VER / 100)
|
||||
# define COMPILER_VERSION_MINOR DEC(_MSC_VER % 100)
|
||||
# if defined(_MSC_FULL_VER)
|
||||
# if _MSC_VER >= 1400
|
||||
/* _MSC_FULL_VER = VVRRPPPPP */
|
||||
# define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 100000)
|
||||
# else
|
||||
/* _MSC_FULL_VER = VVRRPPPP */
|
||||
# define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 10000)
|
||||
# endif
|
||||
# endif
|
||||
# if defined(_MSC_BUILD)
|
||||
# define COMPILER_VERSION_TWEAK DEC(_MSC_BUILD)
|
||||
# endif
|
||||
|
||||
#elif defined(_ADI_COMPILER)
|
||||
# define COMPILER_ID "ADSP"
|
||||
#if defined(__VERSIONNUM__)
|
||||
/* __VERSIONNUM__ = 0xVVRRPPTT */
|
||||
# define COMPILER_VERSION_MAJOR DEC(__VERSIONNUM__ >> 24 & 0xFF)
|
||||
# define COMPILER_VERSION_MINOR DEC(__VERSIONNUM__ >> 16 & 0xFF)
|
||||
# define COMPILER_VERSION_PATCH DEC(__VERSIONNUM__ >> 8 & 0xFF)
|
||||
# define COMPILER_VERSION_TWEAK DEC(__VERSIONNUM__ & 0xFF)
|
||||
#endif
|
||||
|
||||
#elif defined(__IAR_SYSTEMS_ICC__) || defined(__IAR_SYSTEMS_ICC)
|
||||
# define COMPILER_ID "IAR"
|
||||
# if defined(__VER__) && defined(__ICCARM__)
|
||||
# define COMPILER_VERSION_MAJOR DEC((__VER__) / 1000000)
|
||||
# define COMPILER_VERSION_MINOR DEC(((__VER__) / 1000) % 1000)
|
||||
# define COMPILER_VERSION_PATCH DEC((__VER__) % 1000)
|
||||
# define COMPILER_VERSION_INTERNAL DEC(__IAR_SYSTEMS_ICC__)
|
||||
# elif defined(__VER__) && (defined(__ICCAVR__) || defined(__ICCRX__) || defined(__ICCRH850__) || defined(__ICCRL78__) || defined(__ICC430__) || defined(__ICCRISCV__) || defined(__ICCV850__) || defined(__ICC8051__) || defined(__ICCSTM8__))
|
||||
# define COMPILER_VERSION_MAJOR DEC((__VER__) / 100)
|
||||
# define COMPILER_VERSION_MINOR DEC((__VER__) - (((__VER__) / 100)*100))
|
||||
# define COMPILER_VERSION_PATCH DEC(__SUBVERSION__)
|
||||
# define COMPILER_VERSION_INTERNAL DEC(__IAR_SYSTEMS_ICC__)
|
||||
# endif
|
||||
|
||||
#elif defined(__DCC__) && defined(_DIAB_TOOL)
|
||||
# define COMPILER_ID "Diab"
|
||||
# define COMPILER_VERSION_MAJOR DEC(__VERSION_MAJOR_NUMBER__)
|
||||
# define COMPILER_VERSION_MINOR DEC(__VERSION_MINOR_NUMBER__)
|
||||
# define COMPILER_VERSION_PATCH DEC(__VERSION_ARCH_FEATURE_NUMBER__)
|
||||
# define COMPILER_VERSION_TWEAK DEC(__VERSION_BUG_FIX_NUMBER__)
|
||||
|
||||
|
||||
|
||||
/* These compilers are either not known or too old to define an
|
||||
identification macro. Try to identify the platform and guess that
|
||||
it is the native compiler. */
|
||||
#elif defined(__hpux) || defined(__hpua)
|
||||
# define COMPILER_ID "HP"
|
||||
|
||||
#else /* unknown compiler */
|
||||
# define COMPILER_ID ""
|
||||
#endif
|
||||
|
||||
/* Construct the string literal in pieces to prevent the source from
|
||||
getting matched. Store it in a pointer rather than an array
|
||||
because some compilers will just produce instructions to fill the
|
||||
array rather than assigning a pointer to a static array. */
|
||||
char const* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]";
|
||||
#ifdef SIMULATE_ID
|
||||
char const* info_simulate = "INFO" ":" "simulate[" SIMULATE_ID "]";
|
||||
#endif
|
||||
|
||||
#ifdef __QNXNTO__
|
||||
char const* qnxnto = "INFO" ":" "qnxnto[]";
|
||||
#endif
|
||||
|
||||
#if defined(__CRAYXT_COMPUTE_LINUX_TARGET)
|
||||
char const *info_cray = "INFO" ":" "compiler_wrapper[CrayPrgEnv]";
|
||||
#endif
|
||||
|
||||
#define STRINGIFY_HELPER(X) #X
|
||||
#define STRINGIFY(X) STRINGIFY_HELPER(X)
|
||||
|
||||
/* Identify known platforms by name. */
|
||||
#if defined(__linux) || defined(__linux__) || defined(linux)
|
||||
# define PLATFORM_ID "Linux"
|
||||
|
||||
#elif defined(__MSYS__)
|
||||
# define PLATFORM_ID "MSYS"
|
||||
|
||||
#elif defined(__CYGWIN__)
|
||||
# define PLATFORM_ID "Cygwin"
|
||||
|
||||
#elif defined(__MINGW32__)
|
||||
# define PLATFORM_ID "MinGW"
|
||||
|
||||
#elif defined(__APPLE__)
|
||||
# define PLATFORM_ID "Darwin"
|
||||
|
||||
#elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
|
||||
# define PLATFORM_ID "Windows"
|
||||
|
||||
#elif defined(__FreeBSD__) || defined(__FreeBSD)
|
||||
# define PLATFORM_ID "FreeBSD"
|
||||
|
||||
#elif defined(__NetBSD__) || defined(__NetBSD)
|
||||
# define PLATFORM_ID "NetBSD"
|
||||
|
||||
#elif defined(__OpenBSD__) || defined(__OPENBSD)
|
||||
# define PLATFORM_ID "OpenBSD"
|
||||
|
||||
#elif defined(__sun) || defined(sun)
|
||||
# define PLATFORM_ID "SunOS"
|
||||
|
||||
#elif defined(_AIX) || defined(__AIX) || defined(__AIX__) || defined(__aix) || defined(__aix__)
|
||||
# define PLATFORM_ID "AIX"
|
||||
|
||||
#elif defined(__hpux) || defined(__hpux__)
|
||||
# define PLATFORM_ID "HP-UX"
|
||||
|
||||
#elif defined(__HAIKU__)
|
||||
# define PLATFORM_ID "Haiku"
|
||||
|
||||
#elif defined(__BeOS) || defined(__BEOS__) || defined(_BEOS)
|
||||
# define PLATFORM_ID "BeOS"
|
||||
|
||||
#elif defined(__QNX__) || defined(__QNXNTO__)
|
||||
# define PLATFORM_ID "QNX"
|
||||
|
||||
#elif defined(__tru64) || defined(_tru64) || defined(__TRU64__)
|
||||
# define PLATFORM_ID "Tru64"
|
||||
|
||||
#elif defined(__riscos) || defined(__riscos__)
|
||||
# define PLATFORM_ID "RISCos"
|
||||
|
||||
#elif defined(__sinix) || defined(__sinix__) || defined(__SINIX__)
|
||||
# define PLATFORM_ID "SINIX"
|
||||
|
||||
#elif defined(__UNIX_SV__)
|
||||
# define PLATFORM_ID "UNIX_SV"
|
||||
|
||||
#elif defined(__bsdos__)
|
||||
# define PLATFORM_ID "BSDOS"
|
||||
|
||||
#elif defined(_MPRAS) || defined(MPRAS)
|
||||
# define PLATFORM_ID "MP-RAS"
|
||||
|
||||
#elif defined(__osf) || defined(__osf__)
|
||||
# define PLATFORM_ID "OSF1"
|
||||
|
||||
#elif defined(_SCO_SV) || defined(SCO_SV) || defined(sco_sv)
|
||||
# define PLATFORM_ID "SCO_SV"
|
||||
|
||||
#elif defined(__ultrix) || defined(__ultrix__) || defined(_ULTRIX)
|
||||
# define PLATFORM_ID "ULTRIX"
|
||||
|
||||
#elif defined(__XENIX__) || defined(_XENIX) || defined(XENIX)
|
||||
# define PLATFORM_ID "Xenix"
|
||||
|
||||
#elif defined(__WATCOMC__)
|
||||
# if defined(__LINUX__)
|
||||
# define PLATFORM_ID "Linux"
|
||||
|
||||
# elif defined(__DOS__)
|
||||
# define PLATFORM_ID "DOS"
|
||||
|
||||
# elif defined(__OS2__)
|
||||
# define PLATFORM_ID "OS2"
|
||||
|
||||
# elif defined(__WINDOWS__)
|
||||
# define PLATFORM_ID "Windows3x"
|
||||
|
||||
# elif defined(__VXWORKS__)
|
||||
# define PLATFORM_ID "VxWorks"
|
||||
|
||||
# else /* unknown platform */
|
||||
# define PLATFORM_ID
|
||||
# endif
|
||||
|
||||
#elif defined(__INTEGRITY)
|
||||
# if defined(INT_178B)
|
||||
# define PLATFORM_ID "Integrity178"
|
||||
|
||||
# else /* regular Integrity */
|
||||
# define PLATFORM_ID "Integrity"
|
||||
# endif
|
||||
|
||||
# elif defined(_ADI_COMPILER)
|
||||
# define PLATFORM_ID "ADSP"
|
||||
|
||||
#else /* unknown platform */
|
||||
# define PLATFORM_ID
|
||||
|
||||
#endif
|
||||
|
||||
/* For windows compilers MSVC and Intel we can determine
|
||||
the architecture of the compiler being used. This is because
|
||||
the compilers do not have flags that can change the architecture,
|
||||
but rather depend on which compiler is being used
|
||||
*/
|
||||
#if defined(_WIN32) && defined(_MSC_VER)
|
||||
# if defined(_M_IA64)
|
||||
# define ARCHITECTURE_ID "IA64"
|
||||
|
||||
# elif defined(_M_ARM64EC)
|
||||
# define ARCHITECTURE_ID "ARM64EC"
|
||||
|
||||
# elif defined(_M_X64) || defined(_M_AMD64)
|
||||
# define ARCHITECTURE_ID "x64"
|
||||
|
||||
# elif defined(_M_IX86)
|
||||
# define ARCHITECTURE_ID "X86"
|
||||
|
||||
# elif defined(_M_ARM64)
|
||||
# define ARCHITECTURE_ID "ARM64"
|
||||
|
||||
# elif defined(_M_ARM)
|
||||
# if _M_ARM == 4
|
||||
# define ARCHITECTURE_ID "ARMV4I"
|
||||
# elif _M_ARM == 5
|
||||
# define ARCHITECTURE_ID "ARMV5I"
|
||||
# else
|
||||
# define ARCHITECTURE_ID "ARMV" STRINGIFY(_M_ARM)
|
||||
# endif
|
||||
|
||||
# elif defined(_M_MIPS)
|
||||
# define ARCHITECTURE_ID "MIPS"
|
||||
|
||||
# elif defined(_M_SH)
|
||||
# define ARCHITECTURE_ID "SHx"
|
||||
|
||||
# else /* unknown architecture */
|
||||
# define ARCHITECTURE_ID ""
|
||||
# endif
|
||||
|
||||
#elif defined(__WATCOMC__)
|
||||
# if defined(_M_I86)
|
||||
# define ARCHITECTURE_ID "I86"
|
||||
|
||||
# elif defined(_M_IX86)
|
||||
# define ARCHITECTURE_ID "X86"
|
||||
|
||||
# else /* unknown architecture */
|
||||
# define ARCHITECTURE_ID ""
|
||||
# endif
|
||||
|
||||
#elif defined(__IAR_SYSTEMS_ICC__) || defined(__IAR_SYSTEMS_ICC)
|
||||
# if defined(__ICCARM__)
|
||||
# define ARCHITECTURE_ID "ARM"
|
||||
|
||||
# elif defined(__ICCRX__)
|
||||
# define ARCHITECTURE_ID "RX"
|
||||
|
||||
# elif defined(__ICCRH850__)
|
||||
# define ARCHITECTURE_ID "RH850"
|
||||
|
||||
# elif defined(__ICCRL78__)
|
||||
# define ARCHITECTURE_ID "RL78"
|
||||
|
||||
# elif defined(__ICCRISCV__)
|
||||
# define ARCHITECTURE_ID "RISCV"
|
||||
|
||||
# elif defined(__ICCAVR__)
|
||||
# define ARCHITECTURE_ID "AVR"
|
||||
|
||||
# elif defined(__ICC430__)
|
||||
# define ARCHITECTURE_ID "MSP430"
|
||||
|
||||
# elif defined(__ICCV850__)
|
||||
# define ARCHITECTURE_ID "V850"
|
||||
|
||||
# elif defined(__ICC8051__)
|
||||
# define ARCHITECTURE_ID "8051"
|
||||
|
||||
# elif defined(__ICCSTM8__)
|
||||
# define ARCHITECTURE_ID "STM8"
|
||||
|
||||
# else /* unknown architecture */
|
||||
# define ARCHITECTURE_ID ""
|
||||
# endif
|
||||
|
||||
#elif defined(__ghs__)
|
||||
# if defined(__PPC64__)
|
||||
# define ARCHITECTURE_ID "PPC64"
|
||||
|
||||
# elif defined(__ppc__)
|
||||
# define ARCHITECTURE_ID "PPC"
|
||||
|
||||
# elif defined(__ARM__)
|
||||
# define ARCHITECTURE_ID "ARM"
|
||||
|
||||
# elif defined(__x86_64__)
|
||||
# define ARCHITECTURE_ID "x64"
|
||||
|
||||
# elif defined(__i386__)
|
||||
# define ARCHITECTURE_ID "X86"
|
||||
|
||||
# else /* unknown architecture */
|
||||
# define ARCHITECTURE_ID ""
|
||||
# endif
|
||||
|
||||
#elif defined(__clang__) && defined(__ti__)
|
||||
# if defined(__ARM_ARCH)
|
||||
# define ARCHITECTURE_ID "ARM"
|
||||
|
||||
# else /* unknown architecture */
|
||||
# define ARCHITECTURE_ID ""
|
||||
# endif
|
||||
|
||||
#elif defined(__TI_COMPILER_VERSION__)
|
||||
# if defined(__TI_ARM__)
|
||||
# define ARCHITECTURE_ID "ARM"
|
||||
|
||||
# elif defined(__MSP430__)
|
||||
# define ARCHITECTURE_ID "MSP430"
|
||||
|
||||
# elif defined(__TMS320C28XX__)
|
||||
# define ARCHITECTURE_ID "TMS320C28x"
|
||||
|
||||
# elif defined(__TMS320C6X__) || defined(_TMS320C6X)
|
||||
# define ARCHITECTURE_ID "TMS320C6x"
|
||||
|
||||
# else /* unknown architecture */
|
||||
# define ARCHITECTURE_ID ""
|
||||
# endif
|
||||
|
||||
# elif defined(__ADSPSHARC__)
|
||||
# define ARCHITECTURE_ID "SHARC"
|
||||
|
||||
# elif defined(__ADSPBLACKFIN__)
|
||||
# define ARCHITECTURE_ID "Blackfin"
|
||||
|
||||
#elif defined(__TASKING__)
|
||||
|
||||
# if defined(__CTC__) || defined(__CPTC__)
|
||||
# define ARCHITECTURE_ID "TriCore"
|
||||
|
||||
# elif defined(__CMCS__)
|
||||
# define ARCHITECTURE_ID "MCS"
|
||||
|
||||
# elif defined(__CARM__) || defined(__CPARM__)
|
||||
# define ARCHITECTURE_ID "ARM"
|
||||
|
||||
# elif defined(__CARC__)
|
||||
# define ARCHITECTURE_ID "ARC"
|
||||
|
||||
# elif defined(__C51__)
|
||||
# define ARCHITECTURE_ID "8051"
|
||||
|
||||
# elif defined(__CPCP__)
|
||||
# define ARCHITECTURE_ID "PCP"
|
||||
|
||||
# else
|
||||
# define ARCHITECTURE_ID ""
|
||||
# endif
|
||||
|
||||
#elif defined(__RENESAS__)
|
||||
# if defined(__CCRX__)
|
||||
# define ARCHITECTURE_ID "RX"
|
||||
|
||||
# elif defined(__CCRL__)
|
||||
# define ARCHITECTURE_ID "RL78"
|
||||
|
||||
# elif defined(__CCRH__)
|
||||
# define ARCHITECTURE_ID "RH850"
|
||||
|
||||
# else
|
||||
# define ARCHITECTURE_ID ""
|
||||
# endif
|
||||
|
||||
#else
|
||||
# define ARCHITECTURE_ID
|
||||
#endif
|
||||
|
||||
/* Convert integer to decimal digit literals. */
|
||||
#define DEC(n) \
|
||||
('0' + (((n) / 10000000)%10)), \
|
||||
('0' + (((n) / 1000000)%10)), \
|
||||
('0' + (((n) / 100000)%10)), \
|
||||
('0' + (((n) / 10000)%10)), \
|
||||
('0' + (((n) / 1000)%10)), \
|
||||
('0' + (((n) / 100)%10)), \
|
||||
('0' + (((n) / 10)%10)), \
|
||||
('0' + ((n) % 10))
|
||||
|
||||
/* Convert integer to hex digit literals. */
|
||||
#define HEX(n) \
|
||||
('0' + ((n)>>28 & 0xF)), \
|
||||
('0' + ((n)>>24 & 0xF)), \
|
||||
('0' + ((n)>>20 & 0xF)), \
|
||||
('0' + ((n)>>16 & 0xF)), \
|
||||
('0' + ((n)>>12 & 0xF)), \
|
||||
('0' + ((n)>>8 & 0xF)), \
|
||||
('0' + ((n)>>4 & 0xF)), \
|
||||
('0' + ((n) & 0xF))
|
||||
|
||||
/* Construct a string literal encoding the version number. */
|
||||
#ifdef COMPILER_VERSION
|
||||
char const* info_version = "INFO" ":" "compiler_version[" COMPILER_VERSION "]";
|
||||
|
||||
/* Construct a string literal encoding the version number components. */
|
||||
#elif defined(COMPILER_VERSION_MAJOR)
|
||||
char const info_version[] = {
|
||||
'I', 'N', 'F', 'O', ':',
|
||||
'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','[',
|
||||
COMPILER_VERSION_MAJOR,
|
||||
# ifdef COMPILER_VERSION_MINOR
|
||||
'.', COMPILER_VERSION_MINOR,
|
||||
# ifdef COMPILER_VERSION_PATCH
|
||||
'.', COMPILER_VERSION_PATCH,
|
||||
# ifdef COMPILER_VERSION_TWEAK
|
||||
'.', COMPILER_VERSION_TWEAK,
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
']','\0'};
|
||||
#endif
|
||||
|
||||
/* Construct a string literal encoding the internal version number. */
|
||||
#ifdef COMPILER_VERSION_INTERNAL
|
||||
char const info_version_internal[] = {
|
||||
'I', 'N', 'F', 'O', ':',
|
||||
'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','_',
|
||||
'i','n','t','e','r','n','a','l','[',
|
||||
COMPILER_VERSION_INTERNAL,']','\0'};
|
||||
#elif defined(COMPILER_VERSION_INTERNAL_STR)
|
||||
char const* info_version_internal = "INFO" ":" "compiler_version_internal[" COMPILER_VERSION_INTERNAL_STR "]";
|
||||
#endif
|
||||
|
||||
/* Construct a string literal encoding the version number components. */
|
||||
#ifdef SIMULATE_VERSION_MAJOR
|
||||
char const info_simulate_version[] = {
|
||||
'I', 'N', 'F', 'O', ':',
|
||||
's','i','m','u','l','a','t','e','_','v','e','r','s','i','o','n','[',
|
||||
SIMULATE_VERSION_MAJOR,
|
||||
# ifdef SIMULATE_VERSION_MINOR
|
||||
'.', SIMULATE_VERSION_MINOR,
|
||||
# ifdef SIMULATE_VERSION_PATCH
|
||||
'.', SIMULATE_VERSION_PATCH,
|
||||
# ifdef SIMULATE_VERSION_TWEAK
|
||||
'.', SIMULATE_VERSION_TWEAK,
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
']','\0'};
|
||||
#endif
|
||||
|
||||
/* Construct the string literal in pieces to prevent the source from
|
||||
getting matched. Store it in a pointer rather than an array
|
||||
because some compilers will just produce instructions to fill the
|
||||
array rather than assigning a pointer to a static array. */
|
||||
char const* info_platform = "INFO" ":" "platform[" PLATFORM_ID "]";
|
||||
char const* info_arch = "INFO" ":" "arch[" ARCHITECTURE_ID "]";
|
||||
|
||||
|
||||
|
||||
#define CXX_STD_98 199711L
|
||||
#define CXX_STD_11 201103L
|
||||
#define CXX_STD_14 201402L
|
||||
#define CXX_STD_17 201703L
|
||||
#define CXX_STD_20 202002L
|
||||
#define CXX_STD_23 202302L
|
||||
|
||||
#if defined(__INTEL_COMPILER) && defined(_MSVC_LANG)
|
||||
# if _MSVC_LANG > CXX_STD_17
|
||||
# define CXX_STD _MSVC_LANG
|
||||
# elif _MSVC_LANG == CXX_STD_17 && defined(__cpp_aggregate_paren_init)
|
||||
# define CXX_STD CXX_STD_20
|
||||
# elif _MSVC_LANG > CXX_STD_14 && __cplusplus > CXX_STD_17
|
||||
# define CXX_STD CXX_STD_20
|
||||
# elif _MSVC_LANG > CXX_STD_14
|
||||
# define CXX_STD CXX_STD_17
|
||||
# elif defined(__INTEL_CXX11_MODE__) && defined(__cpp_aggregate_nsdmi)
|
||||
# define CXX_STD CXX_STD_14
|
||||
# elif defined(__INTEL_CXX11_MODE__)
|
||||
# define CXX_STD CXX_STD_11
|
||||
# else
|
||||
# define CXX_STD CXX_STD_98
|
||||
# endif
|
||||
#elif defined(_MSC_VER) && defined(_MSVC_LANG)
|
||||
# if _MSVC_LANG > __cplusplus
|
||||
# define CXX_STD _MSVC_LANG
|
||||
# else
|
||||
# define CXX_STD __cplusplus
|
||||
# endif
|
||||
#elif defined(__NVCOMPILER)
|
||||
# if __cplusplus == CXX_STD_17 && defined(__cpp_aggregate_paren_init)
|
||||
# define CXX_STD CXX_STD_20
|
||||
# else
|
||||
# define CXX_STD __cplusplus
|
||||
# endif
|
||||
#elif defined(__INTEL_COMPILER) || defined(__PGI)
|
||||
# if __cplusplus == CXX_STD_11 && defined(__cpp_namespace_attributes)
|
||||
# define CXX_STD CXX_STD_17
|
||||
# elif __cplusplus == CXX_STD_11 && defined(__cpp_aggregate_nsdmi)
|
||||
# define CXX_STD CXX_STD_14
|
||||
# else
|
||||
# define CXX_STD __cplusplus
|
||||
# endif
|
||||
#elif (defined(__IBMCPP__) || defined(__ibmxl__)) && defined(__linux__)
|
||||
# if __cplusplus == CXX_STD_11 && defined(__cpp_aggregate_nsdmi)
|
||||
# define CXX_STD CXX_STD_14
|
||||
# else
|
||||
# define CXX_STD __cplusplus
|
||||
# endif
|
||||
#elif __cplusplus == 1 && defined(__GXX_EXPERIMENTAL_CXX0X__)
|
||||
# define CXX_STD CXX_STD_11
|
||||
#else
|
||||
# define CXX_STD __cplusplus
|
||||
#endif
|
||||
|
||||
const char* info_language_standard_default = "INFO" ":" "standard_default["
|
||||
#if CXX_STD > CXX_STD_23
|
||||
"26"
|
||||
#elif CXX_STD > CXX_STD_20
|
||||
"23"
|
||||
#elif CXX_STD > CXX_STD_17
|
||||
"20"
|
||||
#elif CXX_STD > CXX_STD_14
|
||||
"17"
|
||||
#elif CXX_STD > CXX_STD_11
|
||||
"14"
|
||||
#elif CXX_STD >= CXX_STD_11
|
||||
"11"
|
||||
#else
|
||||
"98"
|
||||
#endif
|
||||
"]";
|
||||
|
||||
const char* info_language_extensions_default = "INFO" ":" "extensions_default["
|
||||
#if (defined(__clang__) || defined(__GNUC__) || defined(__xlC__) || \
|
||||
defined(__TI_COMPILER_VERSION__) || defined(__RENESAS__)) && \
|
||||
!defined(__STRICT_ANSI__)
|
||||
"ON"
|
||||
#else
|
||||
"OFF"
|
||||
#endif
|
||||
"]";
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
int require = 0;
|
||||
require += info_compiler[argc];
|
||||
require += info_platform[argc];
|
||||
require += info_arch[argc];
|
||||
#ifdef COMPILER_VERSION_MAJOR
|
||||
require += info_version[argc];
|
||||
#endif
|
||||
#if defined(COMPILER_VERSION_INTERNAL) || defined(COMPILER_VERSION_INTERNAL_STR)
|
||||
require += info_version_internal[argc];
|
||||
#endif
|
||||
#ifdef SIMULATE_ID
|
||||
require += info_simulate[argc];
|
||||
#endif
|
||||
#ifdef SIMULATE_VERSION_MAJOR
|
||||
require += info_simulate_version[argc];
|
||||
#endif
|
||||
#if defined(__CRAYXT_COMPUTE_LINUX_TARGET)
|
||||
require += info_cray[argc];
|
||||
#endif
|
||||
require += info_language_standard_default[argc];
|
||||
require += info_language_extensions_default[argc];
|
||||
(void)argv;
|
||||
return require;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,16 @@
|
||||
# CMAKE generated file: DO NOT EDIT!
|
||||
# Generated by "Unix Makefiles" Generator, CMake Version 4.3
|
||||
|
||||
# Relative path conversion top directories.
|
||||
set(CMAKE_RELATIVE_PATH_TOP_SOURCE "/home/alardner/cl_polyparti")
|
||||
set(CMAKE_RELATIVE_PATH_TOP_BINARY "/home/alardner/cl_polyparti/build")
|
||||
|
||||
# Force unix paths in dependencies.
|
||||
set(CMAKE_FORCE_UNIX_PATHS 1)
|
||||
|
||||
|
||||
# The C and CXX include file regular expressions for this directory.
|
||||
set(CMAKE_C_INCLUDE_REGEX_SCAN "^.*$")
|
||||
set(CMAKE_C_INCLUDE_REGEX_COMPLAIN "^$")
|
||||
set(CMAKE_CXX_INCLUDE_REGEX_SCAN ${CMAKE_C_INCLUDE_REGEX_SCAN})
|
||||
set(CMAKE_CXX_INCLUDE_REGEX_COMPLAIN ${CMAKE_C_INCLUDE_REGEX_COMPLAIN})
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"InstallScripts" :
|
||||
[
|
||||
"/home/alardner/cl_polyparti/build/cmake_install.cmake"
|
||||
],
|
||||
"Parallel" : false
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
# CMAKE generated file: DO NOT EDIT!
|
||||
# Generated by "Unix Makefiles" Generator, CMake Version 4.3
|
||||
|
||||
# The generator used is:
|
||||
set(CMAKE_DEPENDS_GENERATOR "Unix Makefiles")
|
||||
|
||||
# The top level Makefile was generated from the following files:
|
||||
set(CMAKE_MAKEFILE_DEPENDS
|
||||
"CMakeCache.txt"
|
||||
"/home/alardner/cl_polyparti/CMakeLists.txt"
|
||||
"CMakeFiles/4.3.3/CMakeCXXCompiler.cmake"
|
||||
"CMakeFiles/4.3.3/CMakeSystem.cmake"
|
||||
"CMakeFiles/VerifyGlobs.cmake"
|
||||
"CMakeFiles/cmake.verify_globs"
|
||||
"/opt/intel/oneapi/compiler/2026.0/lib/cmake/IntelSYCL/IntelSYCLConfig.cmake"
|
||||
"/opt/intel/oneapi/compiler/2026.0/lib/cmake/IntelSYCL/IntelSYCLConfigVersion.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/CMakeCXXCompiler.cmake.in"
|
||||
"/usr/share/cmake-4.3/Modules/CMakeCXXCompilerABI.cpp"
|
||||
"/usr/share/cmake-4.3/Modules/CMakeCXXInformation.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/CMakeCommonLanguageInclude.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/CMakeCompilerIdDetection.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/CMakeDetermineCXXCompiler.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/CMakeDetermineCompiler.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/CMakeDetermineCompilerABI.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/CMakeDetermineCompilerId.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/CMakeDetermineCompilerSupport.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/CMakeDetermineSystem.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/CMakeFindBinUtils.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/CMakeGenericSystem.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/CMakeInitializeConfigs.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/CMakeLanguageInformation.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/CMakeParseImplicitIncludeInfo.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/CMakeParseImplicitLinkInfo.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/CMakeParseLibraryArchitecture.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/CMakeSystem.cmake.in"
|
||||
"/usr/share/cmake-4.3/Modules/CMakeSystemSpecificInformation.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/CMakeSystemSpecificInitialize.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/CMakeTestCXXCompiler.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/CMakeTestCompilerCommon.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/CMakeUnixFindMake.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/Compiler/ADSP-DetermineCompiler.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/Compiler/ARMCC-DetermineCompiler.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/Compiler/ARMClang-DetermineCompiler.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/Compiler/AppleClang-DetermineCompiler.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/Compiler/Borland-DetermineCompiler.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/Compiler/CMakeCommonCompilerMacros.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/Compiler/Clang-DetermineCompiler.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/Compiler/Clang-DetermineCompilerInternal.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/Compiler/Compaq-CXX-DetermineCompiler.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/Compiler/Cray-DetermineCompiler.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/Compiler/CrayClang-DetermineCompiler.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/Compiler/Diab-DetermineCompiler.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/Compiler/Embarcadero-DetermineCompiler.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/Compiler/Fujitsu-DetermineCompiler.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/Compiler/FujitsuClang-DetermineCompiler.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/Compiler/GHS-DetermineCompiler.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/Compiler/GNU-CXX-DetermineCompiler.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/Compiler/HP-CXX-DetermineCompiler.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/Compiler/IAR-DetermineCompiler.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/Compiler/IBMCPP-CXX-DetermineVersionInternal.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/Compiler/IBMClang-CXX-DetermineCompiler.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/Compiler/Intel-DetermineCompiler.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/Compiler/IntelLLVM-CXX.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/Compiler/IntelLLVM-DetermineCompiler.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/Compiler/IntelLLVM-FindBinUtils.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/Compiler/IntelLLVM.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/Compiler/LCC-CXX-DetermineCompiler.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/Compiler/MSVC-DetermineCompiler.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/Compiler/NVHPC-DetermineCompiler.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/Compiler/NVIDIA-DetermineCompiler.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/Compiler/OpenWatcom-DetermineCompiler.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/Compiler/OrangeC-DetermineCompiler.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/Compiler/PGI-DetermineCompiler.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/Compiler/PathScale-DetermineCompiler.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/Compiler/Renesas-DetermineCompiler.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/Compiler/SCO-DetermineCompiler.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/Compiler/SunPro-CXX-DetermineCompiler.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/Compiler/TI-DetermineCompiler.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/Compiler/TIClang-DetermineCompiler.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/Compiler/Tasking-DetermineCompiler.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/Compiler/VisualAge-CXX-DetermineCompiler.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/Compiler/Watcom-DetermineCompiler.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/Compiler/XL-CXX-DetermineCompiler.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/Compiler/XLClang-CXX-DetermineCompiler.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/Compiler/zOS-CXX-DetermineCompiler.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/FindPackageHandleStandardArgs.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/FindPackageMessage.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/FindPkgConfig.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/Internal/CMakeCXXLinkerInformation.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/Internal/CMakeCommonLinkerInformation.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/Internal/CMakeDetermineLinkerId.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/Internal/CMakeInspectCXXLinker.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/Internal/FeatureTesting.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/Linker/GNU-CXX.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/Linker/GNU.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/Platform/Linker/GNU.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/Platform/Linker/Linux-GNU-CXX.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/Platform/Linker/Linux-GNU.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/Platform/Linux-Determine-CXX.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/Platform/Linux-Initialize.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/Platform/Linux-IntelLLVM-CXX.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/Platform/Linux-IntelLLVM.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/Platform/Linux.cmake"
|
||||
"/usr/share/cmake-4.3/Modules/Platform/UnixPaths.cmake"
|
||||
)
|
||||
|
||||
# The corresponding makefile is:
|
||||
set(CMAKE_MAKEFILE_OUTPUTS
|
||||
"Makefile"
|
||||
"CMakeFiles/cmake.check_cache"
|
||||
)
|
||||
|
||||
# Byproducts of CMake generate step:
|
||||
set(CMAKE_MAKEFILE_PRODUCTS
|
||||
"CMakeFiles/4.3.3/CMakeSystem.cmake"
|
||||
"CMakeFiles/4.3.3/CMakeCXXCompiler.cmake"
|
||||
"CMakeFiles/4.3.3/CMakeCXXCompiler.cmake"
|
||||
"CMakeFiles/4.3.3/CMakeCXXCompiler.cmake"
|
||||
"CMakeFiles/CMakeDirectoryInformation.cmake"
|
||||
)
|
||||
|
||||
# Dependency information for all targets:
|
||||
set(CMAKE_DEPEND_INFO_FILES
|
||||
"CMakeFiles/cl_polyparti.dir/DependInfo.cmake"
|
||||
)
|
||||
@@ -0,0 +1,123 @@
|
||||
# CMAKE generated file: DO NOT EDIT!
|
||||
# Generated by "Unix Makefiles" Generator, CMake Version 4.3
|
||||
|
||||
# Default target executed when no arguments are given to make.
|
||||
default_target: all
|
||||
.PHONY : default_target
|
||||
|
||||
#=============================================================================
|
||||
# Special targets provided by cmake.
|
||||
|
||||
# Disable implicit rules so canonical targets will work.
|
||||
.SUFFIXES:
|
||||
|
||||
# Disable VCS-based implicit rules.
|
||||
% : %,v
|
||||
|
||||
# Disable VCS-based implicit rules.
|
||||
% : RCS/%
|
||||
|
||||
# Disable VCS-based implicit rules.
|
||||
% : RCS/%,v
|
||||
|
||||
# Disable VCS-based implicit rules.
|
||||
% : SCCS/s.%
|
||||
|
||||
# Disable VCS-based implicit rules.
|
||||
% : s.%
|
||||
|
||||
.SUFFIXES: .hpux_make_needs_suffix_list
|
||||
|
||||
# Command-line flag to silence nested $(MAKE).
|
||||
$(VERBOSE)MAKESILENT = -s
|
||||
|
||||
#Suppress display of executed commands.
|
||||
$(VERBOSE).SILENT:
|
||||
|
||||
# A target that is always out of date.
|
||||
cmake_force:
|
||||
.PHONY : cmake_force
|
||||
|
||||
#=============================================================================
|
||||
# Set environment variables for the build.
|
||||
|
||||
# The shell in which to execute make rules.
|
||||
SHELL = /bin/sh
|
||||
|
||||
# The CMake executable.
|
||||
CMAKE_COMMAND = /usr/bin/cmake
|
||||
|
||||
# The command to remove a file.
|
||||
RM = /usr/bin/cmake -E rm -f
|
||||
|
||||
# Escaping for special characters.
|
||||
EQUALS = =
|
||||
|
||||
# The top-level source directory on which CMake was run.
|
||||
CMAKE_SOURCE_DIR = /home/alardner/cl_polyparti
|
||||
|
||||
# The top-level build directory on which CMake was run.
|
||||
CMAKE_BINARY_DIR = /home/alardner/cl_polyparti/build
|
||||
|
||||
#=============================================================================
|
||||
# Directory level rules for the build root directory
|
||||
|
||||
# The main recursive "all" target.
|
||||
all: CMakeFiles/cl_polyparti.dir/all
|
||||
.PHONY : all
|
||||
|
||||
# The main recursive "codegen" target.
|
||||
codegen: CMakeFiles/cl_polyparti.dir/codegen
|
||||
.PHONY : codegen
|
||||
|
||||
# The main recursive "preinstall" target.
|
||||
preinstall:
|
||||
.PHONY : preinstall
|
||||
|
||||
# The main recursive "clean" target.
|
||||
clean: CMakeFiles/cl_polyparti.dir/clean
|
||||
.PHONY : clean
|
||||
|
||||
#=============================================================================
|
||||
# Target rules for target CMakeFiles/cl_polyparti.dir
|
||||
|
||||
# All Build rule for target.
|
||||
CMakeFiles/cl_polyparti.dir/all:
|
||||
$(MAKE) $(MAKESILENT) -f CMakeFiles/cl_polyparti.dir/build.make CMakeFiles/cl_polyparti.dir/depend
|
||||
$(MAKE) $(MAKESILENT) -f CMakeFiles/cl_polyparti.dir/build.make CMakeFiles/cl_polyparti.dir/build
|
||||
@$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --progress-dir=/home/alardner/cl_polyparti/build/CMakeFiles --progress-num=1,2,3 "Built target cl_polyparti"
|
||||
.PHONY : CMakeFiles/cl_polyparti.dir/all
|
||||
|
||||
# Build rule for subdir invocation for target.
|
||||
CMakeFiles/cl_polyparti.dir/rule: cmake_check_build_system
|
||||
$(CMAKE_COMMAND) -E cmake_progress_start /home/alardner/cl_polyparti/build/CMakeFiles 3
|
||||
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 CMakeFiles/cl_polyparti.dir/all
|
||||
$(CMAKE_COMMAND) -E cmake_progress_start /home/alardner/cl_polyparti/build/CMakeFiles 0
|
||||
.PHONY : CMakeFiles/cl_polyparti.dir/rule
|
||||
|
||||
# Convenience name for target.
|
||||
cl_polyparti: CMakeFiles/cl_polyparti.dir/rule
|
||||
.PHONY : cl_polyparti
|
||||
|
||||
# codegen rule for target.
|
||||
CMakeFiles/cl_polyparti.dir/codegen:
|
||||
$(MAKE) $(MAKESILENT) -f CMakeFiles/cl_polyparti.dir/build.make CMakeFiles/cl_polyparti.dir/codegen
|
||||
@$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --progress-dir=/home/alardner/cl_polyparti/build/CMakeFiles --progress-num=1,2,3 "Finished codegen for target cl_polyparti"
|
||||
.PHONY : CMakeFiles/cl_polyparti.dir/codegen
|
||||
|
||||
# clean rule for target.
|
||||
CMakeFiles/cl_polyparti.dir/clean:
|
||||
$(MAKE) $(MAKESILENT) -f CMakeFiles/cl_polyparti.dir/build.make CMakeFiles/cl_polyparti.dir/clean
|
||||
.PHONY : CMakeFiles/cl_polyparti.dir/clean
|
||||
|
||||
#=============================================================================
|
||||
# Special targets to cleanup operation of make.
|
||||
|
||||
# Special rule to run CMake to check the build system integrity.
|
||||
# No rule that depends on this can have commands that come from listfiles
|
||||
# because they might be regenerated.
|
||||
cmake_check_build_system:
|
||||
$(CMAKE_COMMAND) -P /home/alardner/cl_polyparti/build/CMakeFiles/VerifyGlobs.cmake
|
||||
$(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0
|
||||
.PHONY : cmake_check_build_system
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
int main(){
|
||||
#if defined(SYCL_LANGUAGE_VERSION)
|
||||
cout << "SYCL_LANGUAGE_VERSION="<<SYCL_LANGUAGE_VERSION<<endl;
|
||||
#endif
|
||||
return 0;}
|
||||
@@ -0,0 +1,3 @@
|
||||
/home/alardner/cl_polyparti/build/CMakeFiles/cl_polyparti.dir
|
||||
/home/alardner/cl_polyparti/build/CMakeFiles/edit_cache.dir
|
||||
/home/alardner/cl_polyparti/build/CMakeFiles/rebuild_cache.dir
|
||||
@@ -0,0 +1,29 @@
|
||||
# CMAKE generated file: DO NOT EDIT!
|
||||
# Generated by CMake Version 4.3
|
||||
|
||||
# PROJECT_SOURCES at CMakeLists.txt:10 (file)
|
||||
file(GLOB_RECURSE NEW_GLOB LIST_DIRECTORIES false "/home/alardner/cl_polyparti/*.cpp")
|
||||
set(OLD_GLOB
|
||||
"/home/alardner/cl_polyparti/build/CMakeFiles/4.3.3/CompilerIdCXX/CMakeCXXCompilerId.cpp"
|
||||
"/home/alardner/cl_polyparti/build/CMakeFiles/TESTSYCL/sycl_features.cpp"
|
||||
)
|
||||
if(NOT "${NEW_GLOB}" STREQUAL "${OLD_GLOB}")
|
||||
message("-- GLOB mismatch!")
|
||||
set(NEW_ONLY ${NEW_GLOB})
|
||||
set(OLD_ONLY ${OLD_GLOB})
|
||||
list(REMOVE_ITEM NEW_ONLY ${OLD_GLOB})
|
||||
list(REMOVE_ITEM OLD_ONLY ${NEW_GLOB})
|
||||
if(NEW_ONLY)
|
||||
message("The following files were added:")
|
||||
foreach(VAR_FILE IN LISTS NEW_ONLY)
|
||||
message(" +${VAR_FILE}")
|
||||
endforeach()
|
||||
endif()
|
||||
if(OLD_ONLY)
|
||||
message("The following files were removed:")
|
||||
foreach(VAR_FILE IN LISTS OLD_ONLY)
|
||||
message(" -${VAR_FILE}")
|
||||
endforeach()
|
||||
endif()
|
||||
file(TOUCH_NOCREATE "/home/alardner/cl_polyparti/build/CMakeFiles/cmake.verify_globs")
|
||||
endif()
|
||||
@@ -0,0 +1,25 @@
|
||||
|
||||
# Consider dependencies only in project.
|
||||
set(CMAKE_DEPENDS_IN_PROJECT_ONLY OFF)
|
||||
|
||||
# The set of languages for which implicit dependencies are needed:
|
||||
set(CMAKE_DEPENDS_LANGUAGES
|
||||
)
|
||||
|
||||
# The set of dependency files which are needed:
|
||||
set(CMAKE_DEPENDS_DEPENDENCY_FILES
|
||||
"/home/alardner/cl_polyparti/build/CMakeFiles/4.3.3/CompilerIdCXX/CMakeCXXCompilerId.cpp" "CMakeFiles/cl_polyparti.dir/CMakeFiles/4.3.3/CompilerIdCXX/CMakeCXXCompilerId.cpp.o" "gcc" "CMakeFiles/cl_polyparti.dir/CMakeFiles/4.3.3/CompilerIdCXX/CMakeCXXCompilerId.cpp.o.d"
|
||||
"/home/alardner/cl_polyparti/build/CMakeFiles/TESTSYCL/sycl_features.cpp" "CMakeFiles/cl_polyparti.dir/CMakeFiles/TESTSYCL/sycl_features.cpp.o" "gcc" "CMakeFiles/cl_polyparti.dir/CMakeFiles/TESTSYCL/sycl_features.cpp.o.d"
|
||||
"" "cl_polyparti" "gcc" "CMakeFiles/cl_polyparti.dir/link.d"
|
||||
)
|
||||
|
||||
# Targets to which this target links which contain Fortran sources.
|
||||
set(CMAKE_Fortran_TARGET_LINKED_INFO_FILES
|
||||
)
|
||||
|
||||
# Targets to which this target links which contain Fortran sources.
|
||||
set(CMAKE_Fortran_TARGET_FORWARD_LINKED_INFO_FILES
|
||||
)
|
||||
|
||||
# Fortran module output directory.
|
||||
set(CMAKE_Fortran_TARGET_MODULE_DIR "")
|
||||
@@ -0,0 +1,130 @@
|
||||
# CMAKE generated file: DO NOT EDIT!
|
||||
# Generated by "Unix Makefiles" Generator, CMake Version 4.3
|
||||
|
||||
# Delete rule output on recipe failure.
|
||||
.DELETE_ON_ERROR:
|
||||
|
||||
#=============================================================================
|
||||
# Special targets provided by cmake.
|
||||
|
||||
# Disable implicit rules so canonical targets will work.
|
||||
.SUFFIXES:
|
||||
|
||||
# Disable VCS-based implicit rules.
|
||||
% : %,v
|
||||
|
||||
# Disable VCS-based implicit rules.
|
||||
% : RCS/%
|
||||
|
||||
# Disable VCS-based implicit rules.
|
||||
% : RCS/%,v
|
||||
|
||||
# Disable VCS-based implicit rules.
|
||||
% : SCCS/s.%
|
||||
|
||||
# Disable VCS-based implicit rules.
|
||||
% : s.%
|
||||
|
||||
.SUFFIXES: .hpux_make_needs_suffix_list
|
||||
|
||||
# Command-line flag to silence nested $(MAKE).
|
||||
$(VERBOSE)MAKESILENT = -s
|
||||
|
||||
#Suppress display of executed commands.
|
||||
$(VERBOSE).SILENT:
|
||||
|
||||
# A target that is always out of date.
|
||||
cmake_force:
|
||||
.PHONY : cmake_force
|
||||
|
||||
#=============================================================================
|
||||
# Set environment variables for the build.
|
||||
|
||||
# The shell in which to execute make rules.
|
||||
SHELL = /bin/sh
|
||||
|
||||
# The CMake executable.
|
||||
CMAKE_COMMAND = /usr/bin/cmake
|
||||
|
||||
# The command to remove a file.
|
||||
RM = /usr/bin/cmake -E rm -f
|
||||
|
||||
# Escaping for special characters.
|
||||
EQUALS = =
|
||||
|
||||
# The top-level source directory on which CMake was run.
|
||||
CMAKE_SOURCE_DIR = /home/alardner/cl_polyparti
|
||||
|
||||
# The top-level build directory on which CMake was run.
|
||||
CMAKE_BINARY_DIR = /home/alardner/cl_polyparti/build
|
||||
|
||||
# Include any dependencies generated for this target.
|
||||
include CMakeFiles/cl_polyparti.dir/depend.make
|
||||
# Include any dependencies generated by the compiler for this target.
|
||||
include CMakeFiles/cl_polyparti.dir/compiler_depend.make
|
||||
|
||||
# Include the progress variables for this target.
|
||||
include CMakeFiles/cl_polyparti.dir/progress.make
|
||||
|
||||
# Include the compile flags for this target's objects.
|
||||
include CMakeFiles/cl_polyparti.dir/flags.make
|
||||
|
||||
CMakeFiles/cl_polyparti.dir/codegen:
|
||||
.PHONY : CMakeFiles/cl_polyparti.dir/codegen
|
||||
|
||||
CMakeFiles/cl_polyparti.dir/CMakeFiles/4.3.3/CompilerIdCXX/CMakeCXXCompilerId.cpp.o: CMakeFiles/cl_polyparti.dir/flags.make
|
||||
CMakeFiles/cl_polyparti.dir/CMakeFiles/4.3.3/CompilerIdCXX/CMakeCXXCompilerId.cpp.o: CMakeFiles/4.3.3/CompilerIdCXX/CMakeCXXCompilerId.cpp
|
||||
CMakeFiles/cl_polyparti.dir/CMakeFiles/4.3.3/CompilerIdCXX/CMakeCXXCompilerId.cpp.o: CMakeFiles/cl_polyparti.dir/compiler_depend.ts
|
||||
@$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --green --progress-dir=/home/alardner/cl_polyparti/build/CMakeFiles --progress-num=$(CMAKE_PROGRESS_1) "Building CXX object CMakeFiles/cl_polyparti.dir/CMakeFiles/4.3.3/CompilerIdCXX/CMakeCXXCompilerId.cpp.o"
|
||||
/opt/intel/oneapi/compiler/2026.0/bin/icpx $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -MD -MT CMakeFiles/cl_polyparti.dir/CMakeFiles/4.3.3/CompilerIdCXX/CMakeCXXCompilerId.cpp.o -MF CMakeFiles/cl_polyparti.dir/CMakeFiles/4.3.3/CompilerIdCXX/CMakeCXXCompilerId.cpp.o.d -o CMakeFiles/cl_polyparti.dir/CMakeFiles/4.3.3/CompilerIdCXX/CMakeCXXCompilerId.cpp.o -c /home/alardner/cl_polyparti/build/CMakeFiles/4.3.3/CompilerIdCXX/CMakeCXXCompilerId.cpp
|
||||
|
||||
CMakeFiles/cl_polyparti.dir/CMakeFiles/4.3.3/CompilerIdCXX/CMakeCXXCompilerId.cpp.i: cmake_force
|
||||
@$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --green "Preprocessing CXX source to CMakeFiles/cl_polyparti.dir/CMakeFiles/4.3.3/CompilerIdCXX/CMakeCXXCompilerId.cpp.i"
|
||||
/opt/intel/oneapi/compiler/2026.0/bin/icpx $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -E /home/alardner/cl_polyparti/build/CMakeFiles/4.3.3/CompilerIdCXX/CMakeCXXCompilerId.cpp > CMakeFiles/cl_polyparti.dir/CMakeFiles/4.3.3/CompilerIdCXX/CMakeCXXCompilerId.cpp.i
|
||||
|
||||
CMakeFiles/cl_polyparti.dir/CMakeFiles/4.3.3/CompilerIdCXX/CMakeCXXCompilerId.cpp.s: cmake_force
|
||||
@$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --green "Compiling CXX source to assembly CMakeFiles/cl_polyparti.dir/CMakeFiles/4.3.3/CompilerIdCXX/CMakeCXXCompilerId.cpp.s"
|
||||
/opt/intel/oneapi/compiler/2026.0/bin/icpx $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -S /home/alardner/cl_polyparti/build/CMakeFiles/4.3.3/CompilerIdCXX/CMakeCXXCompilerId.cpp -o CMakeFiles/cl_polyparti.dir/CMakeFiles/4.3.3/CompilerIdCXX/CMakeCXXCompilerId.cpp.s
|
||||
|
||||
CMakeFiles/cl_polyparti.dir/CMakeFiles/TESTSYCL/sycl_features.cpp.o: CMakeFiles/cl_polyparti.dir/flags.make
|
||||
CMakeFiles/cl_polyparti.dir/CMakeFiles/TESTSYCL/sycl_features.cpp.o: CMakeFiles/TESTSYCL/sycl_features.cpp
|
||||
CMakeFiles/cl_polyparti.dir/CMakeFiles/TESTSYCL/sycl_features.cpp.o: CMakeFiles/cl_polyparti.dir/compiler_depend.ts
|
||||
@$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --green --progress-dir=/home/alardner/cl_polyparti/build/CMakeFiles --progress-num=$(CMAKE_PROGRESS_2) "Building CXX object CMakeFiles/cl_polyparti.dir/CMakeFiles/TESTSYCL/sycl_features.cpp.o"
|
||||
/opt/intel/oneapi/compiler/2026.0/bin/icpx $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -MD -MT CMakeFiles/cl_polyparti.dir/CMakeFiles/TESTSYCL/sycl_features.cpp.o -MF CMakeFiles/cl_polyparti.dir/CMakeFiles/TESTSYCL/sycl_features.cpp.o.d -o CMakeFiles/cl_polyparti.dir/CMakeFiles/TESTSYCL/sycl_features.cpp.o -c /home/alardner/cl_polyparti/build/CMakeFiles/TESTSYCL/sycl_features.cpp
|
||||
|
||||
CMakeFiles/cl_polyparti.dir/CMakeFiles/TESTSYCL/sycl_features.cpp.i: cmake_force
|
||||
@$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --green "Preprocessing CXX source to CMakeFiles/cl_polyparti.dir/CMakeFiles/TESTSYCL/sycl_features.cpp.i"
|
||||
/opt/intel/oneapi/compiler/2026.0/bin/icpx $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -E /home/alardner/cl_polyparti/build/CMakeFiles/TESTSYCL/sycl_features.cpp > CMakeFiles/cl_polyparti.dir/CMakeFiles/TESTSYCL/sycl_features.cpp.i
|
||||
|
||||
CMakeFiles/cl_polyparti.dir/CMakeFiles/TESTSYCL/sycl_features.cpp.s: cmake_force
|
||||
@$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --green "Compiling CXX source to assembly CMakeFiles/cl_polyparti.dir/CMakeFiles/TESTSYCL/sycl_features.cpp.s"
|
||||
/opt/intel/oneapi/compiler/2026.0/bin/icpx $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -S /home/alardner/cl_polyparti/build/CMakeFiles/TESTSYCL/sycl_features.cpp -o CMakeFiles/cl_polyparti.dir/CMakeFiles/TESTSYCL/sycl_features.cpp.s
|
||||
|
||||
# Object files for target cl_polyparti
|
||||
cl_polyparti_OBJECTS = \
|
||||
"CMakeFiles/cl_polyparti.dir/CMakeFiles/4.3.3/CompilerIdCXX/CMakeCXXCompilerId.cpp.o" \
|
||||
"CMakeFiles/cl_polyparti.dir/CMakeFiles/TESTSYCL/sycl_features.cpp.o"
|
||||
|
||||
# External object files for target cl_polyparti
|
||||
cl_polyparti_EXTERNAL_OBJECTS =
|
||||
|
||||
cl_polyparti: CMakeFiles/cl_polyparti.dir/CMakeFiles/4.3.3/CompilerIdCXX/CMakeCXXCompilerId.cpp.o
|
||||
cl_polyparti: CMakeFiles/cl_polyparti.dir/CMakeFiles/TESTSYCL/sycl_features.cpp.o
|
||||
cl_polyparti: CMakeFiles/cl_polyparti.dir/build.make
|
||||
cl_polyparti: CMakeFiles/cl_polyparti.dir/compiler_depend.ts
|
||||
cl_polyparti: CMakeFiles/cl_polyparti.dir/link.txt
|
||||
@$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --green --bold --progress-dir=/home/alardner/cl_polyparti/build/CMakeFiles --progress-num=$(CMAKE_PROGRESS_3) "Linking CXX executable cl_polyparti"
|
||||
$(CMAKE_COMMAND) -E cmake_link_script CMakeFiles/cl_polyparti.dir/link.txt --verbose=$(VERBOSE)
|
||||
|
||||
# Rule to build all files generated by this target.
|
||||
CMakeFiles/cl_polyparti.dir/build: cl_polyparti
|
||||
.PHONY : CMakeFiles/cl_polyparti.dir/build
|
||||
|
||||
CMakeFiles/cl_polyparti.dir/clean:
|
||||
$(CMAKE_COMMAND) -P CMakeFiles/cl_polyparti.dir/cmake_clean.cmake
|
||||
.PHONY : CMakeFiles/cl_polyparti.dir/clean
|
||||
|
||||
CMakeFiles/cl_polyparti.dir/depend:
|
||||
cd /home/alardner/cl_polyparti/build && $(CMAKE_COMMAND) -E cmake_depends "Unix Makefiles" /home/alardner/cl_polyparti /home/alardner/cl_polyparti /home/alardner/cl_polyparti/build /home/alardner/cl_polyparti/build /home/alardner/cl_polyparti/build/CMakeFiles/cl_polyparti.dir/DependInfo.cmake "--color=$(COLOR)" cl_polyparti
|
||||
.PHONY : CMakeFiles/cl_polyparti.dir/depend
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
file(REMOVE_RECURSE
|
||||
"CMakeFiles/cl_polyparti.dir/link.d"
|
||||
"CMakeFiles/cl_polyparti.dir/CMakeFiles/4.3.3/CompilerIdCXX/CMakeCXXCompilerId.cpp.o"
|
||||
"CMakeFiles/cl_polyparti.dir/CMakeFiles/4.3.3/CompilerIdCXX/CMakeCXXCompilerId.cpp.o.d"
|
||||
"CMakeFiles/cl_polyparti.dir/CMakeFiles/TESTSYCL/sycl_features.cpp.o"
|
||||
"CMakeFiles/cl_polyparti.dir/CMakeFiles/TESTSYCL/sycl_features.cpp.o.d"
|
||||
"cl_polyparti"
|
||||
"cl_polyparti.pdb"
|
||||
)
|
||||
|
||||
# Per-language clean rules from dependency scanning.
|
||||
foreach(lang CXX)
|
||||
include(CMakeFiles/cl_polyparti.dir/cmake_clean_${lang}.cmake OPTIONAL)
|
||||
endforeach()
|
||||
@@ -0,0 +1,2 @@
|
||||
# Empty compiler generated dependencies file for cl_polyparti.
|
||||
# This may be replaced when dependencies are built.
|
||||
@@ -0,0 +1,2 @@
|
||||
# CMAKE generated file: DO NOT EDIT!
|
||||
# Timestamp file for compiler generated dependencies management for cl_polyparti.
|
||||
@@ -0,0 +1,2 @@
|
||||
# Empty dependencies file for cl_polyparti.
|
||||
# This may be replaced when dependencies are built.
|
||||
@@ -0,0 +1,10 @@
|
||||
# CMAKE generated file: DO NOT EDIT!
|
||||
# Generated by "Unix Makefiles" Generator, CMake Version 4.3
|
||||
|
||||
# compile CXX with /opt/intel/oneapi/compiler/2026.0/bin/icpx
|
||||
CXX_DEFINES =
|
||||
|
||||
CXX_INCLUDES =
|
||||
|
||||
CXX_FLAGS = -std=gnu++17
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
/opt/intel/oneapi/compiler/2026.0/bin/icpx -fsycl -Wl,--dependency-file=CMakeFiles/cl_polyparti.dir/link.d CMakeFiles/cl_polyparti.dir/CMakeFiles/4.3.3/CompilerIdCXX/CMakeCXXCompilerId.cpp.o CMakeFiles/cl_polyparti.dir/CMakeFiles/TESTSYCL/sycl_features.cpp.o -o cl_polyparti
|
||||
@@ -0,0 +1,4 @@
|
||||
CMAKE_PROGRESS_1 = 1
|
||||
CMAKE_PROGRESS_2 = 2
|
||||
CMAKE_PROGRESS_3 = 3
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
# This file is generated by cmake for dependency checking of the CMakeCache.txt file
|
||||
@@ -0,0 +1 @@
|
||||
# This file is generated by CMake for checking of the VerifyGlobs.cmake file
|
||||
@@ -0,0 +1 @@
|
||||
3
|
||||
+210
@@ -0,0 +1,210 @@
|
||||
# CMAKE generated file: DO NOT EDIT!
|
||||
# Generated by "Unix Makefiles" Generator, CMake Version 4.3
|
||||
|
||||
# Default target executed when no arguments are given to make.
|
||||
default_target: all
|
||||
.PHONY : default_target
|
||||
|
||||
# Allow only one "make -f Makefile2" at a time, but pass parallelism.
|
||||
.NOTPARALLEL:
|
||||
|
||||
#=============================================================================
|
||||
# Special targets provided by cmake.
|
||||
|
||||
# Disable implicit rules so canonical targets will work.
|
||||
.SUFFIXES:
|
||||
|
||||
# Disable VCS-based implicit rules.
|
||||
% : %,v
|
||||
|
||||
# Disable VCS-based implicit rules.
|
||||
% : RCS/%
|
||||
|
||||
# Disable VCS-based implicit rules.
|
||||
% : RCS/%,v
|
||||
|
||||
# Disable VCS-based implicit rules.
|
||||
% : SCCS/s.%
|
||||
|
||||
# Disable VCS-based implicit rules.
|
||||
% : s.%
|
||||
|
||||
.SUFFIXES: .hpux_make_needs_suffix_list
|
||||
|
||||
# Command-line flag to silence nested $(MAKE).
|
||||
$(VERBOSE)MAKESILENT = -s
|
||||
|
||||
#Suppress display of executed commands.
|
||||
$(VERBOSE).SILENT:
|
||||
|
||||
# A target that is always out of date.
|
||||
cmake_force:
|
||||
.PHONY : cmake_force
|
||||
|
||||
#=============================================================================
|
||||
# Set environment variables for the build.
|
||||
|
||||
# The shell in which to execute make rules.
|
||||
SHELL = /bin/sh
|
||||
|
||||
# The CMake executable.
|
||||
CMAKE_COMMAND = /usr/bin/cmake
|
||||
|
||||
# The command to remove a file.
|
||||
RM = /usr/bin/cmake -E rm -f
|
||||
|
||||
# Escaping for special characters.
|
||||
EQUALS = =
|
||||
|
||||
# The top-level source directory on which CMake was run.
|
||||
CMAKE_SOURCE_DIR = /home/alardner/cl_polyparti
|
||||
|
||||
# The top-level build directory on which CMake was run.
|
||||
CMAKE_BINARY_DIR = /home/alardner/cl_polyparti/build
|
||||
|
||||
#=============================================================================
|
||||
# Targets provided globally by CMake.
|
||||
|
||||
# Special rule for the target edit_cache
|
||||
edit_cache:
|
||||
@$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --cyan "No interactive CMake dialog available..."
|
||||
/usr/bin/cmake -E echo No\ interactive\ CMake\ dialog\ available.
|
||||
.PHONY : edit_cache
|
||||
|
||||
# Special rule for the target edit_cache
|
||||
edit_cache/fast: edit_cache
|
||||
.PHONY : edit_cache/fast
|
||||
|
||||
# Special rule for the target rebuild_cache
|
||||
rebuild_cache:
|
||||
@$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --cyan "Running CMake to regenerate build system..."
|
||||
/usr/bin/cmake --regenerate-during-build -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
|
||||
.PHONY : rebuild_cache
|
||||
|
||||
# Special rule for the target rebuild_cache
|
||||
rebuild_cache/fast: rebuild_cache
|
||||
.PHONY : rebuild_cache/fast
|
||||
|
||||
# The main all target
|
||||
all: cmake_check_build_system
|
||||
$(CMAKE_COMMAND) -E cmake_progress_start /home/alardner/cl_polyparti/build/CMakeFiles /home/alardner/cl_polyparti/build//CMakeFiles/progress.marks
|
||||
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 all
|
||||
$(CMAKE_COMMAND) -E cmake_progress_start /home/alardner/cl_polyparti/build/CMakeFiles 0
|
||||
.PHONY : all
|
||||
|
||||
# The main clean target
|
||||
clean:
|
||||
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 clean
|
||||
.PHONY : clean
|
||||
|
||||
# The main clean target
|
||||
clean/fast: clean
|
||||
.PHONY : clean/fast
|
||||
|
||||
# Prepare targets for installation.
|
||||
preinstall: all
|
||||
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 preinstall
|
||||
.PHONY : preinstall
|
||||
|
||||
# Prepare targets for installation.
|
||||
preinstall/fast:
|
||||
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 preinstall
|
||||
.PHONY : preinstall/fast
|
||||
|
||||
# clear depends
|
||||
depend:
|
||||
$(CMAKE_COMMAND) -P /home/alardner/cl_polyparti/build/CMakeFiles/VerifyGlobs.cmake
|
||||
$(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1
|
||||
.PHONY : depend
|
||||
|
||||
#=============================================================================
|
||||
# Target rules for targets named cl_polyparti
|
||||
|
||||
# Build rule for target.
|
||||
cl_polyparti: cmake_check_build_system
|
||||
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 cl_polyparti
|
||||
.PHONY : cl_polyparti
|
||||
|
||||
# fast build rule for target.
|
||||
cl_polyparti/fast:
|
||||
$(MAKE) $(MAKESILENT) -f CMakeFiles/cl_polyparti.dir/build.make CMakeFiles/cl_polyparti.dir/build
|
||||
.PHONY : cl_polyparti/fast
|
||||
|
||||
CMakeFiles/4.3.3/CompilerIdCXX/CMakeCXXCompilerId.o: CMakeFiles/4.3.3/CompilerIdCXX/CMakeCXXCompilerId.cpp.o
|
||||
.PHONY : CMakeFiles/4.3.3/CompilerIdCXX/CMakeCXXCompilerId.o
|
||||
|
||||
# target to build an object file
|
||||
CMakeFiles/4.3.3/CompilerIdCXX/CMakeCXXCompilerId.cpp.o:
|
||||
$(MAKE) $(MAKESILENT) -f CMakeFiles/cl_polyparti.dir/build.make CMakeFiles/cl_polyparti.dir/CMakeFiles/4.3.3/CompilerIdCXX/CMakeCXXCompilerId.cpp.o
|
||||
.PHONY : CMakeFiles/4.3.3/CompilerIdCXX/CMakeCXXCompilerId.cpp.o
|
||||
|
||||
CMakeFiles/4.3.3/CompilerIdCXX/CMakeCXXCompilerId.i: CMakeFiles/4.3.3/CompilerIdCXX/CMakeCXXCompilerId.cpp.i
|
||||
.PHONY : CMakeFiles/4.3.3/CompilerIdCXX/CMakeCXXCompilerId.i
|
||||
|
||||
# target to preprocess a source file
|
||||
CMakeFiles/4.3.3/CompilerIdCXX/CMakeCXXCompilerId.cpp.i:
|
||||
$(MAKE) $(MAKESILENT) -f CMakeFiles/cl_polyparti.dir/build.make CMakeFiles/cl_polyparti.dir/CMakeFiles/4.3.3/CompilerIdCXX/CMakeCXXCompilerId.cpp.i
|
||||
.PHONY : CMakeFiles/4.3.3/CompilerIdCXX/CMakeCXXCompilerId.cpp.i
|
||||
|
||||
CMakeFiles/4.3.3/CompilerIdCXX/CMakeCXXCompilerId.s: CMakeFiles/4.3.3/CompilerIdCXX/CMakeCXXCompilerId.cpp.s
|
||||
.PHONY : CMakeFiles/4.3.3/CompilerIdCXX/CMakeCXXCompilerId.s
|
||||
|
||||
# target to generate assembly for a file
|
||||
CMakeFiles/4.3.3/CompilerIdCXX/CMakeCXXCompilerId.cpp.s:
|
||||
$(MAKE) $(MAKESILENT) -f CMakeFiles/cl_polyparti.dir/build.make CMakeFiles/cl_polyparti.dir/CMakeFiles/4.3.3/CompilerIdCXX/CMakeCXXCompilerId.cpp.s
|
||||
.PHONY : CMakeFiles/4.3.3/CompilerIdCXX/CMakeCXXCompilerId.cpp.s
|
||||
|
||||
CMakeFiles/TESTSYCL/sycl_features.o: CMakeFiles/TESTSYCL/sycl_features.cpp.o
|
||||
.PHONY : CMakeFiles/TESTSYCL/sycl_features.o
|
||||
|
||||
# target to build an object file
|
||||
CMakeFiles/TESTSYCL/sycl_features.cpp.o:
|
||||
$(MAKE) $(MAKESILENT) -f CMakeFiles/cl_polyparti.dir/build.make CMakeFiles/cl_polyparti.dir/CMakeFiles/TESTSYCL/sycl_features.cpp.o
|
||||
.PHONY : CMakeFiles/TESTSYCL/sycl_features.cpp.o
|
||||
|
||||
CMakeFiles/TESTSYCL/sycl_features.i: CMakeFiles/TESTSYCL/sycl_features.cpp.i
|
||||
.PHONY : CMakeFiles/TESTSYCL/sycl_features.i
|
||||
|
||||
# target to preprocess a source file
|
||||
CMakeFiles/TESTSYCL/sycl_features.cpp.i:
|
||||
$(MAKE) $(MAKESILENT) -f CMakeFiles/cl_polyparti.dir/build.make CMakeFiles/cl_polyparti.dir/CMakeFiles/TESTSYCL/sycl_features.cpp.i
|
||||
.PHONY : CMakeFiles/TESTSYCL/sycl_features.cpp.i
|
||||
|
||||
CMakeFiles/TESTSYCL/sycl_features.s: CMakeFiles/TESTSYCL/sycl_features.cpp.s
|
||||
.PHONY : CMakeFiles/TESTSYCL/sycl_features.s
|
||||
|
||||
# target to generate assembly for a file
|
||||
CMakeFiles/TESTSYCL/sycl_features.cpp.s:
|
||||
$(MAKE) $(MAKESILENT) -f CMakeFiles/cl_polyparti.dir/build.make CMakeFiles/cl_polyparti.dir/CMakeFiles/TESTSYCL/sycl_features.cpp.s
|
||||
.PHONY : CMakeFiles/TESTSYCL/sycl_features.cpp.s
|
||||
|
||||
# Help Target
|
||||
help:
|
||||
@echo "The following are some of the valid targets for this Makefile:"
|
||||
@echo "... all (the default if no target is provided)"
|
||||
@echo "... clean"
|
||||
@echo "... depend"
|
||||
@echo "... edit_cache"
|
||||
@echo "... rebuild_cache"
|
||||
@echo "... cl_polyparti"
|
||||
@echo "... CMakeFiles/4.3.3/CompilerIdCXX/CMakeCXXCompilerId.o"
|
||||
@echo "... CMakeFiles/4.3.3/CompilerIdCXX/CMakeCXXCompilerId.i"
|
||||
@echo "... CMakeFiles/4.3.3/CompilerIdCXX/CMakeCXXCompilerId.s"
|
||||
@echo "... CMakeFiles/TESTSYCL/sycl_features.o"
|
||||
@echo "... CMakeFiles/TESTSYCL/sycl_features.i"
|
||||
@echo "... CMakeFiles/TESTSYCL/sycl_features.s"
|
||||
.PHONY : help
|
||||
|
||||
|
||||
|
||||
#=============================================================================
|
||||
# Special targets to cleanup operation of make.
|
||||
|
||||
# Special rule to run CMake to check the build system integrity.
|
||||
# No rule that depends on this can have commands that come from listfiles
|
||||
# because they might be regenerated.
|
||||
cmake_check_build_system:
|
||||
$(CMAKE_COMMAND) -P /home/alardner/cl_polyparti/build/CMakeFiles/VerifyGlobs.cmake
|
||||
$(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0
|
||||
.PHONY : cmake_check_build_system
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
# Install script for directory: /home/alardner/cl_polyparti
|
||||
|
||||
# Set the install prefix
|
||||
if(NOT DEFINED CMAKE_INSTALL_PREFIX)
|
||||
set(CMAKE_INSTALL_PREFIX "/usr/local")
|
||||
endif()
|
||||
string(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
|
||||
|
||||
# Set the install configuration name.
|
||||
if(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME)
|
||||
if(BUILD_TYPE)
|
||||
string(REGEX REPLACE "^[^A-Za-z0-9_]+" ""
|
||||
CMAKE_INSTALL_CONFIG_NAME "${BUILD_TYPE}")
|
||||
else()
|
||||
set(CMAKE_INSTALL_CONFIG_NAME "")
|
||||
endif()
|
||||
message(STATUS "Install configuration: \"${CMAKE_INSTALL_CONFIG_NAME}\"")
|
||||
endif()
|
||||
|
||||
# Set the component getting installed.
|
||||
if(NOT CMAKE_INSTALL_COMPONENT)
|
||||
if(COMPONENT)
|
||||
message(STATUS "Install component: \"${COMPONENT}\"")
|
||||
set(CMAKE_INSTALL_COMPONENT "${COMPONENT}")
|
||||
else()
|
||||
set(CMAKE_INSTALL_COMPONENT)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Install shared libraries without execute permission?
|
||||
if(NOT DEFINED CMAKE_INSTALL_SO_NO_EXE)
|
||||
set(CMAKE_INSTALL_SO_NO_EXE "1")
|
||||
endif()
|
||||
|
||||
# Is this installation the result of a crosscompile?
|
||||
if(NOT DEFINED CMAKE_CROSSCOMPILING)
|
||||
set(CMAKE_CROSSCOMPILING "FALSE")
|
||||
endif()
|
||||
|
||||
# Set path to fallback-tool for dependency-resolution.
|
||||
if(NOT DEFINED CMAKE_OBJDUMP)
|
||||
set(CMAKE_OBJDUMP "/usr/bin/llvm-objdump")
|
||||
endif()
|
||||
|
||||
string(REPLACE ";" "\n" CMAKE_INSTALL_MANIFEST_CONTENT
|
||||
"${CMAKE_INSTALL_MANIFEST_FILES}")
|
||||
if(CMAKE_INSTALL_LOCAL_ONLY)
|
||||
file(WRITE "/home/alardner/cl_polyparti/build/install_local_manifest.txt"
|
||||
"${CMAKE_INSTALL_MANIFEST_CONTENT}")
|
||||
endif()
|
||||
if(CMAKE_INSTALL_COMPONENT)
|
||||
if(CMAKE_INSTALL_COMPONENT MATCHES "^[a-zA-Z0-9_.+-]+$")
|
||||
set(CMAKE_INSTALL_MANIFEST "install_manifest_${CMAKE_INSTALL_COMPONENT}.txt")
|
||||
else()
|
||||
string(MD5 CMAKE_INST_COMP_HASH "${CMAKE_INSTALL_COMPONENT}")
|
||||
set(CMAKE_INSTALL_MANIFEST "install_manifest_${CMAKE_INST_COMP_HASH}.txt")
|
||||
unset(CMAKE_INST_COMP_HASH)
|
||||
endif()
|
||||
else()
|
||||
set(CMAKE_INSTALL_MANIFEST "install_manifest.txt")
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_INSTALL_LOCAL_ONLY)
|
||||
file(WRITE "/home/alardner/cl_polyparti/build/${CMAKE_INSTALL_MANIFEST}"
|
||||
"${CMAKE_INSTALL_MANIFEST_CONTENT}")
|
||||
endif()
|
||||
@@ -0,0 +1,14 @@
|
||||
[
|
||||
{
|
||||
"directory": "/home/alardner/cl_polyparti/build",
|
||||
"command": "/opt/intel/oneapi/compiler/2026.0/bin/icpx -std=gnu++17 -o CMakeFiles/cl_polyparti.dir/CMakeFiles/4.3.3/CompilerIdCXX/CMakeCXXCompilerId.cpp.o -c /home/alardner/cl_polyparti/build/CMakeFiles/4.3.3/CompilerIdCXX/CMakeCXXCompilerId.cpp",
|
||||
"file": "/home/alardner/cl_polyparti/build/CMakeFiles/4.3.3/CompilerIdCXX/CMakeCXXCompilerId.cpp",
|
||||
"output": "CMakeFiles/cl_polyparti.dir/CMakeFiles/4.3.3/CompilerIdCXX/CMakeCXXCompilerId.cpp.o"
|
||||
},
|
||||
{
|
||||
"directory": "/home/alardner/cl_polyparti/build",
|
||||
"command": "/opt/intel/oneapi/compiler/2026.0/bin/icpx -std=gnu++17 -o CMakeFiles/cl_polyparti.dir/CMakeFiles/TESTSYCL/sycl_features.cpp.o -c /home/alardner/cl_polyparti/build/CMakeFiles/TESTSYCL/sycl_features.cpp",
|
||||
"file": "/home/alardner/cl_polyparti/build/CMakeFiles/TESTSYCL/sycl_features.cpp",
|
||||
"output": "CMakeFiles/cl_polyparti.dir/CMakeFiles/TESTSYCL/sycl_features.cpp.o"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,71 @@
|
||||
#ifndef RAYLIB_CPP_INCLUDE_AUDIODEVICE_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_AUDIODEVICE_HPP_
|
||||
|
||||
#include "./RaylibException.hpp"
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
#include "./raylib.hpp"
|
||||
|
||||
namespace raylib {
|
||||
/**
|
||||
* Audio device management functions.
|
||||
*/
|
||||
class AudioDevice {
|
||||
public:
|
||||
/**
|
||||
* Initialize audio device and context.
|
||||
*
|
||||
* @param lateInit Whether or not to post-pone initializing the context.
|
||||
*
|
||||
* @throws raylib::RaylibException Throws if the AudioDevice failed to initialize.
|
||||
*/
|
||||
explicit AudioDevice(bool lateInit = false) {
|
||||
if (!lateInit) {
|
||||
Init();
|
||||
}
|
||||
}
|
||||
|
||||
AudioDevice(const AudioDevice&) = delete;
|
||||
AudioDevice& operator=(const AudioDevice&) = delete;
|
||||
|
||||
/**
|
||||
* Close the audio device and context.
|
||||
*/
|
||||
~AudioDevice() { Close(); }
|
||||
|
||||
/**
|
||||
* Initialize audio device and context.
|
||||
*
|
||||
* @throws raylib::RaylibException Throws if the AudioDevice failed to initialize.
|
||||
*/
|
||||
static void Init() {
|
||||
::InitAudioDevice();
|
||||
if (!IsReady()) {
|
||||
throw RaylibException("Failed to initialize AudioDevice");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the audio device and context.
|
||||
*/
|
||||
static void Close() { ::CloseAudioDevice(); }
|
||||
|
||||
/**
|
||||
* Check if audio device has been initialized successfully.
|
||||
*/
|
||||
static bool IsReady() { return ::IsAudioDeviceReady(); }
|
||||
|
||||
/**
|
||||
* Set master volume (listener).
|
||||
*
|
||||
* @param volume The desired volume to set.
|
||||
*/
|
||||
AudioDevice& SetVolume(float volume) {
|
||||
::SetMasterVolume(volume);
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
} // namespace raylib
|
||||
|
||||
using RAudioDevice = raylib::AudioDevice;
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_AUDIODEVICE_HPP_
|
||||
@@ -0,0 +1,55 @@
|
||||
#ifndef RAYLIB_CPP_INCLUDE_AUDIOSTREAM_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_AUDIOSTREAM_HPP_
|
||||
|
||||
#include "./AudioStreamUnmanaged.hpp"
|
||||
|
||||
namespace raylib {
|
||||
/**
|
||||
* AudioStream management functions.
|
||||
*
|
||||
* The audio stream will be unloaded on object destruction. Use raylib::AudioStreamUnmanaged if you're looking to not unload.
|
||||
*
|
||||
* @see raylib::AudioStreamUnmanaged
|
||||
*/
|
||||
class AudioStream : public AudioStreamUnmanaged {
|
||||
public:
|
||||
using AudioStreamUnmanaged::AudioStreamUnmanaged;
|
||||
|
||||
AudioStream(const AudioStream&) = delete;
|
||||
AudioStream& operator=(const AudioStream&) = delete;
|
||||
|
||||
AudioStream(AudioStream&& other) noexcept {
|
||||
set(other);
|
||||
other.buffer = nullptr;
|
||||
other.processor = nullptr;
|
||||
other.sampleRate = 0;
|
||||
other.sampleSize = 0;
|
||||
other.channels = 0;
|
||||
}
|
||||
|
||||
AudioStream& operator=(AudioStream&& other) noexcept {
|
||||
if (this == &other) {
|
||||
return *this;
|
||||
}
|
||||
Unload();
|
||||
set(other);
|
||||
other.buffer = nullptr;
|
||||
other.processor = nullptr;
|
||||
other.sampleRate = 0;
|
||||
other.sampleSize = 0;
|
||||
other.channels = 0;
|
||||
return *this;
|
||||
}
|
||||
|
||||
~AudioStream() { Unload(); }
|
||||
|
||||
void Load(unsigned int sampleRate, unsigned int sampleSize, unsigned int channels = 2) {
|
||||
Unload();
|
||||
AudioStreamUnmanaged::Load(sampleRate, sampleSize, channels);
|
||||
}
|
||||
};
|
||||
} // namespace raylib
|
||||
|
||||
using RAudioStream = raylib::AudioStream;
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_AUDIOSTREAM_HPP_
|
||||
@@ -0,0 +1,200 @@
|
||||
#ifndef RAYLIB_CPP_INCLUDE_AUDIOSTREAMUNMANAGED_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_AUDIOSTREAMUNMANAGED_HPP_
|
||||
|
||||
#include "./RaylibException.hpp"
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
#include "./raylib.hpp"
|
||||
|
||||
namespace raylib {
|
||||
/**
|
||||
* An AudioStream that is not managed by C++ RAII.
|
||||
*
|
||||
* Make sure to Unload() this if needed, otherwise use raylib::AudioStream.
|
||||
*
|
||||
* @see raylib::AudioStream
|
||||
*/
|
||||
class AudioStreamUnmanaged : public ::AudioStream {
|
||||
public:
|
||||
/**
|
||||
* Creates an AudioStreamUnmanaged from an existing AudioStream struct.
|
||||
*/
|
||||
AudioStreamUnmanaged(const ::AudioStream& stream) : ::AudioStream(stream) {}
|
||||
|
||||
/**
|
||||
* Creates an AudioStreamUnmanaged from its components.
|
||||
*/
|
||||
AudioStreamUnmanaged(
|
||||
rAudioBuffer* buffer = nullptr,
|
||||
rAudioProcessor* processor = nullptr,
|
||||
unsigned int sampleRate = 0,
|
||||
unsigned int sampleSize = 0,
|
||||
unsigned int channels = 0)
|
||||
: ::AudioStream{buffer, processor, sampleRate, sampleSize, channels} {}
|
||||
|
||||
/**
|
||||
* Init audio stream (to stream raw audio PCM data).
|
||||
*
|
||||
* @throws raylib::RaylibException Throws if the AudioStream failed to load.
|
||||
*/
|
||||
AudioStreamUnmanaged(unsigned int sampleRate, unsigned int sampleSize, unsigned int channels = 2) {
|
||||
Load(sampleRate, sampleSize, channels);
|
||||
}
|
||||
|
||||
GETTER(rAudioBuffer*, Buffer, buffer)
|
||||
GETTER(rAudioProcessor*, Processor, processor)
|
||||
GETTER(unsigned int, SampleRate, sampleRate)
|
||||
GETTER(unsigned int, SampleSize, sampleSize)
|
||||
GETTER(unsigned int, Channels, channels)
|
||||
|
||||
AudioStreamUnmanaged& operator=(const ::AudioStream& stream) {
|
||||
set(stream);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load audio stream (to stream raw audio PCM data).
|
||||
*
|
||||
* Does NOT call Unload() first — that is the responsibility of the managed class.
|
||||
*
|
||||
* @throws raylib::RaylibException Throws if the AudioStream failed to load.
|
||||
*/
|
||||
void Load(unsigned int sampleRate, unsigned int sampleSize, unsigned int channels = 2) {
|
||||
set(::LoadAudioStream(sampleRate, sampleSize, channels));
|
||||
if (!IsValid()) {
|
||||
throw RaylibException("Failed to load audio stream");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unload audio stream and free memory.
|
||||
*/
|
||||
void Unload() {
|
||||
// Protect against calling UnloadAudioStream() twice.
|
||||
if (buffer != nullptr) {
|
||||
::UnloadAudioStream(*this);
|
||||
buffer = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update audio stream buffers with data.
|
||||
*/
|
||||
AudioStreamUnmanaged& Update(const void* data, int samplesCount) {
|
||||
::UpdateAudioStream(*this, data, samplesCount);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if any audio stream buffers require refill.
|
||||
*/
|
||||
RLCPP_NODISCARD bool IsProcessed() const { return ::IsAudioStreamProcessed(*this); }
|
||||
|
||||
/**
|
||||
* Play audio stream.
|
||||
*/
|
||||
AudioStreamUnmanaged& Play() {
|
||||
::PlayAudioStream(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pause audio stream.
|
||||
*/
|
||||
AudioStreamUnmanaged& Pause() {
|
||||
::PauseAudioStream(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resume audio stream.
|
||||
*/
|
||||
AudioStreamUnmanaged& Resume() {
|
||||
::ResumeAudioStream(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if audio stream is playing.
|
||||
*/
|
||||
RLCPP_NODISCARD bool IsPlaying() const { return ::IsAudioStreamPlaying(*this); }
|
||||
|
||||
/**
|
||||
* Stop audio stream.
|
||||
*/
|
||||
AudioStreamUnmanaged& Stop() {
|
||||
::StopAudioStream(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set volume for audio stream (1.0 is max level).
|
||||
*/
|
||||
AudioStreamUnmanaged& SetVolume(float volume = 1.0f) {
|
||||
::SetAudioStreamVolume(*this, volume);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set pitch for audio stream (1.0 is base level).
|
||||
*/
|
||||
AudioStreamUnmanaged& SetPitch(float pitch) {
|
||||
::SetAudioStreamPitch(*this, pitch);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set pan for audio stream (0.5 is centered).
|
||||
*/
|
||||
AudioStreamUnmanaged& SetPan(float pan = 0.5f) {
|
||||
::SetAudioStreamPan(*this, pan);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Default size for new audio streams.
|
||||
*/
|
||||
static void SetBufferSizeDefault(int size) { ::SetAudioStreamBufferSizeDefault(size); }
|
||||
|
||||
/**
|
||||
* Audio thread callback to request new data.
|
||||
*/
|
||||
AudioStreamUnmanaged& SetCallback(::AudioCallback callback) {
|
||||
::SetAudioStreamCallback(*this, callback);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attach audio stream processor to stream.
|
||||
*/
|
||||
AudioStreamUnmanaged& AttachProcessor(::AudioCallback processor) {
|
||||
::AttachAudioStreamProcessor(*this, processor);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Detach audio stream processor from stream.
|
||||
*/
|
||||
AudioStreamUnmanaged& DetachProcessor(::AudioCallback processor) {
|
||||
::DetachAudioStreamProcessor(*this, processor);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve whether or not the audio stream is ready.
|
||||
*/
|
||||
RLCPP_NODISCARD bool IsValid() const { return ::IsAudioStreamValid(*this); }
|
||||
|
||||
protected:
|
||||
void set(const ::AudioStream& stream) {
|
||||
buffer = stream.buffer;
|
||||
processor = stream.processor;
|
||||
sampleRate = stream.sampleRate;
|
||||
sampleSize = stream.sampleSize;
|
||||
channels = stream.channels;
|
||||
}
|
||||
};
|
||||
} // namespace raylib
|
||||
|
||||
using RAudioStreamUnmanaged = raylib::AudioStreamUnmanaged;
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_AUDIOSTREAMUNMANAGED_HPP_
|
||||
@@ -0,0 +1,142 @@
|
||||
#ifndef RAYLIB_CPP_INCLUDE_AUTOMATIONEVENTLIST_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_AUTOMATIONEVENTLIST_HPP_
|
||||
|
||||
#include "./RaylibException.hpp"
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
#include "./raylib.hpp"
|
||||
|
||||
namespace raylib {
|
||||
/**
|
||||
* AutomationEventList management functions
|
||||
*/
|
||||
class AutomationEventList : public ::AutomationEventList {
|
||||
public:
|
||||
AutomationEventList(const ::AutomationEventList& automationEventList)
|
||||
: ::AutomationEventList(automationEventList) {
|
||||
// Nothing.
|
||||
}
|
||||
|
||||
/**
|
||||
* Load an empty automation events list.
|
||||
*/
|
||||
AutomationEventList() { set(::LoadAutomationEventList(0)); }
|
||||
|
||||
/**
|
||||
* Load automation events list from file.
|
||||
*
|
||||
* @param fileName The file path to load the automation events list from.
|
||||
*/
|
||||
AutomationEventList(const char* fileName) { Load(fileName); }
|
||||
|
||||
AutomationEventList(const AutomationEventList&) = delete;
|
||||
|
||||
AutomationEventList(AutomationEventList&& other) noexcept {
|
||||
set(other);
|
||||
|
||||
other.capacity = 0;
|
||||
other.count = 0;
|
||||
other.events = nullptr;
|
||||
}
|
||||
|
||||
~AutomationEventList() { Unload(); }
|
||||
|
||||
GETTER(unsigned int, Capacity, capacity)
|
||||
GETTER(unsigned int, Count, count)
|
||||
GETTER(AutomationEvent*, Events, events)
|
||||
|
||||
AutomationEventList& operator=(const ::AutomationEventList& other) {
|
||||
set(other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
AutomationEventList& operator=(const AutomationEventList&) = delete;
|
||||
|
||||
AutomationEventList& operator=(AutomationEventList&& other) noexcept {
|
||||
if (this == &other) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
Unload();
|
||||
set(other);
|
||||
|
||||
other.capacity = 0;
|
||||
other.count = 0;
|
||||
other.events = nullptr;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load audio stream (to stream raw audio pcm data)
|
||||
*
|
||||
* @throws raylib::RaylibException Throws if the AutomationEventList failed to load.
|
||||
*/
|
||||
void Load(const char* fileName) {
|
||||
Unload();
|
||||
set(::LoadAutomationEventList(fileName));
|
||||
if (!IsValid()) {
|
||||
throw RaylibException("Failed to load automation event list");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update audio stream buffers with data
|
||||
*/
|
||||
void Unload() {
|
||||
if (!IsValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// The function signature of UnloadAutomationEventList() changes from raylib 5.0.
|
||||
#if RAYLIB_VERSION_MAJOR == 5
|
||||
#if RAYLIB_VERSION_MINOR == 0
|
||||
::UnloadAutomationEventList(this);
|
||||
#elif RAYLIB_VERSION_MINOR >= 1
|
||||
::UnloadAutomationEventList(*this);
|
||||
#endif
|
||||
#else
|
||||
::UnloadAutomationEventList(*this);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool IsValid() { return events != nullptr; }
|
||||
|
||||
bool Export(const char* fileName) { return ::ExportAutomationEventList(*this, fileName); }
|
||||
|
||||
void Set() { ::SetAutomationEventList(this); }
|
||||
|
||||
void SetBaseFrame(int frame) {
|
||||
Set();
|
||||
::SetAutomationEventBaseFrame(frame);
|
||||
}
|
||||
|
||||
void StartRecording() {
|
||||
Set();
|
||||
::StartAutomationEventRecording();
|
||||
}
|
||||
|
||||
void StopRecording() {
|
||||
Set();
|
||||
::StopAutomationEventRecording();
|
||||
}
|
||||
|
||||
void Play(int index) {
|
||||
if (index < 0 || static_cast<unsigned int>(index) >= this->count) {
|
||||
return;
|
||||
}
|
||||
|
||||
Set();
|
||||
::PlayAutomationEvent(this->events[index]);
|
||||
}
|
||||
protected:
|
||||
void set(const ::AutomationEventList& other) {
|
||||
capacity = other.capacity;
|
||||
count = other.count;
|
||||
events = other.events;
|
||||
}
|
||||
};
|
||||
} // namespace raylib
|
||||
|
||||
using RAutomationEventList = raylib::AutomationEventList;
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_AUTOMATIONEVENTLIST_HPP_
|
||||
@@ -0,0 +1,83 @@
|
||||
#ifndef RAYLIB_CPP_INCLUDE_BOUNDINGBOX_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_BOUNDINGBOX_HPP_
|
||||
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
#include "./raylib.hpp"
|
||||
|
||||
namespace raylib {
|
||||
/**
|
||||
* Bounding box type
|
||||
*/
|
||||
class BoundingBox : public ::BoundingBox {
|
||||
public:
|
||||
/*
|
||||
* Copy a bounding box from another bounding box.
|
||||
*/
|
||||
constexpr BoundingBox(const ::BoundingBox& box) : ::BoundingBox{box.min, box.max} {
|
||||
// Nothing.
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute mesh bounding box limits
|
||||
*/
|
||||
BoundingBox(const ::Mesh& mesh) { set(::GetMeshBoundingBox(mesh)); }
|
||||
|
||||
constexpr BoundingBox(::Vector3 minMax = ::Vector3{0.0f, 0.0f, 0.0f}) : ::BoundingBox{minMax, minMax} {}
|
||||
constexpr BoundingBox(::Vector3 min, ::Vector3 max) : ::BoundingBox{min, max} {}
|
||||
|
||||
GETTERSETTER(::Vector3, Min, min)
|
||||
GETTERSETTER(::Vector3, Max, max)
|
||||
|
||||
BoundingBox& operator=(const ::BoundingBox& box) {
|
||||
set(box);
|
||||
return *this;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string ToString() const {
|
||||
return TextFormat(
|
||||
"BoundingBox(min=(%f, %f, %f), max=(%f, %f, %f))",
|
||||
min.x, min.y, min.z, max.x, max.y, max.z
|
||||
);
|
||||
}
|
||||
|
||||
operator std::string() const { return ToString(); }
|
||||
|
||||
/**
|
||||
* Draw a bounding box with wires
|
||||
*/
|
||||
void Draw(::Color color = {255, 255, 255, 255}) const { ::DrawBoundingBox(*this, color); }
|
||||
|
||||
/**
|
||||
* Detect collision between two boxes
|
||||
*/
|
||||
RLCPP_NODISCARD bool CheckCollision(const ::BoundingBox& box2) const { return CheckCollisionBoxes(*this, box2); }
|
||||
|
||||
/**
|
||||
* Detect collision between box and sphere
|
||||
*/
|
||||
RLCPP_NODISCARD bool CheckCollision(::Vector3 center, float radius) const { return CheckCollisionBoxSphere(*this, center, radius); }
|
||||
|
||||
/**
|
||||
* Detect collision between ray and bounding box
|
||||
*/
|
||||
RLCPP_NODISCARD bool CheckCollision(const ::Ray& ray) const { return GetRayCollisionBox(ray, *this).hit; }
|
||||
|
||||
/**
|
||||
* Get collision information between ray and bounding box
|
||||
*/
|
||||
RayCollision GetCollision(const ::Ray& ray) const { return GetRayCollisionBox(ray, *this); }
|
||||
protected:
|
||||
void set(const ::BoundingBox& box) {
|
||||
min = box.min;
|
||||
max = box.max;
|
||||
}
|
||||
void set(const ::Vector3& _min, const ::Vector3& _max) {
|
||||
min = _min;
|
||||
max = _max;
|
||||
}
|
||||
};
|
||||
} // namespace raylib
|
||||
|
||||
using RBoundingBox = raylib::BoundingBox;
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_BOUNDINGBOX_HPP_
|
||||
@@ -0,0 +1,67 @@
|
||||
add_library(raylib_cpp INTERFACE)
|
||||
|
||||
set(RAYLIB_CPP_HEADERS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/AudioDevice.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/AudioStream.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/AutomationEventList.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/BoundingBox.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Camera2D.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Camera3D.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Color.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/FileData.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/FileText.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Font.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Functions.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Gamepad.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Image.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Keyboard.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Material.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Matrix.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Mesh.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/MeshUnmanaged.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Model.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ModelAnimation.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Mouse.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Music.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Quaternion.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Ray.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/RayCollision.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/RaylibException.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/raylib-cpp-utils.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/raylib-cpp.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/raylib.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/raymath.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Rectangle.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/RenderTexture.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ShaderUnmanaged.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Shader.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Sound.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Text.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Texture.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/TextureUnmanaged.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Touch.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Vector2.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Vector3.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Vector4.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/VrStereoConfig.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Wave.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Window.hpp
|
||||
)
|
||||
|
||||
# Include Directory
|
||||
target_include_directories(raylib_cpp INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/)
|
||||
|
||||
# Set the header files as install files.
|
||||
install(FILES
|
||||
${RAYLIB_CPP_HEADERS}
|
||||
DESTINATION include
|
||||
)
|
||||
|
||||
if (RAYLIB_CPP_IS_MAIN)
|
||||
# @TODO: add examples files
|
||||
add_custom_target(format
|
||||
COMMAND clang-format
|
||||
-i
|
||||
${RAYLIB_CPP_HEADERS}
|
||||
)
|
||||
endif()
|
||||
@@ -0,0 +1,68 @@
|
||||
#ifndef RAYLIB_CPP_INCLUDE_CAMERA2D_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_CAMERA2D_HPP_
|
||||
|
||||
#include "./Vector2.hpp"
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
#include "./raylib.hpp"
|
||||
|
||||
namespace raylib {
|
||||
/**
|
||||
* Camera2D type, defines a 2d camera
|
||||
*/
|
||||
class Camera2D : public ::Camera2D {
|
||||
public:
|
||||
Camera2D(const ::Camera2D& camera)
|
||||
: ::Camera2D(camera) {
|
||||
// Nothing.
|
||||
}
|
||||
|
||||
Camera2D(::Vector2 offset = {}, ::Vector2 target = {}, float rotation = 0.0f, float zoom = 1.0f)
|
||||
: ::Camera2D{offset, target, rotation, zoom} {}
|
||||
|
||||
Camera2D& BeginMode() {
|
||||
::BeginMode2D(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
Camera2D& EndMode() {
|
||||
::EndMode2D();
|
||||
return *this;
|
||||
}
|
||||
|
||||
GETTERSETTER(::Vector2, Offset, offset)
|
||||
GETTERSETTER(::Vector2, Target, target)
|
||||
GETTERSETTER(float, Rotation, rotation)
|
||||
GETTERSETTER(float, Zoom, zoom)
|
||||
|
||||
Camera2D& operator=(const ::Camera2D& camera) {
|
||||
set(camera);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns camera 2d transform matrix
|
||||
*/
|
||||
RLCPP_NODISCARD Matrix GetMatrix() const { return ::GetCameraMatrix2D(*this); }
|
||||
|
||||
/**
|
||||
* Returns the world space position for a 2d camera screen space position
|
||||
*/
|
||||
RLCPP_NODISCARD Vector2 GetScreenToWorld(::Vector2 position) const { return ::GetScreenToWorld2D(position, *this); }
|
||||
|
||||
/**
|
||||
* Returns the screen space position for a 2d world space position
|
||||
*/
|
||||
RLCPP_NODISCARD Vector2 GetWorldToScreen(::Vector2 position) const { return ::GetWorldToScreen2D(position, *this); }
|
||||
protected:
|
||||
void set(const ::Camera2D& camera) {
|
||||
offset = camera.offset;
|
||||
target = camera.target;
|
||||
rotation = camera.rotation;
|
||||
zoom = camera.zoom;
|
||||
}
|
||||
};
|
||||
} // namespace raylib
|
||||
|
||||
using RCamera2D = raylib::Camera2D;
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_CAMERA2D_HPP_
|
||||
@@ -0,0 +1,146 @@
|
||||
#ifndef RAYLIB_CPP_INCLUDE_CAMERA3D_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_CAMERA3D_HPP_
|
||||
|
||||
#include "./Vector3.hpp"
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
#include "./raylib.hpp"
|
||||
|
||||
namespace raylib {
|
||||
/**
|
||||
* Camera type, defines a camera position/orientation in 3d space
|
||||
*/
|
||||
class Camera3D : public ::Camera3D {
|
||||
public:
|
||||
Camera3D(const ::Camera3D& camera) : ::Camera3D(camera) { }
|
||||
|
||||
/**
|
||||
* Create a new Camera3D.
|
||||
*
|
||||
* @param position Camera position
|
||||
* @param target Camera target it looks-at
|
||||
* @param up Camera up vector (rotation over its axis)
|
||||
* @param fovy Camera field-of-view apperture in Y (degrees) in perspective, used as near plane width in
|
||||
* orthographic
|
||||
* @param projection Camera projection: CAMERA_PERSPECTIVE or CAMERA_ORTHOGRAPHIC
|
||||
*/
|
||||
Camera3D(
|
||||
::Vector3 position = ::Vector3{0.0f, 0.0f, 0.0f},
|
||||
::Vector3 target = ::Vector3{0.0f, 0.0f, -1.0f},
|
||||
::Vector3 up = ::Vector3{0.0f, 1.0f, 0.0f},
|
||||
float fovy = 45.0f,
|
||||
int projection = CAMERA_PERSPECTIVE)
|
||||
: ::Camera3D{position, target, up, fovy, projection} {}
|
||||
|
||||
GETTERSETTER(::Vector3, Position, position)
|
||||
GETTERSETTER(::Vector3, Target, target)
|
||||
GETTERSETTER(::Vector3, Up, up)
|
||||
GETTERSETTER(float, Fovy, fovy)
|
||||
GETTERSETTER(int, Projection, projection)
|
||||
|
||||
Camera3D& operator=(const ::Camera3D& camera) {
|
||||
set(camera);
|
||||
return *this;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string ToString() const {
|
||||
return TextFormat(
|
||||
"Camera3D(position=(%f, %f, %f), target=(%f, %f, %f), fovy=%f)",
|
||||
position.x, position.y, position.z,
|
||||
target.x, target.y, target.z,
|
||||
fovy
|
||||
);
|
||||
}
|
||||
|
||||
operator std::string() const { return ToString(); }
|
||||
|
||||
/**
|
||||
* Initializes 3D mode with custom camera (3D)
|
||||
*/
|
||||
Camera3D& BeginMode() {
|
||||
::BeginMode3D(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ends 3D mode and returns to default 2D orthographic mode
|
||||
*/
|
||||
Camera3D& EndMode() {
|
||||
::EndMode3D();
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get camera transform matrix (view matrix)
|
||||
*/
|
||||
Matrix GetMatrix() const { return ::GetCameraMatrix(*this); }
|
||||
|
||||
/**
|
||||
* Update camera position for selected mode
|
||||
*/
|
||||
Camera3D& Update(int mode) {
|
||||
::UpdateCamera(this, mode);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update camera movement/rotation
|
||||
*/
|
||||
Camera3D& Update(::Vector3 movement, ::Vector3 rotation, float zoom = 1.0f) {
|
||||
::UpdateCameraPro(this, movement, rotation, zoom);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a ray trace from mouse position
|
||||
*/
|
||||
Ray GetMouseRay(::Vector2 mousePosition) const { return ::GetMouseRay(mousePosition, *this); }
|
||||
|
||||
/**
|
||||
* Returns the screen space position for a 3d world space position
|
||||
*/
|
||||
Vector2 GetWorldToScreen(::Vector3 position) const { return ::GetWorldToScreen(position, *this); }
|
||||
|
||||
/**
|
||||
* Get a ray trace from screen position (i.e mouse) in a viewport
|
||||
*/
|
||||
Ray GetScreenToWorldRay(::Vector2 position, int width, int height) {
|
||||
return ::GetScreenToWorldRayEx(position, *this, width, height);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw a billboard texture.
|
||||
*/
|
||||
void
|
||||
DrawBillboard(const ::Texture2D& texture, ::Vector3 center, float size, ::Color tint = {255, 255, 255, 255}) const {
|
||||
::DrawBillboard(*this, texture, center, size, tint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw a billboard texture defined by source.
|
||||
*/
|
||||
void DrawBillboard(
|
||||
const ::Texture2D& texture,
|
||||
::Rectangle sourceRec,
|
||||
::Vector3 center,
|
||||
::Vector2 size,
|
||||
::Color tint = {255, 255, 255, 255}) const {
|
||||
::DrawBillboardRec(*this, texture, sourceRec, center, size, tint);
|
||||
}
|
||||
protected:
|
||||
void set(const ::Camera3D& camera) {
|
||||
position = camera.position;
|
||||
target = camera.target;
|
||||
up = camera.up;
|
||||
fovy = camera.fovy;
|
||||
projection = camera.projection;
|
||||
}
|
||||
};
|
||||
|
||||
using Camera = Camera3D;
|
||||
|
||||
} // namespace raylib
|
||||
|
||||
using RCamera = raylib::Camera;
|
||||
using RCamera3D = raylib::Camera3D;
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_CAMERA3D_HPP_
|
||||
@@ -0,0 +1,259 @@
|
||||
#ifndef RAYLIB_CPP_INCLUDE_COLOR_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_COLOR_HPP_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "./Vector4.hpp"
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
#include "./raylib.hpp"
|
||||
|
||||
namespace raylib {
|
||||
/**
|
||||
* Color type, RGBA (32bit)
|
||||
*/
|
||||
class Color : public ::Color {
|
||||
public:
|
||||
constexpr Color(const ::Color& color) : ::Color{color.r, color.g, color.b, color.a} {}
|
||||
|
||||
constexpr Color(unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha = 255)
|
||||
: ::Color{red, green, blue, alpha} {};
|
||||
|
||||
/**
|
||||
* Black.
|
||||
*/
|
||||
constexpr Color() : ::Color{0, 0, 0, 255} {};
|
||||
|
||||
/**
|
||||
* Returns a Color from HSV values
|
||||
*/
|
||||
Color(::Vector3 hsv) { set(::ColorFromHSV(hsv.x, hsv.y, hsv.z)); }
|
||||
|
||||
/**
|
||||
* Returns a Color from HSV values
|
||||
*/
|
||||
static ::Color FromHSV(float hue, float saturation, float value) { return ::ColorFromHSV(hue, saturation, value); }
|
||||
|
||||
/**
|
||||
* Get Color structure from hexadecimal value
|
||||
*/
|
||||
explicit Color(unsigned int hexValue) : ::Color(::GetColor(hexValue)) { }
|
||||
|
||||
Color(void* srcPtr, int format) : ::Color(::GetPixelColor(srcPtr, format)) { }
|
||||
|
||||
/**
|
||||
* Returns hexadecimal value for a Color
|
||||
*/
|
||||
RLCPP_NODISCARD int ToInt() const { return ::ColorToInt(*this); }
|
||||
|
||||
/**
|
||||
* Returns hexadecimal value for a Color
|
||||
*/
|
||||
explicit operator int() const { return ::ColorToInt(*this); }
|
||||
|
||||
RLCPP_NODISCARD std::string ToString() const { return TextFormat("Color(%d, %d, %d, %d)", r, g, b, a); }
|
||||
|
||||
explicit operator std::string() const { return ToString(); }
|
||||
|
||||
/**
|
||||
* Returns color with alpha applied, alpha goes from 0.0f to 1.0f
|
||||
*/
|
||||
RLCPP_NODISCARD Color Fade(float alpha) const { return ::Fade(*this, alpha); }
|
||||
|
||||
/**
|
||||
* Returns Color normalized as float [0..1]
|
||||
*/
|
||||
RLCPP_NODISCARD Vector4 Normalize() const { return ::ColorNormalize(*this); }
|
||||
|
||||
/**
|
||||
* Returns Color from normalized values [0..1]
|
||||
*/
|
||||
explicit Color(::Vector4 normalized) : Color(::ColorFromNormalized(normalized)) { }
|
||||
|
||||
/**
|
||||
* Returns HSV values for a Color
|
||||
*/
|
||||
RLCPP_NODISCARD Vector3 ToHSV() const { return ::ColorToHSV(*this); }
|
||||
|
||||
GETTERSETTER(unsigned char, R, r)
|
||||
GETTERSETTER(unsigned char, G, g)
|
||||
GETTERSETTER(unsigned char, B, b)
|
||||
GETTERSETTER(unsigned char, A, a)
|
||||
|
||||
Color& operator=(const ::Color& color) {
|
||||
set(color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set background color (framebuffer clear color)
|
||||
*/
|
||||
Color& ClearBackground() {
|
||||
::ClearBackground(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
void DrawPixel(int x, int y) const { ::DrawPixel(x, y, *this); }
|
||||
|
||||
/**
|
||||
* Draw a pixel
|
||||
*/
|
||||
void DrawPixel(::Vector2 pos) const { ::DrawPixelV(pos, *this); }
|
||||
|
||||
/**
|
||||
* Draw a line
|
||||
*/
|
||||
void DrawLine(int startPosX, int startPosY, int endPosX, int endPosY) const {
|
||||
::DrawLine(startPosX, startPosY, endPosX, endPosY, *this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw a line using Vector points
|
||||
*/
|
||||
void DrawLine(::Vector2 startPos, ::Vector2 endPos) const { ::DrawLineV(startPos, endPos, *this); }
|
||||
|
||||
/**
|
||||
* Draw a line using Vector points, with a given thickness
|
||||
*/
|
||||
void DrawLine(::Vector2 startPos, ::Vector2 endPos, float thick) const {
|
||||
::DrawLineEx(startPos, endPos, thick, *this);
|
||||
}
|
||||
|
||||
void DrawLineBezier(::Vector2 startPos, ::Vector2 endPos, float thick = 1.0f) const {
|
||||
::DrawLineBezier(startPos, endPos, thick, *this);
|
||||
}
|
||||
|
||||
void DrawLineStrip(::Vector2* points, int numPoints) const { ::DrawLineStrip(points, numPoints, *this); }
|
||||
|
||||
void DrawText(const char* text, int posX = 0, int posY = 0, int fontSize = 10.0f) const {
|
||||
::DrawText(text, posX, posY, fontSize, *this);
|
||||
}
|
||||
|
||||
void DrawText(const std::string& text, int posX = 0, int posY = 0, int fontSize = 10.0f) const {
|
||||
::DrawText(text.c_str(), posX, posY, fontSize, *this);
|
||||
}
|
||||
|
||||
void DrawText(const ::Font& font, const char* text, ::Vector2 position, float fontSize, float spacing) const {
|
||||
::DrawTextEx(font, text, position, fontSize, spacing, *this);
|
||||
}
|
||||
|
||||
void
|
||||
DrawText(const ::Font& font, const std::string& text, ::Vector2 position, float fontSize, float spacing) const {
|
||||
::DrawTextEx(font, text.c_str(), position, fontSize, spacing, *this);
|
||||
}
|
||||
|
||||
void DrawText(
|
||||
const ::Font& font,
|
||||
const char* text,
|
||||
::Vector2 position,
|
||||
::Vector2 origin,
|
||||
float rotation,
|
||||
float fontSize,
|
||||
float spacing) const {
|
||||
::DrawTextPro(font, text, position, origin, rotation, fontSize, spacing, *this);
|
||||
}
|
||||
|
||||
void DrawText(
|
||||
const ::Font& font,
|
||||
const std::string& text,
|
||||
::Vector2 position,
|
||||
::Vector2 origin,
|
||||
float rotation,
|
||||
float fontSize,
|
||||
float spacing) const {
|
||||
::DrawTextPro(font, text.c_str(), position, origin, rotation, fontSize, spacing, *this);
|
||||
}
|
||||
|
||||
void DrawRectangle(int posX, int posY, int width, int height) const {
|
||||
::DrawRectangle(posX, posY, width, height, *this);
|
||||
}
|
||||
|
||||
void DrawRectangle(::Vector2 position, ::Vector2 size) const { ::DrawRectangleV(position, size, *this); }
|
||||
|
||||
void DrawRectangle(::Rectangle rec) const { ::DrawRectangleRec(rec, *this); }
|
||||
|
||||
void DrawRectangle(::Rectangle rec, ::Vector2 origin, float rotation) const {
|
||||
::DrawRectanglePro(rec, origin, rotation, *this);
|
||||
}
|
||||
|
||||
void DrawRectangleLines(int posX, int posY, int width, int height) const {
|
||||
::DrawRectangleLines(posX, posY, width, height, *this);
|
||||
}
|
||||
|
||||
void DrawRectangleLines(::Rectangle rec, float lineThick) const { ::DrawRectangleLinesEx(rec, lineThick, *this); }
|
||||
|
||||
bool IsEqual(::Color color) {
|
||||
return ::ColorIsEqual(*this, color);
|
||||
}
|
||||
|
||||
bool operator==(const ::Color& other) const { return ::ColorIsEqual(*this, other); }
|
||||
bool operator!=(const ::Color& other) const { return !::ColorIsEqual(*this, other); }
|
||||
|
||||
/**
|
||||
* Get color multiplied with another color
|
||||
*/
|
||||
Color Tint(::Color tint) { return ::ColorTint(*this, tint); }
|
||||
|
||||
/**
|
||||
* Get color with brightness correction, brightness factor goes from -1.0f to 1.0f
|
||||
*/
|
||||
Color Brightness(float factor) { return ::ColorBrightness(*this, factor); }
|
||||
|
||||
/**
|
||||
* Get color with contrast correction, contrast values between -1.0f and 1.0f
|
||||
*/
|
||||
Color Contrast(float contrast) { return ::ColorContrast(*this, contrast); }
|
||||
|
||||
/**
|
||||
* Returns color with alpha applied, alpha goes from 0.0f to 1.0f
|
||||
*/
|
||||
RLCPP_NODISCARD Color Alpha(float alpha) const { return ::ColorAlpha(*this, alpha); }
|
||||
|
||||
Color Lerp(::Color color2, float factor) {
|
||||
return ::ColorLerp(*this, color2, factor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns src alpha-blended into dst color with tint
|
||||
*/
|
||||
RLCPP_NODISCARD Color AlphaBlend(::Color dst, ::Color tint) const { return ::ColorAlphaBlend(dst, *this, tint); }
|
||||
|
||||
static Color LightGray() { return LIGHTGRAY; }
|
||||
static Color Gray() { return GRAY; }
|
||||
static Color DarkGray() { return DARKGRAY; }
|
||||
static Color Yellow() { return YELLOW; }
|
||||
static Color Gold() { return GOLD; }
|
||||
static Color Orange() { return ORANGE; }
|
||||
static Color Pink() { return PINK; }
|
||||
static Color Red() { return RED; }
|
||||
static Color Maroon() { return MAROON; }
|
||||
static Color Green() { return GREEN; }
|
||||
static Color Lime() { return LIME; }
|
||||
static Color DarkGreen() { return DARKGREEN; }
|
||||
static Color SkyBlue() { return SKYBLUE; }
|
||||
static Color Blue() { return BLUE; }
|
||||
static Color DarkBlue() { return DARKBLUE; }
|
||||
static Color Purple() { return PURPLE; }
|
||||
static Color Violet() { return VIOLET; }
|
||||
static Color DarkPurple() { return DARKPURPLE; }
|
||||
static Color Beige() { return BEIGE; }
|
||||
static Color Brown() { return BROWN; }
|
||||
static Color DarkBrown() { return DARKBROWN; }
|
||||
static Color White() { return WHITE; }
|
||||
static Color Black() { return BLACK; }
|
||||
static Color Blank() { return BLANK; }
|
||||
static Color Magenta() { return MAGENTA; }
|
||||
static Color RayWhite() { return RAYWHITE; }
|
||||
protected:
|
||||
void set(const ::Color& color) {
|
||||
r = color.r;
|
||||
g = color.g;
|
||||
b = color.b;
|
||||
a = color.a;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace raylib
|
||||
|
||||
using RColor = raylib::Color;
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_COLOR_HPP_
|
||||
@@ -0,0 +1,55 @@
|
||||
#ifndef RAYLIB_CPP_INCLUDE_FILEDATA_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_FILEDATA_HPP_
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
#include "./raylib.hpp"
|
||||
|
||||
namespace raylib {
|
||||
|
||||
class FileData {
|
||||
public:
|
||||
FileData() = default;
|
||||
FileData(const FileData&) = delete;
|
||||
FileData(FileData&& other) noexcept : data(other.data), bytesRead(other.bytesRead) {
|
||||
other.data = nullptr;
|
||||
other.bytesRead = 0;
|
||||
}
|
||||
FileData& operator=(const FileData&) = delete;
|
||||
FileData& operator=(FileData&& other) noexcept {
|
||||
std::swap(data, other.data);
|
||||
std::swap(bytesRead, other.bytesRead);
|
||||
return *this;
|
||||
}
|
||||
~FileData() { Unload(); }
|
||||
|
||||
explicit FileData(const std::string& fileName) { Load(fileName); }
|
||||
|
||||
GETTER(const unsigned char*, Data, data)
|
||||
GETTER(int, BytesRead, bytesRead)
|
||||
|
||||
void Load(const std::string& fileName) { Load(fileName.c_str()); }
|
||||
void Load(const char* fileName) {
|
||||
Unload();
|
||||
data = ::LoadFileData(fileName, &bytesRead);
|
||||
}
|
||||
|
||||
void Unload() {
|
||||
if (data != nullptr) {
|
||||
::UnloadFileData(data);
|
||||
data = nullptr;
|
||||
bytesRead = 0;
|
||||
}
|
||||
}
|
||||
private:
|
||||
unsigned char* data{nullptr};
|
||||
int bytesRead{0};
|
||||
};
|
||||
|
||||
} // namespace raylib
|
||||
|
||||
using RFileData = raylib::FileData;
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_FILEDATA_HPP_
|
||||
@@ -0,0 +1,60 @@
|
||||
#ifndef RAYLIB_CPP_INCLUDE_FILETEXT_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_FILETEXT_HPP_
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
#include "./raylib.hpp"
|
||||
|
||||
namespace raylib {
|
||||
|
||||
class FileText {
|
||||
public:
|
||||
FileText() = default;
|
||||
FileText(const FileText&) = delete;
|
||||
FileText(FileText&& other) noexcept : data(other.data), length(other.length) {
|
||||
other.data = nullptr;
|
||||
other.length = 0;
|
||||
}
|
||||
FileText& operator=(const FileText&) = delete;
|
||||
FileText& operator=(FileText&& other) noexcept {
|
||||
std::swap(data, other.data);
|
||||
std::swap(length, other.length);
|
||||
return *this;
|
||||
}
|
||||
~FileText() { Unload(); }
|
||||
|
||||
explicit FileText(const std::string& fileName) { Load(fileName); }
|
||||
|
||||
GETTER(const char*, Data, data)
|
||||
GETTER(unsigned int, Length, length)
|
||||
|
||||
RLCPP_NODISCARD const char* c_str() const { return data; }
|
||||
|
||||
RLCPP_NODISCARD std::string ToString() const { return data; }
|
||||
explicit operator std::string() const { return data; }
|
||||
|
||||
void Load(const std::string& fileName) { Load(fileName.c_str()); }
|
||||
void Load(const char* fileName) {
|
||||
data = ::LoadFileText(fileName);
|
||||
length = ::TextLength(data);
|
||||
}
|
||||
|
||||
void Unload() {
|
||||
if (data != nullptr) {
|
||||
::UnloadFileText(data);
|
||||
data = nullptr;
|
||||
length = 0;
|
||||
}
|
||||
}
|
||||
private:
|
||||
char* data{nullptr};
|
||||
unsigned int length{0};
|
||||
};
|
||||
|
||||
} // namespace raylib
|
||||
|
||||
using RFileText = raylib::FileText;
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_FILETEXT_HPP_
|
||||
@@ -0,0 +1,84 @@
|
||||
#ifndef RAYLIB_CPP_INCLUDE_FONT_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_FONT_HPP_
|
||||
|
||||
#include "./FontUnmanaged.hpp"
|
||||
|
||||
namespace raylib {
|
||||
/**
|
||||
* Font type, includes texture and charSet array data.
|
||||
*
|
||||
* The font will be unloaded on object destruction. Use raylib::FontUnmanaged if you're looking to not unload.
|
||||
*
|
||||
* @see raylib::FontUnmanaged
|
||||
*/
|
||||
class Font : public FontUnmanaged {
|
||||
public:
|
||||
using FontUnmanaged::FontUnmanaged;
|
||||
|
||||
Font(const Font&) = delete;
|
||||
Font& operator=(const Font&) = delete;
|
||||
|
||||
Font(Font&& other) noexcept {
|
||||
set(other);
|
||||
other.baseSize = 0;
|
||||
other.glyphCount = 0;
|
||||
other.glyphPadding = 0;
|
||||
other.texture = {};
|
||||
other.recs = nullptr;
|
||||
other.glyphs = nullptr;
|
||||
}
|
||||
|
||||
Font& operator=(Font&& other) noexcept {
|
||||
if (this == &other) {
|
||||
return *this;
|
||||
}
|
||||
Unload();
|
||||
set(other);
|
||||
other.baseSize = 0;
|
||||
other.glyphCount = 0;
|
||||
other.glyphPadding = 0;
|
||||
other.texture = {};
|
||||
other.recs = nullptr;
|
||||
other.glyphs = nullptr;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Font& operator=(const ::Font& font) {
|
||||
Unload();
|
||||
set(font);
|
||||
return *this;
|
||||
}
|
||||
|
||||
~Font() { Unload(); }
|
||||
|
||||
void Load(const std::string& fileName) {
|
||||
Unload();
|
||||
FontUnmanaged::Load(fileName);
|
||||
}
|
||||
|
||||
void Load(const std::string& fileName, int fontSize, const int* codepoints = nullptr, int codepointCount = 0) {
|
||||
Unload();
|
||||
FontUnmanaged::Load(fileName, fontSize, codepoints, codepointCount);
|
||||
}
|
||||
|
||||
void Load(const ::Image& image, ::Color key, int firstChar) {
|
||||
Unload();
|
||||
FontUnmanaged::Load(image, key, firstChar);
|
||||
}
|
||||
|
||||
void Load(
|
||||
const std::string& fileType,
|
||||
const unsigned char* fileData,
|
||||
int dataSize,
|
||||
int fontSize,
|
||||
const int* codepoints,
|
||||
int codepointCount) {
|
||||
Unload();
|
||||
FontUnmanaged::Load(fileType, fileData, dataSize, fontSize, codepoints, codepointCount);
|
||||
}
|
||||
};
|
||||
} // namespace raylib
|
||||
|
||||
using RFont = raylib::Font;
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_FONT_HPP_
|
||||
@@ -0,0 +1,312 @@
|
||||
#ifndef RAYLIB_CPP_INCLUDE_FONTUNMANAGED_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_FONTUNMANAGED_HPP_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "./RaylibException.hpp"
|
||||
#include "./TextureUnmanaged.hpp"
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
#include "./raylib.hpp"
|
||||
|
||||
namespace raylib {
|
||||
/**
|
||||
* A Font that is not managed by C++ RAII.
|
||||
*
|
||||
* Make sure to Unload() this if needed, otherwise use raylib::Font.
|
||||
*
|
||||
* @see raylib::Font
|
||||
*/
|
||||
class FontUnmanaged : public ::Font {
|
||||
public:
|
||||
FontUnmanaged(
|
||||
int baseSize,
|
||||
int glyphCount,
|
||||
int glyphPadding,
|
||||
::Texture2D texture,
|
||||
::Rectangle* recs = nullptr,
|
||||
::GlyphInfo* glyphs = nullptr)
|
||||
: ::Font{baseSize, glyphCount, glyphPadding, texture, recs, glyphs} {
|
||||
// Nothing.
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the default Font.
|
||||
*/
|
||||
FontUnmanaged() : ::Font(::GetFontDefault()) {}
|
||||
|
||||
/**
|
||||
* Creates a FontUnmanaged from an existing Font struct.
|
||||
*/
|
||||
FontUnmanaged(const ::Font& font) : ::Font(font) {}
|
||||
|
||||
/**
|
||||
* Loads a Font from the given file.
|
||||
*
|
||||
* @throws raylib::RaylibException Throws if the given font failed to initialize.
|
||||
*/
|
||||
FontUnmanaged(const std::string& fileName) { Load(fileName); }
|
||||
|
||||
/**
|
||||
* Loads a Font from the given file, with generation parameters.
|
||||
*
|
||||
* @throws raylib::RaylibException Throws if the given font failed to initialize.
|
||||
*/
|
||||
FontUnmanaged(const std::string& fileName, int fontSize, const int* codepoints = nullptr, int codepointCount = 0) {
|
||||
Load(fileName, fontSize, codepoints, codepointCount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a Font from the given image with a color key.
|
||||
*
|
||||
* @throws raylib::RaylibException Throws if the given font failed to initialize.
|
||||
*/
|
||||
FontUnmanaged(const ::Image& image, ::Color key, int firstChar) { Load(image, key, firstChar); }
|
||||
|
||||
/**
|
||||
* Loads a font from memory, based on the given file type and file data.
|
||||
*
|
||||
* @throws raylib::RaylibException Throws if the given font failed to initialize.
|
||||
*/
|
||||
FontUnmanaged(
|
||||
const std::string& fileType,
|
||||
const unsigned char* fileData,
|
||||
int dataSize,
|
||||
int fontSize,
|
||||
const int* codepoints,
|
||||
int codepointCount) {
|
||||
Load(fileType, fileData, dataSize, fontSize, codepoints, codepointCount);
|
||||
}
|
||||
|
||||
GETTER(int, BaseSize, baseSize)
|
||||
GETTER(int, GlyphCount, glyphCount)
|
||||
GETTER(int, GlyphPadding, glyphPadding)
|
||||
GETTER(::Rectangle*, Recs, recs)
|
||||
GETTER(::GlyphInfo*, Glyphs, glyphs)
|
||||
|
||||
/**
|
||||
* Get the texture atlas containing the glyphs.
|
||||
*/
|
||||
TextureUnmanaged GetTexture() { return texture; }
|
||||
RLCPP_NODISCARD TextureUnmanaged GetTexture() const { return texture; }
|
||||
|
||||
/**
|
||||
* Set the texture atlas containing the glyphs.
|
||||
*/
|
||||
void SetTexture(const ::Texture& newTexture) { texture = newTexture; }
|
||||
|
||||
FontUnmanaged& operator=(const ::Font& font) {
|
||||
set(font);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a font from a given file.
|
||||
*
|
||||
* @throws raylib::RaylibException Throws if the given font failed to initialize.
|
||||
*/
|
||||
void Load(const std::string& fileName) {
|
||||
set(::LoadFont(fileName.c_str()));
|
||||
if (!IsValid()) {
|
||||
throw RaylibException("Failed to load Font with from file: " + fileName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a font from a given file with generation parameters.
|
||||
*
|
||||
* @throws raylib::RaylibException Throws if the given font failed to initialize.
|
||||
*/
|
||||
void Load(const std::string& fileName, int fontSize, const int* codepoints = nullptr, int codepointCount = 0) {
|
||||
set(::LoadFontEx(fileName.c_str(), fontSize, codepoints, codepointCount));
|
||||
if (!IsValid()) {
|
||||
throw RaylibException("Failed to load Font with from file with font size: " + fileName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a font from an image with a color key.
|
||||
*
|
||||
* @throws raylib::RaylibException Throws if the given font failed to initialize.
|
||||
*/
|
||||
void Load(const ::Image& image, ::Color key, int firstChar) {
|
||||
set(::LoadFontFromImage(image, key, firstChar));
|
||||
if (!IsValid()) {
|
||||
throw RaylibException("Failed to load Font with from image");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a font from memory.
|
||||
*
|
||||
* @throws raylib::RaylibException Throws if the given font failed to initialize.
|
||||
*/
|
||||
void Load(
|
||||
const std::string& fileType,
|
||||
const unsigned char* fileData,
|
||||
int dataSize,
|
||||
int fontSize,
|
||||
const int* codepoints,
|
||||
int codepointCount) {
|
||||
set(::LoadFontFromMemory(fileType.c_str(), fileData, dataSize, fontSize, codepoints, codepointCount));
|
||||
if (!IsValid()) {
|
||||
throw RaylibException("Failed to load Font " + fileType + " with from file data");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unload font from memory.
|
||||
*/
|
||||
void Unload() {
|
||||
// Protect against calling UnloadFont() twice.
|
||||
if (baseSize != 0) {
|
||||
::UnloadFont(*this);
|
||||
baseSize = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the font is ready to be used.
|
||||
*/
|
||||
RLCPP_NODISCARD bool IsValid() const { return ::IsFontValid(*this); }
|
||||
|
||||
/**
|
||||
* Draw text using font and additional parameters.
|
||||
*/
|
||||
void DrawText(const char* text, ::Vector2 position, float fontSize, float spacing, ::Color tint = WHITE) const {
|
||||
::DrawTextEx(*this, text, position, fontSize, spacing, tint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw text using font and additional parameters.
|
||||
*/
|
||||
void DrawText(
|
||||
const std::string& text,
|
||||
::Vector2 position,
|
||||
float fontSize,
|
||||
float spacing,
|
||||
::Color tint = WHITE) const {
|
||||
::DrawTextEx(*this, text.c_str(), position, fontSize, spacing, tint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw text using font and additional parameters.
|
||||
*/
|
||||
void DrawText(const char* text, int posX, int posY, float fontSize, float spacing, ::Color tint = WHITE) const {
|
||||
::DrawTextEx(*this, text, {static_cast<float>(posX), static_cast<float>(posY)}, fontSize, spacing, tint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw text using font and additional parameters.
|
||||
*/
|
||||
void DrawText(
|
||||
const std::string& text,
|
||||
int posX,
|
||||
int posY,
|
||||
float fontSize,
|
||||
float spacing,
|
||||
::Color tint = WHITE) const {
|
||||
::DrawTextEx(
|
||||
*this,
|
||||
text.c_str(),
|
||||
{static_cast<float>(posX), static_cast<float>(posY)},
|
||||
fontSize,
|
||||
spacing,
|
||||
tint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw text using font with pro parameters (rotation).
|
||||
*/
|
||||
void DrawText(
|
||||
const char* text,
|
||||
::Vector2 position,
|
||||
::Vector2 origin,
|
||||
float rotation,
|
||||
float fontSize,
|
||||
float spacing,
|
||||
::Color tint = WHITE) const {
|
||||
::DrawTextPro(*this, text, position, origin, rotation, fontSize, spacing, tint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw text using font with pro parameters (rotation).
|
||||
*/
|
||||
void DrawText(
|
||||
const std::string& text,
|
||||
::Vector2 position,
|
||||
::Vector2 origin,
|
||||
float rotation,
|
||||
float fontSize,
|
||||
float spacing,
|
||||
::Color tint = WHITE) const {
|
||||
::DrawTextPro(*this, text.c_str(), position, origin, rotation, fontSize, spacing, tint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw one character (codepoint).
|
||||
*/
|
||||
void DrawText(int codepoint, ::Vector2 position, float fontSize, ::Color tint = {255, 255, 255, 255}) const {
|
||||
::DrawTextCodepoint(*this, codepoint, position, fontSize, tint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw multiple characters (codepoints).
|
||||
*/
|
||||
void DrawText(
|
||||
const int* codepoints,
|
||||
int count,
|
||||
::Vector2 position,
|
||||
float fontSize,
|
||||
float spacing,
|
||||
::Color tint = {255, 255, 255, 255}) const {
|
||||
::DrawTextCodepoints(*this, codepoints, count, position, fontSize, spacing, tint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Measure string size for Font.
|
||||
*/
|
||||
RLCPP_NODISCARD Vector2 MeasureText(const char* text, float fontSize, float spacing) const {
|
||||
return ::MeasureTextEx(*this, text, fontSize, spacing);
|
||||
}
|
||||
|
||||
/**
|
||||
* Measure string size for Font.
|
||||
*/
|
||||
RLCPP_NODISCARD Vector2 MeasureText(const std::string& text, float fontSize, float spacing) const {
|
||||
return ::MeasureTextEx(*this, text.c_str(), fontSize, spacing);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get index position for a unicode character on font.
|
||||
*/
|
||||
RLCPP_NODISCARD int GetGlyphIndex(int character) const { return ::GetGlyphIndex(*this, character); }
|
||||
|
||||
/**
|
||||
* Create an image from text (custom sprite font).
|
||||
*/
|
||||
RLCPP_NODISCARD ::Image ImageText(const char* text, float fontSize, float spacing, ::Color tint) const {
|
||||
return ::ImageTextEx(*this, text, fontSize, spacing, tint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an image from text (custom sprite font).
|
||||
*/
|
||||
RLCPP_NODISCARD ::Image ImageText(const std::string& text, float fontSize, float spacing, ::Color tint) const {
|
||||
return ::ImageTextEx(*this, text.c_str(), fontSize, spacing, tint);
|
||||
}
|
||||
|
||||
protected:
|
||||
void set(const ::Font& font) {
|
||||
baseSize = font.baseSize;
|
||||
glyphCount = font.glyphCount;
|
||||
glyphPadding = font.glyphPadding;
|
||||
texture = font.texture;
|
||||
recs = font.recs;
|
||||
glyphs = font.glyphs;
|
||||
}
|
||||
};
|
||||
} // namespace raylib
|
||||
|
||||
using RFontUnmanaged = raylib::FontUnmanaged;
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_FONTUNMANAGED_HPP_
|
||||
@@ -0,0 +1,464 @@
|
||||
/**
|
||||
* C++ wrapper functions for raylib.
|
||||
*/
|
||||
#ifndef RAYLIB_CPP_INCLUDE_FUNCTIONS_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_FUNCTIONS_HPP_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "./raylib.hpp"
|
||||
|
||||
/**
|
||||
* Allow changing the declare type for all raylib-cpp global functions. Defaults to static.
|
||||
*/
|
||||
#ifndef RLCPPAPI
|
||||
#define RLCPPAPI static
|
||||
#endif
|
||||
|
||||
namespace raylib {
|
||||
|
||||
/**
|
||||
* Initialize window and OpenGL context
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline void InitWindow(int width, int height, const std::string& title = "raylib") {
|
||||
::InitWindow(width, height, title.c_str());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set title for window
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline void SetWindowTitle(const std::string& title) {
|
||||
::SetWindowTitle(title.c_str());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the human-readable, UTF-8 encoded name of the primary monitor
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline std::string GetMonitorName(int monitor = 0) {
|
||||
return ::GetMonitorName(monitor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set clipboard text content
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline void SetClipboardText(const std::string& text) {
|
||||
::SetClipboardText(text.c_str());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get clipboard text content
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline std::string GetClipboardText() {
|
||||
return ::GetClipboardText();
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes a screenshot of current screen (saved a .png)
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline void TakeScreenshot(const std::string& fileName) {
|
||||
::TakeScreenshot(fileName.c_str());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get gamepad internal name id
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline std::string GetGamepadName(int gamepad) {
|
||||
return ::GetGamepadName(gamepad);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load text data from file (read)
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI std::string LoadFileText(const std::string& fileName) {
|
||||
char* text = ::LoadFileText(fileName.c_str());
|
||||
std::string output(text);
|
||||
::UnloadFileText(text);
|
||||
return output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save text data to file (write)
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline bool SaveFileText(const std::string& fileName, const std::string& text) {
|
||||
return ::SaveFileText(fileName.c_str(), text.c_str());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if file exists
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline bool FileExists(const std::string& fileName) {
|
||||
return ::FileExists(fileName.c_str());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if directory path exists
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline bool DirectoryExists(const std::string& dirPath) {
|
||||
return ::DirectoryExists(dirPath.c_str());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check file extension (including point: .png, .wav)
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline bool IsFileExtension(const std::string& fileName, const std::string& ext) {
|
||||
return ::IsFileExtension(fileName.c_str(), ext.c_str());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get pointer to extension for a filename string (including point: ".png")
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline std::string GetFileExtension(const std::string& fileName) {
|
||||
return ::GetFileExtension(fileName.c_str());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get pointer to filename for a path string
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline std::string GetFileName(const std::string& filePath) {
|
||||
return ::GetFileName(filePath.c_str());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get filename string without extension
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline std::string GetFileNameWithoutExt(const std::string& filePath) {
|
||||
return ::GetFileNameWithoutExt(filePath.c_str());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get full path for a given fileName with path
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline std::string GetDirectoryPath(const std::string& filePath) {
|
||||
return ::GetDirectoryPath(filePath.c_str());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get previous directory path for a given path
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline std::string GetPrevDirectoryPath(const std::string& dirPath) {
|
||||
return ::GetPrevDirectoryPath(dirPath.c_str());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current working directory
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline std::string GetWorkingDirectory() {
|
||||
return ::GetWorkingDirectory();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get filenames in a directory path
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI std::vector<std::string> LoadDirectoryFiles(const std::string& dirPath) {
|
||||
FilePathList files = ::LoadDirectoryFiles(dirPath.c_str());
|
||||
std::vector<std::string> output(files.paths, files.paths + files.count);
|
||||
::UnloadDirectoryFiles(files);
|
||||
return output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load directory filepaths with extension filtering and optional subdirectory scanning
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI std::vector<std::string>
|
||||
LoadDirectoryFilesEx(const std::string& basePath, const std::string& filter, bool scanSubdirs = false) {
|
||||
FilePathList files = ::LoadDirectoryFilesEx(basePath.c_str(), filter.c_str(), scanSubdirs);
|
||||
std::vector<std::string> output(files.paths, files.paths + files.count);
|
||||
::UnloadDirectoryFiles(files);
|
||||
return output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change working directory, return true on success
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline bool ChangeDirectory(const std::string& dir) {
|
||||
return ::ChangeDirectory(dir.c_str());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get dropped files names
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI std::vector<std::string> LoadDroppedFiles() {
|
||||
if (!::IsFileDropped()) {
|
||||
return std::vector<std::string>();
|
||||
}
|
||||
FilePathList files = ::LoadDroppedFiles();
|
||||
std::vector<std::string> output(files.paths, files.paths + files.count);
|
||||
::UnloadDroppedFiles(files);
|
||||
return output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get file modification time (last write time)
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline long GetFileModTime(const std::string& fileName) { // NOLINT
|
||||
return ::GetFileModTime(fileName.c_str());
|
||||
}
|
||||
|
||||
/**
|
||||
* Open URL with default system browser (if available)
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline void OpenURL(const std::string& url) {
|
||||
return ::OpenURL(url.c_str());
|
||||
}
|
||||
|
||||
/**
|
||||
* Load an image.
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline ::Image LoadImage(const std::string& fileName) {
|
||||
return ::LoadImage(fileName.c_str());
|
||||
}
|
||||
|
||||
/**
|
||||
* Load an image from RAW file data
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline ::Image
|
||||
LoadImageRaw(const std::string& fileName, int width, int height, int format, int headerSize) {
|
||||
return ::LoadImageRaw(fileName.c_str(), width, height, format, headerSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load animated image data
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline ::Image LoadImageAnim(const std::string& fileName, int* frames) {
|
||||
return ::LoadImageAnim(fileName.c_str(), frames);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load image from memory buffer, fileType refers to extension like "png"
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline ::Image
|
||||
LoadImageFromMemory(const std::string& fileType, const unsigned char* fileData, int dataSize) {
|
||||
return ::LoadImageFromMemory(fileType.c_str(), fileData, dataSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Export image data to file
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline bool ExportImage(const Image& image, const std::string& fileName) {
|
||||
return ::ExportImage(image, fileName.c_str());
|
||||
}
|
||||
|
||||
/**
|
||||
* Export image as code file (.h) defining an array of bytes
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline bool ExportImageAsCode(const Image& image, const std::string& fileName) {
|
||||
return ::ExportImageAsCode(image, fileName.c_str());
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw text (using default font)
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline void DrawText(const char* text, int posX, int posY, int fontSize, ::Color color) {
|
||||
::DrawText(text, posX, posY, fontSize, color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw text (using default font)
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline void
|
||||
DrawText(const std::string& text, int posX, int posY, int fontSize, ::Color color) {
|
||||
::DrawText(text.c_str(), posX, posY, fontSize, color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw text using font and additional parameters
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline void
|
||||
DrawTextEx(const Font& font, const char* text, Vector2 position, float fontSize, float spacing, ::Color tint) {
|
||||
::DrawTextEx(font, text, position, fontSize, spacing, tint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw text using font and additional parameters
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline void
|
||||
DrawTextEx(const Font& font, const std::string& text, Vector2 position, float fontSize, float spacing, ::Color tint) {
|
||||
::DrawTextEx(font, text.c_str(), position, fontSize, spacing, tint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw text using Font and pro parameters (rotation)
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline void DrawTextPro(
|
||||
const Font& font,
|
||||
const char* text,
|
||||
Vector2 position,
|
||||
Vector2 origin,
|
||||
float rotation,
|
||||
float fontSize,
|
||||
float spacing,
|
||||
::Color tint) {
|
||||
::DrawTextPro(font, text, position, origin, rotation, fontSize, spacing, tint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw text using Font and pro parameters (rotation)
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline void DrawTextPro(
|
||||
const Font& font,
|
||||
const std::string& text,
|
||||
Vector2 position,
|
||||
Vector2 origin,
|
||||
float rotation,
|
||||
float fontSize,
|
||||
float spacing,
|
||||
::Color tint) {
|
||||
::DrawTextPro(font, text.c_str(), position, origin, rotation, fontSize, spacing, tint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load font from file (filename must include file extension)
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline ::Font LoadFont(const std::string& fileName) {
|
||||
return ::LoadFont(fileName.c_str());
|
||||
}
|
||||
|
||||
/**
|
||||
* Load font from file (filename must include file extension)
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline ::Font
|
||||
LoadFontEx(const std::string& fileName, int fontSize, const int* codepoints = nullptr, int codepointCount = 0) {
|
||||
return ::LoadFontEx(fileName.c_str(), fontSize, codepoints, codepointCount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Measure string width for default font
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline int MeasureText(const char* text, int fontSize) {
|
||||
return ::MeasureText(text, fontSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Measure string width for default font
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline int MeasureText(const std::string& text, int fontSize) {
|
||||
return ::MeasureText(text.c_str(), fontSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if two text string are equal
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline bool TextIsEqual(const char* text1, const char* text2) {
|
||||
return ::TextIsEqual(text1, text2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if two text string are equal
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline bool TextIsEqual(const std::string& text1, const std::string& text2) {
|
||||
return ::TextIsEqual(text1.c_str(), text2.c_str());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get text length, checks for '\0' ending
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline unsigned int TextLength(const char* text) {
|
||||
return ::TextLength(text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get text length, checks for '\0' ending
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline unsigned int TextLength(const std::string& text) {
|
||||
return ::TextLength(text.c_str());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a piece of a text string
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline std::string TextSubtext(const std::string& text, int position, int length) {
|
||||
return ::TextSubtext(text.c_str(), position, length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace text string
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI std::string
|
||||
TextReplace(const std::string& text, const std::string& replace, const std::string& by) {
|
||||
const char* output = ::TextReplace(text.c_str(), replace.c_str(), by.c_str());
|
||||
if (output != NULL) {
|
||||
return std::string(output);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert text in a position
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI std::string TextInsert(const std::string& text, const std::string& insert, int position) {
|
||||
const char* output = ::TextInsert(text.c_str(), insert.c_str(), position);
|
||||
if (output != NULL) {
|
||||
return std::string(output);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Split text into multiple strings
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI std::vector<std::string> TextSplit(const std::string& text, char delimiter) {
|
||||
int count;
|
||||
const char* const* split = ::TextSplit(text.c_str(), delimiter, &count);
|
||||
return std::vector<std::string>(split, split + count);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find first text occurrence within a string
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline int TextFindIndex(const std::string& text, const std::string& find) {
|
||||
return ::TextFindIndex(text.c_str(), find.c_str());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get upper case version of provided string
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline std::string TextToUpper(const std::string& text) {
|
||||
return ::TextToUpper(text.c_str());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get lower case version of provided string
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline std::string TextToLower(const std::string& text) {
|
||||
return ::TextToLower(text.c_str());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Pascal case notation version of provided string
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline std::string TextToPascal(const std::string& text) {
|
||||
return ::TextToPascal(text.c_str());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Snake case notation version of provided string
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline std::string TextToSnake(const std::string& text) {
|
||||
return ::TextToSnake(text.c_str());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Camel case notation version of provided string
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline std::string TextToCamel(const std::string& text) {
|
||||
return ::TextToCamel(text.c_str());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get integer value from text (negative values not supported)
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline int TextToInteger(const std::string& text) {
|
||||
return ::TextToInteger(text.c_str());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get float value from text
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline float TextToFloat(const std::string& text) {
|
||||
return ::TextToFloat(text.c_str());
|
||||
}
|
||||
|
||||
} // namespace raylib
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_FUNCTIONS_HPP_
|
||||
@@ -0,0 +1,106 @@
|
||||
#ifndef RAYLIB_CPP_INCLUDE_GAMEPAD_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_GAMEPAD_HPP_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
#include "./raylib.hpp"
|
||||
|
||||
namespace raylib {
|
||||
/**
|
||||
* Input-related functions: gamepads
|
||||
*/
|
||||
class Gamepad {
|
||||
public:
|
||||
Gamepad(int gamepadNumber = 0) : number(gamepadNumber) {};
|
||||
int number;
|
||||
|
||||
GETTERSETTER(int, Number, number)
|
||||
|
||||
Gamepad& operator=(const Gamepad& gamepad) {
|
||||
if (this != &gamepad) {
|
||||
set(static_cast<int>(gamepad));
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
Gamepad& operator=(int gamepadNumber) {
|
||||
if (this->number != gamepadNumber) {
|
||||
set(gamepadNumber);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
explicit operator int() const { return number; }
|
||||
|
||||
/**
|
||||
* Detect if a gamepad is available
|
||||
*/
|
||||
RLCPP_NODISCARD bool IsAvailable() const { return ::IsGamepadAvailable(number); }
|
||||
|
||||
/**
|
||||
* Detect if a gamepad is available
|
||||
*/
|
||||
static bool IsAvailable(int number) { return ::IsGamepadAvailable(number); }
|
||||
|
||||
/**
|
||||
* Return gamepad internal name id
|
||||
*/
|
||||
RLCPP_NODISCARD std::string GetName() const { return ::GetGamepadName(number); }
|
||||
|
||||
/**
|
||||
* Return gamepad internal name id
|
||||
*/
|
||||
explicit operator std::string() const { return GetName(); }
|
||||
|
||||
/**
|
||||
* Detect if a gamepad button has been pressed once
|
||||
*/
|
||||
RLCPP_NODISCARD bool IsButtonPressed(int button) const { return ::IsGamepadButtonPressed(number, button); }
|
||||
|
||||
/**
|
||||
* Detect if a gamepad button is being pressed
|
||||
*/
|
||||
RLCPP_NODISCARD bool IsButtonDown(int button) const { return ::IsGamepadButtonDown(number, button); }
|
||||
|
||||
/**
|
||||
* Detect if a gamepad button has been released once
|
||||
*/
|
||||
RLCPP_NODISCARD bool IsButtonReleased(int button) const { return ::IsGamepadButtonReleased(number, button); }
|
||||
|
||||
/**
|
||||
* Detect if a gamepad button is NOT being pressed
|
||||
*/
|
||||
RLCPP_NODISCARD bool IsButtonUp(int button) const { return ::IsGamepadButtonUp(number, button); }
|
||||
|
||||
/**
|
||||
* Get the last gamepad button pressed
|
||||
*/
|
||||
static int GetButtonPressed() { return ::GetGamepadButtonPressed(); }
|
||||
|
||||
/**
|
||||
* Return gamepad axis count for a gamepad
|
||||
*/
|
||||
RLCPP_NODISCARD int GetAxisCount() const { return ::GetGamepadAxisCount(number); }
|
||||
|
||||
/**
|
||||
* Return axis movement value for a gamepad axis
|
||||
*/
|
||||
RLCPP_NODISCARD float GetAxisMovement(int axis) const { return ::GetGamepadAxisMovement(number, axis); }
|
||||
|
||||
static int SetMappings(const std::string& mappings) { return SetGamepadMappings(mappings.c_str()); }
|
||||
|
||||
/**
|
||||
* Set gamepad vibration for both motors (duration in seconds)
|
||||
*/
|
||||
void SetVibration(float leftMotor, float rightMotor, float duration) const {
|
||||
::SetGamepadVibration(number, leftMotor, rightMotor, duration);
|
||||
}
|
||||
protected:
|
||||
void set(int gamepadNumber) { number = gamepadNumber; }
|
||||
};
|
||||
} // namespace raylib
|
||||
|
||||
using RGamepad = raylib::Gamepad;
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_GAMEPAD_HPP_
|
||||
@@ -0,0 +1,775 @@
|
||||
#ifndef RAYLIB_CPP_INCLUDE_IMAGE_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_IMAGE_HPP_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "./Color.hpp"
|
||||
#include "./RaylibException.hpp"
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
#include "./raylib.hpp"
|
||||
|
||||
namespace raylib {
|
||||
/**
|
||||
* Image type, bpp always RGBA (32bit)
|
||||
*
|
||||
* Data stored in CPU memory (RAM)
|
||||
*/
|
||||
class Image : public ::Image {
|
||||
public:
|
||||
Image(
|
||||
void* data = nullptr,
|
||||
int width = 0,
|
||||
int height = 0,
|
||||
int mipmaps = 1,
|
||||
int format = PIXELFORMAT_UNCOMPRESSED_R8G8B8A8)
|
||||
: ::Image{data, width, height, mipmaps, format} {
|
||||
// Nothing.
|
||||
}
|
||||
|
||||
Image(const ::Image& image) : ::Image(image) { }
|
||||
|
||||
/**
|
||||
* Load an image from the given file.
|
||||
*
|
||||
* @throws raylib::RaylibException Thrown if the image failed to load from the file.
|
||||
*
|
||||
* @see Load()
|
||||
*/
|
||||
Image(const std::string& fileName) { Load(fileName); }
|
||||
|
||||
/**
|
||||
* Load a raw image from the given file, with the provided width, height, and formats.
|
||||
*
|
||||
* @throws raylib::RaylibException Thrown if the image failed to load from the file.
|
||||
*
|
||||
* @see LoadRaw()
|
||||
*/
|
||||
Image(const std::string& fileName, int width, int height, int format, int headerSize = 0) {
|
||||
Load(fileName, width, height, format, headerSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load an animation image from the given file.
|
||||
*
|
||||
* @throws raylib::RaylibException Thrown if the image failed to load from the file.
|
||||
*
|
||||
* @see LoadAnim()
|
||||
*/
|
||||
Image(const std::string& fileName, int* frames) { Load(fileName, frames); }
|
||||
|
||||
/**
|
||||
* Load an image from the given file.
|
||||
*
|
||||
* @throws raylib::RaylibException Thrown if the image failed to load from the file.
|
||||
*/
|
||||
Image(const std::string& fileType, const unsigned char* fileData, int dataSize) {
|
||||
Load(fileType, fileData, dataSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load an image from the given file.
|
||||
*
|
||||
* @throws raylib::RaylibException Thrown if the image failed to load from the file.
|
||||
*/
|
||||
Image(const ::Texture2D& texture) { Load(texture); }
|
||||
|
||||
Image(int width, int height, ::Color color = {255, 255, 255, 255}) { set(::GenImageColor(width, height, color)); }
|
||||
|
||||
Image(const std::string& text, int fontSize, ::Color color = {255, 255, 255, 255}) {
|
||||
set(::ImageText(text.c_str(), fontSize, color));
|
||||
}
|
||||
|
||||
Image(
|
||||
const ::Font& font,
|
||||
const std::string& text,
|
||||
float fontSize,
|
||||
float spacing,
|
||||
::Color tint = {255, 255, 255, 255}) {
|
||||
set(::ImageTextEx(font, text.c_str(), fontSize, spacing, tint));
|
||||
}
|
||||
|
||||
Image(const Image& other) { set(other.Copy()); }
|
||||
|
||||
Image(Image&& other) noexcept {
|
||||
set(other);
|
||||
|
||||
other.data = nullptr;
|
||||
other.width = 0;
|
||||
other.height = 0;
|
||||
other.mipmaps = 0;
|
||||
other.format = 0;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string ToString() const { return TextFormat("Image(width=%d, height=%d)", width, height); }
|
||||
|
||||
operator std::string() const { return ToString(); }
|
||||
|
||||
static ::Image Text(const std::string& text, int fontSize, ::Color color = {255, 255, 255, 255}) {
|
||||
return ::ImageText(text.c_str(), fontSize, color);
|
||||
}
|
||||
|
||||
static ::Image Text(
|
||||
const ::Font& font,
|
||||
const std::string& text,
|
||||
float fontSize,
|
||||
float spacing,
|
||||
::Color tint = {255, 255, 255, 255}) {
|
||||
return ::ImageTextEx(font, text.c_str(), fontSize, spacing, tint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get pixel data from screen buffer and return an Image (screenshot)
|
||||
*/
|
||||
static ::Image LoadFromScreen() { return ::LoadImageFromScreen(); }
|
||||
|
||||
/**
|
||||
* Generate image: plain color
|
||||
*/
|
||||
static ::Image Color(int width, int height, ::Color color = {255, 255, 255, 255}) {
|
||||
return ::GenImageColor(width, height, color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate image: linear gradient
|
||||
*/
|
||||
static ::Image GradientLinear(int width, int height, int direction, ::Color start, ::Color end) {
|
||||
return ::GenImageGradientLinear(width, height, direction, start, end);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate image: radial gradient
|
||||
*/
|
||||
static ::Image GradientRadial(int width, int height, float density, ::Color inner, ::Color outer) {
|
||||
return ::GenImageGradientRadial(width, height, density, inner, outer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate image: checked
|
||||
*/
|
||||
static ::Image Checked(
|
||||
int width,
|
||||
int height,
|
||||
int checksX,
|
||||
int checksY,
|
||||
::Color col1 = {255, 255, 255, 255},
|
||||
::Color col2 = {0, 0, 0, 255}) {
|
||||
return ::GenImageChecked(width, height, checksX, checksY, col1, col2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate image: white noise
|
||||
*/
|
||||
static ::Image WhiteNoise(int width, int height, float factor) {
|
||||
return ::GenImageWhiteNoise(width, height, factor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate image: cellular algorithm. Bigger tileSize means bigger cells
|
||||
*/
|
||||
static ::Image Cellular(int width, int height, int tileSize) { return ::GenImageCellular(width, height, tileSize); }
|
||||
|
||||
/**
|
||||
* Get clipboard image content.
|
||||
*/
|
||||
static ::Image GetClipboard() { return ::GetClipboardImage(); }
|
||||
|
||||
~Image() { Unload(); }
|
||||
|
||||
Image& operator=(const ::Image& image) {
|
||||
set(image);
|
||||
return *this;
|
||||
}
|
||||
|
||||
Image& operator=(const Image& other) {
|
||||
if (this == &other) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
Unload();
|
||||
set(other.Copy());
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Image& operator=(Image&& other) noexcept {
|
||||
if (this == &other) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
Unload();
|
||||
set(other);
|
||||
|
||||
other.data = nullptr;
|
||||
other.width = 0;
|
||||
other.height = 0;
|
||||
other.mipmaps = 0;
|
||||
other.format = 0;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load image from file into CPU memory (RAM)
|
||||
*
|
||||
* @throws raylib::RaylibException Thrown if the image failed to load from the file.
|
||||
*
|
||||
* @see ::LoadImage()
|
||||
*/
|
||||
void Load(const std::string& fileName) {
|
||||
set(::LoadImage(fileName.c_str()));
|
||||
if (!IsValid()) {
|
||||
throw RaylibException("Failed to load Image from file: " + fileName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load image from RAW file data.
|
||||
*
|
||||
* @throws raylib::RaylibException Thrown if the image failed to load from the file.
|
||||
*
|
||||
* @see ::LoadImageRaw()
|
||||
*/
|
||||
void Load(const std::string& fileName, int width, int height, int format, int headerSize) {
|
||||
set(::LoadImageRaw(fileName.c_str(), width, height, format, headerSize));
|
||||
if (!IsValid()) {
|
||||
throw RaylibException("Failed to load Image from file: " + fileName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load image sequence from file (frames appended to image.data).
|
||||
*
|
||||
* @throws raylib::RaylibException Thrown if the image animation to load from the file.
|
||||
*
|
||||
* @see ::LoadImageAnim()
|
||||
*/
|
||||
void Load(const std::string& fileName, int* frames) {
|
||||
set(::LoadImageAnim(fileName.c_str(), frames));
|
||||
if (!IsValid()) {
|
||||
throw RaylibException("Failed to load Image from file: " + fileName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load image from memory buffer, fileType refers to extension: i.e. "png".
|
||||
*
|
||||
* @throws raylib::RaylibException Thrown if the image animation to load from the file.
|
||||
*
|
||||
* @see ::LoadImageFromMemory()
|
||||
*/
|
||||
void Load(const std::string& fileType, const unsigned char* fileData, int dataSize) {
|
||||
set(::LoadImageFromMemory(fileType.c_str(), fileData, dataSize));
|
||||
if (!IsValid()) {
|
||||
throw RaylibException("Failed to load Image data with file type: " + fileType);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load an image from the given file.
|
||||
*
|
||||
* @throws raylib::RaylibException Thrown if the image animation to load from the file.
|
||||
*
|
||||
* @see ::LoadImageFromTexture()
|
||||
*/
|
||||
void Load(const ::Texture2D& texture) {
|
||||
set(::LoadImageFromTexture(texture));
|
||||
if (!IsValid()) {
|
||||
throw RaylibException("Failed to load Image from texture.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unload image from CPU memory (RAM)
|
||||
*/
|
||||
void Unload() {
|
||||
if (data != nullptr) {
|
||||
::UnloadImage(*this);
|
||||
data = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Export image data to file, returns true on success
|
||||
*
|
||||
* @throws raylib::RaylibException Thrown if the image failed to load from the file.
|
||||
*/
|
||||
void Export(const std::string& fileName) const {
|
||||
if (!::ExportImage(*this, fileName.c_str())) {
|
||||
throw RaylibException(TextFormat("Failed to export Image to file: %s", fileName.c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Export image to memory buffer
|
||||
*/
|
||||
unsigned char* ExportToMemory(const char* fileType, int* fileSize) {
|
||||
return ::ExportImageToMemory(*this, fileType, fileSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Export image as code file defining an array of bytes, returns true on success
|
||||
*
|
||||
* @throws raylib::RaylibException Thrown if the image failed to load from the file.
|
||||
*/
|
||||
void ExportAsCode(const std::string& fileName) const {
|
||||
if (!::ExportImageAsCode(*this, fileName.c_str())) {
|
||||
throw RaylibException(TextFormat("Failed to export Image code to file: %s", fileName.c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
GETTER(void*, Data, data)
|
||||
GETTER(int, Width, width)
|
||||
GETTER(int, Height, height)
|
||||
GETTER(int, Mipmaps, mipmaps)
|
||||
GETTER(int, Format, format)
|
||||
|
||||
/**
|
||||
* Set the width of the image canvas.
|
||||
*
|
||||
* @see ResizeCanvas
|
||||
*/
|
||||
void SetWidth(int width, int offsetX = 0, int offsetY = 0, ::Color fill = {255, 255, 255, 255}) {
|
||||
ResizeCanvas(width, height, offsetX, offsetY, fill);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the height of the image canvas.
|
||||
*
|
||||
* @see ResizeCanvas
|
||||
*/
|
||||
void SetHeight(int height, int offsetX = 0, int offsetY = 0, ::Color fill = {255, 255, 255, 255}) {
|
||||
ResizeCanvas(width, height, offsetX, offsetY, fill);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the width and height of the image.
|
||||
*/
|
||||
RLCPP_NODISCARD ::Vector2 GetSize() const { return {static_cast<float>(width), static_cast<float>(height)}; }
|
||||
|
||||
/**
|
||||
* Create an image duplicate (useful for transformations)
|
||||
*/
|
||||
RLCPP_NODISCARD ::Image Copy() const { return ::ImageCopy(*this); }
|
||||
|
||||
/**
|
||||
* Create an image from another image piece
|
||||
*/
|
||||
RLCPP_NODISCARD ::Image FromImage(::Rectangle rec) const { return ::ImageFromImage(*this, rec); }
|
||||
|
||||
/**
|
||||
* Convert image data to desired format
|
||||
*/
|
||||
Image& Format(int newFormat) {
|
||||
::ImageFormat(this, newFormat);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert image to POT (power-of-two)
|
||||
*/
|
||||
Image& ToPOT(::Color fillColor) {
|
||||
::ImageToPOT(this, fillColor);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Crop an image to area defined by a rectangle
|
||||
*/
|
||||
Image& Crop(::Rectangle crop) {
|
||||
::ImageCrop(this, crop);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Crop image depending on alpha value
|
||||
*/
|
||||
Image& AlphaCrop(float threshold) {
|
||||
::ImageAlphaCrop(this, threshold);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear alpha channel to desired color
|
||||
*/
|
||||
Image& AlphaClear(::Color color, float threshold) {
|
||||
::ImageAlphaClear(this, color, threshold);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply alpha mask to image
|
||||
*/
|
||||
Image& AlphaMask(const ::Image& alphaMask) {
|
||||
::ImageAlphaMask(this, alphaMask);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Premultiply alpha channel
|
||||
*/
|
||||
Image& AlphaPremultiply() {
|
||||
::ImageAlphaPremultiply(this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Crop an image to a new given width and height.
|
||||
*/
|
||||
Image& Crop(int newWidth, int newHeight) { return Crop(0, 0, newWidth, newHeight); }
|
||||
|
||||
/**
|
||||
* Crop an image to a new given width and height based on a vector.
|
||||
*/
|
||||
Image& Crop(::Vector2 size) { return Crop(0, 0, static_cast<int>(size.x), static_cast<int>(size.y)); }
|
||||
|
||||
/**
|
||||
* Crop an image to area defined by a rectangle
|
||||
*/
|
||||
Image& Crop(int offsetX, int offsetY, int newWidth, int newHeight) {
|
||||
::Rectangle rect{
|
||||
static_cast<float>(offsetX),
|
||||
static_cast<float>(offsetY),
|
||||
static_cast<float>(newWidth),
|
||||
static_cast<float>(newHeight)};
|
||||
::ImageCrop(this, rect);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resize and image to new size
|
||||
*/
|
||||
Image& Resize(int newWidth, int newHeight) {
|
||||
::ImageResize(this, newWidth, newHeight);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resize and image to new size using Nearest-Neighbor scaling algorithm
|
||||
*/
|
||||
Image& ResizeNN(int newWidth, int newHeight) {
|
||||
::ImageResizeNN(this, newWidth, newHeight);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resize canvas and fill with color
|
||||
*/
|
||||
Image&
|
||||
ResizeCanvas(int newWidth, int newHeight, int offsetX = 0, int offsetY = 0, ::Color color = {255, 255, 255, 255}) {
|
||||
::ImageResizeCanvas(this, newWidth, newHeight, offsetX, offsetY, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate all mipmap levels for a provided image
|
||||
*/
|
||||
Image& Mipmaps() {
|
||||
::ImageMipmaps(this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dither image data to 16bpp or lower (Floyd-Steinberg dithering)
|
||||
*/
|
||||
Image& Dither(int rBpp, int gBpp, int bBpp, int aBpp) {
|
||||
::ImageDither(this, rBpp, gBpp, bBpp, aBpp);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Flip image vertically
|
||||
*/
|
||||
Image& FlipVertical() {
|
||||
::ImageFlipVertical(this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Flip image horizontally
|
||||
*/
|
||||
Image& FlipHorizontal() {
|
||||
::ImageFlipHorizontal(this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rotate image by input angle in degrees (-359 to 359)
|
||||
*/
|
||||
Image& Rotate(int degrees) {
|
||||
::ImageRotate(this, degrees);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rotate image clockwise 90deg
|
||||
*/
|
||||
Image& RotateCW() {
|
||||
::ImageRotateCW(this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rotate image counter-clockwise 90deg
|
||||
*/
|
||||
Image& RotateCCW() {
|
||||
::ImageRotateCCW(this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify image color: tint
|
||||
*/
|
||||
Image& ColorTint(::Color color = {255, 255, 255, 255}) {
|
||||
::ImageColorTint(this, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify image color: invert
|
||||
*/
|
||||
Image& ColorInvert() {
|
||||
::ImageColorInvert(this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify image color: grayscale
|
||||
*/
|
||||
Image& ColorGrayscale() {
|
||||
::ImageColorGrayscale(this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify image color: contrast
|
||||
*
|
||||
* @param contrast Contrast values between -100 and 100
|
||||
*/
|
||||
Image& ColorContrast(float contrast) {
|
||||
::ImageColorContrast(this, contrast);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify image color: brightness
|
||||
*
|
||||
* @param brightness Brightness values between -255 and 255
|
||||
*/
|
||||
Image& ColorBrightness(int brightness) {
|
||||
::ImageColorBrightness(this, brightness);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify image color: replace color
|
||||
*/
|
||||
Image& ColorReplace(::Color color, ::Color replace) {
|
||||
::ImageColorReplace(this, color, replace);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get image alpha border rectangle
|
||||
*
|
||||
* @param threshold Threshold is defined as a percentatge: 0.0f -> 1.0f
|
||||
*/
|
||||
RLCPP_NODISCARD Rectangle GetAlphaBorder(float threshold) const { return ::GetImageAlphaBorder(*this, threshold); }
|
||||
|
||||
/**
|
||||
* Get image pixel color at (x, y) position
|
||||
*/
|
||||
RLCPP_NODISCARD raylib::Color GetColor(int x = 0, int y = 0) const { return ::GetImageColor(*this, x, y); }
|
||||
|
||||
/**
|
||||
* Get image pixel color at vector position
|
||||
*/
|
||||
RLCPP_NODISCARD raylib::Color GetColor(::Vector2 position) const {
|
||||
return ::GetImageColor(*this, static_cast<int>(position.x), static_cast<int>(position.y));
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear image background with given color
|
||||
*/
|
||||
Image& ClearBackground(::Color color = {0, 0, 0, 255}) {
|
||||
::ImageClearBackground(this, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw pixel within an image
|
||||
*/
|
||||
void DrawPixel(int posX, int posY, ::Color color = {255, 255, 255, 255}) {
|
||||
::ImageDrawPixel(this, posX, posY, color);
|
||||
}
|
||||
|
||||
void DrawPixel(::Vector2 position, ::Color color = {255, 255, 255, 255}) {
|
||||
::ImageDrawPixelV(this, position, color);
|
||||
}
|
||||
|
||||
void DrawLine(int startPosX, int startPosY, int endPosX, int endPosY, ::Color color = {255, 255, 255, 255}) {
|
||||
::ImageDrawLine(this, startPosX, startPosY, endPosX, endPosY, color);
|
||||
}
|
||||
|
||||
void DrawLine(::Vector2 start, ::Vector2 end, ::Color color = {255, 255, 255, 255}) {
|
||||
::ImageDrawLineV(this, start, end, color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Description: Draw a line defining thickness within an image
|
||||
*/
|
||||
void DrawLine(::Vector2 start, ::Vector2 end, int thick, ::Color color = {255, 255, 255, 255}) {
|
||||
ImageDrawLineEx(this, start, end, thick, color);
|
||||
}
|
||||
|
||||
void DrawCircle(int centerX, int centerY, int radius, ::Color color = {255, 255, 255, 255}) {
|
||||
::ImageDrawCircle(this, centerX, centerY, radius, color);
|
||||
}
|
||||
|
||||
void DrawCircle(::Vector2 center, int radius, ::Color color = {255, 255, 255, 255}) {
|
||||
::ImageDrawCircleV(this, center, radius, color);
|
||||
}
|
||||
|
||||
void DrawRectangle(int posX, int posY, int width, int height, ::Color color = {255, 255, 255, 255}) {
|
||||
::ImageDrawRectangle(this, posX, posY, width, height, color);
|
||||
}
|
||||
|
||||
void DrawRectangle(Vector2 position, Vector2 size, ::Color color = {255, 255, 255, 255}) {
|
||||
::ImageDrawRectangleV(this, position, size, color);
|
||||
}
|
||||
|
||||
void DrawRectangle(::Rectangle rec, ::Color color = {255, 255, 255, 255}) {
|
||||
::ImageDrawRectangleRec(this, rec, color);
|
||||
}
|
||||
|
||||
void DrawRectangleLines(::Rectangle rec, int thick = 1, ::Color color = {255, 255, 255, 255}) {
|
||||
::ImageDrawRectangleLines(this, rec, thick, color);
|
||||
}
|
||||
|
||||
// TODO: Add ImageDrawTriangle()
|
||||
|
||||
void Draw(const ::Image& src, ::Rectangle srcRec, ::Rectangle dstRec, ::Color tint = {255, 255, 255, 255}) {
|
||||
::ImageDraw(this, src, srcRec, dstRec, tint);
|
||||
}
|
||||
|
||||
void DrawText(const char* text, ::Vector2 position, int fontSize, ::Color color = {255, 255, 255, 255}) {
|
||||
::ImageDrawText(this, text, static_cast<int>(position.x), static_cast<int>(position.y), fontSize, color);
|
||||
}
|
||||
|
||||
void DrawText(const std::string& text, ::Vector2 position, int fontSize, ::Color color = {255, 255, 255, 255}) {
|
||||
::ImageDrawText(
|
||||
this,
|
||||
text.c_str(),
|
||||
static_cast<int>(position.x),
|
||||
static_cast<int>(position.y),
|
||||
fontSize,
|
||||
color);
|
||||
}
|
||||
|
||||
void DrawText(const std::string& text, int x, int y, int fontSize, ::Color color = {255, 255, 255, 255}) {
|
||||
::ImageDrawText(this, text.c_str(), x, y, fontSize, color);
|
||||
}
|
||||
|
||||
void DrawText(const char* text, int x, int y, int fontSize, ::Color color = {255, 255, 255, 255}) {
|
||||
::ImageDrawText(this, text, x, y, fontSize, color);
|
||||
}
|
||||
|
||||
void DrawText(
|
||||
const ::Font& font,
|
||||
const std::string& text,
|
||||
::Vector2 position,
|
||||
float fontSize,
|
||||
float spacing,
|
||||
::Color tint = {255, 255, 255, 255}) {
|
||||
::ImageDrawTextEx(this, font, text.c_str(), position, fontSize, spacing, tint);
|
||||
}
|
||||
|
||||
void DrawText(
|
||||
const ::Font& font,
|
||||
const char* text,
|
||||
::Vector2 position,
|
||||
float fontSize,
|
||||
float spacing,
|
||||
::Color tint = {255, 255, 255, 255}) {
|
||||
::ImageDrawTextEx(this, font, text, position, fontSize, spacing, tint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load color data from image as a Color array (RGBA - 32bit)
|
||||
*/
|
||||
RLCPP_NODISCARD ::Color* LoadColors() const { return ::LoadImageColors(*this); }
|
||||
|
||||
/**
|
||||
* Load colors palette from image as a Color array (RGBA - 32bit)
|
||||
*/
|
||||
::Color* LoadPalette(int maxPaletteSize, int* colorsCount) const {
|
||||
return ::LoadImagePalette(*this, maxPaletteSize, colorsCount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unload color data loaded with LoadImageColors()
|
||||
*/
|
||||
void UnloadColors(::Color* colors) const { ::UnloadImageColors(colors); }
|
||||
|
||||
/**
|
||||
* Unload colors palette loaded with LoadImagePalette()
|
||||
*/
|
||||
void UnloadPalette(::Color* colors) const { ::UnloadImagePalette(colors); }
|
||||
|
||||
/**
|
||||
* Load texture from image data.
|
||||
*/
|
||||
RLCPP_NODISCARD ::Texture2D LoadTexture() const { return ::LoadTextureFromImage(*this); }
|
||||
|
||||
/**
|
||||
* Loads a texture from the image data.
|
||||
*
|
||||
* @see LoadTexture()
|
||||
*/
|
||||
operator ::Texture2D() const { return LoadTexture(); }
|
||||
|
||||
/**
|
||||
* Get pixel data size in bytes for certain format
|
||||
*/
|
||||
static int GetPixelDataSize(int width, int height, int format = PIXELFORMAT_UNCOMPRESSED_R32G32B32A32) {
|
||||
return ::GetPixelDataSize(width, height, format);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the pixel data size based on the current image.
|
||||
*
|
||||
* @return The pixel data size of the image.
|
||||
*/
|
||||
RLCPP_NODISCARD int GetPixelDataSize() const { return ::GetPixelDataSize(width, height, format); }
|
||||
|
||||
/**
|
||||
* Retrieve whether or not the Image has been loaded.
|
||||
*
|
||||
* @return True or false depending on whether the Image has been loaded.
|
||||
*/
|
||||
RLCPP_NODISCARD bool IsValid() const { return ::IsImageValid(*this); }
|
||||
|
||||
/**
|
||||
* Create an image from a selected channel of another image (GRAYSCALE)
|
||||
*/
|
||||
::Image Channel(int selectedChannel) { return ::ImageFromChannel(*this, selectedChannel); }
|
||||
|
||||
/**
|
||||
* Apply custom square convolution kernel to image
|
||||
*/
|
||||
void KernelConvolution(const float* kernel, int kernelSize) {
|
||||
::ImageKernelConvolution(this, kernel, kernelSize);
|
||||
}
|
||||
protected:
|
||||
void set(const ::Image& image) {
|
||||
data = image.data;
|
||||
width = image.width;
|
||||
height = image.height;
|
||||
mipmaps = image.mipmaps;
|
||||
format = image.format;
|
||||
}
|
||||
};
|
||||
} // namespace raylib
|
||||
|
||||
using RImage = raylib::Image;
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_IMAGE_HPP_
|
||||
@@ -0,0 +1,66 @@
|
||||
#ifndef RAYLIB_CPP_INCLUDE_KEYBOARD_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_KEYBOARD_HPP_
|
||||
|
||||
#include "./Functions.hpp"
|
||||
#include "./raylib.hpp"
|
||||
|
||||
namespace raylib {
|
||||
/**
|
||||
* Input-related functions: keyboard
|
||||
*/
|
||||
namespace Keyboard {
|
||||
/**
|
||||
* Detect if a key has been pressed once
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline bool IsKeyPressed(int key) {
|
||||
return ::IsKeyPressed(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect if a key has been pressed again (Only PLATFORM_DESKTOP)
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline bool IsKeyPressedRepeat(int key) {
|
||||
return ::IsKeyPressedRepeat(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect if a key is being pressed
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline bool IsKeyDown(int key) {
|
||||
return ::IsKeyDown(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect if a key has been released once
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline bool IsKeyReleased(int key) {
|
||||
return ::IsKeyReleased(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect if a key is NOT being pressed
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline bool IsKeyUp(int key) {
|
||||
return ::IsKeyUp(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get key pressed (keycode), call it multiple times for keys queued, returns 0 when the queue is empty
|
||||
*/
|
||||
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline int GetKeyPressed() {
|
||||
return ::GetKeyPressed();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get char pressed (unicode), call it multiple times for chars queued, returns 0 when the queue is empty
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline int GetCharPressed() {
|
||||
return ::GetCharPressed();
|
||||
}
|
||||
} // namespace Keyboard
|
||||
} // namespace raylib
|
||||
|
||||
namespace RKeyboard = raylib::Keyboard;
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_KEYBOARD_HPP_
|
||||
@@ -0,0 +1,54 @@
|
||||
#ifndef RAYLIB_CPP_INCLUDE_MATERIAL_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_MATERIAL_HPP_
|
||||
|
||||
#include "./MaterialUnmanaged.hpp"
|
||||
|
||||
namespace raylib {
|
||||
/**
|
||||
* Material type (generic).
|
||||
*
|
||||
* The material will be unloaded on object destruction. Use raylib::MaterialUnmanaged if you're looking to not unload.
|
||||
*
|
||||
* @see raylib::MaterialUnmanaged
|
||||
*/
|
||||
class Material : public MaterialUnmanaged {
|
||||
public:
|
||||
using MaterialUnmanaged::MaterialUnmanaged;
|
||||
|
||||
Material(const Material&) = delete;
|
||||
Material& operator=(const Material&) = delete;
|
||||
|
||||
Material(Material&& other) noexcept {
|
||||
set(other);
|
||||
other.maps = nullptr;
|
||||
other.shader = {};
|
||||
other.params[0] = 0.0f;
|
||||
other.params[1] = 0.0f;
|
||||
other.params[2] = 0.0f;
|
||||
other.params[3] = 0.0f;
|
||||
}
|
||||
|
||||
Material& operator=(Material&& other) noexcept {
|
||||
if (this == &other) {
|
||||
return *this;
|
||||
}
|
||||
Unload();
|
||||
set(other);
|
||||
other.maps = nullptr;
|
||||
other.shader = {};
|
||||
return *this;
|
||||
}
|
||||
|
||||
Material& operator=(const ::Material& material) {
|
||||
Unload();
|
||||
set(material);
|
||||
return *this;
|
||||
}
|
||||
|
||||
~Material() { Unload(); }
|
||||
};
|
||||
} // namespace raylib
|
||||
|
||||
using RMaterial = raylib::Material;
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_MATERIAL_HPP_
|
||||
@@ -0,0 +1,96 @@
|
||||
#ifndef RAYLIB_CPP_INCLUDE_MATERIALUNMANAGED_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_MATERIALUNMANAGED_HPP_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
#include "./raylib.hpp"
|
||||
|
||||
namespace raylib {
|
||||
/**
|
||||
* A Material that is not managed by C++ RAII.
|
||||
*
|
||||
* Make sure to Unload() this if needed, otherwise use raylib::Material.
|
||||
*
|
||||
* @see raylib::Material
|
||||
*/
|
||||
class MaterialUnmanaged : public ::Material {
|
||||
public:
|
||||
/**
|
||||
* Creates a MaterialUnmanaged from an existing Material struct.
|
||||
*/
|
||||
MaterialUnmanaged(const ::Material& material) : ::Material(material) {}
|
||||
|
||||
/**
|
||||
* Load default material (Supports: DIFFUSE, SPECULAR, NORMAL maps).
|
||||
*/
|
||||
MaterialUnmanaged() : ::Material(::LoadMaterialDefault()) {}
|
||||
|
||||
/**
|
||||
* Load materials from model file.
|
||||
*/
|
||||
static std::vector<MaterialUnmanaged> Load(const std::string& fileName) {
|
||||
int count = 0;
|
||||
::Material* mats = ::LoadMaterials(fileName.c_str(), &count);
|
||||
return std::vector<MaterialUnmanaged>(mats, mats + count);
|
||||
}
|
||||
|
||||
GETTERSETTER(::Shader, Shader, shader)
|
||||
GETTERSETTER(::MaterialMap*, Maps, maps)
|
||||
|
||||
MaterialUnmanaged& operator=(const ::Material& material) {
|
||||
set(material);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unload material from memory.
|
||||
*/
|
||||
void Unload() {
|
||||
if (maps != nullptr) {
|
||||
::UnloadMaterial(*this);
|
||||
maps = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set texture for a material map type (MAP_DIFFUSE, MAP_SPECULAR...).
|
||||
*/
|
||||
MaterialUnmanaged& SetTexture(int mapType, const ::Texture2D& texture) {
|
||||
::SetMaterialTexture(this, mapType, texture);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw a 3d mesh with material and transform.
|
||||
*/
|
||||
void DrawMesh(const ::Mesh& mesh, ::Matrix transform) const { ::DrawMesh(mesh, *this, transform); }
|
||||
|
||||
/**
|
||||
* Draw multiple mesh instances with material and different transforms.
|
||||
*/
|
||||
void DrawMesh(const ::Mesh& mesh, ::Matrix* transforms, int instances) const {
|
||||
::DrawMeshInstanced(mesh, *this, transforms, instances);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if material is ready.
|
||||
*/
|
||||
RLCPP_NODISCARD bool IsValid() const { return ::IsMaterialValid(*this); }
|
||||
|
||||
protected:
|
||||
void set(const ::Material& material) {
|
||||
shader = material.shader;
|
||||
maps = material.maps;
|
||||
params[0] = material.params[0];
|
||||
params[1] = material.params[1];
|
||||
params[2] = material.params[2];
|
||||
params[3] = material.params[3];
|
||||
}
|
||||
};
|
||||
} // namespace raylib
|
||||
|
||||
using RMaterialUnmanaged = raylib::MaterialUnmanaged;
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_MATERIALUNMANAGED_HPP_
|
||||
@@ -0,0 +1,201 @@
|
||||
#ifndef RAYLIB_CPP_INCLUDE_MATRIX_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_MATRIX_HPP_
|
||||
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
#include "./raylib.hpp"
|
||||
#include "./raymath.hpp"
|
||||
|
||||
#ifndef RAYLIB_CPP_NO_MATH
|
||||
#include <cmath>
|
||||
#endif
|
||||
|
||||
namespace raylib {
|
||||
/**
|
||||
* Matrix type (OpenGL style 4x4 - right handed, column major)
|
||||
*/
|
||||
class Matrix : public ::Matrix {
|
||||
public:
|
||||
constexpr Matrix(const ::Matrix& mat)
|
||||
: ::Matrix(mat) {
|
||||
// Nothing.
|
||||
}
|
||||
|
||||
constexpr Matrix(
|
||||
float m0 = 0,
|
||||
float m4 = 0,
|
||||
float m8 = 0,
|
||||
float m12 = 0,
|
||||
float m1 = 0,
|
||||
float m5 = 0,
|
||||
float m9 = 0,
|
||||
float m13 = 0,
|
||||
float m2 = 0,
|
||||
float m6 = 0,
|
||||
float m10 = 0,
|
||||
float m14 = 0,
|
||||
float m3 = 0,
|
||||
float m7 = 0,
|
||||
float m11 = 0,
|
||||
float m15 = 0)
|
||||
: ::Matrix{m0, m4, m8, m12, m1, m5, m9, m13, m2, m6, m10, m14, m3, m7, m11, m15} {
|
||||
// Nothing.
|
||||
}
|
||||
|
||||
GETTERSETTER(float, M0, m0)
|
||||
GETTERSETTER(float, M1, m1)
|
||||
GETTERSETTER(float, M2, m2)
|
||||
GETTERSETTER(float, M3, m3)
|
||||
GETTERSETTER(float, M4, m4)
|
||||
GETTERSETTER(float, M5, m5)
|
||||
GETTERSETTER(float, M6, m6)
|
||||
GETTERSETTER(float, M7, m7)
|
||||
GETTERSETTER(float, M8, m8)
|
||||
GETTERSETTER(float, M9, m9)
|
||||
GETTERSETTER(float, M10, m10)
|
||||
GETTERSETTER(float, M11, m11)
|
||||
GETTERSETTER(float, M12, m12)
|
||||
GETTERSETTER(float, M13, m13)
|
||||
GETTERSETTER(float, M14, m14)
|
||||
GETTERSETTER(float, M15, m15)
|
||||
|
||||
Matrix& operator=(const ::Matrix& matrix) {
|
||||
if (this != &matrix) {
|
||||
set(matrix);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
Matrix& operator=(const Matrix& matrix) {
|
||||
if (this != &matrix) {
|
||||
set(matrix);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
constexpr bool operator==(const ::Matrix& other) {
|
||||
return m0 == other.m0 && m1 == other.m1 && m2 == other.m2 && m3 == other.m3 && m4 == other.m4 &&
|
||||
m5 == other.m5 && m6 == other.m6 && m7 == other.m7 && m8 == other.m8 && m9 == other.m9 &&
|
||||
m10 == other.m10 && m11 == other.m11 && m12 == other.m12 && m13 == other.m13 && m14 == other.m14 &&
|
||||
m15 == other.m15;
|
||||
}
|
||||
|
||||
constexpr bool operator!=(const ::Matrix& other) { return !(*this == other); }
|
||||
|
||||
[[nodiscard]] std::string ToString() const {
|
||||
return TextFormat(
|
||||
"Matrix(\n"
|
||||
" %f, %f, %f, %f\n"
|
||||
" %f, %f, %f, %f\n"
|
||||
" %f, %f, %f, %f\n"
|
||||
" %f, %f, %f, %f\n"
|
||||
")",
|
||||
m0, m4, m8, m12,
|
||||
m1, m5, m9, m13,
|
||||
m2, m6, m10, m14,
|
||||
m3, m7, m11, m15
|
||||
);
|
||||
}
|
||||
|
||||
operator std::string() const { return ToString(); }
|
||||
|
||||
#ifndef RAYLIB_CPP_NO_MATH
|
||||
/**
|
||||
* Returns the trace of the matrix (sum of the values along the diagonal)
|
||||
*/
|
||||
RLCPP_NODISCARD float Trace() const { return ::MatrixTrace(*this); }
|
||||
|
||||
/**
|
||||
* Transposes provided matrix
|
||||
*/
|
||||
RLCPP_NODISCARD Matrix Transpose() const { return ::MatrixTranspose(*this); }
|
||||
|
||||
RLCPP_NODISCARD Matrix Invert() const { return ::MatrixInvert(*this); }
|
||||
|
||||
static Matrix Identity() { return ::MatrixIdentity(); }
|
||||
|
||||
Matrix Add(const ::Matrix& right) { return ::MatrixAdd(*this, right); }
|
||||
|
||||
Matrix operator+(const ::Matrix& matrix) { return ::MatrixAdd(*this, matrix); }
|
||||
|
||||
Matrix Subtract(const ::Matrix& right) { return ::MatrixSubtract(*this, right); }
|
||||
|
||||
Matrix operator-(const ::Matrix& matrix) { return ::MatrixSubtract(*this, matrix); }
|
||||
|
||||
static Matrix Translate(float x, float y, float z) { return ::MatrixTranslate(x, y, z); }
|
||||
|
||||
static Matrix Rotate(Vector3 axis, float angle) { return ::MatrixRotate(axis, angle); }
|
||||
|
||||
static Matrix RotateXYZ(Vector3 angle) { return ::MatrixRotateXYZ(angle); }
|
||||
|
||||
static Matrix RotateX(float angle) { return ::MatrixRotateX(angle); }
|
||||
|
||||
static Matrix RotateY(float angle) { return ::MatrixRotateY(angle); }
|
||||
|
||||
static Matrix RotateZ(float angle) { return ::MatrixRotateZ(angle); }
|
||||
|
||||
static Matrix Scale(float x, float y, float z) { return ::MatrixScale(x, y, z); }
|
||||
|
||||
RLCPP_NODISCARD Matrix Multiply(const ::Matrix& right) const { return ::MatrixMultiply(*this, right); }
|
||||
|
||||
RLCPP_NODISCARD Matrix Multiply(float value) const { return ::MatrixMultiplyValue(*this, value); }
|
||||
|
||||
Matrix operator*(const ::Matrix& matrix) { return ::MatrixMultiply(*this, matrix); }
|
||||
|
||||
Matrix operator*(float value) { return ::MatrixMultiplyValue(*this, value); }
|
||||
|
||||
static Matrix Frustum(double left, double right, double bottom, double top, double near, double far) {
|
||||
return ::MatrixFrustum(left, right, bottom, top, near, far);
|
||||
}
|
||||
|
||||
static Matrix Perspective(double fovy, double aspect, double near, double far) {
|
||||
return ::MatrixPerspective(fovy, aspect, near, far);
|
||||
}
|
||||
|
||||
static Matrix Ortho(double left, double right, double bottom, double top, double near, double far) {
|
||||
return ::MatrixOrtho(left, right, bottom, top, near, far);
|
||||
}
|
||||
|
||||
static Matrix LookAt(Vector3 eye, Vector3 target, Vector3 up) { return ::MatrixLookAt(eye, target, up); }
|
||||
|
||||
RLCPP_NODISCARD float16 ToFloatV() const { return ::MatrixToFloatV(*this); }
|
||||
|
||||
operator float16() const { return ToFloatV(); }
|
||||
|
||||
/**
|
||||
* Set shader uniform value (matrix 4x4)
|
||||
*/
|
||||
Matrix& SetShaderValue(const ::Shader& shader, int uniformLoc) {
|
||||
::SetShaderValueMatrix(shader, uniformLoc, *this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
static Matrix GetCamera(const ::Camera& camera) { return ::GetCameraMatrix(camera); }
|
||||
|
||||
static Matrix GetCamera(const ::Camera2D& camera) { return ::GetCameraMatrix2D(camera); }
|
||||
|
||||
#endif
|
||||
protected:
|
||||
void set(const ::Matrix& mat) {
|
||||
m0 = mat.m0;
|
||||
m1 = mat.m1;
|
||||
m2 = mat.m2;
|
||||
m3 = mat.m3;
|
||||
m4 = mat.m4;
|
||||
m5 = mat.m5;
|
||||
m6 = mat.m6;
|
||||
m7 = mat.m7;
|
||||
m8 = mat.m8;
|
||||
m9 = mat.m9;
|
||||
m10 = mat.m10;
|
||||
m11 = mat.m11;
|
||||
m12 = mat.m12;
|
||||
m13 = mat.m13;
|
||||
m14 = mat.m14;
|
||||
m15 = mat.m15;
|
||||
}
|
||||
};
|
||||
} // namespace raylib
|
||||
|
||||
using RMatrix = raylib::Matrix;
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_MATRIX_HPP_
|
||||
@@ -0,0 +1,92 @@
|
||||
#ifndef RAYLIB_CPP_INCLUDE_MESH_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_MESH_HPP_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "./MeshUnmanaged.hpp"
|
||||
#include "./Model.hpp"
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
#include "./raylib.hpp"
|
||||
|
||||
namespace raylib {
|
||||
/**
|
||||
* Vertex data defining a mesh
|
||||
*
|
||||
* The Mesh will be unloaded on object destruction.
|
||||
*
|
||||
* @see raylib::MeshUnmanaged
|
||||
*/
|
||||
class Mesh : public MeshUnmanaged {
|
||||
public:
|
||||
using MeshUnmanaged::MeshUnmanaged;
|
||||
|
||||
/**
|
||||
* Explicitly forbid the copy constructor.
|
||||
*/
|
||||
Mesh(const Mesh&) = delete;
|
||||
|
||||
/**
|
||||
* Explicitly forbid copy assignment.
|
||||
*/
|
||||
Mesh& operator=(const Mesh&) = delete;
|
||||
|
||||
/**
|
||||
* Move constructor.
|
||||
*/
|
||||
Mesh(Mesh&& other) noexcept {
|
||||
set(other);
|
||||
|
||||
other.vertexCount = 0;
|
||||
other.triangleCount = 0;
|
||||
other.vertices = nullptr;
|
||||
other.texcoords = nullptr;
|
||||
other.texcoords2 = nullptr;
|
||||
other.normals = nullptr;
|
||||
other.tangents = nullptr;
|
||||
other.colors = nullptr;
|
||||
other.indices = nullptr;
|
||||
other.animVertices = nullptr;
|
||||
other.animNormals = nullptr;
|
||||
other.boneIndices = nullptr;
|
||||
other.boneWeights = nullptr;
|
||||
other.boneCount = 0;
|
||||
other.vaoId = 0;
|
||||
other.vboId = nullptr;
|
||||
}
|
||||
|
||||
Mesh& operator=(Mesh&& other) noexcept {
|
||||
if (this == &other) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
Unload();
|
||||
set(other);
|
||||
|
||||
other.vertexCount = 0;
|
||||
other.triangleCount = 0;
|
||||
other.vertices = nullptr;
|
||||
other.texcoords = nullptr;
|
||||
other.texcoords2 = nullptr;
|
||||
other.normals = nullptr;
|
||||
other.tangents = nullptr;
|
||||
other.colors = nullptr;
|
||||
other.indices = nullptr;
|
||||
other.animVertices = nullptr;
|
||||
other.animNormals = nullptr;
|
||||
other.boneIndices = nullptr;
|
||||
other.boneWeights = nullptr;
|
||||
other.boneCount = 0;
|
||||
other.vaoId = 0;
|
||||
other.vboId = nullptr;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
~Mesh() { Unload(); }
|
||||
};
|
||||
} // namespace raylib
|
||||
|
||||
using RMesh = raylib::Mesh;
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_MESH_HPP_
|
||||
@@ -0,0 +1,265 @@
|
||||
#ifndef RAYLIB_CPP_INCLUDE_MESHUNMANAGED_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_MESHUNMANAGED_HPP_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "./BoundingBox.hpp"
|
||||
#include "./Matrix.hpp"
|
||||
#include "./Model.hpp"
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
|
||||
namespace raylib {
|
||||
|
||||
/**
|
||||
* Vertex data defining a mesh, not managed by C++ RAII.
|
||||
*
|
||||
* Make sure to Unload() this if needed, otherwise use raylib::Mesh.
|
||||
*
|
||||
* @see raylib::Mesh
|
||||
*/
|
||||
class MeshUnmanaged : public ::Mesh {
|
||||
public:
|
||||
/**
|
||||
* Default texture constructor.
|
||||
*/
|
||||
MeshUnmanaged() {
|
||||
vertexCount = 0;
|
||||
triangleCount = 0;
|
||||
vertices = nullptr;
|
||||
texcoords = nullptr;
|
||||
texcoords2 = nullptr;
|
||||
normals = nullptr;
|
||||
tangents = nullptr;
|
||||
colors = nullptr;
|
||||
indices = nullptr;
|
||||
animVertices = nullptr;
|
||||
animNormals = nullptr;
|
||||
boneIndices = nullptr;
|
||||
boneWeights = nullptr;
|
||||
boneCount = 0;
|
||||
vaoId = 0;
|
||||
vboId = nullptr;
|
||||
}
|
||||
|
||||
MeshUnmanaged(const ::Mesh& mesh) { set(mesh); }
|
||||
|
||||
MeshUnmanaged(::Mesh&& mesh) { set(mesh); }
|
||||
|
||||
/**
|
||||
* Load meshes from model file
|
||||
*/
|
||||
// static std::vector<Mesh> Load(const std::string& fileName) {
|
||||
// int count = 0;
|
||||
// ::Mesh* meshes = LoadMeshes(fileName.c_str(), &count);
|
||||
// return std::vector<Mesh>(meshes, meshes + count);
|
||||
// }
|
||||
|
||||
/**
|
||||
* Generate polygonal mesh
|
||||
*/
|
||||
static ::Mesh Poly(int sides, float radius) { return ::GenMeshPoly(sides, radius); }
|
||||
|
||||
/**
|
||||
* Generate plane mesh (with subdivisions)
|
||||
*/
|
||||
static ::Mesh Plane(float width, float length, int resX, int resZ) {
|
||||
return ::GenMeshPlane(width, length, resX, resZ);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate cuboid mesh
|
||||
*/
|
||||
static ::Mesh Cube(float width, float height, float length) { return ::GenMeshCube(width, height, length); }
|
||||
|
||||
/**
|
||||
* Generate sphere mesh (standard sphere)
|
||||
*/
|
||||
static ::Mesh Sphere(float radius, int rings, int slices) { return ::GenMeshSphere(radius, rings, slices); }
|
||||
|
||||
/**
|
||||
* Generate half-sphere mesh (no bottom cap)
|
||||
*/
|
||||
static ::Mesh HemiSphere(float radius, int rings, int slices) { return ::GenMeshHemiSphere(radius, rings, slices); }
|
||||
|
||||
/**
|
||||
* Generate cylinder mesh
|
||||
*/
|
||||
static ::Mesh Cylinder(float radius, float height, int slices) { return ::GenMeshCylinder(radius, height, slices); }
|
||||
|
||||
/**
|
||||
* Generate cone/pyramid mesh
|
||||
*/
|
||||
static ::Mesh Cone(float radius, float height, int slices) { return ::GenMeshCone(radius, height, slices); }
|
||||
|
||||
/**
|
||||
* Generate torus mesh
|
||||
*/
|
||||
static ::Mesh Torus(float radius, float size, int radSeg, int sides) {
|
||||
return ::GenMeshTorus(radius, size, radSeg, sides);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate trefoil knot mesh
|
||||
*/
|
||||
static ::Mesh Knot(float radius, float size, int radSeg, int sides) {
|
||||
return ::GenMeshKnot(radius, size, radSeg, sides);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate heightmap mesh from image data
|
||||
*/
|
||||
static ::Mesh Heightmap(const ::Image& heightmap, ::Vector3 size) { return ::GenMeshHeightmap(heightmap, size); }
|
||||
|
||||
/**
|
||||
* Generate cubes-based map mesh from image data
|
||||
*/
|
||||
static ::Mesh Cubicmap(const ::Image& cubicmap, ::Vector3 cubeSize) {
|
||||
return ::GenMeshCubicmap(cubicmap, cubeSize);
|
||||
}
|
||||
|
||||
GETTERSETTER(int, VertexCount, vertexCount)
|
||||
GETTERSETTER(int, TriangleCount, triangleCount)
|
||||
GETTERSETTER(float*, Vertices, vertices)
|
||||
GETTERSETTER(float*, TexCoords, texcoords)
|
||||
GETTERSETTER(float*, TexCoords2, texcoords2)
|
||||
GETTERSETTER(float*, Normals, normals)
|
||||
GETTERSETTER(float*, Tangents, tangents)
|
||||
GETTERSETTER(unsigned char*, Colors, colors)
|
||||
GETTERSETTER(unsigned short*, Indices, indices) // NOLINT
|
||||
GETTERSETTER(float*, AnimVertices, animVertices)
|
||||
GETTERSETTER(float*, AnimNormals, animNormals)
|
||||
GETTERSETTER(unsigned char*, BoneIndices, boneIndices)
|
||||
GETTERSETTER(float*, BoneWeights, boneWeights)
|
||||
GETTERSETTER(int, BoneCount, boneCount)
|
||||
GETTERSETTER(unsigned int, VaoId, vaoId)
|
||||
GETTERSETTER(unsigned int*, VboId, vboId)
|
||||
|
||||
MeshUnmanaged& operator=(const ::Mesh& mesh) {
|
||||
set(mesh);
|
||||
return *this;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string ToString() const {
|
||||
return TextFormat(
|
||||
"Mesh(vertexCount=%d, triangleCount=%d, boneCount=%d)",
|
||||
vertexCount, triangleCount, boneCount
|
||||
);
|
||||
}
|
||||
|
||||
operator std::string() const { return ToString(); }
|
||||
|
||||
/**
|
||||
* Unload mesh from memory (RAM and/or VRAM)
|
||||
*/
|
||||
void Unload() {
|
||||
if (vboId != nullptr) {
|
||||
::UnloadMesh(*this);
|
||||
vboId = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload mesh vertex data to GPU (VRAM)
|
||||
*/
|
||||
void Upload(bool dynamic = false) { ::UploadMesh(this, dynamic); }
|
||||
|
||||
/**
|
||||
* Upload mesh vertex data to GPU (VRAM)
|
||||
*/
|
||||
void UpdateBuffer(int index, void* data, int dataSize, int offset = 0) {
|
||||
::UpdateMeshBuffer(*this, index, data, dataSize, offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw a 3d mesh with material and transform
|
||||
*/
|
||||
void Draw(const ::Material& material, const ::Matrix& transform) const { ::DrawMesh(*this, material, transform); }
|
||||
|
||||
/**
|
||||
* Draw multiple mesh instances with material and different transforms
|
||||
*/
|
||||
void Draw(const ::Material& material, const ::Matrix* transforms, int instances) const {
|
||||
::DrawMeshInstanced(*this, material, transforms, instances);
|
||||
}
|
||||
|
||||
/**
|
||||
* Export mesh data to file
|
||||
*
|
||||
* @throws raylib::RaylibException Throws if failed to export the Mesh.
|
||||
*/
|
||||
void Export(const std::string& fileName) {
|
||||
if (!::ExportMesh(*this, fileName.c_str())) {
|
||||
throw RaylibException("Failed to export the Mesh");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Export mesh as code file (.h) defining multiple arrays of vertex attributes
|
||||
*
|
||||
* @throws raylib::RaylibException Throws if failed to export the Mesh.
|
||||
*/
|
||||
void ExportCode(const std::string& fileName) {
|
||||
if (!::ExportMeshAsCode(*this, fileName.c_str())) {
|
||||
throw RaylibException("Failed to export the Mesh");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute mesh bounding box limits
|
||||
*/
|
||||
RLCPP_NODISCARD raylib::BoundingBox BoundingBox() const { return ::GetMeshBoundingBox(*this); }
|
||||
|
||||
/**
|
||||
* Compute mesh bounding box limits
|
||||
*/
|
||||
operator raylib::BoundingBox() const { return BoundingBox(); }
|
||||
|
||||
/**
|
||||
* Compute mesh tangents
|
||||
*/
|
||||
MeshUnmanaged& GenTangents() {
|
||||
::GenMeshTangents(this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load model from generated mesh
|
||||
*/
|
||||
RLCPP_NODISCARD raylib::Model LoadModelFrom() const { return ::LoadModelFromMesh(*this); }
|
||||
|
||||
/**
|
||||
* Load model from generated mesh
|
||||
*/
|
||||
operator raylib::Model() { return ::LoadModelFromMesh(*this); }
|
||||
|
||||
/**
|
||||
* Returns whether or not the Mesh is valid.
|
||||
*/
|
||||
RLCPP_NODISCARD bool IsValid() const { return vaoId != 0 && vertexCount > 0; }
|
||||
|
||||
protected:
|
||||
void set(const ::Mesh& mesh) {
|
||||
vertexCount = mesh.vertexCount;
|
||||
triangleCount = mesh.triangleCount;
|
||||
vertices = mesh.vertices;
|
||||
texcoords = mesh.texcoords;
|
||||
texcoords2 = mesh.texcoords2;
|
||||
normals = mesh.normals;
|
||||
tangents = mesh.tangents;
|
||||
colors = mesh.colors;
|
||||
indices = mesh.indices;
|
||||
animVertices = mesh.animVertices;
|
||||
animNormals = mesh.animNormals;
|
||||
boneIndices = mesh.boneIndices;
|
||||
boneWeights = mesh.boneWeights;
|
||||
boneCount = mesh.boneCount;
|
||||
vaoId = mesh.vaoId;
|
||||
vboId = mesh.vboId;
|
||||
}
|
||||
};
|
||||
} // namespace raylib
|
||||
|
||||
using RMeshUnmanaged = raylib::MeshUnmanaged;
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_MESHUNMANAGED_HPP_
|
||||
@@ -0,0 +1,86 @@
|
||||
#ifndef RAYLIB_CPP_INCLUDE_MODEL_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_MODEL_HPP_
|
||||
|
||||
#include "./ModelUnmanaged.hpp"
|
||||
|
||||
namespace raylib {
|
||||
class Mesh;
|
||||
/**
|
||||
* Model type.
|
||||
*
|
||||
* The model will be unloaded on object destruction. Use raylib::ModelUnmanaged if you're looking to not unload.
|
||||
*
|
||||
* @see raylib::ModelUnmanaged
|
||||
*/
|
||||
class Model : public ModelUnmanaged {
|
||||
public:
|
||||
using ModelUnmanaged::ModelUnmanaged;
|
||||
|
||||
/**
|
||||
* The Model constructor with a Mesh() is removed.
|
||||
*
|
||||
* Use `raylib::MeshUnmanaged` or `::Mesh` instead, as raylib will take ownership of the data.
|
||||
*
|
||||
* @see raylib::MeshUnmanaged
|
||||
*/
|
||||
Model(const raylib::Mesh& mesh) = delete;
|
||||
|
||||
Model(const Model&) = delete;
|
||||
Model& operator=(const Model&) = delete;
|
||||
|
||||
Model(Model&& other) noexcept {
|
||||
set(other);
|
||||
other.meshCount = 0;
|
||||
other.materialCount = 0;
|
||||
other.meshes = nullptr;
|
||||
other.materials = nullptr;
|
||||
other.meshMaterial = nullptr;
|
||||
other.skeleton.boneCount = 0;
|
||||
other.skeleton.bones = nullptr;
|
||||
other.skeleton.bindPose = nullptr;
|
||||
other.currentPose = nullptr;
|
||||
other.boneMatrices = nullptr;
|
||||
}
|
||||
|
||||
Model& operator=(Model&& other) noexcept {
|
||||
if (this == &other) {
|
||||
return *this;
|
||||
}
|
||||
Unload();
|
||||
set(other);
|
||||
other.meshCount = 0;
|
||||
other.materialCount = 0;
|
||||
other.meshes = nullptr;
|
||||
other.materials = nullptr;
|
||||
other.meshMaterial = nullptr;
|
||||
other.skeleton.boneCount = 0;
|
||||
other.skeleton.bones = nullptr;
|
||||
other.skeleton.bindPose = nullptr;
|
||||
other.currentPose = nullptr;
|
||||
other.boneMatrices = nullptr;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Model& operator=(const ::Model& model) {
|
||||
Unload();
|
||||
set(model);
|
||||
return *this;
|
||||
}
|
||||
|
||||
~Model() { Unload(); }
|
||||
|
||||
void Load(const std::string& fileName) {
|
||||
Unload();
|
||||
ModelUnmanaged::Load(fileName);
|
||||
}
|
||||
|
||||
void Load(const ::Mesh& mesh) {
|
||||
Unload();
|
||||
ModelUnmanaged::Load(mesh);
|
||||
}
|
||||
};
|
||||
} // namespace raylib
|
||||
|
||||
using RModel = raylib::Model;
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_MODEL_HPP_
|
||||
@@ -0,0 +1,123 @@
|
||||
#ifndef RAYLIB_CPP_INCLUDE_MODELANIMATION_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_MODELANIMATION_HPP_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "./Mesh.hpp"
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
#include "./raylib.hpp"
|
||||
|
||||
namespace raylib {
|
||||
/**
|
||||
* Model animation
|
||||
*/
|
||||
class ModelAnimation : public ::ModelAnimation {
|
||||
public:
|
||||
ModelAnimation(const ::ModelAnimation& model) { set(model); }
|
||||
|
||||
ModelAnimation(const ModelAnimation&) = delete;
|
||||
|
||||
ModelAnimation(ModelAnimation&& other) noexcept {
|
||||
set(other);
|
||||
|
||||
other.boneCount = 0;
|
||||
other.keyframeCount = 0;
|
||||
other.keyframePoses = nullptr;
|
||||
}
|
||||
|
||||
// Unloads animation data using populated animCount field, which is set by Load() method.
|
||||
~ModelAnimation() { Unload(); }
|
||||
|
||||
/**
|
||||
* Load model animations from file
|
||||
*/
|
||||
static std::vector<ModelAnimation> Load(const std::string& fileName) {
|
||||
int count = 0;
|
||||
::ModelAnimation* modelAnimations = ::LoadModelAnimations(fileName.c_str(), &count);
|
||||
|
||||
std::vector<ModelAnimation> mats(modelAnimations, modelAnimations + count);
|
||||
|
||||
RL_FREE(modelAnimations);
|
||||
|
||||
return mats;
|
||||
}
|
||||
|
||||
GETTERSETTER(int, BoneCount, boneCount)
|
||||
GETTERSETTER(int, KeyframeCount, keyframeCount)
|
||||
GETTERSETTER(::Transform**, KeyframePoses, keyframePoses)
|
||||
|
||||
ModelAnimation& operator=(const ::ModelAnimation& model) {
|
||||
set(model);
|
||||
return *this;
|
||||
}
|
||||
|
||||
ModelAnimation& operator=(const ModelAnimation&) = delete;
|
||||
|
||||
ModelAnimation& operator=(ModelAnimation&& other) noexcept {
|
||||
if (this == &other) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
Unload();
|
||||
set(other);
|
||||
|
||||
other.boneCount = 0;
|
||||
other.keyframeCount = 0;
|
||||
other.keyframePoses = nullptr;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unload animation data
|
||||
*/
|
||||
void Unload() {
|
||||
if (keyframePoses != nullptr) {
|
||||
::UnloadModelAnimations(this, 1);
|
||||
keyframePoses = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
static void Unload(ModelAnimation *modelAnimation, int count) {
|
||||
::UnloadModelAnimations(modelAnimation, count);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update model animation pose
|
||||
*/
|
||||
ModelAnimation& Update(const ::Model& model, float frame) {
|
||||
::UpdateModelAnimation(model, *this, frame);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Blend two animation poses
|
||||
*/
|
||||
ModelAnimation& Blend(const ::Model& model, float frameA, const ::ModelAnimation& animB, float frameB, float blend) {
|
||||
::UpdateModelAnimationEx(model, *this, frameA, animB, frameB, blend);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check model animation skeleton match
|
||||
*/
|
||||
RLCPP_NODISCARD bool IsValid(const ::Model& model) const { return ::IsModelAnimationValid(model, *this); }
|
||||
protected:
|
||||
void set(const ::ModelAnimation& model) {
|
||||
boneCount = model.boneCount;
|
||||
keyframeCount = model.keyframeCount;
|
||||
keyframePoses = model.keyframePoses;
|
||||
|
||||
// Duplicate the name. TextCopy() uses the null terminator, which we ignore here.
|
||||
for (int i = 0; i < 32; i++) {
|
||||
name[i] = model.name[i];
|
||||
}
|
||||
}
|
||||
};
|
||||
} // namespace raylib
|
||||
|
||||
using RModelAnimation = raylib::ModelAnimation;
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_MODELANIMATION_HPP_
|
||||
@@ -0,0 +1,211 @@
|
||||
#ifndef RAYLIB_CPP_INCLUDE_MODELUNMANAGED_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_MODELUNMANAGED_HPP_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "./BoundingBox.hpp"
|
||||
#include "./RaylibException.hpp"
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
#include "./raylib.hpp"
|
||||
|
||||
namespace raylib {
|
||||
/**
|
||||
* A Model that is not managed by C++ RAII.
|
||||
*
|
||||
* Make sure to Unload() this if needed, otherwise use raylib::Model.
|
||||
*
|
||||
* @see raylib::Model
|
||||
*/
|
||||
class ModelUnmanaged : public ::Model {
|
||||
public:
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
ModelUnmanaged() {}
|
||||
|
||||
/**
|
||||
* Creates a ModelUnmanaged from an existing Model struct.
|
||||
*/
|
||||
ModelUnmanaged(const ::Model& model) : ::Model(model) {}
|
||||
|
||||
/**
|
||||
* Loads a Model from the given file.
|
||||
*
|
||||
* @throws raylib::RaylibException Throws if failed to load the Model.
|
||||
*/
|
||||
ModelUnmanaged(const std::string& fileName) { Load(fileName); }
|
||||
|
||||
/**
|
||||
* Loads a Model from the given Mesh.
|
||||
*
|
||||
* @throws raylib::RaylibException Throws if failed to load the Model.
|
||||
*/
|
||||
ModelUnmanaged(const ::Mesh& mesh) { Load(mesh); }
|
||||
|
||||
GETTERSETTER(::Matrix, Transform, transform)
|
||||
GETTERSETTER(int, MeshCount, meshCount)
|
||||
GETTERSETTER(int, MaterialCount, materialCount)
|
||||
GETTERSETTER(::Mesh*, Meshes, meshes)
|
||||
GETTERSETTER(::Material*, Materials, materials)
|
||||
GETTERSETTER(int*, MeshMaterial, meshMaterial)
|
||||
GETTERSETTER(int, BoneCount, skeleton.boneCount)
|
||||
GETTERSETTER(::BoneInfo*, Bones, skeleton.bones)
|
||||
GETTERSETTER(::Transform*, BindPose, skeleton.bindPose)
|
||||
GETTERSETTER(::ModelAnimPose, CurrentPose, currentPose)
|
||||
GETTERSETTER(::Matrix*, BoneMatrices, boneMatrices)
|
||||
|
||||
ModelUnmanaged& operator=(const ::Model& model) {
|
||||
set(model);
|
||||
return *this;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string ToString() const { return TextFormat("Model(meshCount=%d, materialCount=%d)", meshCount, materialCount); }
|
||||
|
||||
operator std::string() const { return ToString(); }
|
||||
|
||||
/**
|
||||
* Loads a Model from the given file.
|
||||
*
|
||||
* @throws raylib::RaylibException Throws if failed to load the Model.
|
||||
*/
|
||||
void Load(const std::string& fileName) {
|
||||
set(::LoadModel(fileName.c_str()));
|
||||
if (!IsValid()) {
|
||||
throw RaylibException("Failed to load Model from " + fileName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a Model from the given Mesh.
|
||||
*
|
||||
* @throws raylib::RaylibException Throws if failed to load the Model.
|
||||
*/
|
||||
void Load(const ::Mesh& mesh) {
|
||||
set(::LoadModelFromMesh(mesh));
|
||||
if (!IsValid()) {
|
||||
throw RaylibException("Failed to load Model from Mesh");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unload model (including meshes) from memory (RAM and/or VRAM).
|
||||
*/
|
||||
void Unload() {
|
||||
if (meshes != nullptr || materials != nullptr) {
|
||||
::UnloadModel(*this);
|
||||
meshes = nullptr;
|
||||
materials = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set material for a mesh.
|
||||
*/
|
||||
ModelUnmanaged& SetMeshMaterial(int meshId, int materialId) {
|
||||
::SetModelMeshMaterial(this, meshId, materialId);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update model animation pose.
|
||||
*/
|
||||
ModelUnmanaged& UpdateAnimation(const ::ModelAnimation& anim, float frame) {
|
||||
::UpdateModelAnimation(*this, anim, frame);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Blend two model animation poses.
|
||||
*/
|
||||
ModelUnmanaged& BlendAnimation(
|
||||
const ::ModelAnimation& animA,
|
||||
float frameA,
|
||||
const ::ModelAnimation& animB,
|
||||
float frameB,
|
||||
float blend) {
|
||||
::UpdateModelAnimationEx(*this, animA, frameA, animB, frameB, blend);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check model animation skeleton match.
|
||||
*/
|
||||
RLCPP_NODISCARD bool IsModelAnimationValid(const ::ModelAnimation& anim) const {
|
||||
return ::IsModelAnimationValid(*this, anim);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw a model (with texture if set).
|
||||
*/
|
||||
void Draw(::Vector3 position, float scale = 1.0f, ::Color tint = {255, 255, 255, 255}) const {
|
||||
::DrawModel(*this, position, scale, tint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw a model with extended parameters.
|
||||
*/
|
||||
void Draw(
|
||||
::Vector3 position,
|
||||
::Vector3 rotationAxis,
|
||||
float rotationAngle = 0.0f,
|
||||
::Vector3 scale = {1.0f, 1.0f, 1.0f},
|
||||
::Color tint = {255, 255, 255, 255}) const {
|
||||
::DrawModelEx(*this, position, rotationAxis, rotationAngle, scale, tint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw a model wires (with texture if set).
|
||||
*/
|
||||
void DrawWires(::Vector3 position, float scale = 1.0f, ::Color tint = {255, 255, 255, 255}) const {
|
||||
::DrawModelWires(*this, position, scale, tint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw a model wires (with texture if set) with extended parameters.
|
||||
*/
|
||||
void DrawWires(
|
||||
::Vector3 position,
|
||||
::Vector3 rotationAxis,
|
||||
float rotationAngle = 0.0f,
|
||||
::Vector3 scale = {1.0f, 1.0f, 1.0f},
|
||||
::Color tint = {255, 255, 255, 255}) const {
|
||||
::DrawModelWiresEx(*this, position, rotationAxis, rotationAngle, scale, tint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute model bounding box limits (considers all meshes).
|
||||
*/
|
||||
RLCPP_NODISCARD BoundingBox GetBoundingBox() const { return ::GetModelBoundingBox(*this); }
|
||||
|
||||
/**
|
||||
* Compute model bounding box limits (considers all meshes).
|
||||
*/
|
||||
explicit operator BoundingBox() const { return ::GetModelBoundingBox(*this); }
|
||||
|
||||
/**
|
||||
* Determines whether or not the Model has data in it.
|
||||
*/
|
||||
RLCPP_NODISCARD bool IsValid() const { return ::IsModelValid(*this); }
|
||||
|
||||
protected:
|
||||
void set(const ::Model& model) {
|
||||
transform = model.transform;
|
||||
|
||||
meshCount = model.meshCount;
|
||||
materialCount = model.materialCount;
|
||||
meshes = model.meshes;
|
||||
materials = model.materials;
|
||||
meshMaterial = model.meshMaterial;
|
||||
|
||||
skeleton.boneCount = model.skeleton.boneCount;
|
||||
skeleton.bones = model.skeleton.bones;
|
||||
skeleton.bindPose = model.skeleton.bindPose;
|
||||
currentPose = model.currentPose;
|
||||
boneMatrices = model.boneMatrices;
|
||||
}
|
||||
};
|
||||
} // namespace raylib
|
||||
|
||||
using RModelUnmanaged = raylib::ModelUnmanaged;
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_MODELUNMANAGED_HPP_
|
||||
@@ -0,0 +1,153 @@
|
||||
#ifndef RAYLIB_CPP_INCLUDE_MOUSE_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_MOUSE_HPP_
|
||||
|
||||
#include "./Functions.hpp"
|
||||
#include "./Vector2.hpp"
|
||||
#include "./raylib.hpp"
|
||||
|
||||
namespace raylib {
|
||||
/**
|
||||
* Input-related functions: mouse
|
||||
*/
|
||||
namespace Mouse {
|
||||
/**
|
||||
* Detect if a mouse button has been pressed once
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline bool IsButtonPressed(int button) {
|
||||
return ::IsMouseButtonPressed(button);
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect if a mouse button is being pressed
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline bool IsButtonDown(int button) {
|
||||
return ::IsMouseButtonDown(button);
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect if a mouse button has been released once
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline bool IsButtonReleased(int button) {
|
||||
return ::IsMouseButtonReleased(button);
|
||||
}
|
||||
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline bool IsButtonUp(int button) {
|
||||
return ::IsMouseButtonUp(button);
|
||||
}
|
||||
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline int GetX() {
|
||||
return ::GetMouseX();
|
||||
}
|
||||
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline int GetY() {
|
||||
return ::GetMouseY();
|
||||
}
|
||||
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline void SetX(int x) {
|
||||
::SetMousePosition(x, GetY());
|
||||
}
|
||||
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline void SetY(int y) {
|
||||
::SetMousePosition(GetX(), y);
|
||||
}
|
||||
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline Vector2 GetPosition() {
|
||||
return ::GetMousePosition();
|
||||
}
|
||||
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline void SetPosition(int x, int y) {
|
||||
::SetMousePosition(x, y);
|
||||
}
|
||||
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline void SetPosition(::Vector2 position) {
|
||||
::SetMousePosition(static_cast<int>(position.x), static_cast<int>(position.y));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get mouse delta between frames
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline Vector2 GetDelta() {
|
||||
return ::GetMouseDelta();
|
||||
}
|
||||
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline void SetOffset(int offsetX = 0, int offsetY = 0) {
|
||||
::SetMouseOffset(offsetX, offsetY);
|
||||
}
|
||||
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline void SetOffset(::Vector2 offset) {
|
||||
::SetMouseOffset(static_cast<int>(offset.x), static_cast<int>(offset.y));
|
||||
}
|
||||
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline void SetScale(float scaleX = 1.0f, float scaleY = 1.0f) {
|
||||
::SetMouseScale(scaleX, scaleY);
|
||||
}
|
||||
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline void SetScale(::Vector2 scale) {
|
||||
::SetMouseScale(scale.x, scale.y);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get mouse wheel movement for X or Y, whichever is larger
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline float GetWheelMove() {
|
||||
return ::GetMouseWheelMove();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get mouse wheel movement for both X and Y
|
||||
*
|
||||
* @see ::GetMouseWheelMoveV()
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline Vector2 GetWheelMoveV() {
|
||||
return GetMouseWheelMoveV();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the current mouse cursor icon.
|
||||
*
|
||||
* @see ::MouseCursor
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline void SetCursor(int cursor = MOUSE_CURSOR_DEFAULT) {
|
||||
::SetMouseCursor(cursor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get touch position X for touch point 0 (relative to screen size)
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline int GetTouchX() {
|
||||
return ::GetTouchX();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get touch position Y for touch point 0 (relative to screen size)
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline int GetTouchY() {
|
||||
return ::GetTouchY();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get touch position XY for a touch point index (relative to screen size)
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline Vector2 GetTouchPosition(int index) {
|
||||
return ::GetTouchPosition(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a ray trace from mouse position
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline Ray GetRay(::Vector2 mousePosition, const ::Camera& camera) {
|
||||
return ::GetMouseRay(mousePosition, camera);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a ray trace from mouse position
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline Ray GetRay(const ::Camera& camera) {
|
||||
return ::GetMouseRay(::GetMousePosition(), camera);
|
||||
}
|
||||
} // namespace Mouse
|
||||
} // namespace raylib
|
||||
|
||||
namespace RMouse = raylib::Mouse;
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_MOUSE_HPP_
|
||||
@@ -0,0 +1,66 @@
|
||||
#ifndef RAYLIB_CPP_INCLUDE_MUSIC_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_MUSIC_HPP_
|
||||
|
||||
#include "./MusicUnmanaged.hpp"
|
||||
|
||||
namespace raylib {
|
||||
/**
|
||||
* Music stream type (audio file streaming from memory).
|
||||
*
|
||||
* The music stream will be unloaded on object destruction. Use raylib::MusicUnmanaged if you're looking to not unload.
|
||||
*
|
||||
* @see raylib::MusicUnmanaged
|
||||
*/
|
||||
class Music : public MusicUnmanaged {
|
||||
public:
|
||||
using MusicUnmanaged::MusicUnmanaged;
|
||||
|
||||
Music(const Music&) = delete;
|
||||
Music& operator=(const Music&) = delete;
|
||||
|
||||
Music(Music&& other) noexcept {
|
||||
set(other);
|
||||
other.stream = {};
|
||||
other.frameCount = 0;
|
||||
other.looping = false;
|
||||
other.ctxType = 0;
|
||||
other.ctxData = nullptr;
|
||||
}
|
||||
|
||||
Music& operator=(Music&& other) noexcept {
|
||||
if (this == &other) {
|
||||
return *this;
|
||||
}
|
||||
Unload();
|
||||
set(other);
|
||||
other.ctxType = 0;
|
||||
other.ctxData = nullptr;
|
||||
other.looping = false;
|
||||
other.frameCount = 0;
|
||||
other.stream = {};
|
||||
return *this;
|
||||
}
|
||||
|
||||
Music& operator=(const ::Music& music) {
|
||||
Unload();
|
||||
set(music);
|
||||
return *this;
|
||||
}
|
||||
|
||||
~Music() { Unload(); }
|
||||
|
||||
void Load(const std::string& fileName) {
|
||||
Unload();
|
||||
MusicUnmanaged::Load(fileName);
|
||||
}
|
||||
|
||||
void Load(const std::string& fileType, unsigned char* data, int dataSize) {
|
||||
Unload();
|
||||
MusicUnmanaged::Load(fileType, data, dataSize);
|
||||
}
|
||||
};
|
||||
} // namespace raylib
|
||||
|
||||
using RMusic = raylib::Music;
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_MUSIC_HPP_
|
||||
@@ -0,0 +1,209 @@
|
||||
#ifndef RAYLIB_CPP_INCLUDE_MUSICUNMANAGED_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_MUSICUNMANAGED_HPP_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "./RaylibException.hpp"
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
#include "./raylib.hpp"
|
||||
|
||||
namespace raylib {
|
||||
/**
|
||||
* A Music stream that is not managed by C++ RAII.
|
||||
*
|
||||
* Make sure to Unload() this if needed, otherwise use raylib::Music.
|
||||
*
|
||||
* @see raylib::Music
|
||||
*/
|
||||
class MusicUnmanaged : public ::Music {
|
||||
public:
|
||||
/**
|
||||
* Creates a MusicUnmanaged with the given components.
|
||||
*/
|
||||
MusicUnmanaged(
|
||||
::AudioStream stream = {nullptr, nullptr, 0, 0, 0},
|
||||
unsigned int frameCount = 0,
|
||||
bool looping = false,
|
||||
int ctxType = 0,
|
||||
void* ctxData = nullptr)
|
||||
: ::Music{stream, frameCount, looping, ctxType, ctxData} {}
|
||||
|
||||
/**
|
||||
* Creates a MusicUnmanaged from an existing Music struct.
|
||||
*/
|
||||
MusicUnmanaged(const ::Music& music) : ::Music(music) {}
|
||||
|
||||
/**
|
||||
* Load music stream from file.
|
||||
*
|
||||
* @throws raylib::RaylibException Throws if the music failed to load.
|
||||
*/
|
||||
MusicUnmanaged(const std::string& fileName) { Load(fileName); }
|
||||
|
||||
/**
|
||||
* Load music stream from memory.
|
||||
*
|
||||
* @throws raylib::RaylibException Throws if the music failed to load.
|
||||
*/
|
||||
MusicUnmanaged(const std::string& fileType, unsigned char* data, int dataSize) {
|
||||
Load(fileType, data, dataSize);
|
||||
}
|
||||
|
||||
GETTER(::AudioStream, Stream, stream)
|
||||
GETTER(unsigned int, FrameCount, frameCount)
|
||||
GETTERSETTER(bool, Looping, looping)
|
||||
GETTER(int, CtxType, ctxType)
|
||||
GETTER(void*, CtxData, ctxData)
|
||||
|
||||
MusicUnmanaged& operator=(const ::Music& music) {
|
||||
set(music);
|
||||
return *this;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string ToString() const { return TextFormat("Music(frameCount=%u, looping=%s)", frameCount, looping ? "true" : "false"); }
|
||||
|
||||
operator std::string() const { return ToString(); }
|
||||
|
||||
/**
|
||||
* Load music stream from file.
|
||||
*
|
||||
* @throws raylib::RaylibException Throws if the music failed to load.
|
||||
*/
|
||||
void Load(const std::string& fileName) {
|
||||
set(::LoadMusicStream(fileName.c_str()));
|
||||
if (!IsValid()) {
|
||||
throw RaylibException(TextFormat("Failed to load Music from file: %s", fileName.c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load music stream from memory.
|
||||
*
|
||||
* @throws raylib::RaylibException Throws if the music failed to load.
|
||||
*/
|
||||
void Load(const std::string& fileType, unsigned char* data, int dataSize) {
|
||||
set(::LoadMusicStreamFromMemory(fileType.c_str(), data, dataSize));
|
||||
if (!IsValid()) {
|
||||
throw RaylibException(TextFormat("Failed to load Music from %s file data", fileType.c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unload music stream.
|
||||
*/
|
||||
void Unload() {
|
||||
if (IsValid()) {
|
||||
::UnloadMusicStream(*this);
|
||||
ctxData = nullptr;
|
||||
ctxType = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Start music playing.
|
||||
*/
|
||||
MusicUnmanaged& Play() {
|
||||
::PlayMusicStream(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates buffers for music streaming.
|
||||
*/
|
||||
MusicUnmanaged& Update() {
|
||||
::UpdateMusicStream(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop music playing.
|
||||
*/
|
||||
MusicUnmanaged& Stop() {
|
||||
::StopMusicStream(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pause music playing.
|
||||
*/
|
||||
MusicUnmanaged& Pause() {
|
||||
::PauseMusicStream(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resume music playing.
|
||||
*/
|
||||
MusicUnmanaged& Resume() {
|
||||
::ResumeMusicStream(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Seek music to a position (in seconds).
|
||||
*/
|
||||
MusicUnmanaged& Seek(float position) {
|
||||
::SeekMusicStream(*this, position);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if music is playing.
|
||||
*/
|
||||
RLCPP_NODISCARD bool IsPlaying() const { return ::IsMusicStreamPlaying(*this); }
|
||||
|
||||
/**
|
||||
* Set volume for music.
|
||||
*/
|
||||
MusicUnmanaged& SetVolume(float volume) {
|
||||
::SetMusicVolume(*this, volume);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set pitch for music.
|
||||
*/
|
||||
MusicUnmanaged& SetPitch(float pitch) {
|
||||
::SetMusicPitch(*this, pitch);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set pan for a music (0.5 is center).
|
||||
*/
|
||||
MusicUnmanaged& SetPan(float pan = 0.5f) {
|
||||
::SetMusicPan(*this, pan);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get music time length (in seconds).
|
||||
*/
|
||||
RLCPP_NODISCARD float GetTimeLength() const { return ::GetMusicTimeLength(*this); }
|
||||
|
||||
/**
|
||||
* Get current music time played (in seconds).
|
||||
*/
|
||||
RLCPP_NODISCARD float GetTimePlayed() const { return ::GetMusicTimePlayed(*this); }
|
||||
|
||||
/**
|
||||
* Retrieve whether or not the Music has been loaded.
|
||||
*
|
||||
* @return True or false depending on whether the Music has been loaded.
|
||||
*/
|
||||
RLCPP_NODISCARD bool IsValid() const { return ::IsMusicValid(*this); }
|
||||
|
||||
protected:
|
||||
void set(const ::Music& music) {
|
||||
stream = music.stream;
|
||||
frameCount = music.frameCount;
|
||||
looping = music.looping;
|
||||
ctxType = music.ctxType;
|
||||
ctxData = music.ctxData;
|
||||
}
|
||||
};
|
||||
} // namespace raylib
|
||||
|
||||
using RMusicUnmanaged = raylib::MusicUnmanaged;
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_MUSICUNMANAGED_HPP_
|
||||
@@ -0,0 +1,296 @@
|
||||
#ifndef RAYLIB_CPP_INCLUDE_QUATERNION_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_QUATERNION_HPP_
|
||||
|
||||
#ifndef RAYLIB_CPP_NO_MATH
|
||||
#include <cmath>
|
||||
#include <utility>
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
#include "./raylib.hpp"
|
||||
#include "./raymath.hpp"
|
||||
|
||||
namespace raylib {
|
||||
class Vector4 : public ::Vector4 {};
|
||||
|
||||
/**
|
||||
* Quaternion type
|
||||
*/
|
||||
class Quaternion : public ::Quaternion {
|
||||
public:
|
||||
constexpr Quaternion(const ::Quaternion& quat) : ::Quaternion{quat.x, quat.y, quat.z, quat.w} {}
|
||||
explicit constexpr Quaternion(const raylib::Vector4 vec4) : ::Quaternion{vec4.x, vec4.y, vec4.z, vec4.w} {}
|
||||
|
||||
explicit constexpr Quaternion(const float x = 0, const float y = 0, const float z = 0, const float w = 1) : ::Quaternion{x, y, z, w} {}
|
||||
|
||||
GETTERSETTER(float, X, x)
|
||||
GETTERSETTER(float, Y, y)
|
||||
GETTERSETTER(float, Z, z)
|
||||
GETTERSETTER(float, W, w)
|
||||
|
||||
Quaternion& operator=(const ::Quaternion& quaternion) {
|
||||
set(quaternion);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/*
|
||||
* An exact value by value equality comparison.
|
||||
* Due to floating point inaccuracies consider using Equals instead.
|
||||
*/
|
||||
constexpr bool operator==(const ::Quaternion& other) const {
|
||||
return x == other.x && y == other.y && z == other.z && w == other.w;
|
||||
}
|
||||
|
||||
/*
|
||||
* An exact value by value inequality comparison.
|
||||
* Due to floating point inaccuracies consider using Equals instead.
|
||||
*/
|
||||
constexpr bool operator!=(const ::Quaternion& other) const { return !(*this == other); }
|
||||
|
||||
RLCPP_NODISCARD std::string ToString() const { return ::TextFormat("Quaternion(%f, %f, %f, %f)", x, y, z, w); }
|
||||
|
||||
operator std::string() const { return ToString(); }
|
||||
|
||||
#ifndef RAYLIB_CPP_NO_MATH
|
||||
/**
|
||||
* Add two quaternions
|
||||
*/
|
||||
RLCPP_NODISCARD Quaternion Add(const ::Quaternion& quaternion) const { return ::QuaternionAdd(*this, quaternion); }
|
||||
|
||||
/**
|
||||
* Add two quaternions
|
||||
*/
|
||||
Quaternion operator+(const ::Quaternion& quaternion) const { return ::QuaternionAdd(*this, quaternion); }
|
||||
|
||||
Quaternion& operator+=(const ::Quaternion& quaternion) {
|
||||
set(::QuaternionAdd(*this, quaternion));
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add quaternion and float value
|
||||
*/
|
||||
RLCPP_NODISCARD Quaternion Add(const float value) const {
|
||||
return ::QuaternionAddValue(*this, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add quaternion and float value
|
||||
*/
|
||||
Quaternion operator+(const float value) const {
|
||||
return ::QuaternionAddValue(*this, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add quaternion and float value
|
||||
*/
|
||||
Quaternion& operator+=(const float value) {
|
||||
set(::QuaternionAddValue(*this, value));
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add quaternion and float value
|
||||
*/
|
||||
friend Quaternion operator+(const float lhs, const Quaternion& rhs) { return rhs + lhs; }
|
||||
|
||||
/**
|
||||
* Subtract two quaternions.
|
||||
*/
|
||||
RLCPP_NODISCARD Quaternion Subtract(const ::Quaternion& quaternion) const { return ::QuaternionSubtract(*this, quaternion); }
|
||||
|
||||
/**
|
||||
* Subtract two quaternions.
|
||||
*/
|
||||
Quaternion operator-(const ::Quaternion& quaternion) const { return ::QuaternionSubtract(*this, quaternion); }
|
||||
|
||||
Quaternion& operator-=(const ::Quaternion& quaternion) {
|
||||
set(::QuaternionSubtract(*this, quaternion));
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Subtract quaternion by float value
|
||||
*/
|
||||
RLCPP_NODISCARD Quaternion Subtract(const float value) const {
|
||||
return ::QuaternionSubtractValue(*this, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get identity quaternion
|
||||
*/
|
||||
static RLCPP_NODISCARD Quaternion Identity() {
|
||||
return ::QuaternionIdentity();
|
||||
}
|
||||
|
||||
RLCPP_NODISCARD float Length() const { return ::QuaternionLength(*this); }
|
||||
|
||||
RLCPP_NODISCARD Quaternion Normalize() const { return ::QuaternionNormalize(*this); }
|
||||
|
||||
RLCPP_NODISCARD Quaternion Invert() const { return ::QuaternionInvert(*this); }
|
||||
|
||||
/**
|
||||
* Multiply quaternion by quaternion
|
||||
*/
|
||||
RLCPP_NODISCARD Quaternion Multiply(const ::Quaternion& other) const { return ::QuaternionMultiply(*this, other); }
|
||||
|
||||
/**
|
||||
* Multiply quaternion by quaternion
|
||||
*/
|
||||
Quaternion operator*(const ::Quaternion& other) const { return ::QuaternionMultiply(*this, other); }
|
||||
|
||||
/**
|
||||
* Multiply quaternion by quaternion
|
||||
*/
|
||||
Quaternion& operator*=(const ::Quaternion& other) {
|
||||
set(::QuaternionMultiply(*this, other));
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scale quaternion components by value (multiply)
|
||||
*/
|
||||
RLCPP_NODISCARD Quaternion Scale(const float scale) const { return ::QuaternionScale(*this, scale); }
|
||||
|
||||
/**
|
||||
* Divide quaternion by quaternion
|
||||
*/
|
||||
RLCPP_NODISCARD Quaternion Divide(const ::Quaternion& quaternion) const { return ::QuaternionDivide(*this, quaternion); }
|
||||
|
||||
/**
|
||||
* Divide quaternion by quaternion
|
||||
*/
|
||||
Quaternion operator/(const ::Quaternion& quaternion) const { return ::QuaternionDivide(*this, quaternion); }
|
||||
|
||||
/**
|
||||
* Divide quaternion by quaternion
|
||||
*/
|
||||
Quaternion& operator/=(const ::Quaternion& quaternion) {
|
||||
set(::QuaternionDivide(*this, quaternion));
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Divide quaternion components by value
|
||||
*/
|
||||
RLCPP_NODISCARD constexpr Quaternion Divide(const float div) const { return ::Quaternion{x / div, y / div, z / div, w / div}; }
|
||||
|
||||
RLCPP_NODISCARD Quaternion Lerp(const ::Quaternion& v2, const float amount) const
|
||||
{
|
||||
return ::QuaternionLerp(*this, v2, amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate normalized linear interpolation between two quaternions
|
||||
*/
|
||||
RLCPP_NODISCARD Quaternion Nlerp(const ::Quaternion& v2, const float amount) const {
|
||||
return ::QuaternionNlerp(*this, v2, amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates spherical linear interpolation between two quaternions
|
||||
*/
|
||||
RLCPP_NODISCARD Quaternion Slerp(const ::Quaternion& v2, const float amount) const {
|
||||
return ::QuaternionSlerp(*this, v2, amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate quaternion cubic spline interpolation using Cubic Hermite Spline
|
||||
*/
|
||||
RLCPP_NODISCARD Quaternion CubicHermiteSpline(
|
||||
const ::Quaternion& outTangent1,
|
||||
const ::Quaternion& q2,
|
||||
const ::Quaternion& inTangent2,
|
||||
const float t
|
||||
) const {
|
||||
return ::QuaternionCubicHermiteSpline(*this, outTangent1, q2, inTangent2, t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate quaternion based on the rotation from one vector to another
|
||||
*/
|
||||
static RLCPP_NODISCARD Quaternion FromVector3ToVector3(const ::Vector3& from, const ::Vector3& to) {
|
||||
return ::QuaternionFromVector3ToVector3(from, to);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a quaternion for a given rotation matrix
|
||||
*/
|
||||
static RLCPP_NODISCARD Quaternion FromMatrix(const ::Matrix& mat) {
|
||||
return ::QuaternionFromMatrix(mat);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a matrix for this quaternion
|
||||
*/
|
||||
RLCPP_NODISCARD ::Matrix ToMatrix() const {
|
||||
return ::QuaternionToMatrix(*this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get rotation quaternion for an angle and axis
|
||||
* NOTE: Angle must be provided in radians
|
||||
*/
|
||||
static RLCPP_NODISCARD Quaternion FromAxisAngle(const ::Vector3& axis, const float angle) {
|
||||
return ::QuaternionFromAxisAngle(axis, angle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the rotation angle and axis for this quaternion
|
||||
*/
|
||||
void ToAxisAngle(::Vector3* outAxis, float* outAngle) const {
|
||||
::QuaternionToAxisAngle(*this, outAxis, outAngle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the quaternion equivalent to Euler angles
|
||||
* NOTE: Rotation order is ZYX
|
||||
*/
|
||||
static RLCPP_NODISCARD Quaternion FromEuler(const float pitch, const float yaw, const float roll) {
|
||||
return ::QuaternionFromEuler(pitch, yaw, roll);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Euler angles equivalent to quaternion
|
||||
* NOTE: Angles are returned in radians
|
||||
*/
|
||||
RLCPP_NODISCARD ::Vector3 ToEuler() const {
|
||||
return ::QuaternionToEuler(*this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform quaternion given transformation matrix
|
||||
*/
|
||||
RLCPP_NODISCARD Quaternion Transform(const ::Matrix& mat) const {
|
||||
return ::QuaternionTransform(*this, mat);
|
||||
}
|
||||
|
||||
/*
|
||||
* Check whether two given quaternions are almost equal
|
||||
*/
|
||||
RLCPP_NODISCARD bool Equals(const ::Quaternion& other) const {
|
||||
return static_cast<bool>(::QuaternionEquals(*this, other));
|
||||
}
|
||||
#endif
|
||||
protected:
|
||||
void set(const ::Quaternion& quat) {
|
||||
x = quat.x;
|
||||
y = quat.y;
|
||||
z = quat.z;
|
||||
w = quat.w;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace raylib
|
||||
|
||||
using RQuaternion = raylib::Quaternion;
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_QUATERNION_HPP_
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
#ifndef RAYLIB_CPP_INCLUDE_RAY_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_RAY_HPP_
|
||||
|
||||
#include "./RayCollision.hpp"
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
#include "./raylib.hpp"
|
||||
|
||||
namespace raylib {
|
||||
/**
|
||||
* Ray type (useful for raycast)
|
||||
*/
|
||||
class Ray : public ::Ray {
|
||||
public:
|
||||
Ray(const ::Ray& ray) { set(ray); }
|
||||
|
||||
constexpr Ray(::Vector3 position = {0.0f, 0.0f, 0.0f}, ::Vector3 direction = {0.0f, 0.0f, 0.0f})
|
||||
: ::Ray{position, direction} {
|
||||
// Nothing.
|
||||
}
|
||||
|
||||
Ray(::Vector2 mousePosition, const ::Camera& camera) { set(::GetMouseRay(mousePosition, camera)); }
|
||||
|
||||
Ray& operator=(const ::Ray& ray) {
|
||||
set(ray);
|
||||
return *this;
|
||||
}
|
||||
|
||||
GETTERSETTER(::Vector3, Position, position)
|
||||
GETTERSETTER(::Vector3, Direction, direction)
|
||||
|
||||
/**
|
||||
* Draw a ray line
|
||||
*/
|
||||
void Draw(::Color color) const { DrawRay(*this, color); }
|
||||
|
||||
/**
|
||||
* Get collision information between ray and sphere
|
||||
*/
|
||||
RayCollision GetCollision(::Vector3 center, float radius) const {
|
||||
return ::GetRayCollisionSphere(*this, center, radius);
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect collision between ray and box
|
||||
*/
|
||||
RayCollision GetCollision(const ::BoundingBox& box) const { return ::GetRayCollisionBox(*this, box); }
|
||||
|
||||
/**
|
||||
* Get collision information between ray and mesh
|
||||
*/
|
||||
RayCollision GetCollision(const ::Mesh& mesh, const ::Matrix& transform) const {
|
||||
return ::GetRayCollisionMesh(*this, mesh, transform);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get collision info between ray and triangle
|
||||
*/
|
||||
RayCollision GetCollision(::Vector3 p1, ::Vector3 p2, ::Vector3 p3) const {
|
||||
return ::GetRayCollisionTriangle(*this, p1, p2, p3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get collision info between ray and quad
|
||||
*/
|
||||
RayCollision GetCollision(::Vector3 p1, ::Vector3 p2, ::Vector3 p3, ::Vector3 p4) const {
|
||||
return ::GetRayCollisionQuad(*this, p1, p2, p3, p4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a ray trace from mouse position
|
||||
*/
|
||||
static Ray GetMouse(::Vector2 mousePosition, const ::Camera& camera) {
|
||||
return ::GetMouseRay(mousePosition, camera);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a ray trace from mouse position
|
||||
*/
|
||||
static Ray GetMouse(const ::Camera& camera) { return ::GetMouseRay(::GetMousePosition(), camera); }
|
||||
protected:
|
||||
void set(const ::Ray& ray) {
|
||||
position = ray.position;
|
||||
direction = ray.direction;
|
||||
}
|
||||
};
|
||||
} // namespace raylib
|
||||
|
||||
using RRay = raylib::Ray;
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_RAY_HPP_
|
||||
@@ -0,0 +1,93 @@
|
||||
#ifndef RAYLIB_CPP_INCLUDE_RAYCOLLISION_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_RAYCOLLISION_HPP_
|
||||
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
#include "./raylib.hpp"
|
||||
|
||||
namespace raylib {
|
||||
/**
|
||||
* Raycast hit information
|
||||
*/
|
||||
class RayCollision : public ::RayCollision {
|
||||
public:
|
||||
RayCollision(const ::RayCollision& ray) : ::RayCollision(ray) { }
|
||||
|
||||
constexpr RayCollision(bool hit, float distance, ::Vector3 point, ::Vector3 normal)
|
||||
: ::RayCollision{hit, distance, point, normal} {
|
||||
// Nothing.
|
||||
}
|
||||
|
||||
/**
|
||||
* Get collision info between ray and bounding box
|
||||
*/
|
||||
RayCollision(const ::Ray& ray, const ::BoundingBox& box)
|
||||
: ::RayCollision(::GetRayCollisionBox(ray, box)) {
|
||||
// Nothing.
|
||||
}
|
||||
|
||||
/**
|
||||
* Get collision info between ray and mesh
|
||||
*/
|
||||
RayCollision(const ::Ray& ray, const ::Mesh& mesh, const ::Matrix& transform)
|
||||
: ::RayCollision(::GetRayCollisionMesh(ray, mesh, transform)) {
|
||||
// Nothing.
|
||||
}
|
||||
|
||||
/**
|
||||
* Get collision info between ray and quad
|
||||
*/
|
||||
RayCollision(const ::Ray& ray, ::Vector3 p1, ::Vector3 p2, ::Vector3 p3, ::Vector3 p4)
|
||||
: ::RayCollision(::GetRayCollisionQuad(ray, p1, p2, p3, p4)) {
|
||||
// Nothing.
|
||||
}
|
||||
|
||||
/**
|
||||
* Get collision info between ray and sphere
|
||||
*/
|
||||
RayCollision(const ::Ray& ray, ::Vector3 center, float radius)
|
||||
: ::RayCollision(::GetRayCollisionSphere(ray, center, radius)) {
|
||||
// Nothing.
|
||||
}
|
||||
|
||||
/**
|
||||
* Get collision info between ray and triangle
|
||||
*/
|
||||
RayCollision(const ::Ray& ray, ::Vector3 p1, ::Vector3 p2, ::Vector3 p3)
|
||||
: ::RayCollision(::GetRayCollisionTriangle(ray, p1, p2, p3)) {
|
||||
// Nothing.
|
||||
}
|
||||
|
||||
RayCollision& operator=(const ::RayCollision& ray) {
|
||||
set(ray);
|
||||
return *this;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string ToString() const {
|
||||
return TextFormat(
|
||||
"RayCollision(hit=%s, distance=%f, point=(%f, %f, %f), normal=(%f, %f, %f))",
|
||||
hit ? "true" : "false",
|
||||
distance,
|
||||
point.x, point.y, point.z,
|
||||
normal.x, normal.y, normal.z
|
||||
);
|
||||
}
|
||||
|
||||
operator std::string() const { return ToString(); }
|
||||
|
||||
GETTERSETTER(bool, Hit, hit)
|
||||
GETTERSETTER(float, Distance, distance)
|
||||
GETTERSETTER(::Vector3, Position, point)
|
||||
GETTERSETTER(::Vector3, Normal, normal)
|
||||
protected:
|
||||
void set(const ::RayCollision& ray) {
|
||||
hit = ray.hit;
|
||||
distance = ray.distance;
|
||||
point = ray.point;
|
||||
normal = ray.normal;
|
||||
}
|
||||
};
|
||||
} // namespace raylib
|
||||
|
||||
using RRayCollision = raylib::RayCollision;
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_RAYCOLLISION_HPP_
|
||||
@@ -0,0 +1,36 @@
|
||||
#ifndef RAYLIB_CPP_INCLUDE_RAYLIBEXCEPTION_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_RAYLIBEXCEPTION_HPP_
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
#include "./raylib.hpp"
|
||||
|
||||
namespace raylib {
|
||||
/**
|
||||
* Exception used for most raylib-related exceptions.
|
||||
*/
|
||||
class RaylibException : public std::runtime_error {
|
||||
public:
|
||||
/**
|
||||
* Construct a runtime exception with the given message.
|
||||
*
|
||||
* @param message The message to provide for the exception.
|
||||
*/
|
||||
explicit RaylibException(const std::string& message) noexcept : std::runtime_error(message) {
|
||||
// Nothing
|
||||
}
|
||||
|
||||
/**
|
||||
* Outputs the exception message to TraceLog().
|
||||
*
|
||||
* @param logLevel The output status to use when outputing.
|
||||
*/
|
||||
void TraceLog(int logLevel = LOG_ERROR) { ::TraceLog(logLevel, std::runtime_error::what()); }
|
||||
};
|
||||
|
||||
} // namespace raylib
|
||||
|
||||
using RRaylibException = raylib::RaylibException;
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_RAYLIBEXCEPTION_HPP_
|
||||
@@ -0,0 +1,162 @@
|
||||
#ifndef RAYLIB_CPP_INCLUDE_RECTANGLE_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_RECTANGLE_HPP_
|
||||
|
||||
#include "./Vector2.hpp"
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
#include "./raylib.hpp"
|
||||
|
||||
namespace raylib {
|
||||
/**
|
||||
* Rectangle type
|
||||
*/
|
||||
class Rectangle : public ::Rectangle {
|
||||
public:
|
||||
constexpr Rectangle(const ::Rectangle& rect) : ::Rectangle{rect.x, rect.y, rect.width, rect.height} {}
|
||||
|
||||
constexpr Rectangle(float x = 0, float y = 0, float width = 0, float height = 0) : ::Rectangle{x, y, width, height} {}
|
||||
|
||||
constexpr Rectangle(::Vector2 position, ::Vector2 size) : ::Rectangle{position.x, position.y, size.x, size.y} {}
|
||||
constexpr Rectangle(::Vector2 size) : ::Rectangle{0, 0, size.x, size.y} {}
|
||||
constexpr Rectangle(::Vector4 rect) : ::Rectangle{rect.x, rect.y, rect.z, rect.w} {}
|
||||
|
||||
GETTERSETTER(float, X, x)
|
||||
GETTERSETTER(float, Y, y)
|
||||
GETTERSETTER(float, Width, width)
|
||||
GETTERSETTER(float, Height, height)
|
||||
|
||||
Rectangle& operator=(const ::Rectangle& rect) {
|
||||
set(rect);
|
||||
return *this;
|
||||
}
|
||||
|
||||
constexpr ::Vector4 ToVector4() const { return {x, y, width, height}; }
|
||||
|
||||
constexpr explicit operator ::Vector4() const { return {x, y, width, height}; }
|
||||
|
||||
[[nodiscard]] std::string ToString() const { return TextFormat("Rectangle(%fx%f, %fx%f)", x, y, width, height); }
|
||||
|
||||
operator std::string() const { return ToString(); }
|
||||
|
||||
/**
|
||||
* Draw a color-filled rectangle
|
||||
*/
|
||||
static void Draw(int posX, int posY, int width, int height, ::Color color) {
|
||||
::DrawRectangle(posX, posY, width, height, color);
|
||||
}
|
||||
|
||||
static void Draw(::Vector2 position, ::Vector2 size, ::Color color) {
|
||||
::DrawRectangleV(position, size, color);
|
||||
}
|
||||
|
||||
void Draw(::Color color) const { ::DrawRectangleRec(*this, color); }
|
||||
|
||||
void Draw(::Vector2 origin, float rotation, ::Color color) const {
|
||||
::DrawRectanglePro(*this, origin, rotation, color);
|
||||
}
|
||||
|
||||
void DrawGradientV(::Color color1, ::Color color2) const {
|
||||
::DrawRectangleGradientV(
|
||||
static_cast<int>(x),
|
||||
static_cast<int>(y),
|
||||
static_cast<int>(width),
|
||||
static_cast<int>(height),
|
||||
color1,
|
||||
color2);
|
||||
}
|
||||
|
||||
void DrawGradientH(::Color color1, ::Color color2) const {
|
||||
::DrawRectangleGradientH(
|
||||
static_cast<int>(x),
|
||||
static_cast<int>(y),
|
||||
static_cast<int>(width),
|
||||
static_cast<int>(height),
|
||||
color1,
|
||||
color2);
|
||||
}
|
||||
|
||||
void DrawGradient(::Color topLeft, ::Color bottomLeft, ::Color bottomRight, ::Color topRight) const {
|
||||
::DrawRectangleGradientEx(*this, topLeft, bottomLeft, bottomRight, topRight);
|
||||
}
|
||||
|
||||
void DrawLines(::Color color) const {
|
||||
::DrawRectangleLines(
|
||||
static_cast<int>(x),
|
||||
static_cast<int>(y),
|
||||
static_cast<int>(width),
|
||||
static_cast<int>(height),
|
||||
color);
|
||||
}
|
||||
|
||||
void DrawLines(::Color color, float lineThick) const { ::DrawRectangleLinesEx(*this, lineThick, color); }
|
||||
|
||||
void DrawRounded(float roundness, int segments, ::Color color) const {
|
||||
::DrawRectangleRounded(*this, roundness, segments, color);
|
||||
}
|
||||
|
||||
void DrawRoundedLines(float roundness, int segments, ::Color color) const {
|
||||
::DrawRectangleRoundedLines(*this, roundness, segments, color);
|
||||
}
|
||||
|
||||
void DrawRoundedLines(float roundness, int segments, float lineThick, ::Color color) const {
|
||||
::DrawRectangleRoundedLinesEx(*this, roundness, segments, lineThick, color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check collision between two rectangles
|
||||
*/
|
||||
RLCPP_NODISCARD bool CheckCollision(::Rectangle rec2) const { return ::CheckCollisionRecs(*this, rec2); }
|
||||
|
||||
/**
|
||||
* Get collision rectangle for two rectangles collision
|
||||
*/
|
||||
RLCPP_NODISCARD ::Rectangle GetCollision(::Rectangle rec2) const { return ::GetCollisionRec(*this, rec2); }
|
||||
|
||||
/**
|
||||
* Check if point is inside rectangle
|
||||
*/
|
||||
RLCPP_NODISCARD bool CheckCollision(::Vector2 point) const { return ::CheckCollisionPointRec(point, *this); }
|
||||
|
||||
/**
|
||||
* Check collision between circle and rectangle
|
||||
*/
|
||||
RLCPP_NODISCARD bool CheckCollision(::Vector2 center, float radius) const {
|
||||
return ::CheckCollisionCircleRec(center, radius, *this);
|
||||
}
|
||||
|
||||
RLCPP_NODISCARD Vector2 GetSize() const { return {width, height}; }
|
||||
|
||||
Rectangle& SetSize(float newWidth, float newHeight) {
|
||||
width = newWidth;
|
||||
height = newHeight;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Rectangle& SetSize(const ::Vector2& size) { return SetSize(size.x, size.y); }
|
||||
|
||||
Rectangle& SetShapesTexture(const ::Texture2D& texture) {
|
||||
::SetShapesTexture(texture, *this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
RLCPP_NODISCARD Vector2 GetPosition() const { return {x, y}; }
|
||||
|
||||
Rectangle& SetPosition(float newX, float newY) {
|
||||
x = newX;
|
||||
y = newY;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Rectangle& SetPosition(const ::Vector2& position) { return SetPosition(position.x, position.y); }
|
||||
protected:
|
||||
void set(const ::Rectangle& rect) {
|
||||
x = rect.x;
|
||||
y = rect.y;
|
||||
width = rect.width;
|
||||
height = rect.height;
|
||||
}
|
||||
};
|
||||
} // namespace raylib
|
||||
|
||||
using RRectangle = raylib::Rectangle;
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_RECTANGLE_HPP_
|
||||
@@ -0,0 +1,65 @@
|
||||
#ifndef RAYLIB_CPP_INCLUDE_RENDERTEXTURE_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_RENDERTEXTURE_HPP_
|
||||
|
||||
#include "./RenderTextureUnmanaged.hpp"
|
||||
|
||||
namespace raylib {
|
||||
/**
|
||||
* RenderTexture type, for texture rendering.
|
||||
*
|
||||
* The render texture will be unloaded on object destruction. Use raylib::RenderTextureUnmanaged
|
||||
* if you're looking to not unload.
|
||||
*
|
||||
* @see raylib::RenderTextureUnmanaged
|
||||
*/
|
||||
class RenderTexture : public RenderTextureUnmanaged {
|
||||
public:
|
||||
using RenderTextureUnmanaged::RenderTextureUnmanaged;
|
||||
|
||||
RenderTexture(const RenderTexture&) = delete;
|
||||
RenderTexture& operator=(const RenderTexture&) = delete;
|
||||
|
||||
RenderTexture(RenderTexture&& other) noexcept {
|
||||
set(other);
|
||||
other.id = 0;
|
||||
other.texture = {};
|
||||
other.depth = {};
|
||||
}
|
||||
|
||||
RenderTexture& operator=(RenderTexture&& other) noexcept {
|
||||
if (this == &other) {
|
||||
return *this;
|
||||
}
|
||||
Unload();
|
||||
set(other);
|
||||
other.id = 0;
|
||||
other.texture = {};
|
||||
other.depth = {};
|
||||
return *this;
|
||||
}
|
||||
|
||||
RenderTexture& operator=(const ::RenderTexture& other) {
|
||||
Unload();
|
||||
set(other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
~RenderTexture() { Unload(); }
|
||||
|
||||
/**
|
||||
* Unload previous render texture, then load a new one.
|
||||
*/
|
||||
void Load(int width, int height) {
|
||||
Unload();
|
||||
RenderTextureUnmanaged::Load(width, height);
|
||||
}
|
||||
};
|
||||
|
||||
using RenderTexture2D = RenderTexture;
|
||||
|
||||
} // namespace raylib
|
||||
|
||||
using RRenderTexture = raylib::RenderTexture;
|
||||
using RRenderTexture2D = raylib::RenderTexture2D;
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_RENDERTEXTURE_HPP_
|
||||
@@ -0,0 +1,123 @@
|
||||
#ifndef RAYLIB_CPP_INCLUDE_RENDERTEXTUREUNMANAGED_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_RENDERTEXTUREUNMANAGED_HPP_
|
||||
|
||||
#include "./RaylibException.hpp"
|
||||
#include "./TextureUnmanaged.hpp"
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
|
||||
namespace raylib {
|
||||
/**
|
||||
* A RenderTexture that is not managed by C++ RAII.
|
||||
*
|
||||
* Make sure to Unload() this if needed, otherwise use raylib::RenderTexture.
|
||||
*
|
||||
* @see raylib::RenderTexture
|
||||
*/
|
||||
class RenderTextureUnmanaged : public ::RenderTexture {
|
||||
public:
|
||||
/**
|
||||
* Default constructor to build an empty RenderTexture.
|
||||
*/
|
||||
RenderTextureUnmanaged() : ::RenderTexture{0, {}, {}} {}
|
||||
|
||||
/**
|
||||
* Creates a RenderTexture from an existing RenderTexture struct.
|
||||
*/
|
||||
RenderTextureUnmanaged(const ::RenderTexture& renderTexture) : ::RenderTexture(renderTexture) {}
|
||||
|
||||
/**
|
||||
* Creates a RenderTexture from its components.
|
||||
*/
|
||||
RenderTextureUnmanaged(unsigned int id, const ::Texture& texture, const ::Texture& depth)
|
||||
: ::RenderTexture{id, texture, depth} {}
|
||||
|
||||
/**
|
||||
* Load texture for rendering (framebuffer).
|
||||
*
|
||||
* @throws raylib::RaylibException Throws if failed to create the render texture.
|
||||
*/
|
||||
RenderTextureUnmanaged(int width, int height) { Load(width, height); }
|
||||
|
||||
[[nodiscard]] std::string ToString() const { return TextFormat("RenderTexture(id=%u)", id); }
|
||||
|
||||
operator std::string() const { return ToString(); }
|
||||
|
||||
GETTER(unsigned int, Id, id)
|
||||
|
||||
/**
|
||||
* Get the color buffer attachment texture.
|
||||
*/
|
||||
TextureUnmanaged GetTexture() { return texture; }
|
||||
RLCPP_NODISCARD TextureUnmanaged GetTexture() const { return texture; }
|
||||
void SetTexture(const ::Texture& newTexture) { texture = newTexture; }
|
||||
|
||||
/**
|
||||
* Get the depth buffer attachment texture.
|
||||
*/
|
||||
TextureUnmanaged GetDepth() { return depth; }
|
||||
void SetDepth(const ::Texture& newDepth) { depth = newDepth; }
|
||||
|
||||
RenderTextureUnmanaged& operator=(const ::RenderTexture& other) {
|
||||
set(other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load texture for rendering (framebuffer).
|
||||
*
|
||||
* @throws raylib::RaylibException Throws if failed to create the render texture.
|
||||
*/
|
||||
void Load(int width, int height) {
|
||||
set(::LoadRenderTexture(width, height));
|
||||
if (!IsValid()) {
|
||||
throw RaylibException("Failed to create RenderTexture");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unload render texture from GPU memory (VRAM).
|
||||
*/
|
||||
void Unload() {
|
||||
if (IsValid()) {
|
||||
::UnloadRenderTexture(*this);
|
||||
id = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes render texture for drawing.
|
||||
*/
|
||||
RenderTextureUnmanaged& BeginMode() {
|
||||
::BeginTextureMode(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ends drawing to render texture.
|
||||
*/
|
||||
RenderTextureUnmanaged& EndMode() {
|
||||
::EndTextureMode();
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves whether or not the render texture is ready.
|
||||
*/
|
||||
RLCPP_NODISCARD bool IsValid() const { return ::IsRenderTextureValid(*this); }
|
||||
|
||||
protected:
|
||||
void set(const ::RenderTexture& renderTexture) {
|
||||
id = renderTexture.id;
|
||||
texture = renderTexture.texture;
|
||||
depth = renderTexture.depth;
|
||||
}
|
||||
};
|
||||
|
||||
using RenderTexture2DUnmanaged = RenderTextureUnmanaged;
|
||||
|
||||
} // namespace raylib
|
||||
|
||||
using RRenderTextureUnmanaged = raylib::RenderTextureUnmanaged;
|
||||
using RRenderTexture2DUnmanaged = raylib::RenderTexture2DUnmanaged;
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_RENDERTEXTUREUNMANAGED_HPP_
|
||||
@@ -0,0 +1,53 @@
|
||||
#ifndef RAYLIB_CPP_INCLUDE_SHADER_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_SHADER_HPP_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "ShaderUnmanaged.hpp"
|
||||
#include "Texture.hpp"
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
#include "./raylib.hpp"
|
||||
|
||||
namespace raylib {
|
||||
/**
|
||||
* Shader type (generic)
|
||||
*/
|
||||
class Shader : public ShaderUnmanaged {
|
||||
public:
|
||||
using ShaderUnmanaged::ShaderUnmanaged;
|
||||
|
||||
Shader(const Shader&) = delete;
|
||||
|
||||
Shader(Shader&& other) noexcept {
|
||||
set(other);
|
||||
|
||||
other.id = 0;
|
||||
other.locs = nullptr;
|
||||
}
|
||||
|
||||
Shader& operator=(const Shader&) = delete;
|
||||
|
||||
Shader& operator=(Shader&& other) noexcept {
|
||||
if (this == &other) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
Unload();
|
||||
set(other);
|
||||
|
||||
other.id = 0;
|
||||
other.locs = nullptr;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unload shader from GPU memory (VRAM)
|
||||
*/
|
||||
~Shader() { Unload(); }
|
||||
};
|
||||
} // namespace raylib
|
||||
|
||||
using RShader = raylib::Shader;
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_SHADER_HPP_
|
||||
@@ -0,0 +1,160 @@
|
||||
#ifndef RAYLIB_CPP_INCLUDE_SHADERUNMANAGED_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_SHADERUNMANAGED_HPP_
|
||||
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
#include "./raylib.hpp"
|
||||
|
||||
#include <rlgl.h>
|
||||
#include <string>
|
||||
|
||||
namespace raylib {
|
||||
|
||||
/**
|
||||
* Shader type (generic), not managed by C++ RAII.
|
||||
*/
|
||||
class ShaderUnmanaged : public ::Shader {
|
||||
public:
|
||||
ShaderUnmanaged() : ::Shader{rlGetShaderIdDefault(), rlGetShaderLocsDefault()} {}
|
||||
|
||||
ShaderUnmanaged(const ::Shader& shader) : ::Shader(shader) { }
|
||||
|
||||
ShaderUnmanaged(unsigned int id, int* locs = nullptr) : ::Shader{id, locs} {}
|
||||
|
||||
ShaderUnmanaged(const std::string& vsFileName, const std::string& fsFileName) {
|
||||
set(::LoadShader(vsFileName.c_str(), fsFileName.c_str()));
|
||||
}
|
||||
ShaderUnmanaged(const char* vsFileName, const char* fsFileName) { set(::LoadShader(vsFileName, fsFileName)); }
|
||||
|
||||
/**
|
||||
* Load shader from files and bind default locations.
|
||||
*
|
||||
* @see ::LoadShader
|
||||
*/
|
||||
static ::Shader Load(const std::string& vsFileName, const std::string& fsFileName) {
|
||||
return ::LoadShader(vsFileName.c_str(), fsFileName.c_str());
|
||||
}
|
||||
static ::Shader Load(const char* vsFileName, const char* fsFileName) {
|
||||
return ::LoadShader(vsFileName, fsFileName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a shader from memory.
|
||||
*
|
||||
* @see ::LoadShaderFromMemory
|
||||
*/
|
||||
static ::Shader LoadFromMemory(const std::string& vsCode, const std::string& fsCode) {
|
||||
return ::LoadShaderFromMemory(vsCode.c_str(), fsCode.c_str());
|
||||
}
|
||||
static ::Shader LoadFromMemory(const char* vsCode, const char* fsCode) {
|
||||
return ::LoadShaderFromMemory(vsCode, fsCode);
|
||||
}
|
||||
|
||||
GETTER(unsigned int, Id, id)
|
||||
GETTER(int*, Locs, locs)
|
||||
|
||||
ShaderUnmanaged& operator=(const ::Shader& shader) {
|
||||
set(shader);
|
||||
return *this;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string ToString() const { return TextFormat("Shader(id=%u)", id); }
|
||||
|
||||
operator std::string() const { return ToString(); }
|
||||
|
||||
/**
|
||||
* Begin custom shader drawing.
|
||||
*/
|
||||
ShaderUnmanaged& BeginMode() {
|
||||
::BeginShaderMode(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* End custom shader drawing (use default shader).
|
||||
*/
|
||||
ShaderUnmanaged& EndMode() {
|
||||
::EndShaderMode();
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get shader uniform location
|
||||
*
|
||||
* @see GetShaderLocation()
|
||||
*/
|
||||
RLCPP_NODISCARD int GetLocation(const std::string& uniformName) const { return ::GetShaderLocation(*this, uniformName.c_str()); }
|
||||
|
||||
/**
|
||||
* Get shader attribute location
|
||||
*
|
||||
* @see GetShaderLocationAttrib()
|
||||
*/
|
||||
RLCPP_NODISCARD int GetLocationAttrib(const std::string& attribName) const {
|
||||
return ::GetShaderLocationAttrib(*this, attribName.c_str());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set shader uniform value
|
||||
*
|
||||
* @see SetShaderValue()
|
||||
*/
|
||||
ShaderUnmanaged& SetValue(int uniformLoc, const void* value, int uniformType) {
|
||||
::SetShaderValue(*this, uniformLoc, value, uniformType);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set shader uniform value vector
|
||||
*
|
||||
* @see SetShaderValueV()
|
||||
*/
|
||||
ShaderUnmanaged& SetValue(int uniformLoc, const void* value, int uniformType, int count) {
|
||||
::SetShaderValueV(*this, uniformLoc, value, uniformType, count);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set shader uniform value (matrix 4x4)
|
||||
*
|
||||
* @see SetShaderValueMatrix()
|
||||
*/
|
||||
ShaderUnmanaged& SetValue(int uniformLoc, const ::Matrix& mat) {
|
||||
::SetShaderValueMatrix(*this, uniformLoc, mat);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set shader uniform value for texture
|
||||
*
|
||||
* @see SetShaderValueTexture()
|
||||
*/
|
||||
ShaderUnmanaged& SetValue(int uniformLoc, const ::Texture2D& texture) {
|
||||
::SetShaderValueTexture(*this, uniformLoc, texture);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unload shader from GPU memory (VRAM).
|
||||
*/
|
||||
void Unload() {
|
||||
if (locs != nullptr) {
|
||||
::UnloadShader(*this);
|
||||
locs = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves whether or not the shader is ready.
|
||||
*/
|
||||
RLCPP_NODISCARD bool IsValid() const { return ::IsShaderValid(*this); }
|
||||
protected:
|
||||
void set(const ::Shader& shader) {
|
||||
id = shader.id;
|
||||
locs = shader.locs;
|
||||
}
|
||||
};
|
||||
} // namespace raylib
|
||||
|
||||
using RShaderUnmanaged = raylib::ShaderUnmanaged;
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_SHADERUNMANAGED_HPP_
|
||||
@@ -0,0 +1,59 @@
|
||||
#ifndef RAYLIB_CPP_INCLUDE_SOUND_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_SOUND_HPP_
|
||||
|
||||
#include "./SoundUnmanaged.hpp"
|
||||
|
||||
namespace raylib {
|
||||
/**
|
||||
* Wave/Sound management functions.
|
||||
*
|
||||
* The sound will be unloaded on object destruction. Use raylib::SoundUnmanaged if you're looking to not unload.
|
||||
*
|
||||
* @code
|
||||
* raylib::Sound boom("boom.wav");
|
||||
* boom.Play();
|
||||
* @endcode
|
||||
*
|
||||
* @see raylib::SoundUnmanaged
|
||||
*/
|
||||
class Sound : public SoundUnmanaged {
|
||||
public:
|
||||
using SoundUnmanaged::SoundUnmanaged;
|
||||
|
||||
Sound(const Sound&) = delete;
|
||||
Sound& operator=(const Sound&) = delete;
|
||||
|
||||
Sound(Sound&& other) noexcept {
|
||||
set(other);
|
||||
other.stream = {nullptr, nullptr, 0, 0, 0};
|
||||
other.frameCount = 0;
|
||||
}
|
||||
|
||||
Sound& operator=(Sound&& other) noexcept {
|
||||
if (this == &other) {
|
||||
return *this;
|
||||
}
|
||||
Unload();
|
||||
set(other);
|
||||
other.frameCount = 0;
|
||||
other.stream = {nullptr, nullptr, 0, 0, 0};
|
||||
return *this;
|
||||
}
|
||||
|
||||
~Sound() { Unload(); }
|
||||
|
||||
void Load(const std::string& fileName) {
|
||||
Unload();
|
||||
SoundUnmanaged::Load(fileName);
|
||||
}
|
||||
|
||||
void Load(const ::Wave& wave) {
|
||||
Unload();
|
||||
SoundUnmanaged::Load(wave);
|
||||
}
|
||||
};
|
||||
} // namespace raylib
|
||||
|
||||
using RSound = raylib::Sound;
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_SOUND_HPP_
|
||||
@@ -0,0 +1,190 @@
|
||||
#ifndef RAYLIB_CPP_INCLUDE_SOUNDUNMANAGED_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_SOUNDUNMANAGED_HPP_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "./RaylibException.hpp"
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
#include "./raylib.hpp"
|
||||
|
||||
namespace raylib {
|
||||
/**
|
||||
* A Sound that is not managed by C++ RAII.
|
||||
*
|
||||
* Make sure to Unload() this if needed, otherwise use raylib::Sound.
|
||||
*
|
||||
* @see raylib::Sound
|
||||
*/
|
||||
class SoundUnmanaged : public ::Sound {
|
||||
public:
|
||||
/**
|
||||
* Default constructor, creates an empty Sound.
|
||||
*/
|
||||
SoundUnmanaged() : ::Sound{{nullptr, nullptr, 0, 0, 0}, 0} {}
|
||||
|
||||
/**
|
||||
* Creates a SoundUnmanaged from its components.
|
||||
*/
|
||||
SoundUnmanaged(::AudioStream stream, unsigned int frameCount) : ::Sound{stream, frameCount} {}
|
||||
|
||||
/**
|
||||
* Creates a SoundUnmanaged from an existing Sound struct.
|
||||
*/
|
||||
SoundUnmanaged(const ::Sound& sound) : ::Sound(sound) {}
|
||||
|
||||
/**
|
||||
* Loads a Sound from the given file.
|
||||
*
|
||||
* @throws raylib::RaylibException Throws if the Sound failed to load.
|
||||
*/
|
||||
SoundUnmanaged(const std::string& fileName) { Load(fileName); }
|
||||
|
||||
/**
|
||||
* Loads a Sound from the given Wave.
|
||||
*
|
||||
* @throws raylib::RaylibException Throws if the Sound failed to load.
|
||||
*/
|
||||
SoundUnmanaged(const ::Wave& wave) { Load(wave); }
|
||||
|
||||
GETTER(unsigned int, FrameCount, frameCount)
|
||||
GETTER(::AudioStream, Stream, stream)
|
||||
|
||||
SoundUnmanaged& operator=(const ::Sound& sound) {
|
||||
set(sound);
|
||||
return *this;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string ToString() const { return TextFormat("Sound(frameCount=%u)", frameCount); }
|
||||
|
||||
operator std::string() const { return ToString(); }
|
||||
|
||||
/**
|
||||
* Load a sound from the given file.
|
||||
*
|
||||
* @throws raylib::RaylibException Throws if the Sound failed to load.
|
||||
*/
|
||||
void Load(const std::string& fileName) {
|
||||
set(::LoadSound(fileName.c_str()));
|
||||
if (!IsValid()) {
|
||||
throw RaylibException("Failed to load Sound from file");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a sound from the given Wave.
|
||||
*
|
||||
* @throws raylib::RaylibException Throws if the Sound failed to load.
|
||||
*/
|
||||
void Load(const ::Wave& wave) {
|
||||
set(::LoadSoundFromWave(wave));
|
||||
if (!IsValid()) {
|
||||
throw RaylibException("Failed to load Wave");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unload sound.
|
||||
*/
|
||||
void Unload() {
|
||||
// Protect against calling UnloadSound() twice.
|
||||
if (frameCount != 0) {
|
||||
::UnloadSound(*this);
|
||||
frameCount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update sound buffer with new data.
|
||||
*/
|
||||
SoundUnmanaged& Update(const void* data, int samplesCount) {
|
||||
::UpdateSound(*this, data, samplesCount);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update sound buffer with new data, assuming it's the same sample count.
|
||||
*/
|
||||
SoundUnmanaged& Update(const void* data) {
|
||||
::UpdateSound(*this, data, static_cast<int>(frameCount));
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Play a sound.
|
||||
*/
|
||||
SoundUnmanaged& Play() {
|
||||
::PlaySound(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop playing a sound.
|
||||
*/
|
||||
SoundUnmanaged& Stop() {
|
||||
::StopSound(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pause a sound.
|
||||
*/
|
||||
SoundUnmanaged& Pause() {
|
||||
::PauseSound(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resume a paused sound.
|
||||
*/
|
||||
SoundUnmanaged& Resume() {
|
||||
::ResumeSound(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a sound is currently playing.
|
||||
*/
|
||||
RLCPP_NODISCARD bool IsPlaying() const { return ::IsSoundPlaying(*this); }
|
||||
|
||||
/**
|
||||
* Set volume for a sound (1.0 is max level).
|
||||
*/
|
||||
SoundUnmanaged& SetVolume(float volume) {
|
||||
::SetSoundVolume(*this, volume);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set pitch for a sound (1.0 is base level).
|
||||
*/
|
||||
SoundUnmanaged& SetPitch(float pitch) {
|
||||
::SetSoundPitch(*this, pitch);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set pan for a sound (0.5 is center).
|
||||
*/
|
||||
SoundUnmanaged& SetPan(float pan = 0.5f) {
|
||||
::SetSoundPan(*this, pan);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve whether or not the Sound buffer is loaded.
|
||||
*
|
||||
* @return True or false depending on whether the Sound buffer is loaded.
|
||||
*/
|
||||
RLCPP_NODISCARD bool IsValid() const { return ::IsSoundValid(*this); }
|
||||
|
||||
protected:
|
||||
void set(const ::Sound& sound) {
|
||||
stream = sound.stream;
|
||||
frameCount = sound.frameCount;
|
||||
}
|
||||
};
|
||||
} // namespace raylib
|
||||
|
||||
using RSoundUnmanaged = raylib::SoundUnmanaged;
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_SOUNDUNMANAGED_HPP_
|
||||
@@ -0,0 +1,199 @@
|
||||
#ifndef RAYLIB_CPP_INCLUDE_TEXT_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_TEXT_HPP_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "./RaylibException.hpp"
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
#include "./raylib.hpp"
|
||||
|
||||
namespace raylib {
|
||||
/**
|
||||
* Text Functions.
|
||||
*/
|
||||
class Text {
|
||||
public:
|
||||
/**
|
||||
* The internal text.
|
||||
*/
|
||||
std::string text;
|
||||
|
||||
/**
|
||||
* The size of the text.
|
||||
*/
|
||||
float fontSize;
|
||||
|
||||
/**
|
||||
* The color of the text.
|
||||
*/
|
||||
::Color color;
|
||||
|
||||
/**
|
||||
* The internal raylib font to use for the text.
|
||||
*/
|
||||
::Font font;
|
||||
|
||||
/**
|
||||
* The character spacing for the text.
|
||||
*/
|
||||
float spacing;
|
||||
|
||||
/**
|
||||
* Initializes a new Text object.
|
||||
*
|
||||
* @param text Text to initialize.
|
||||
* @param fontSize The size of the text.
|
||||
* @param color The color of the font.
|
||||
* @param font Font to initialize.
|
||||
* @param spacing The spacing of the text.
|
||||
*/
|
||||
Text(
|
||||
const std::string& text = "",
|
||||
float fontSize = 10,
|
||||
const ::Color& color = WHITE,
|
||||
const ::Font& font = ::GetFontDefault(),
|
||||
float spacing = 0)
|
||||
: text(text)
|
||||
, fontSize(fontSize)
|
||||
, color(color)
|
||||
, font(font)
|
||||
, spacing(spacing) {
|
||||
// Nothing.
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes a new Text object with a custom font.
|
||||
*
|
||||
* @param font Font to initialize.
|
||||
* @param text Text to initialize.
|
||||
* @param fontSize The size of the text.
|
||||
* @param spacing The spacing of the text.
|
||||
* @param color The color of the font.
|
||||
*/
|
||||
Text(
|
||||
const ::Font& font,
|
||||
const std::string& text = "",
|
||||
float fontSize = 10,
|
||||
float spacing = 0,
|
||||
const ::Color& color = WHITE)
|
||||
: text(text)
|
||||
, fontSize(fontSize)
|
||||
, color(color)
|
||||
, font(font)
|
||||
, spacing(spacing) {
|
||||
// Nothing.
|
||||
}
|
||||
|
||||
GETTERSETTER(const std::string&, Text, text)
|
||||
GETTERSETTER(float, FontSize, fontSize)
|
||||
GETTERSETTER(::Font, Font, font)
|
||||
GETTERSETTER(::Color, Color, color)
|
||||
GETTERSETTER(float, Spacing, spacing)
|
||||
|
||||
/**
|
||||
* Draw text with values in class.
|
||||
*/
|
||||
void Draw(const ::Vector2& position) const { ::DrawTextEx(font, text.c_str(), position, fontSize, spacing, color); }
|
||||
|
||||
/**
|
||||
* Draw text with values in class.
|
||||
*/
|
||||
void Draw(int posX, int posY) const {
|
||||
::DrawTextEx(
|
||||
font,
|
||||
text.c_str(),
|
||||
{static_cast<float>(posX), static_cast<float>(posY)},
|
||||
fontSize,
|
||||
spacing,
|
||||
color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw text using Font and pro parameters (rotation).
|
||||
*
|
||||
* @see DrawTextPro()
|
||||
*/
|
||||
void Draw(const ::Vector2& position, float rotation, const ::Vector2& origin = {0, 0}) const {
|
||||
::DrawTextPro(font, text.c_str(), position, origin, rotation, fontSize, spacing, color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Measure string width for default font
|
||||
*/
|
||||
RLCPP_NODISCARD int Measure() const { return ::MeasureText(text.c_str(), static_cast<int>(fontSize)); }
|
||||
|
||||
/**
|
||||
* Measure string size for Font
|
||||
*/
|
||||
RLCPP_NODISCARD Vector2 MeasureEx() const { return ::MeasureTextEx(font, text.c_str(), fontSize, spacing); }
|
||||
|
||||
Text& operator=(const Text& other) {
|
||||
if (this == &other) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
text = other.text;
|
||||
fontSize = other.fontSize;
|
||||
color = other.color;
|
||||
font = other.font;
|
||||
spacing = other.spacing;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw text using font and color
|
||||
*
|
||||
* @see ::DrawText
|
||||
*/
|
||||
static void
|
||||
Draw(const std::string& text, const int posX, const int posY, const int fontSize, const ::Color& color) {
|
||||
::DrawText(text.c_str(), posX, posY, fontSize, color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw text using font and color, with position defined as Vector2
|
||||
*
|
||||
* @see ::DrawText
|
||||
*/
|
||||
static void Draw(const std::string& text, const ::Vector2& pos, const int fontSize, const ::Color& color) {
|
||||
::DrawText(text.c_str(), static_cast<int>(pos.x), static_cast<int>(pos.y), fontSize, color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw text using font, color, position, font size and spacing
|
||||
*
|
||||
* @see ::DrawTextEx
|
||||
*/
|
||||
static void Draw(
|
||||
const ::Font& font,
|
||||
const std::string& text,
|
||||
const ::Vector2& position,
|
||||
const float fontSize,
|
||||
const float spacing,
|
||||
const ::Color& color) {
|
||||
::DrawTextEx(font, text.c_str(), position, fontSize, spacing, color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw text using font, color, position, origin, font size and spacing
|
||||
*
|
||||
* @see ::DrawTextPro
|
||||
*/
|
||||
static void Draw(
|
||||
const ::Font& font,
|
||||
const std::string& text,
|
||||
const ::Vector2& position,
|
||||
const ::Vector2& origin,
|
||||
const float rotation,
|
||||
const float fontSize,
|
||||
const float spacing,
|
||||
const ::Color& color) {
|
||||
::DrawTextPro(font, text.c_str(), position, origin, rotation, fontSize, spacing, color);
|
||||
}
|
||||
};
|
||||
} // namespace raylib
|
||||
|
||||
using RText = raylib::Text;
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_TEXT_HPP_
|
||||
@@ -0,0 +1,102 @@
|
||||
#ifndef RAYLIB_CPP_INCLUDE_TEXTURE_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_TEXTURE_HPP_
|
||||
|
||||
#include "./TextureUnmanaged.hpp"
|
||||
|
||||
namespace raylib {
|
||||
/**
|
||||
* Texture type
|
||||
*
|
||||
* The texture will be unloaded on object destruction. Use raylib::TextureUnmanaged if you're looking to not unload.
|
||||
*
|
||||
* @see raylib::TextureUnmanaged
|
||||
*/
|
||||
class Texture : public TextureUnmanaged {
|
||||
public:
|
||||
using TextureUnmanaged::TextureUnmanaged;
|
||||
|
||||
/**
|
||||
* Explicitly forbid the copy constructor.
|
||||
*/
|
||||
Texture(const Texture&) = delete;
|
||||
|
||||
/**
|
||||
* Explicitly forbid copy assignment.
|
||||
*/
|
||||
Texture& operator=(const Texture&) = delete;
|
||||
|
||||
/**
|
||||
* Move constructor.
|
||||
*/
|
||||
Texture(Texture&& other) noexcept {
|
||||
set(other);
|
||||
|
||||
other.id = 0;
|
||||
other.width = 0;
|
||||
other.height = 0;
|
||||
other.mipmaps = 0;
|
||||
other.format = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* On destruction, unload the Texture.
|
||||
*/
|
||||
~Texture() { Unload(); }
|
||||
|
||||
/**
|
||||
* Move assignment.
|
||||
*/
|
||||
Texture& operator=(Texture&& other) noexcept {
|
||||
if (this == &other) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
Unload();
|
||||
set(other);
|
||||
|
||||
other.id = 0;
|
||||
other.width = 0;
|
||||
other.height = 0;
|
||||
other.mipmaps = 0;
|
||||
other.format = 0;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unload previous texture, then load texture from image data
|
||||
*/
|
||||
void Load(const ::Image& image) {
|
||||
Unload();
|
||||
TextureUnmanaged::Load(image);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unload previous texture, then load cubemap from image.
|
||||
* Multiple image cubemap layouts supported
|
||||
*/
|
||||
void Load(const ::Image& image, int layoutType) {
|
||||
Unload();
|
||||
TextureUnmanaged::Load(image, layoutType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unload previous texture, then load texture from file into GPU memory (VRAM)
|
||||
*/
|
||||
void Load(const std::string& fileName) {
|
||||
Unload();
|
||||
TextureUnmanaged::Load(fileName);
|
||||
}
|
||||
};
|
||||
|
||||
// Create the Texture aliases.
|
||||
using Texture2D = Texture;
|
||||
using TextureCubemap = Texture;
|
||||
|
||||
} // namespace raylib
|
||||
|
||||
using RTexture = raylib::Texture;
|
||||
using RTexture2D = raylib::Texture2D;
|
||||
using RTextureCubemap = raylib::TextureCubemap;
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_TEXTURE_HPP_
|
||||
@@ -0,0 +1,347 @@
|
||||
#ifndef RAYLIB_CPP_INCLUDE_TEXTUREUNMANAGED_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_TEXTUREUNMANAGED_HPP_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "./Image.hpp"
|
||||
#include "./Material.hpp"
|
||||
#include "./RaylibException.hpp"
|
||||
#include "./Vector2.hpp"
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
#include "./raylib.hpp"
|
||||
|
||||
namespace raylib {
|
||||
/**
|
||||
* A Texture that is not managed by C++ RAII.
|
||||
*
|
||||
* Make sure to Unload() this if needed, otherwise use raylib::Texture.
|
||||
*
|
||||
* @see raylib::Texture
|
||||
*/
|
||||
class TextureUnmanaged : public ::Texture {
|
||||
public:
|
||||
/**
|
||||
* Default texture constructor.
|
||||
*/
|
||||
TextureUnmanaged() : ::Texture{0, 0, 0, 0, 0} {
|
||||
// Nothing.
|
||||
}
|
||||
|
||||
/**
|
||||
* Move/Create a texture structure manually.
|
||||
*/
|
||||
TextureUnmanaged(
|
||||
unsigned int id,
|
||||
int width,
|
||||
int height,
|
||||
int mipmaps = 1,
|
||||
int format = PIXELFORMAT_UNCOMPRESSED_R8G8B8A8)
|
||||
: ::Texture{id, width, height, mipmaps, format} {
|
||||
// Nothing.
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a texture object based on the given Texture struct data.
|
||||
*/
|
||||
TextureUnmanaged(const ::Texture& texture)
|
||||
: ::Texture{texture.id, texture.width, texture.height, texture.mipmaps, texture.format} {
|
||||
// Nothing.
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a texture from the given Image.
|
||||
*
|
||||
* @throws raylib::RaylibException Throws if failed to create the texture from the given image.
|
||||
*/
|
||||
TextureUnmanaged(const ::Image& image) { Load(image); }
|
||||
|
||||
/**
|
||||
* Load cubemap from image, multiple image cubemap layouts supported.
|
||||
*
|
||||
* @throws raylib::RaylibException Throws if failed to create the texture from the given cubemap.
|
||||
*
|
||||
* @see LoadTextureCubemap()
|
||||
*/
|
||||
TextureUnmanaged(const ::Image& image, int layout) { Load(image, layout); }
|
||||
|
||||
/**
|
||||
* Load texture from file into GPU memory (VRAM)
|
||||
*
|
||||
* @throws raylib::RaylibException Throws if failed to create the texture from the given file.
|
||||
*/
|
||||
TextureUnmanaged(const std::string& fileName) { Load(fileName); }
|
||||
|
||||
TextureUnmanaged(::Texture&& other) : ::Texture{other.id, other.width, other.height, other.mipmaps, other.format} {
|
||||
// Nothing.
|
||||
}
|
||||
|
||||
GETTER(unsigned int, Id, id)
|
||||
GETTER(int, Width, width)
|
||||
GETTER(int, Height, height)
|
||||
GETTER(int, Mipmaps, mipmaps)
|
||||
GETTER(int, Format, format)
|
||||
|
||||
TextureUnmanaged& operator=(const ::Texture& texture) {
|
||||
set(texture);
|
||||
return *this;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string ToString() const { return TextFormat("Texture(id=%u, %dx%d)", id, width, height); }
|
||||
|
||||
operator std::string() const { return ToString(); }
|
||||
|
||||
/**
|
||||
* Retrieve the width and height of the texture.
|
||||
*/
|
||||
RLCPP_NODISCARD Vector2 GetSize() const { return {static_cast<float>(width), static_cast<float>(height)}; }
|
||||
|
||||
/**
|
||||
* Load texture from image data
|
||||
*/
|
||||
void Load(const ::Image& image) {
|
||||
set(::LoadTextureFromImage(image));
|
||||
if (!IsValid()) {
|
||||
throw RaylibException("Failed to load Texture from Image");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load cubemap from image, multiple image cubemap layouts supported
|
||||
*/
|
||||
void Load(const ::Image& image, int layoutType) {
|
||||
set(::LoadTextureCubemap(image, layoutType));
|
||||
if (!IsValid()) {
|
||||
throw RaylibException("Failed to load Texture from Cubemap");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load texture from file into GPU memory (VRAM)
|
||||
*/
|
||||
void Load(const std::string& fileName) {
|
||||
set(::LoadTexture(fileName.c_str()));
|
||||
if (!IsValid()) {
|
||||
throw RaylibException("Failed to load Texture from file: " + fileName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unload texture from GPU memory (VRAM)
|
||||
*/
|
||||
void Unload() {
|
||||
// Protect against calling UnloadTexture() twice.
|
||||
if (id != 0) {
|
||||
::UnloadTexture(*this);
|
||||
id = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update GPU texture with new data
|
||||
*/
|
||||
TextureUnmanaged& Update(const void* pixels) {
|
||||
::UpdateTexture(*this, pixels);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update GPU texture rectangle with new data
|
||||
*/
|
||||
TextureUnmanaged& Update(::Rectangle rec, const void* pixels) {
|
||||
UpdateTextureRec(*this, rec, pixels);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get pixel data from GPU texture and return an Image
|
||||
*/
|
||||
RLCPP_NODISCARD ::Image GetData() const { return ::LoadImageFromTexture(*this); }
|
||||
|
||||
/**
|
||||
* Get pixel data from GPU texture and return an Image
|
||||
*/
|
||||
operator Image() { return GetData(); }
|
||||
|
||||
/**
|
||||
* Generate GPU mipmaps for a texture
|
||||
*/
|
||||
TextureUnmanaged& GenMipmaps() {
|
||||
::GenTextureMipmaps(this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set texture scaling filter mode
|
||||
*/
|
||||
TextureUnmanaged& SetFilter(int filterMode) {
|
||||
::SetTextureFilter(*this, filterMode);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set texture wrapping mode
|
||||
*/
|
||||
TextureUnmanaged& SetWrap(int wrapMode) {
|
||||
::SetTextureWrap(*this, wrapMode);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw a Texture2D
|
||||
*
|
||||
* @see ::DrawTexture()
|
||||
*/
|
||||
void Draw(int posX = 0, int posY = 0, ::Color tint = {255, 255, 255, 255}) const {
|
||||
::DrawTexture(*this, posX, posY, tint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw a Texture2D with position defined as Vector2
|
||||
*
|
||||
* @see ::DrawTextureV()
|
||||
*/
|
||||
void Draw(::Vector2 position, ::Color tint = {255, 255, 255, 255}) const { ::DrawTextureV(*this, position, tint); }
|
||||
|
||||
/**
|
||||
* Draw a Texture2D with extended parameters
|
||||
*
|
||||
* @see ::DrawTextureEx()
|
||||
*/
|
||||
void Draw(::Vector2 position, float rotation, float scale = 1.0f, ::Color tint = {255, 255, 255, 255}) const {
|
||||
::DrawTextureEx(*this, position, rotation, scale, tint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw a part of a texture defined by a rectangle
|
||||
*
|
||||
* @see ::DrawTextureRec()
|
||||
*/
|
||||
void Draw(::Rectangle sourceRec, ::Vector2 position = {0, 0}, ::Color tint = {255, 255, 255, 255}) const {
|
||||
::DrawTextureRec(*this, sourceRec, position, tint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw a part of a texture defined by a rectangle with 'pro' parameters
|
||||
*
|
||||
* @see ::DrawTexturePro()
|
||||
*/
|
||||
void Draw(
|
||||
::Rectangle sourceRec,
|
||||
::Rectangle destRec,
|
||||
::Vector2 origin = {0, 0},
|
||||
float rotation = 0,
|
||||
::Color tint = {255, 255, 255, 255}) const {
|
||||
::DrawTexturePro(*this, sourceRec, destRec, origin, rotation, tint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws a texture (or part of it) that stretches or shrinks nicely
|
||||
*
|
||||
* @see ::DrawTextureNPatch()
|
||||
*/
|
||||
void Draw(
|
||||
::NPatchInfo nPatchInfo,
|
||||
::Rectangle destRec,
|
||||
::Vector2 origin = {0, 0},
|
||||
float rotation = 0,
|
||||
::Color tint = {255, 255, 255, 255}) const {
|
||||
::DrawTextureNPatch(*this, nPatchInfo, destRec, origin, rotation, tint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw a billboard texture
|
||||
*
|
||||
* @see ::DrawBillboard()
|
||||
*/
|
||||
void
|
||||
DrawBillboard(const ::Camera& camera, ::Vector3 position, float size, ::Color tint = {255, 255, 255, 255}) const {
|
||||
::DrawBillboard(camera, *this, position, size, tint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw a billboard texture defined by source
|
||||
*
|
||||
* @see ::DrawBillboardRec()
|
||||
*/
|
||||
void DrawBillboard(
|
||||
const ::Camera& camera,
|
||||
::Rectangle source,
|
||||
::Vector3 position,
|
||||
::Vector2 size,
|
||||
::Color tint = {255, 255, 255, 255}) const {
|
||||
DrawBillboardRec(camera, *this, source, position, size, tint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw a billboard texture defined by source and rotation
|
||||
*
|
||||
* @see ::DrawBillboardPro()
|
||||
*/
|
||||
void DrawBillboard(
|
||||
const ::Camera& camera,
|
||||
::Rectangle source,
|
||||
Vector3 position,
|
||||
::Vector3 up,
|
||||
Vector2 size,
|
||||
Vector2 origin,
|
||||
float rotation = 0.0f,
|
||||
::Color tint = {255, 255, 255, 255}) const {
|
||||
DrawBillboardPro(camera, *this, source, position, up, size, origin, rotation, tint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set texture for a material map type (MAP_DIFFUSE, MAP_SPECULAR...)
|
||||
*/
|
||||
TextureUnmanaged& SetMaterial(::Material* material, int mapType = MATERIAL_MAP_NORMAL) {
|
||||
::SetMaterialTexture(material, mapType, *this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
TextureUnmanaged& SetMaterial(const ::Material& material, int mapType = MATERIAL_MAP_NORMAL) {
|
||||
::SetMaterialTexture(const_cast<::Material*>(&material), mapType, *this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set texture and rectangle to be used on shapes drawing.
|
||||
*/
|
||||
TextureUnmanaged& SetShapes(const ::Rectangle& source) {
|
||||
::SetShapesTexture(*this, source);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set shader uniform value for texture (sampler2d)
|
||||
*/
|
||||
TextureUnmanaged& SetShaderValue(const ::Shader& shader, int locIndex) {
|
||||
::SetShaderValueTexture(shader, locIndex, *this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether or not the Texture has been loaded and is ready.
|
||||
*
|
||||
* @return True or false depending on whether the Texture has data.
|
||||
*/
|
||||
RLCPP_NODISCARD bool IsValid() const { return IsTextureValid(*this); }
|
||||
protected:
|
||||
void set(const ::Texture& texture) {
|
||||
id = texture.id;
|
||||
width = texture.width;
|
||||
height = texture.height;
|
||||
mipmaps = texture.mipmaps;
|
||||
format = texture.format;
|
||||
}
|
||||
};
|
||||
|
||||
// Create the TextureUnmanaged aliases.
|
||||
using Texture2DUnmanaged = TextureUnmanaged;
|
||||
using TextureCubemapUnmanaged = TextureUnmanaged;
|
||||
|
||||
} // namespace raylib
|
||||
|
||||
using RTextureUnmanaged = raylib::TextureUnmanaged;
|
||||
using RTexture2DUnmanaged = raylib::Texture2DUnmanaged;
|
||||
using RTextureCubemapUnmanaged = raylib::TextureCubemapUnmanaged;
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_TEXTUREUNMANAGED_HPP_
|
||||
@@ -0,0 +1,51 @@
|
||||
#ifndef RAYLIB_CPP_INCLUDE_TOUCH_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_TOUCH_HPP_
|
||||
|
||||
#include "./Functions.hpp"
|
||||
#include "./raylib.hpp"
|
||||
|
||||
namespace raylib {
|
||||
/**
|
||||
* Input-related functions: touch
|
||||
*/
|
||||
namespace Touch {
|
||||
/**
|
||||
* Get touch position X for touch point 0 (relative to screen size)
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline int GetX() {
|
||||
return ::GetTouchX();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get touch position Y for touch point 0 (relative to screen size)
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline int GetY() {
|
||||
return ::GetTouchY();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get touch position XY for a touch point index (relative to screen size)
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline Vector2 GetPosition(int index) {
|
||||
return ::GetTouchPosition(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get touch point identifier for given index
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline int GetPointId(int index) {
|
||||
return ::GetTouchPointId(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get number of touch points
|
||||
*/
|
||||
RLCPP_MAYBEUNUSED RLCPPAPI inline int GetPointCount() {
|
||||
return ::GetTouchPointCount();
|
||||
}
|
||||
} // namespace Touch
|
||||
} // namespace raylib
|
||||
|
||||
namespace RTouch = raylib::Touch;
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_TOUCH_HPP_
|
||||
@@ -0,0 +1,396 @@
|
||||
#ifndef RAYLIB_CPP_INCLUDE_VECTOR2_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_VECTOR2_HPP_
|
||||
|
||||
#ifndef RAYLIB_CPP_NO_MATH
|
||||
#include <cmath>
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
#include "./raylib.hpp"
|
||||
#include "./raymath.hpp"
|
||||
|
||||
namespace raylib {
|
||||
/**
|
||||
* Vector2 type
|
||||
*/
|
||||
class Vector2 : public ::Vector2 {
|
||||
public:
|
||||
constexpr Vector2(const ::Vector2& vec) : ::Vector2{vec.x, vec.y} {}
|
||||
|
||||
constexpr Vector2(float x = 0, float y = 0) : ::Vector2{x, y} {}
|
||||
|
||||
GETTERSETTER(float, X, x)
|
||||
GETTERSETTER(float, Y, y)
|
||||
|
||||
/**
|
||||
* Set the Vector2 to the same as the given Vector2.
|
||||
*/
|
||||
Vector2& operator=(const ::Vector2& vector2) {
|
||||
set(vector2);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether or not the vectors are equal.
|
||||
*/
|
||||
constexpr bool operator==(const ::Vector2& other) const { return x == other.x && y == other.y; }
|
||||
|
||||
/**
|
||||
* Determines if the vectors are not equal.
|
||||
*/
|
||||
constexpr bool operator!=(const ::Vector2& other) const { return !(*this == other); }
|
||||
|
||||
RLCPP_NODISCARD std::string ToString() const { return TextFormat("Vector2(%f, %f)", x, y); }
|
||||
|
||||
operator std::string() const { return ToString(); }
|
||||
|
||||
#ifndef RAYLIB_CPP_NO_MATH
|
||||
/**
|
||||
* Add two vectors (v1 + v2)
|
||||
*/
|
||||
Vector2 Add(const ::Vector2& vector2) const { return Vector2Add(*this, vector2); }
|
||||
|
||||
/**
|
||||
* Add two vectors (v1 + v2)
|
||||
*/
|
||||
Vector2 operator+(const ::Vector2& vector2) const { return Vector2Add(*this, vector2); }
|
||||
|
||||
/**
|
||||
* Add two vectors (v1 + v2)
|
||||
*/
|
||||
Vector2& operator+=(const ::Vector2& vector2) {
|
||||
set(Vector2Add(*this, vector2));
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add vector and float value
|
||||
*/
|
||||
Vector2 Add(float value) const {
|
||||
return Vector2AddValue(*this, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add vector and float value
|
||||
*/
|
||||
Vector2 operator+(float value) const {
|
||||
return Vector2AddValue(*this, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add vector and float value
|
||||
*/
|
||||
Vector2& operator+=(float value) {
|
||||
set(Vector2AddValue(*this, value));
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Subtract two vectors (v1 - v2)
|
||||
*/
|
||||
RLCPP_NODISCARD Vector2 Subtract(const ::Vector2& vector2) const { return Vector2Subtract(*this, vector2); }
|
||||
|
||||
/**
|
||||
* Subtract two vectors (v1 - v2)
|
||||
*/
|
||||
Vector2 operator-(const ::Vector2& vector2) const { return Vector2Subtract(*this, vector2); }
|
||||
|
||||
/**
|
||||
* Subtract two vectors (v1 - v2)
|
||||
*/
|
||||
Vector2& operator-=(const ::Vector2& vector2) {
|
||||
set(Vector2Subtract(*this, vector2));
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Subtract vector by float value
|
||||
*/
|
||||
RLCPP_NODISCARD Vector2 Subtract(float value) const {
|
||||
return Vector2SubtractValue(*this, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Subtract vector by float value
|
||||
*/
|
||||
Vector2 operator-(float value) const {
|
||||
return Vector2SubtractValue(*this, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Subtract vector by float value
|
||||
*/
|
||||
Vector2& operator-=(float value) {
|
||||
set(Vector2SubtractValue(*this, value));
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Negate vector
|
||||
*/
|
||||
RLCPP_NODISCARD Vector2 Negate() const { return Vector2Negate(*this); }
|
||||
|
||||
/**
|
||||
* Negate vector
|
||||
*/
|
||||
Vector2 operator-() const { return Vector2Negate(*this); }
|
||||
|
||||
/**
|
||||
* Multiply vector by vector
|
||||
*/
|
||||
RLCPP_NODISCARD Vector2 Multiply(const ::Vector2& vector2) const { return Vector2Multiply(*this, vector2); }
|
||||
|
||||
/**
|
||||
* Multiply vector by vector
|
||||
*/
|
||||
Vector2 operator*(const ::Vector2& vector2) const { return Vector2Multiply(*this, vector2); }
|
||||
|
||||
/**
|
||||
* Multiply vector by vector
|
||||
*/
|
||||
Vector2& operator*=(const ::Vector2& vector2) {
|
||||
set(Vector2Multiply(*this, vector2));
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scale vector (multiply by value)
|
||||
*/
|
||||
RLCPP_NODISCARD Vector2 Scale(const float scale) const { return Vector2Scale(*this, scale); }
|
||||
|
||||
/**
|
||||
* Scale vector (multiply by value)
|
||||
*/
|
||||
Vector2 operator*(const float scale) const { return Vector2Scale(*this, scale); }
|
||||
|
||||
/**
|
||||
* Scale vector (multiply by value)
|
||||
*/
|
||||
Vector2& operator*=(const float scale) {
|
||||
set(Vector2Scale(*this, scale));
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Divide vector by vector
|
||||
*/
|
||||
RLCPP_NODISCARD Vector2 Divide(const ::Vector2& vector2) const { return Vector2Divide(*this, vector2); }
|
||||
|
||||
|
||||
/**
|
||||
* Divide vector by vector
|
||||
*/
|
||||
Vector2 operator/(const ::Vector2& vector2) const { return Vector2Divide(*this, vector2); }
|
||||
|
||||
/**
|
||||
* Divide vector by vector
|
||||
*/
|
||||
Vector2& operator/=(const ::Vector2& vector2) {
|
||||
set(Vector2Divide(*this, vector2));
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Divide vector by value
|
||||
*/
|
||||
RLCPP_NODISCARD Vector2 Divide(const float div) const { return ::Vector2{x / div, y / div}; }
|
||||
|
||||
/**
|
||||
* Divide vector by value
|
||||
*/
|
||||
Vector2 operator/(const float div) const { return Divide(div); }
|
||||
|
||||
/**
|
||||
* Divide vector by value
|
||||
*/
|
||||
Vector2& operator/=(const float div) {
|
||||
this->x /= div;
|
||||
this->y /= div;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize provided vector
|
||||
*/
|
||||
RLCPP_NODISCARD Vector2 Normalize() const { return Vector2Normalize(*this); }
|
||||
|
||||
/**
|
||||
* Transforms a Vector2 by a given Matrix
|
||||
*/
|
||||
RLCPP_NODISCARD Vector2 Transform(::Matrix mat) const { return ::Vector2Transform(*this, mat); }
|
||||
|
||||
/**
|
||||
* Calculate linear interpolation between two vectors
|
||||
*/
|
||||
RLCPP_NODISCARD Vector2 Lerp(const ::Vector2& vector2, float amount) const { return Vector2Lerp(*this, vector2, amount); }
|
||||
|
||||
/**
|
||||
* Calculate reflected vector to normal
|
||||
*/
|
||||
RLCPP_NODISCARD Vector2 Reflect(const ::Vector2& normal) const { return Vector2Reflect(*this, normal); }
|
||||
|
||||
/**
|
||||
* Rotate Vector by float in radians
|
||||
*/
|
||||
RLCPP_NODISCARD Vector2 Rotate(float angle) const { return Vector2Rotate(*this, angle); }
|
||||
|
||||
/**
|
||||
* Move Vector towards target
|
||||
*/
|
||||
RLCPP_NODISCARD Vector2 MoveTowards(const ::Vector2& target, float maxDistance) const {
|
||||
return Vector2MoveTowards(*this, target, maxDistance);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invert the given vector
|
||||
*/
|
||||
RLCPP_NODISCARD Vector2 Invert() const { return ::Vector2Invert(*this); }
|
||||
|
||||
/**
|
||||
* Clamp the components of the vector between
|
||||
*/
|
||||
RLCPP_NODISCARD Vector2 Clamp(::Vector2 min, ::Vector2 max) const { return ::Vector2Clamp(*this, min, max); }
|
||||
|
||||
/**
|
||||
* // Clamp the magnitude of the vector between two min and max values
|
||||
*/
|
||||
RLCPP_NODISCARD Vector2 Clamp(float min, float max) const { return ::Vector2ClampValue(*this, min, max); }
|
||||
|
||||
/**
|
||||
* Check whether two given vectors are almost equal
|
||||
*/
|
||||
RLCPP_NODISCARD int Equals(::Vector2 q) const { return ::Vector2Equals(*this, q); }
|
||||
|
||||
/**
|
||||
* Calculate vector length
|
||||
*/
|
||||
RLCPP_NODISCARD float Length() const { return Vector2Length(*this); }
|
||||
|
||||
/**
|
||||
* Calculate vector square length
|
||||
*/
|
||||
RLCPP_NODISCARD float LengthSqr() const { return Vector2LengthSqr(*this); }
|
||||
|
||||
/**
|
||||
* Calculate two vectors dot product
|
||||
*/
|
||||
RLCPP_NODISCARD float DotProduct(const ::Vector2& vector2) const { return Vector2DotProduct(*this, vector2); }
|
||||
|
||||
/**
|
||||
* Calculate distance between two vectors
|
||||
*/
|
||||
RLCPP_NODISCARD float Distance(const ::Vector2& vector2) const { return Vector2Distance(*this, vector2); }
|
||||
|
||||
/**
|
||||
* Calculate square distance between two vectors
|
||||
*/
|
||||
RLCPP_NODISCARD float DistanceSqr(::Vector2 v2) const { return ::Vector2DistanceSqr(*this, v2); }
|
||||
|
||||
/**
|
||||
* Calculate angle from two vectors in X-axis
|
||||
*/
|
||||
RLCPP_NODISCARD float Angle(const ::Vector2& vector2) const { return Vector2Angle(*this, vector2); }
|
||||
|
||||
/**
|
||||
* Vector with components value 0.0f
|
||||
*/
|
||||
static Vector2 Zero() { return Vector2Zero(); }
|
||||
|
||||
/**
|
||||
* Vector with components value 1.0f
|
||||
*/
|
||||
static Vector2 One() { return Vector2One(); }
|
||||
#endif
|
||||
|
||||
void DrawPixel(::Color color = {0, 0, 0, 255}) const { ::DrawPixelV(*this, color); }
|
||||
|
||||
void DrawLine(::Vector2 endPos, ::Color color = {0, 0, 0, 255}) const { ::DrawLineV(*this, endPos, color); }
|
||||
|
||||
void DrawLine(::Vector2 endPos, float thick, ::Color color = {0, 0, 0, 255}) const {
|
||||
::DrawLineEx(*this, endPos, thick, color);
|
||||
}
|
||||
|
||||
void DrawLineBezier(::Vector2 endPos, float thick, ::Color color = {0, 0, 0, 255}) const {
|
||||
::DrawLineBezier(*this, endPos, thick, color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw a color-filled circle (Vector version)
|
||||
*/
|
||||
void DrawCircle(float radius, ::Color color = {0, 0, 0, 255}) const { ::DrawCircleV(*this, radius, color); }
|
||||
|
||||
void DrawRectangle(::Vector2 size, ::Color color = {0, 0, 0, 255}) const { ::DrawRectangleV(*this, size, color); }
|
||||
|
||||
void DrawPoly(int sides, float radius, float rotation, ::Color color = {0, 0, 0, 255}) const {
|
||||
::DrawPoly(*this, sides, radius, rotation, color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check collision between two circles
|
||||
*/
|
||||
RLCPP_NODISCARD bool CheckCollisionCircle(float radius1, ::Vector2 center2, float radius2) const {
|
||||
return ::CheckCollisionCircles(*this, radius1, center2, radius2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check collision between circle and rectangle
|
||||
*/
|
||||
RLCPP_NODISCARD bool CheckCollisionCircle(float radius, ::Rectangle rec) const {
|
||||
return ::CheckCollisionCircleRec(*this, radius, rec);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if point is inside rectangle
|
||||
*/
|
||||
RLCPP_NODISCARD bool CheckCollision(::Rectangle rec) const { return ::CheckCollisionPointRec(*this, rec); }
|
||||
|
||||
/**
|
||||
* Check if point is inside circle
|
||||
*/
|
||||
RLCPP_NODISCARD bool CheckCollision(::Vector2 center, float radius) const {
|
||||
return ::CheckCollisionPointCircle(*this, center, radius);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if point is inside a triangle
|
||||
*/
|
||||
RLCPP_NODISCARD bool CheckCollision(::Vector2 p1, ::Vector2 p2, ::Vector2 p3) const {
|
||||
return ::CheckCollisionPointTriangle(*this, p1, p2, p3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the collision between two lines defined by two points each, returns collision point by reference
|
||||
*/
|
||||
bool
|
||||
CheckCollisionLines(::Vector2 endPos1, ::Vector2 startPos2, ::Vector2 endPos2, ::Vector2* collisionPoint) const {
|
||||
return ::CheckCollisionLines(*this, endPos1, startPos2, endPos2, collisionPoint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if point belongs to line created between two points [p1] and [p2] with defined margin in pixels [threshold]
|
||||
*/
|
||||
RLCPP_NODISCARD bool CheckCollisionPointLine(::Vector2 p1, ::Vector2 p2, int threshold = 1) const {
|
||||
return ::CheckCollisionPointLine(*this, p1, p2, threshold);
|
||||
}
|
||||
protected:
|
||||
void set(const ::Vector2& vec) {
|
||||
x = vec.x;
|
||||
y = vec.y;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace raylib
|
||||
|
||||
using RVector2 = raylib::Vector2;
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_VECTOR2_HPP_
|
||||
@@ -0,0 +1,312 @@
|
||||
#ifndef RAYLIB_CPP_INCLUDE_VECTOR3_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_VECTOR3_HPP_
|
||||
|
||||
#ifndef RAYLIB_CPP_NO_MATH
|
||||
#include <cmath>
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
#include "./raylib.hpp"
|
||||
#include "./raymath.hpp"
|
||||
|
||||
namespace raylib {
|
||||
/**
|
||||
* Vector3 type
|
||||
*/
|
||||
class Vector3 : public ::Vector3 {
|
||||
public:
|
||||
constexpr Vector3(const ::Vector3& vec) : ::Vector3{vec.x, vec.y, vec.z} {}
|
||||
|
||||
constexpr Vector3(float x = 0, float y = 0, float z = 0) : ::Vector3{x, y, z} {}
|
||||
|
||||
Vector3(::Color color) { set(ColorToHSV(color)); }
|
||||
|
||||
GETTERSETTER(float, X, x)
|
||||
GETTERSETTER(float, Y, y)
|
||||
GETTERSETTER(float, Z, z)
|
||||
|
||||
Vector3& operator=(const ::Vector3& vector3) {
|
||||
set(vector3);
|
||||
return *this;
|
||||
}
|
||||
|
||||
constexpr bool operator==(const ::Vector3& other) const { return x == other.x && y == other.y && z == other.z; }
|
||||
|
||||
constexpr bool operator!=(const ::Vector3& other) const { return !(*this == other); }
|
||||
|
||||
RLCPP_NODISCARD std::string ToString() const { return TextFormat("Vector3(%f, %f, %f)", x, y, z); }
|
||||
|
||||
operator std::string() const { return ToString(); }
|
||||
|
||||
#ifndef RAYLIB_CPP_NO_MATH
|
||||
/**
|
||||
* Add two vectors
|
||||
*/
|
||||
RLCPP_NODISCARD Vector3 Add(const ::Vector3& vector3) const { return Vector3Add(*this, vector3); }
|
||||
|
||||
/**
|
||||
* Add two vectors
|
||||
*/
|
||||
Vector3 operator+(const ::Vector3& vector3) const { return Vector3Add(*this, vector3); }
|
||||
|
||||
Vector3& operator+=(const ::Vector3& vector3) {
|
||||
set(Vector3Add(*this, vector3));
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add vector and float value
|
||||
*/
|
||||
RLCPP_NODISCARD Vector3 Add(float value) const {
|
||||
return Vector3AddValue(*this, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add vector and float value
|
||||
*/
|
||||
Vector3 operator+(float value) const {
|
||||
return Vector3AddValue(*this, value);
|
||||
}
|
||||
|
||||
Vector3& operator+=(float value) {
|
||||
set(Vector3AddValue(*this, value));
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Subtract two vectors.
|
||||
*/
|
||||
RLCPP_NODISCARD Vector3 Subtract(const ::Vector3& vector3) const { return Vector3Subtract(*this, vector3); }
|
||||
|
||||
/**
|
||||
* Subtract two vectors.
|
||||
*/
|
||||
Vector3 operator-(const ::Vector3& vector3) const { return Vector3Subtract(*this, vector3); }
|
||||
|
||||
Vector3& operator-=(const ::Vector3& vector3) {
|
||||
set(Vector3Subtract(*this, vector3));
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Subtract vector by float value
|
||||
*/
|
||||
RLCPP_NODISCARD Vector3 Subtract(float value) const {
|
||||
return Vector3SubtractValue(*this, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Subtract vector by float value
|
||||
*/
|
||||
Vector3 operator-(float value) const {
|
||||
return Vector3SubtractValue(*this, value);
|
||||
}
|
||||
|
||||
Vector3& operator-=(float value) {
|
||||
set(Vector3SubtractValue(*this, value));
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Negate provided vector (invert direction)
|
||||
*/
|
||||
RLCPP_NODISCARD Vector3 Negate() const { return Vector3Negate(*this); }
|
||||
|
||||
/**
|
||||
* Negate provided vector (invert direction)
|
||||
*/
|
||||
Vector3 operator-() const { return Vector3Negate(*this); }
|
||||
|
||||
/**
|
||||
* Multiply vector by vector
|
||||
*/
|
||||
RLCPP_NODISCARD Vector3 Multiply(const ::Vector3& vector3) const { return Vector3Multiply(*this, vector3); }
|
||||
|
||||
/**
|
||||
* Multiply vector by vector
|
||||
*/
|
||||
Vector3 operator*(const ::Vector3& vector3) const { return Vector3Multiply(*this, vector3); }
|
||||
|
||||
/**
|
||||
* Multiply vector by vector
|
||||
*/
|
||||
Vector3& operator*=(const ::Vector3& vector3) {
|
||||
set(Vector3Multiply(*this, vector3));
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Multiply vector by scalar
|
||||
*/
|
||||
RLCPP_NODISCARD Vector3 Scale(const float scaler) const { return Vector3Scale(*this, scaler); }
|
||||
|
||||
/**
|
||||
* Multiply vector by scalar
|
||||
*/
|
||||
Vector3 operator*(const float scaler) const { return Vector3Scale(*this, scaler); }
|
||||
|
||||
/**
|
||||
* Multiply vector by scalar
|
||||
*/
|
||||
Vector3& operator*=(const float scaler) {
|
||||
set(Vector3Scale(*this, scaler));
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Divide vector by vector
|
||||
*/
|
||||
RLCPP_NODISCARD Vector3 Divide(const ::Vector3& vector3) const { return Vector3Divide(*this, vector3); }
|
||||
|
||||
/**
|
||||
* Divide vector by vector
|
||||
*/
|
||||
Vector3 operator/(const ::Vector3& vector3) const { return Vector3Divide(*this, vector3); }
|
||||
|
||||
/**
|
||||
* Divide vector by vector
|
||||
*/
|
||||
Vector3& operator/=(const ::Vector3& vector3) {
|
||||
x /= vector3.x;
|
||||
y /= vector3.y;
|
||||
z /= vector3.z;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Divide a vector by a value.
|
||||
*/
|
||||
RLCPP_NODISCARD Vector3 Divide(const float div) const { return ::Vector3{x / div, y / div, z / div}; }
|
||||
|
||||
/**
|
||||
* Divide a vector by a value.
|
||||
*/
|
||||
Vector3 operator/(const float div) const { return Divide(div); }
|
||||
|
||||
/**
|
||||
* Divide a vector by a value.
|
||||
*/
|
||||
Vector3& operator/=(const float div) {
|
||||
x /= div;
|
||||
y /= div;
|
||||
z /= div;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate vector length
|
||||
*/
|
||||
RLCPP_NODISCARD float Length() const { return Vector3Length(*this); }
|
||||
|
||||
/**
|
||||
* Calculate vector square length
|
||||
*/
|
||||
RLCPP_NODISCARD float LengthSqr() const { return Vector3LengthSqr(*this); }
|
||||
|
||||
RLCPP_NODISCARD Vector3 Normalize() const { return Vector3Normalize(*this); }
|
||||
|
||||
RLCPP_NODISCARD float DotProduct(const ::Vector3& vector3) const { return Vector3DotProduct(*this, vector3); }
|
||||
|
||||
RLCPP_NODISCARD float Distance(const ::Vector3& vector3) const { return Vector3Distance(*this, vector3); }
|
||||
|
||||
RLCPP_NODISCARD Vector3 Lerp(const ::Vector3& vector3, const float amount) const { return Vector3Lerp(*this, vector3, amount); }
|
||||
|
||||
RLCPP_NODISCARD Vector3 CrossProduct(const ::Vector3& vector3) const { return Vector3CrossProduct(*this, vector3); }
|
||||
|
||||
RLCPP_NODISCARD Vector3 Perpendicular() const { return Vector3Perpendicular(*this); }
|
||||
|
||||
RLCPP_NODISCARD Vector3 Project(const ::Vector3& vector3) const { return Vector3Project(*this, vector3); }
|
||||
|
||||
RLCPP_NODISCARD Vector3 Reject(const ::Vector3& vector3) const { return Vector3Reject(*this, vector3); }
|
||||
|
||||
void OrthoNormalize(::Vector3* vector3) { Vector3OrthoNormalize(this, vector3); }
|
||||
|
||||
RLCPP_NODISCARD Vector3 Transform(const ::Matrix& matrix) const { return Vector3Transform(*this, matrix); }
|
||||
|
||||
RLCPP_NODISCARD Vector3 RotateByQuaternion(const ::Quaternion& quaternion) const {
|
||||
return Vector3RotateByQuaternion(*this, quaternion);
|
||||
}
|
||||
|
||||
RLCPP_NODISCARD Vector3 Reflect(const ::Vector3& normal) const { return Vector3Reflect(*this, normal); }
|
||||
|
||||
RLCPP_NODISCARD Vector3 Min(const ::Vector3& vector3) const { return Vector3Min(*this, vector3); }
|
||||
|
||||
RLCPP_NODISCARD Vector3 Max(const ::Vector3& vector3) const { return Vector3Max(*this, vector3); }
|
||||
|
||||
RLCPP_NODISCARD Vector3 Barycenter(const ::Vector3& a, const ::Vector3& b, const ::Vector3& c) const {
|
||||
return Vector3Barycenter(*this, a, b, c);
|
||||
}
|
||||
|
||||
static Vector3 Zero() { return Vector3Zero(); }
|
||||
|
||||
static Vector3 One() { return Vector3One(); }
|
||||
#endif
|
||||
|
||||
void DrawLine3D(const ::Vector3& endPos, ::Color color) const { ::DrawLine3D(*this, endPos, color); }
|
||||
|
||||
void DrawPoint3D(::Color color) const { ::DrawPoint3D(*this, color); }
|
||||
|
||||
void DrawCircle3D(float radius, const ::Vector3& rotationAxis, float rotationAngle, Color color) const {
|
||||
::DrawCircle3D(*this, radius, rotationAxis, rotationAngle, color);
|
||||
}
|
||||
|
||||
void DrawCube(float width, float height, float length, ::Color color) const {
|
||||
::DrawCube(*this, width, height, length, color);
|
||||
}
|
||||
|
||||
void DrawCube(const ::Vector3& size, ::Color color) const { ::DrawCubeV(*this, size, color); }
|
||||
|
||||
void DrawCubeWires(float width, float height, float length, ::Color color) const {
|
||||
::DrawCubeWires(*this, width, height, length, color);
|
||||
}
|
||||
|
||||
void DrawCubeWires(const ::Vector3& size, ::Color color) const { ::DrawCubeWiresV(*this, size, color); }
|
||||
|
||||
void DrawSphere(float radius, ::Color color) const { ::DrawSphere(*this, radius, color); }
|
||||
|
||||
void DrawSphere(float radius, int rings, int slices, ::Color color) const {
|
||||
::DrawSphereEx(*this, radius, rings, slices, color);
|
||||
}
|
||||
|
||||
void DrawSphereWires(float radius, int rings, int slices, ::Color color) const {
|
||||
::DrawSphereWires(*this, radius, rings, slices, color);
|
||||
}
|
||||
|
||||
void DrawCylinder(float radiusTop, float radiusBottom, float height, int slices, ::Color color) const {
|
||||
::DrawCylinder(*this, radiusTop, radiusBottom, height, slices, color);
|
||||
}
|
||||
|
||||
void DrawCylinderWires(float radiusTop, float radiusBottom, float height, int slices, ::Color color) const {
|
||||
::DrawCylinderWires(*this, radiusTop, radiusBottom, height, slices, color);
|
||||
}
|
||||
|
||||
void DrawPlane(const ::Vector2& size, ::Color color) const { ::DrawPlane(*this, size, color); }
|
||||
|
||||
/**
|
||||
* Detect collision between two spheres
|
||||
*/
|
||||
RLCPP_NODISCARD bool CheckCollision(float radius1, const ::Vector3& center2, float radius2) const {
|
||||
return CheckCollisionSpheres(*this, radius1, center2, radius2);
|
||||
}
|
||||
protected:
|
||||
void set(const ::Vector3& vec) {
|
||||
x = vec.x;
|
||||
y = vec.y;
|
||||
z = vec.z;
|
||||
}
|
||||
};
|
||||
} // namespace raylib
|
||||
|
||||
using RVector3 = raylib::Vector3;
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_VECTOR3_HPP_
|
||||
@@ -0,0 +1,308 @@
|
||||
#ifndef RAYLIB_CPP_INCLUDE_VECTOR4_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_VECTOR4_HPP_
|
||||
|
||||
#ifndef RAYLIB_CPP_NO_MATH
|
||||
#include <cmath>
|
||||
#include <utility>
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
#include "./raylib.hpp"
|
||||
#include "./raymath.hpp"
|
||||
|
||||
namespace raylib {
|
||||
class Quaternion : public ::Quaternion {};
|
||||
|
||||
/**
|
||||
* Vector4 type
|
||||
*/
|
||||
class Vector4 : public ::Vector4 {
|
||||
public:
|
||||
constexpr Vector4(const ::Vector4& vec) : ::Vector4{vec.x, vec.y, vec.z, vec.w} {}
|
||||
explicit constexpr Vector4(const raylib::Quaternion quat) : ::Vector4{quat.x, quat.y, quat.z, quat.w} {}
|
||||
|
||||
explicit constexpr Vector4(const float x = 0, const float y = 0, const float z = 0, const float w = 0) : ::Vector4{x, y, z, w} {}
|
||||
explicit constexpr Vector4(const ::Rectangle rectangle) : ::Vector4{rectangle.x, rectangle.y, rectangle.width, rectangle.height} {}
|
||||
|
||||
explicit Vector4(const ::Color color) { set(ColorNormalize(color)); }
|
||||
|
||||
GETTERSETTER(float, X, x)
|
||||
GETTERSETTER(float, Y, y)
|
||||
GETTERSETTER(float, Z, z)
|
||||
GETTERSETTER(float, W, w)
|
||||
|
||||
Vector4& operator=(const ::Vector4& vector4) {
|
||||
set(vector4);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/*
|
||||
* An exact value by value equality comparison.
|
||||
* Due to floating point inaccuracies consider using Equals instead.
|
||||
*/
|
||||
constexpr bool operator==(const ::Vector4& other) const {
|
||||
return x == other.x && y == other.y && z == other.z && w == other.w;
|
||||
}
|
||||
|
||||
/*
|
||||
* An exact value by value inequality comparison.
|
||||
* Due to floating point inaccuracies consider using Equals instead.
|
||||
*/
|
||||
constexpr bool operator!=(const ::Vector4& other) const { return !(*this == other); }
|
||||
|
||||
RLCPP_NODISCARD constexpr ::Rectangle ToRectangle() const { return {x, y, z, w}; }
|
||||
|
||||
constexpr operator ::Rectangle() const { return {x, y, z, w}; }
|
||||
|
||||
RLCPP_NODISCARD std::string ToString() const { return ::TextFormat("Vector4(%f, %f, %f, %f)", x, y, z, w); }
|
||||
|
||||
operator std::string() const { return ToString(); }
|
||||
|
||||
#ifndef RAYLIB_CPP_NO_MATH
|
||||
static Vector4 Zero() { return ::Vector4Zero(); }
|
||||
|
||||
static Vector4 One() { return ::Vector4One(); }
|
||||
|
||||
/**
|
||||
* Add two vectors
|
||||
*/
|
||||
RLCPP_NODISCARD Vector4 Add(const ::Vector4& vector4) const { return ::Vector4Add(*this, vector4); }
|
||||
|
||||
/**
|
||||
* Add two vectors
|
||||
*/
|
||||
Vector4 operator+(const ::Vector4& vector4) const { return ::Vector4Add(*this, vector4); }
|
||||
|
||||
Vector4& operator+=(const ::Vector4& vector4) {
|
||||
set(::Vector4Add(*this, vector4));
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add vector and float value
|
||||
*/
|
||||
RLCPP_NODISCARD Vector4 Add(const float value) const {
|
||||
return ::Vector4AddValue(*this, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add vector and float value
|
||||
*/
|
||||
Vector4 operator+(const float value) const {
|
||||
return ::Vector4AddValue(*this, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add vector and float value
|
||||
*/
|
||||
Vector4& operator+=(const float value) {
|
||||
set(::Vector4AddValue(*this, value));
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add vector and float value
|
||||
*/
|
||||
friend Vector4 operator+(const float lhs, const Vector4& rhs) { return rhs + lhs; }
|
||||
|
||||
/**
|
||||
* Subtract two vectors.
|
||||
*/
|
||||
RLCPP_NODISCARD Vector4 Subtract(const ::Vector4& vector4) const { return ::Vector4Subtract(*this, vector4); }
|
||||
|
||||
/**
|
||||
* Subtract two vectors.
|
||||
*/
|
||||
Vector4 operator-(const ::Vector4& vector4) const { return ::Vector4Subtract(*this, vector4); }
|
||||
|
||||
Vector4& operator-=(const ::Vector4& vector4) {
|
||||
set(::Vector4Subtract(*this, vector4));
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Subtract vector by float value
|
||||
*/
|
||||
RLCPP_NODISCARD Vector4 Subtract(const float value) const {
|
||||
return ::Vector4SubtractValue(*this, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Subtract vector by float value
|
||||
*/
|
||||
Vector4 operator-(const float value) const {
|
||||
return ::Vector4SubtractValue(*this, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Subtract vector by float value
|
||||
*/
|
||||
Vector4& operator-=(const float value) {
|
||||
set(::Vector4SubtractValue(*this, value));
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Subtract vector by float value
|
||||
*/
|
||||
friend Vector4 operator-(const float lhs, const Vector4& rhs) { return rhs - lhs; }
|
||||
|
||||
/**
|
||||
* Negate provided vector
|
||||
*/
|
||||
RLCPP_NODISCARD Vector4 Negate() const { return ::Vector4Negate(*this); }
|
||||
|
||||
/**
|
||||
* Negate provided vector
|
||||
*/
|
||||
Vector4 operator-() const { return ::Vector4Negate(*this); }
|
||||
|
||||
/**
|
||||
* Multiply vector by vector
|
||||
*/
|
||||
RLCPP_NODISCARD Vector4 Multiply(const ::Vector4& other) const { return ::Vector4Multiply(*this, other); }
|
||||
|
||||
/**
|
||||
* Multiply vector by vector
|
||||
*/
|
||||
Vector4 operator*(const ::Vector4& other) const { return ::Vector4Multiply(*this, other); }
|
||||
|
||||
/**
|
||||
* Multiply vector by vector
|
||||
*/
|
||||
Vector4& operator*=(const ::Vector4& other) {
|
||||
set(::Vector4Multiply(*this, other));
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scale vector components by value (multiply)
|
||||
*/
|
||||
RLCPP_NODISCARD Vector4 Scale(const float scale) const { return ::Vector4Scale(*this, scale); }
|
||||
|
||||
/**
|
||||
* Scale vector components by value (multiply)
|
||||
*/
|
||||
Vector4 operator*(const float scale) const { return ::Vector4Scale(*this, scale); }
|
||||
|
||||
/**
|
||||
* Scale vector components by value (multiply)
|
||||
*/
|
||||
Vector4& operator*=(const float scale) {
|
||||
set(::Vector4Scale(*this, scale));
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scale vector components by value (multiply)
|
||||
*/
|
||||
friend Vector4 operator*(const float lhs, const Vector4& rhs) { return rhs * lhs; }
|
||||
|
||||
/**
|
||||
* Divide vector by vector
|
||||
*/
|
||||
RLCPP_NODISCARD Vector4 Divide(const ::Vector4& vector4) const { return ::Vector4Divide(*this, vector4); }
|
||||
|
||||
/**
|
||||
* Divide vector by vector
|
||||
*/
|
||||
Vector4 operator/(const ::Vector4& vector4) const { return ::Vector4Divide(*this, vector4); }
|
||||
|
||||
/**
|
||||
* Divide vector by vector
|
||||
*/
|
||||
Vector4& operator/=(const ::Vector4& vector4) {
|
||||
set(::Vector4Divide(*this, vector4));
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Divide vector components by value
|
||||
*/
|
||||
RLCPP_NODISCARD constexpr Vector4 Divide(const float div) const { return ::Vector4{x / div, y / div, z / div, w / div}; }
|
||||
|
||||
/**
|
||||
* Divide vector components by value
|
||||
*/
|
||||
Vector4 operator/(const float div) const { return Divide(div); }
|
||||
|
||||
/**
|
||||
* Divide vector components by value
|
||||
*/
|
||||
Vector4& operator/=(const float div) {
|
||||
x /= div;
|
||||
y /= div;
|
||||
z /= div;
|
||||
w /= div;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Divide vector components by value
|
||||
*/
|
||||
constexpr friend Vector4 operator/(const float lhs, const Vector4& rhs) {
|
||||
return Vector4{
|
||||
lhs / rhs.x,
|
||||
lhs / rhs.y,
|
||||
lhs / rhs.z,
|
||||
lhs / rhs.w
|
||||
};
|
||||
}
|
||||
|
||||
RLCPP_NODISCARD float Length() const { return ::Vector4Length(*this); }
|
||||
|
||||
RLCPP_NODISCARD float LengthSqr() const { return ::Vector4LengthSqr(*this); }
|
||||
|
||||
RLCPP_NODISCARD float DotProduct(const ::Vector4& v2) const { return ::Vector4DotProduct(*this, v2); }
|
||||
|
||||
RLCPP_NODISCARD float Distance(const ::Vector4& v2) const { return ::Vector4Distance(*this, v2); }
|
||||
|
||||
RLCPP_NODISCARD float DistanceSqr(const ::Vector4& v2) const { return ::Vector4DistanceSqr(*this, v2); }
|
||||
|
||||
RLCPP_NODISCARD Vector4 Normalize() const { return ::Vector4Normalize(*this); }
|
||||
|
||||
RLCPP_NODISCARD Vector4 Min(const ::Vector4& v2) const { return ::Vector4Min(*this, v2); }
|
||||
|
||||
RLCPP_NODISCARD Vector4 Max(const ::Vector4& v2) const { return ::Vector4Max(*this, v2); }
|
||||
|
||||
RLCPP_NODISCARD Vector4 Lerp(const ::Vector4& v2, const float amount) const { return ::Vector4Lerp(*this, v2, amount); }
|
||||
|
||||
RLCPP_NODISCARD Vector4 MoveTowards(const ::Vector4& target, const float maxDistance) const { return ::Vector4MoveTowards(*this, target, maxDistance); }
|
||||
|
||||
RLCPP_NODISCARD Vector4 Invert() const { return ::Vector4Invert(*this); }
|
||||
|
||||
/*
|
||||
* Check whether two given vectors are almost equal
|
||||
*/
|
||||
RLCPP_NODISCARD bool Equals(const ::Vector4& other) const {
|
||||
return static_cast<bool>(::Vector4Equals(*this, other));
|
||||
}
|
||||
#endif
|
||||
|
||||
RLCPP_NODISCARD Color ColorFromNormalized() const { return ::ColorFromNormalized(*this); }
|
||||
|
||||
operator Color() const { return ColorFromNormalized(); }
|
||||
protected:
|
||||
void set(const ::Vector4& vec4) {
|
||||
x = vec4.x;
|
||||
y = vec4.y;
|
||||
z = vec4.z;
|
||||
w = vec4.w;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace raylib
|
||||
|
||||
using RVector4 = raylib::Vector4;
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_VECTOR4_HPP_
|
||||
@@ -0,0 +1,74 @@
|
||||
#ifndef RAYLIB_CPP_INCLUDE_VRSTEREOCONFIG_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_VRSTEREOCONFIG_HPP_
|
||||
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
#include "./raylib.hpp"
|
||||
|
||||
namespace raylib {
|
||||
/**
|
||||
* VR stereo config functions for VR simulator
|
||||
*/
|
||||
class VrStereoConfig : public ::VrStereoConfig {
|
||||
public:
|
||||
VrStereoConfig(const ::VrDeviceInfo& info) { Load(info); }
|
||||
|
||||
VrStereoConfig(const VrStereoConfig&) = delete;
|
||||
VrStereoConfig& operator=(const VrStereoConfig&) = delete;
|
||||
VrStereoConfig(VrStereoConfig&&) = default;
|
||||
VrStereoConfig& operator=(VrStereoConfig&&) = default;
|
||||
|
||||
/**
|
||||
* Load VR stereo config for VR simulator device parameters
|
||||
*/
|
||||
void Load(const ::VrDeviceInfo& info) { set(LoadVrStereoConfig(info)); }
|
||||
|
||||
/**
|
||||
* Unload VR stereo config
|
||||
*/
|
||||
~VrStereoConfig() { Unload(); }
|
||||
|
||||
/**
|
||||
* Begin stereo rendering
|
||||
*/
|
||||
VrStereoConfig& BeginMode() {
|
||||
::BeginVrStereoMode(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* End stereo rendering
|
||||
*/
|
||||
VrStereoConfig& EndMode() {
|
||||
::EndVrStereoMode();
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unload VR stereo config
|
||||
*/
|
||||
void Unload() { ::UnloadVrStereoConfig(*this); }
|
||||
protected:
|
||||
void set(const ::VrStereoConfig& config) {
|
||||
projection[0] = config.projection[0];
|
||||
projection[1] = config.projection[1];
|
||||
viewOffset[0] = config.viewOffset[0];
|
||||
viewOffset[1] = config.viewOffset[1];
|
||||
leftLensCenter[0] = config.leftLensCenter[0];
|
||||
leftLensCenter[1] = config.leftLensCenter[1];
|
||||
rightLensCenter[0] = config.rightLensCenter[0];
|
||||
rightLensCenter[1] = config.rightLensCenter[1];
|
||||
leftScreenCenter[0] = config.leftScreenCenter[0];
|
||||
leftScreenCenter[1] = config.leftScreenCenter[1];
|
||||
rightScreenCenter[0] = config.rightScreenCenter[0];
|
||||
rightScreenCenter[1] = config.rightScreenCenter[1];
|
||||
scale[0] = config.scale[0];
|
||||
scale[1] = config.scale[1];
|
||||
scaleIn[0] = config.scaleIn[0];
|
||||
scaleIn[1] = config.scaleIn[1];
|
||||
}
|
||||
};
|
||||
} // namespace raylib
|
||||
|
||||
using RVrStereoConfig = raylib::VrStereoConfig;
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_VRSTEREOCONFIG_HPP_
|
||||
@@ -0,0 +1,74 @@
|
||||
#ifndef RAYLIB_CPP_INCLUDE_WAVE_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_WAVE_HPP_
|
||||
|
||||
#include "./WaveUnmanaged.hpp"
|
||||
|
||||
namespace raylib {
|
||||
/**
|
||||
* Wave type, defines audio wave data.
|
||||
*
|
||||
* The wave will be unloaded on object destruction. Use raylib::WaveUnmanaged if you're looking to not unload.
|
||||
* Unlike other resource types, Wave supports value-copy semantics via WaveCopy().
|
||||
*
|
||||
* @see raylib::WaveUnmanaged
|
||||
*/
|
||||
class Wave : public WaveUnmanaged {
|
||||
public:
|
||||
using WaveUnmanaged::WaveUnmanaged;
|
||||
|
||||
Wave(const Wave& other) : WaveUnmanaged(other.Copy()) {}
|
||||
|
||||
Wave(Wave&& other) noexcept : WaveUnmanaged(other) {
|
||||
other.frameCount = 0;
|
||||
other.sampleRate = 0;
|
||||
other.sampleSize = 0;
|
||||
other.channels = 0;
|
||||
other.data = nullptr;
|
||||
}
|
||||
|
||||
Wave& operator=(const ::Wave& wave) {
|
||||
Unload();
|
||||
set(wave);
|
||||
return *this;
|
||||
}
|
||||
|
||||
Wave& operator=(const Wave& other) {
|
||||
if (this == &other) {
|
||||
return *this;
|
||||
}
|
||||
Unload();
|
||||
set(other.Copy());
|
||||
return *this;
|
||||
}
|
||||
|
||||
Wave& operator=(Wave&& other) noexcept {
|
||||
if (this == &other) {
|
||||
return *this;
|
||||
}
|
||||
Unload();
|
||||
set(other);
|
||||
other.frameCount = 0;
|
||||
other.sampleRate = 0;
|
||||
other.sampleSize = 0;
|
||||
other.channels = 0;
|
||||
other.data = nullptr;
|
||||
return *this;
|
||||
}
|
||||
|
||||
~Wave() { Unload(); }
|
||||
|
||||
void Load(const std::string& fileName) {
|
||||
Unload();
|
||||
WaveUnmanaged::Load(fileName);
|
||||
}
|
||||
|
||||
void Load(const std::string& fileType, const unsigned char* fileData, int dataSize) {
|
||||
Unload();
|
||||
WaveUnmanaged::Load(fileType, fileData, dataSize);
|
||||
}
|
||||
};
|
||||
} // namespace raylib
|
||||
|
||||
using RWave = raylib::Wave;
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_WAVE_HPP_
|
||||
@@ -0,0 +1,178 @@
|
||||
#ifndef RAYLIB_CPP_INCLUDE_WAVEUNMANAGED_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_WAVEUNMANAGED_HPP_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "./RaylibException.hpp"
|
||||
#include "./raylib-cpp-utils.hpp"
|
||||
#include "./raylib.hpp"
|
||||
|
||||
namespace raylib {
|
||||
/**
|
||||
* A Wave that is not managed by C++ RAII.
|
||||
*
|
||||
* Make sure to Unload() this if needed, otherwise use raylib::Wave.
|
||||
*
|
||||
* @see raylib::Wave
|
||||
*/
|
||||
class WaveUnmanaged : public ::Wave {
|
||||
public:
|
||||
/**
|
||||
* Creates a WaveUnmanaged from an existing Wave struct.
|
||||
*/
|
||||
WaveUnmanaged(const ::Wave& wave) : ::Wave(wave) {}
|
||||
|
||||
/**
|
||||
* Creates a WaveUnmanaged from its components.
|
||||
*/
|
||||
WaveUnmanaged(
|
||||
unsigned int frameCount = 0,
|
||||
unsigned int sampleRate = 0,
|
||||
unsigned int sampleSize = 0,
|
||||
unsigned int channels = 0,
|
||||
void* data = nullptr)
|
||||
: ::Wave{frameCount, sampleRate, sampleSize, channels, data} {}
|
||||
|
||||
/**
|
||||
* Load wave data from file.
|
||||
*
|
||||
* @throws raylib::RaylibException Throws if the Wave failed to load.
|
||||
*/
|
||||
WaveUnmanaged(const std::string& fileName) { Load(fileName); }
|
||||
|
||||
/**
|
||||
* Load wave from memory buffer; fileType refers to extension: i.e. "wav".
|
||||
*
|
||||
* @throws raylib::RaylibException Throws if the Wave failed to load.
|
||||
*/
|
||||
WaveUnmanaged(const std::string& fileType, const unsigned char* fileData, int dataSize) {
|
||||
Load(fileType, fileData, dataSize);
|
||||
}
|
||||
|
||||
GETTER(unsigned int, FrameCount, frameCount)
|
||||
GETTER(unsigned int, SampleRate, sampleRate)
|
||||
GETTER(unsigned int, SampleSize, sampleSize)
|
||||
GETTER(unsigned int, Channels, channels)
|
||||
GETTER(void*, Data, data)
|
||||
|
||||
WaveUnmanaged& operator=(const ::Wave& wave) {
|
||||
set(wave);
|
||||
return *this;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string ToString() const {
|
||||
return TextFormat(
|
||||
"Wave(frameCount=%u, sampleRate=%u, sampleSize=%u, channels=%u, data=%p)",
|
||||
frameCount, sampleRate, sampleSize, channels, data
|
||||
);
|
||||
}
|
||||
|
||||
operator std::string() const { return ToString(); }
|
||||
|
||||
/**
|
||||
* Load wave data from file.
|
||||
*
|
||||
* @throws raylib::RaylibException Throws if the Wave failed to load.
|
||||
*/
|
||||
void Load(const std::string& fileName) {
|
||||
set(::LoadWave(fileName.c_str()));
|
||||
if (!IsValid()) {
|
||||
throw RaylibException("Failed to load Wave from file: " + fileName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load wave from memory buffer; fileType refers to extension: i.e. "wav".
|
||||
*
|
||||
* @throws raylib::RaylibException Throws if the Wave failed to load.
|
||||
*/
|
||||
void Load(const std::string& fileType, const unsigned char* fileData, int dataSize) {
|
||||
set(::LoadWaveFromMemory(fileType.c_str(), fileData, dataSize));
|
||||
if (!IsValid()) {
|
||||
throw RaylibException("Failed to load Wave from file data of type: " + fileType);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unload wave data.
|
||||
*/
|
||||
void Unload() {
|
||||
// Protect against calling UnloadWave() twice.
|
||||
if (data != nullptr) {
|
||||
::UnloadWave(*this);
|
||||
data = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy a wave to a new wave.
|
||||
*/
|
||||
RLCPP_NODISCARD ::Wave Copy() const { return ::WaveCopy(*this); }
|
||||
|
||||
/**
|
||||
* Crop a wave to defined samples range.
|
||||
*/
|
||||
WaveUnmanaged& Crop(int initSample, int finalSample) {
|
||||
::WaveCrop(this, initSample, finalSample);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert wave data to desired format.
|
||||
*/
|
||||
WaveUnmanaged& Format(int sampleRate, int sampleSize, int channels = 2) {
|
||||
::WaveFormat(this, sampleRate, sampleSize, channels);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load samples data from wave as a floats array.
|
||||
*/
|
||||
float* LoadSamples() { return ::LoadWaveSamples(*this); }
|
||||
|
||||
/**
|
||||
* Unload samples data loaded with LoadWaveSamples().
|
||||
*/
|
||||
static void UnloadSamples(float* samples) { ::UnloadWaveSamples(samples); }
|
||||
|
||||
/**
|
||||
* Export wave data to file, returns true on success.
|
||||
*/
|
||||
bool Export(const std::string& fileName) { return ::ExportWave(*this, fileName.c_str()); }
|
||||
|
||||
/**
|
||||
* Export wave sample data to code (.h), returns true on success.
|
||||
*/
|
||||
bool ExportAsCode(const std::string& fileName) { return ::ExportWaveAsCode(*this, fileName.c_str()); }
|
||||
|
||||
/**
|
||||
* Load sound from wave data.
|
||||
*/
|
||||
::Sound LoadSound() { return ::LoadSoundFromWave(*this); }
|
||||
|
||||
/**
|
||||
* Load sound from wave data.
|
||||
*/
|
||||
operator ::Sound() { return LoadSound(); }
|
||||
|
||||
/**
|
||||
* Retrieve whether or not the Wave data has been loaded.
|
||||
*
|
||||
* @return True or false depending on whether the wave data has been loaded.
|
||||
*/
|
||||
RLCPP_NODISCARD bool IsValid() const { return ::IsWaveValid(*this); }
|
||||
|
||||
protected:
|
||||
void set(const ::Wave& wave) {
|
||||
frameCount = wave.frameCount;
|
||||
sampleRate = wave.sampleRate;
|
||||
sampleSize = wave.sampleSize;
|
||||
channels = wave.channels;
|
||||
data = wave.data;
|
||||
}
|
||||
};
|
||||
} // namespace raylib
|
||||
|
||||
using RWaveUnmanaged = raylib::WaveUnmanaged;
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_WAVEUNMANAGED_HPP_
|
||||
@@ -0,0 +1,474 @@
|
||||
#ifndef RAYLIB_CPP_INCLUDE_WINDOW_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_WINDOW_HPP_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "./RaylibException.hpp"
|
||||
#include "./Vector2.hpp"
|
||||
#include "./raylib.hpp"
|
||||
|
||||
namespace raylib {
|
||||
/**
|
||||
* Window and Graphics Device Functions.
|
||||
*/
|
||||
class Window {
|
||||
public:
|
||||
/**
|
||||
* Build a Window object, but defer the initialization. Ensure you call Init() manually.
|
||||
*
|
||||
* @see Init()
|
||||
*/
|
||||
Window() = default;
|
||||
|
||||
/**
|
||||
* Initialize window and OpenGL context.
|
||||
*
|
||||
* @param width The width of the window.
|
||||
* @param height The height of the window.
|
||||
* @param title The desired title of the window.
|
||||
* @param flags The ConfigFlags to set prior to initializing the window. See SetConfigFlags for more details.
|
||||
* @param logLevel The the current threshold (minimum) log level
|
||||
*
|
||||
* @see ::SetConfigFlags()
|
||||
* @see ConfigFlags
|
||||
*
|
||||
* @throws raylib::RaylibException Thrown if the window failed to initiate.
|
||||
*/
|
||||
Window(int width, int height, const std::string& title = "raylib", unsigned int flags = 0, TraceLogLevel logLevel = LOG_ALL) {
|
||||
Init(width, height, title, flags, logLevel);
|
||||
}
|
||||
|
||||
Window(const Window&) = delete;
|
||||
Window& operator=(const Window&) = delete;
|
||||
|
||||
/**
|
||||
* Close window and unload OpenGL context
|
||||
*/
|
||||
~Window() { Close(); }
|
||||
|
||||
[[nodiscard]] std::string ToString() const { return TextFormat("Window(%dx%d)", GetWidth(), GetHeight()); }
|
||||
|
||||
operator std::string() const { return ToString(); }
|
||||
|
||||
/**
|
||||
* Initializes the window.
|
||||
*
|
||||
* @param width The width of the window.
|
||||
* @param height The height of the window.
|
||||
* @param title The desired title of the window.
|
||||
* @param flags The ConfigFlags to set prior to initializing the window. See SetConfigFlags for more details.
|
||||
*
|
||||
* @see ::SetConfigFlags()
|
||||
* @see ConfigFlags
|
||||
*
|
||||
* @throws raylib::RaylibException Thrown if the window failed to initiate.
|
||||
*/
|
||||
static void Init(int width = 800, int height = 450, const std::string& title = "raylib", unsigned int flags = 0, TraceLogLevel logLevel = LOG_ALL) {
|
||||
if (flags != 0) {
|
||||
::SetConfigFlags(flags);
|
||||
}
|
||||
::SetTraceLogLevel(logLevel);
|
||||
::InitWindow(width, height, title.c_str());
|
||||
if (!::IsWindowReady()) {
|
||||
throw RaylibException("Failed to create Window");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if KEY_ESCAPE pressed or Close icon pressed
|
||||
*/
|
||||
static bool ShouldClose() { return ::WindowShouldClose(); }
|
||||
|
||||
/**
|
||||
* Set a custom key to exit program (default is ESC)
|
||||
*/
|
||||
static void SetExitKey(int key) { ::SetExitKey(key); }
|
||||
|
||||
/**
|
||||
* Close window and unload OpenGL context
|
||||
*/
|
||||
static void Close() {
|
||||
if (::IsWindowReady()) {
|
||||
::CloseWindow();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if cursor is on the current screen
|
||||
*/
|
||||
static bool IsCursorOnScreen() { return ::IsCursorOnScreen(); }
|
||||
|
||||
/**
|
||||
* Check if cursor is not visible
|
||||
*/
|
||||
static bool IsCursorHidden() { return ::IsCursorHidden(); }
|
||||
|
||||
/**
|
||||
* Hides cursor
|
||||
*/
|
||||
static void HideCursor() { ::HideCursor(); }
|
||||
|
||||
/**
|
||||
* Shows cursor
|
||||
*/
|
||||
static void ShowCursor() { ::ShowCursor(); }
|
||||
|
||||
/**
|
||||
* Check if window is currently fullscreen
|
||||
*/
|
||||
static bool IsFullscreen() { return ::IsWindowFullscreen(); }
|
||||
|
||||
/**
|
||||
* Check if window is currently hidden
|
||||
*/
|
||||
static bool IsHidden() { return ::IsWindowHidden(); }
|
||||
|
||||
/**
|
||||
* Check if window is currently minimized
|
||||
*/
|
||||
static bool IsMinimized() { return ::IsWindowMinimized(); }
|
||||
|
||||
/**
|
||||
* Check if window is currently minimized
|
||||
*/
|
||||
static bool IsMaximized() { return ::IsWindowMaximized(); }
|
||||
|
||||
/**
|
||||
* Check if window is currently focused
|
||||
*/
|
||||
static bool IsFocused() { return ::IsWindowFocused(); }
|
||||
|
||||
/**
|
||||
* Check if window has been resized last frame
|
||||
*/
|
||||
static bool IsResized() { return ::IsWindowResized(); }
|
||||
|
||||
/**
|
||||
* Check if one specific window flag is enabled
|
||||
*/
|
||||
static bool IsState(unsigned int flag) { return ::IsWindowState(flag); }
|
||||
|
||||
/**
|
||||
* Set window configuration state using flags
|
||||
*/
|
||||
Window& SetState(unsigned int flag) {
|
||||
::SetWindowState(flag);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear window configuration state flags
|
||||
*/
|
||||
Window& ClearState(unsigned int flag) {
|
||||
::ClearWindowState(flag);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear window with given color.
|
||||
*/
|
||||
Window& ClearBackground(const ::Color& color = BLACK) {
|
||||
::ClearBackground(color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle window state: fullscreen/windowed
|
||||
*/
|
||||
Window& ToggleFullscreen() {
|
||||
::ToggleFullscreen();
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether or not the application should be fullscreen.
|
||||
*/
|
||||
Window& SetFullscreen(bool fullscreen) {
|
||||
if (fullscreen) {
|
||||
if (!IsFullscreen()) {
|
||||
ToggleFullscreen();
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (IsFullscreen()) {
|
||||
ToggleFullscreen();
|
||||
}
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle window state: borderless/windowed
|
||||
*/
|
||||
Window& ToggleBorderless() {
|
||||
::ToggleBorderlessWindowed();
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set window state: maximized, if resizable (only PLATFORM_DESKTOP)
|
||||
*/
|
||||
Window& Maximize() {
|
||||
::MaximizeWindow();
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set window state: minimized, if resizable (only PLATFORM_DESKTOP)
|
||||
*/
|
||||
Window& Minimize() {
|
||||
::MinimizeWindow();
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set window state: not minimized/maximized (only PLATFORM_DESKTOP)
|
||||
*/
|
||||
Window& Restore() {
|
||||
::RestoreWindow();
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set icon for window
|
||||
*/
|
||||
Window& SetIcon(const ::Image& image) {
|
||||
::SetWindowIcon(image);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set icon for window (multiple images, RGBA 32bit, only PLATFORM_DESKTOP)
|
||||
*/
|
||||
Window& SetIcons(Image* images, int count) {
|
||||
::SetWindowIcons(images, count);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set title for window
|
||||
*/
|
||||
Window& SetTitle(const std::string& title) {
|
||||
::SetWindowTitle(title.c_str());
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set window position on screen
|
||||
*/
|
||||
Window& SetPosition(int x, int y) {
|
||||
::SetWindowPosition(x, y);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set window position on screen
|
||||
*/
|
||||
Window& SetPosition(const ::Vector2& position) {
|
||||
return SetPosition(static_cast<int>(position.x), static_cast<int>(position.y));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set monitor for the current window
|
||||
*/
|
||||
Window& SetMonitor(int monitor) {
|
||||
::SetWindowMonitor(monitor);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set window minimum dimensions
|
||||
*/
|
||||
Window& SetMinSize(int width, int height) {
|
||||
::SetWindowMinSize(width, height);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set window minimum dimensions
|
||||
*/
|
||||
Window& SetMinSize(const ::Vector2& size) {
|
||||
::SetWindowMinSize(static_cast<int>(size.x), static_cast<int>(size.y));
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set window dimensions
|
||||
*/
|
||||
Window& SetSize(int width, int height) {
|
||||
::SetWindowSize(width, height);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set window opacity [0.0f..1.0f] (only PLATFORM_DESKTOP)
|
||||
*/
|
||||
Window& SetOpacity(float opacity) {
|
||||
::SetWindowOpacity(opacity);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set window focused (only PLATFORM_DESKTOP)
|
||||
*/
|
||||
Window& SetFocused() {
|
||||
::SetWindowFocused();
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set window dimensions
|
||||
*/
|
||||
Window& SetSize(const ::Vector2& size) { return SetSize(static_cast<int>(size.x), static_cast<int>(size.y)); }
|
||||
|
||||
/**
|
||||
* Get the screen's width and height.
|
||||
*/
|
||||
static Vector2 GetSize() { return {static_cast<float>(GetWidth()), static_cast<float>(GetHeight())}; }
|
||||
|
||||
/**
|
||||
* Get native window handle
|
||||
*/
|
||||
static void* GetHandle() { return ::GetWindowHandle(); }
|
||||
|
||||
/**
|
||||
* Setup canvas (framebuffer) to start drawing
|
||||
*/
|
||||
Window& BeginDrawing() {
|
||||
::BeginDrawing();
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* End canvas drawing and swap buffers (double buffering)
|
||||
*/
|
||||
Window& EndDrawing() {
|
||||
::EndDrawing();
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current screen width
|
||||
*/
|
||||
static int GetWidth() { return ::GetScreenWidth(); }
|
||||
|
||||
/**
|
||||
* Get current screen height
|
||||
*/
|
||||
static int GetHeight() { return ::GetScreenHeight(); }
|
||||
|
||||
/**
|
||||
* Get current render width (it considers HiDPI)
|
||||
*/
|
||||
static int GetRenderWidth() { return ::GetRenderWidth(); }
|
||||
|
||||
/**
|
||||
* Get current render height (it considers HiDPI)
|
||||
*/
|
||||
static int GetRenderHeight() { return ::GetRenderHeight(); }
|
||||
|
||||
/**
|
||||
* Get window position XY on monitor
|
||||
*/
|
||||
static Vector2 GetPosition() { return ::GetWindowPosition(); }
|
||||
|
||||
/*
|
||||
* Get current window monitor
|
||||
*/
|
||||
static int GetMonitor() { return ::GetCurrentMonitor(); }
|
||||
|
||||
/**
|
||||
* Get window scale DPI factor
|
||||
*/
|
||||
static Vector2 GetScaleDPI() { return ::GetWindowScaleDPI(); }
|
||||
|
||||
/**
|
||||
* Set clipboard text content
|
||||
*/
|
||||
static void SetClipboardText(const std::string& text) { ::SetClipboardText(text.c_str()); }
|
||||
|
||||
/**
|
||||
* Get clipboard text content
|
||||
*/
|
||||
static std::string GetClipboardText() { return ::GetClipboardText(); }
|
||||
|
||||
/**
|
||||
* Set target FPS (maximum)
|
||||
*/
|
||||
Window& SetTargetFPS(int fps) {
|
||||
::SetTargetFPS(fps);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns current FPS
|
||||
*/
|
||||
static int GetFPS() { return ::GetFPS(); }
|
||||
|
||||
/**
|
||||
* Draw current FPS
|
||||
*/
|
||||
static void DrawFPS(int posX = 10, int posY = 10) { ::DrawFPS(posX, posY); }
|
||||
|
||||
/**
|
||||
* Returns time in seconds for last frame drawn
|
||||
*/
|
||||
static float GetFrameTime() { return ::GetFrameTime(); }
|
||||
|
||||
/**
|
||||
* Returns elapsed time in seconds since InitWindow()
|
||||
*/
|
||||
static double GetTime() { return ::GetTime(); }
|
||||
|
||||
/**
|
||||
* Check if window has been initialized successfully
|
||||
*/
|
||||
static bool IsReady() { return ::IsWindowReady(); }
|
||||
|
||||
/**
|
||||
* Sets the configuration flags for raylib.
|
||||
*
|
||||
* @param flags The ConfigFlags to apply to the configuration.
|
||||
*
|
||||
* @see ::SetConfigFlags
|
||||
*/
|
||||
static void SetConfigFlags(unsigned int flags) { ::SetConfigFlags(flags); }
|
||||
|
||||
/**
|
||||
* Alternates between calling `BeginDrawing()` and `EndDrawing()`.
|
||||
*
|
||||
* @code
|
||||
* while (window.Drawing()) {
|
||||
* DrawRectangle();
|
||||
* }
|
||||
* @endcode
|
||||
*
|
||||
* @return True if we're within the `BeginDrawing()` scope.
|
||||
*/
|
||||
bool Drawing() {
|
||||
if (m_drawing) {
|
||||
EndDrawing();
|
||||
m_drawing = false;
|
||||
}
|
||||
else {
|
||||
BeginDrawing();
|
||||
m_drawing = true;
|
||||
}
|
||||
|
||||
return m_drawing;
|
||||
}
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Handles the internal drawing state for calling either `BeginDrawing()` or `EndDrawing()` from the `Drawing()` function.
|
||||
*
|
||||
* @see Drawing()
|
||||
*/
|
||||
bool m_drawing = false;
|
||||
};
|
||||
} // namespace raylib
|
||||
|
||||
using RWindow = raylib::Window;
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_WINDOW_HPP_
|
||||
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* Utility for raylib-cpp.
|
||||
*/
|
||||
#ifndef RAYLIB_CPP_INCLUDE_RAYLIB_CPP_UTILS_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_RAYLIB_CPP_UTILS_HPP_
|
||||
|
||||
#ifndef GETTER
|
||||
/**
|
||||
* A utility to build a get method on top of a property.
|
||||
*
|
||||
* @param type The type of the property.
|
||||
* @param method The human-readable name for the method.
|
||||
* @param name The machine-readable name of the property.
|
||||
*/
|
||||
#define GETTER(type, method, name) \
|
||||
/** Retrieves the name value for the object. @return The name value of the object. */ \
|
||||
type Get##method() const { \
|
||||
return name; \
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef GETTERSETTER
|
||||
/**
|
||||
* A utility to build get and set methods on top of a property.
|
||||
*
|
||||
* @param type The type of the property.
|
||||
* @param method The human-readable name for the method.
|
||||
* @param name The machine-readable name of the property.
|
||||
*/
|
||||
#define GETTERSETTER(type, method, name) \
|
||||
GETTER(type, method, name) \
|
||||
/** Sets the name value for the object. @param value The value of which to set name to. */ \
|
||||
void Set##method(type value) { \
|
||||
name = value; \
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_RAYLIB_CPP_UTILS_HPP_
|
||||
@@ -0,0 +1,88 @@
|
||||
/**
|
||||
* [raylib-cpp](https://github.com/RobLoach/raylib-cpp) is a C++ wrapper library for raylib, a simple and easy-to-use library to enjoy videogames programming. This C++ header provides object-oriented wrappers around raylib's struct interfaces.
|
||||
*
|
||||
* @see raylib namespace for a list of all available classes.
|
||||
* @mainpage raylib-cpp
|
||||
* @include core_basic_window.cpp
|
||||
* @author Rob Loach (RobLoach)
|
||||
* @copyright zlib/libpng
|
||||
*
|
||||
* raylib-cpp is licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||
* BSD-like license that allows static linking with closed source software:
|
||||
*
|
||||
* Copyright 2020 Rob Loach (RobLoach)
|
||||
*
|
||||
* This software is provided "as-is", without any express or implied warranty. In no event
|
||||
* will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose, including commercial
|
||||
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not claim that you
|
||||
* wrote the original software. If you use this software in a product, an acknowledgment
|
||||
* in the product documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
|
||||
* as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef RAYLIB_CPP_INCLUDE_RAYLIB_CPP_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_RAYLIB_CPP_HPP_
|
||||
|
||||
#include "./AudioDevice.hpp"
|
||||
#include "./AudioStream.hpp"
|
||||
#include "./AudioStreamUnmanaged.hpp"
|
||||
#include "./AutomationEventList.hpp"
|
||||
#include "./BoundingBox.hpp"
|
||||
#include "./Camera2D.hpp"
|
||||
#include "./Camera3D.hpp"
|
||||
#include "./Color.hpp"
|
||||
#include "./FileData.hpp"
|
||||
#include "./FileText.hpp"
|
||||
#include "./Font.hpp"
|
||||
#include "./FontUnmanaged.hpp"
|
||||
#include "./Functions.hpp"
|
||||
#include "./Gamepad.hpp"
|
||||
#include "./Image.hpp"
|
||||
#include "./Keyboard.hpp"
|
||||
#include "./Material.hpp"
|
||||
#include "./MaterialUnmanaged.hpp"
|
||||
#include "./Matrix.hpp"
|
||||
#include "./Mesh.hpp"
|
||||
#include "./Model.hpp"
|
||||
#include "./ModelUnmanaged.hpp"
|
||||
#include "./ModelAnimation.hpp"
|
||||
#include "./Mouse.hpp"
|
||||
#include "./Music.hpp"
|
||||
#include "./MusicUnmanaged.hpp"
|
||||
#include "./Ray.hpp"
|
||||
#include "./RayCollision.hpp"
|
||||
#include "./RaylibException.hpp"
|
||||
#include "./Rectangle.hpp"
|
||||
#include "./RenderTexture.hpp"
|
||||
#include "./RenderTextureUnmanaged.hpp"
|
||||
#include "./Shader.hpp"
|
||||
#include "./Sound.hpp"
|
||||
#include "./SoundUnmanaged.hpp"
|
||||
#include "./Text.hpp"
|
||||
#include "./Texture.hpp"
|
||||
#include "./TextureUnmanaged.hpp"
|
||||
#include "./Touch.hpp"
|
||||
#include "./Vector2.hpp"
|
||||
#include "./Vector3.hpp"
|
||||
#include "./Vector4.hpp"
|
||||
#include "./VrStereoConfig.hpp"
|
||||
#include "./Wave.hpp"
|
||||
#include "./WaveUnmanaged.hpp"
|
||||
#include "./Window.hpp"
|
||||
|
||||
/**
|
||||
* All raylib-cpp classes and functions appear in the raylib namespace.
|
||||
*/
|
||||
namespace raylib {
|
||||
// Nothing.
|
||||
} // namespace raylib
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_RAYLIB_CPP_HPP_
|
||||
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* C++ header to wrap raylib.h.
|
||||
*/
|
||||
#ifndef RAYLIB_CPP_INCLUDE_RAYLIB_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_RAYLIB_HPP_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef RAYLIB_H_FILE
|
||||
#define RAYLIB_H_FILE "raylib.h"
|
||||
#endif
|
||||
|
||||
#include RAYLIB_H_FILE // NOLINT
|
||||
|
||||
#if !defined(RAYLIB_VERSION_MAJOR) || !defined(RAYLIB_VERSION_MINOR)
|
||||
#error "raylib-cpp requires raylib >= 5"
|
||||
#endif
|
||||
|
||||
#if RAYLIB_VERSION_MAJOR < 6
|
||||
#error "raylib-cpp requires raylib >= 6"
|
||||
#endif
|
||||
|
||||
#if RAYLIB_VERSION_MAJOR > 6
|
||||
#error "raylib-cpp requires raylib ~6.0. Use the `next` branch for the next version of raylib."
|
||||
#endif
|
||||
|
||||
#ifndef RLCPP_MAYBEUNUSED
|
||||
# if defined(__has_cpp_attribute)
|
||||
# if __has_cpp_attribute(maybe_unused) && __cplusplus >= 201703L
|
||||
# define RLCPP_MAYBEUNUSED [[maybe_unused]]
|
||||
# else
|
||||
# define RLCPP_MAYBEUNUSED
|
||||
# endif
|
||||
# elif (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || (__cplusplus >= 201703L)
|
||||
# define RLCPP_MAYBEUNUSED [[maybe_unused]]
|
||||
# else
|
||||
# define RLCPP_MAYBEUNUSED
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef RLCPP_NODISCARD
|
||||
# if defined(__has_cpp_attribute)
|
||||
# if __has_cpp_attribute(nodiscard) && __cplusplus >= 201703L
|
||||
# define RLCPP_NODISCARD [[nodiscard]]
|
||||
# else
|
||||
# define RLCPP_NODISCARD
|
||||
# endif
|
||||
# elif (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || (__cplusplus >= 201703L)
|
||||
# define RLCPP_NODISCARD [[nodiscard]]
|
||||
# else
|
||||
# define RLCPP_NODISCARD
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_RAYLIB_HPP_
|
||||
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* C++ header to wrap raymath.h.
|
||||
*/
|
||||
#ifndef RAYLIB_CPP_INCLUDE_RAYMATH_HPP_
|
||||
#define RAYLIB_CPP_INCLUDE_RAYMATH_HPP_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#ifndef RAYLIB_CPP_NO_MATH
|
||||
#ifndef BUILD_RAYLIB_CPP_MODULES
|
||||
#ifndef RAYMATH_STATIC_INLINE
|
||||
#define RAYMATH_STATIC_INLINE
|
||||
#endif
|
||||
#endif
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic push // These throw a warnings on visual studio, need to check if __GNUC__ is defined to use it.
|
||||
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
|
||||
#endif
|
||||
#define RAYMATH_DISABLE_CPP_OPERATORS
|
||||
#include "raymath.h" // NOLINT
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // RAYLIB_CPP_INCLUDE_RAYMATH_HPP_
|
||||
@@ -0,0 +1,151 @@
|
||||
#include "polypartiCL.hpp"
|
||||
#include "include/raylib-cpp.hpp"
|
||||
#include <vector>
|
||||
#include "rlgl.h"
|
||||
#include <exception>
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
string roomName = "rooms/load.room";
|
||||
string partName = "particles/load.prtc";
|
||||
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
const int fps = 60;
|
||||
const int screenWidth = 1920;
|
||||
const int screenHeight = 1080;
|
||||
float angle = 0.05;
|
||||
float d_interval_pct = 0.00001;
|
||||
bool rotate = false;
|
||||
bool drawLines = true;
|
||||
bool drawFPS = false;
|
||||
bool useShader = true;
|
||||
bool paused = false;
|
||||
// bool counterclockwise = false;
|
||||
//
|
||||
for (int i = 0; i < argc; i++) {
|
||||
if (argv[i] == "--rotate"s || argv[i] == "-r"s) {
|
||||
rotate = true;
|
||||
}
|
||||
}
|
||||
|
||||
Polyparti::Room sim(screenWidth, screenHeight, fps);
|
||||
|
||||
vector<raylib::Vector2> lines;
|
||||
cout << "ok-1" << endl;
|
||||
|
||||
sim.loadRoom(roomName);
|
||||
sim.loadParticles(partName);
|
||||
sim.addFields();
|
||||
for (const auto& item : sim.getCorners()) {
|
||||
lines.push_back({item[0], item[1]});
|
||||
}
|
||||
raylib::Window window(screenWidth, screenHeight, "polypartiCL");
|
||||
//raylib::Button::key R(KEY_R);
|
||||
|
||||
window.SetTargetFPS(fps);
|
||||
|
||||
raylib::RenderTexture2D renderTarget(screenWidth, screenHeight);
|
||||
raylib::RenderTexture2D blur(screenWidth, screenHeight);
|
||||
raylib::Shader blurShader("", "shaders/blur2.fs");
|
||||
raylib::Vector2 mouse_i, mouse_f, mouse_d;
|
||||
raylib::Vector2 midpoint(screenWidth * 0.5, screenHeight * 0.5);
|
||||
|
||||
int resXY = blurShader.GetLocation("resolution");
|
||||
int dirXY = blurShader.GetLocation("direction");
|
||||
float resolution[2] = { float(screenWidth), float(screenHeight)};
|
||||
blurShader.SetValue(resXY, resolution, RL_SHADER_UNIFORM_VEC2);
|
||||
|
||||
while(!window.ShouldClose()) {
|
||||
if (IsKeyPressed(KEY_R)) rotate = !rotate;
|
||||
if (IsKeyPressed(KEY_L)) drawLines = !drawLines;
|
||||
if (IsKeyPressed(KEY_F)) drawFPS = !drawFPS;
|
||||
if (IsKeyPressed(KEY_D)) angle *= -1;
|
||||
if (IsKeyPressed(KEY_B)) useShader = !useShader;
|
||||
if (IsKeyPressed(KEY_SPACE)) paused = !paused;
|
||||
if (IsKeyPressed(KEY_T)) sim.reverseInterval();
|
||||
//if (IsKeyPressed(KEY_UP)) sim.adjustInterval(d_interval_pct);
|
||||
//if (IsKeyPressed(KEY_DOWN)) sim.adjustInterval(-d_interval_pct);
|
||||
/*if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) {
|
||||
mouse_f = GetMousePosition();
|
||||
mouse_f -= midpoint;
|
||||
mouse_d = GetMouseDelta();
|
||||
mouse_i = mouse_f - mouse_d;
|
||||
angle = mouse_f.DotProduct(mouse_i);
|
||||
angle = angle / mouse_f.Length() * mouse_i.Length();
|
||||
angle = acos(angle);
|
||||
}*/
|
||||
if (!paused) {
|
||||
sim.updateFields();
|
||||
if (rotate) sim.rotateRoom(angle);
|
||||
lines.clear();
|
||||
}
|
||||
for(const auto& item : sim.getCorners()) lines.push_back({item[0], item[1]});
|
||||
|
||||
if (useShader) {
|
||||
renderTarget.BeginMode();
|
||||
ClearBackground(BLACK);
|
||||
|
||||
if(drawLines) {
|
||||
for(int i = 0; i < (lines.size() - 1); i++)
|
||||
lines[i].DrawLine(lines[i+1], WHITE);
|
||||
}
|
||||
|
||||
for (int i = 0; i < sim.getFieldCount(); i++) {
|
||||
auto& field = sim.getField(i);
|
||||
int *color = field.getColor();
|
||||
rlBegin(RL_LINES);
|
||||
rlColor4ub(color[0], color[1], color[2], color[3]);
|
||||
for (const auto& p : field.getPositions()) {
|
||||
rlVertex2f(p[0],p[1]);
|
||||
rlVertex2f(p[0]+1.0f,p[1]+1.0f);
|
||||
}
|
||||
rlEnd();
|
||||
}
|
||||
renderTarget.EndMode();
|
||||
|
||||
float dirH[2] = {1.0f, 0.0f};
|
||||
float dirV[2] = {0.0f, 1.0f};
|
||||
|
||||
blurShader.SetValue(dirXY, dirH, SHADER_UNIFORM_VEC2);
|
||||
|
||||
blur.BeginMode();
|
||||
ClearBackground(BLACK);
|
||||
blurShader.BeginMode();
|
||||
DrawTextureRec(renderTarget.texture, {0, 0, resolution[0], -resolution[1]},
|
||||
{0, 0}, WHITE);
|
||||
blurShader.EndMode();
|
||||
blur.EndMode();
|
||||
|
||||
blurShader.SetValue(dirXY, dirV, SHADER_UNIFORM_VEC2);
|
||||
}
|
||||
while(window.Drawing()) {
|
||||
window.ClearBackground(BLACK);
|
||||
|
||||
if (useShader) {
|
||||
blurShader.BeginMode();
|
||||
DrawTextureRec(blur.texture, {0, 0, resolution[0], -resolution[1]}, {0,0}, WHITE);
|
||||
blurShader.EndMode();
|
||||
} else {
|
||||
for (int i = 0; i < (int)lines.size() - 1; i++) {
|
||||
lines[i].DrawLine(lines[i+1], WHITE);
|
||||
}
|
||||
|
||||
for (int i = 0; i < sim.getFieldCount(); i++) {
|
||||
auto& field = sim.getField(i);
|
||||
int *color = field.getColor();
|
||||
rlBegin(RL_LINES);
|
||||
rlColor4ub(color[0], color[1], color[2], color[3]);
|
||||
for (const auto& p : field.getPositions()) {
|
||||
rlVertex2f(p[0],p[1]);
|
||||
rlVertex2f(p[0]+1.0f,p[1]+1.0f);
|
||||
}
|
||||
rlEnd();
|
||||
}
|
||||
}
|
||||
if(drawFPS) window.DrawFPS(10,10);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
s
|
||||
30000 0.64 0.78 0 360 yellow
|
||||
30000 0.5 0.3333 0 360 magenta
|
||||
30000 0.36 0.78 0 360 cyan
|
||||
@@ -0,0 +1,4 @@
|
||||
r
|
||||
20000 0.4 0.5 0 360 blue
|
||||
20000 0.6 0.5 0 360 green
|
||||
20000 0.5 0.5 0 360 red
|
||||
@@ -0,0 +1,4 @@
|
||||
s
|
||||
20000 0.5 0.33333333333 0 360 cyan
|
||||
20000 0.3555 0.783 0 360 magenta
|
||||
20000 0.6445 0.783 0 360 yellow
|
||||
@@ -0,0 +1,4 @@
|
||||
r
|
||||
20000 0.2421875 0.899999999 0 60 blue
|
||||
20000 0.7578125 0.899999999 120 180 green
|
||||
20000 0.5 0.1 180 360 red
|
||||
@@ -0,0 +1,4 @@
|
||||
r
|
||||
20000 0.333 0.78 0 360 blue
|
||||
20000 0.666 0.78 0 360 green
|
||||
20000 0.5 0.3333 0 360 red
|
||||
@@ -0,0 +1,6 @@
|
||||
r
|
||||
12000 0.5 0.5 0 360 cyan
|
||||
12000 0.25 0.25 0 360 magenta
|
||||
12000 0.25 0.75 0 360 yellow
|
||||
12000 0.75 0.25 0 360 green
|
||||
12000 0.75 0.75 0 360 red
|
||||
+514
@@ -0,0 +1,514 @@
|
||||
//use floats, not doubles, for 32-bit iGPUs
|
||||
|
||||
#include "polypartiCL.hpp"
|
||||
#include <cmath>
|
||||
#include <sycl/sycl.hpp>
|
||||
#include <exception>
|
||||
#include <vector>
|
||||
#include <fstream>
|
||||
#include <algorithm>
|
||||
|
||||
using namespace sycl;
|
||||
|
||||
struct Polyparti::ParticleField::ColCode {
|
||||
std::vector<XYVector> positions, velocities;
|
||||
float t, fieldTime, lifeTime;
|
||||
int count, decay = 0;
|
||||
int color[4];
|
||||
//float decay = 1.0f;
|
||||
bool dies = false, dead = false;
|
||||
|
||||
// allocate only one queue so we don't reinitialize every step of the calculation
|
||||
static queue& q_shared() {
|
||||
static queue q{gpu_selector_v, property::queue::in_order()};
|
||||
return q;
|
||||
}
|
||||
|
||||
void checkCollisions(std::vector<XYVector> verticies) {
|
||||
queue& q = q_shared();
|
||||
int len_points = positions.size();
|
||||
|
||||
//Pointers to malloc on GPU VRAM for calculations. malloc_shared pointers are entry/exit
|
||||
//point for data in CPU RAM
|
||||
float *v_ptr = malloc_shared<float>(2 * len_points, q);
|
||||
float *d_ptr = malloc_shared<float>(2 * len_points, q);
|
||||
float *c_ptr = malloc_shared<float>(2 * len_points, q);
|
||||
float *ray_ptr = malloc_device<float>(2 * len_points, q);
|
||||
float *det_ptr = malloc_device<float>(len_points, q);
|
||||
float *bestA_ptr = malloc_device<float>(2 * len_points, q);
|
||||
float *bestSlope_ptr = malloc_device<float>(2 * len_points, q);
|
||||
float *r_ptr = malloc_device<float>(len_points, q);
|
||||
float *s_ptr = malloc_device<float>(len_points, q);
|
||||
float *rPref_ptr = malloc_device<float>(len_points, q);
|
||||
float *sPref_ptr = malloc_device<float>(len_points, q);
|
||||
float *nml_ptr = malloc_device<float>(len_points * 2, q);
|
||||
float *dot_ptr = malloc_device<float>(len_points, q);
|
||||
|
||||
float *t_ptr = malloc_shared<float>(1, q);
|
||||
std::vector<float> sPrefInit(len_points, float(1000000.0f));
|
||||
|
||||
XYVector A, B, borderSlope;
|
||||
|
||||
//Copy arrays from CPU RAM to shared pointer with GPU VRAM & CPU RAM
|
||||
//SYCL can only handle one memcpy per kernel
|
||||
|
||||
q.submit([&](handler& h) {h.memcpy(c_ptr, &positions[0], len_points * 2 * sizeof(float)); });
|
||||
q.wait();
|
||||
|
||||
q.submit([&](handler& h) {h.memcpy(v_ptr, &velocities[0], len_points * 2 * sizeof(float));});
|
||||
q.wait();
|
||||
|
||||
q.submit([&](handler& h) {h.memcpy(sPref_ptr, &sPrefInit[0], len_points * sizeof(float)); });
|
||||
q.wait();
|
||||
|
||||
q.submit([&](handler& h) { h.memcpy(t_ptr, &t, sizeof(float)); });
|
||||
q.wait();
|
||||
|
||||
|
||||
//Calculate expected location of each particle after imminent time step, and vectorize the
|
||||
//difference <dx, dy> from the current position. We will use Cramer's Rule with the
|
||||
//vectorized boundary, also <dx, dy>, to check intersection
|
||||
|
||||
q.submit([&](handler& h) {
|
||||
h.parallel_for(len_points * 2, [=](id<1> i) {
|
||||
d_ptr[i] = v_ptr[i] * *t_ptr + c_ptr[i];
|
||||
ray_ptr[i] = d_ptr[i] - c_ptr[i];
|
||||
});
|
||||
});
|
||||
q.wait();
|
||||
|
||||
//Iterate over each room boundary in terms of their endpoints. Note that iterative and
|
||||
//parallel computing concepts can work in tandem, with the next kernel executed
|
||||
//sychronously within the for loop
|
||||
|
||||
for (int i = 1; i < verticies.size(); i++) {
|
||||
A = verticies[i-1], B = verticies[i];
|
||||
borderSlope[0] = B[0] - A[0];
|
||||
borderSlope[1] = B[1] - A[1];
|
||||
|
||||
q.submit([&](handler& h) {
|
||||
h.parallel_for(len_points, [=](id<1> i) {
|
||||
//Calculate determinant of 2x2 matrix of both vectors
|
||||
det_ptr[i] = borderSlope[0] * ray_ptr[(i*2) + 1] - borderSlope[1] * ray_ptr[(i*2)];
|
||||
if (fabs(det_ptr[i]) > float(1e-5) * hypot(borderSlope[0], borderSlope[1]) * hypot(ray_ptr[i*2], ray_ptr[(i*2) + 1])) {
|
||||
//
|
||||
r_ptr[i] = ((c_ptr[i*2] - A[0]) * ray_ptr[(i*2)+1] - (c_ptr[(2*i)+1] - A[1]) * ray_ptr[i*2]) / det_ptr[i];
|
||||
s_ptr[i] = ((c_ptr[i*2] - A[0]) * borderSlope[1] - (c_ptr[(i*2) + 1] - A[1]) * borderSlope[0]) / det_ptr[i];
|
||||
} else {
|
||||
r_ptr[i] = float(-1.0f);
|
||||
s_ptr[i] = float(-1.0f);
|
||||
}
|
||||
});
|
||||
});
|
||||
q.wait();
|
||||
|
||||
q.submit([&](handler& h) {
|
||||
h.parallel_for(len_points, [=](id<1> i) {
|
||||
if (r_ptr[i] >= float(0.0) && r_ptr[i] <= float(1.0)
|
||||
&& s_ptr[i] >= float(0.0) && s_ptr[i] <= float(1.0)) {
|
||||
if (s_ptr[i] < sPref_ptr[i]) {
|
||||
sPref_ptr[i] = s_ptr[i];
|
||||
rPref_ptr[i] = r_ptr[i];
|
||||
bestA_ptr[i*2] = A[0];
|
||||
bestA_ptr[(i*2) + 1] = A[1];
|
||||
bestSlope_ptr[i*2] = borderSlope[0];
|
||||
bestSlope_ptr[(i*2) + 1] = borderSlope[1];
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
q.wait();
|
||||
}
|
||||
q.submit([&](handler& h) {
|
||||
h.parallel_for(len_points, [=](id<1> i) {
|
||||
if (sPref_ptr[i] < float(1000000.0f)) {
|
||||
nml_ptr[(i*2)] = (-1 * bestSlope_ptr[(i*2) + 1]) / hypot(bestSlope_ptr[i*2], bestSlope_ptr[(i*2) + 1]);
|
||||
nml_ptr[(i*2) + 1] = bestSlope_ptr[i*2] / hypot(bestSlope_ptr[i*2], bestSlope_ptr[(i*2) + 1]);
|
||||
|
||||
dot_ptr[i] = (nml_ptr[i*2] * v_ptr[i*2]) + (nml_ptr[(i*2) + 1] * v_ptr[(i*2) + 1]);
|
||||
|
||||
if (dot_ptr[i] > 0) {
|
||||
nml_ptr[i*2] = nml_ptr[i*2] * -1;
|
||||
nml_ptr[(i*2) + 1] = nml_ptr[(i*2) + 1] * -1;
|
||||
dot_ptr[i] *= -1;
|
||||
}
|
||||
|
||||
v_ptr[i*2] -= 2 * dot_ptr[i] * nml_ptr[i*2];
|
||||
v_ptr[(i*2) + 1] -= 2 * dot_ptr[i] * nml_ptr[(i*2) + 1];
|
||||
|
||||
c_ptr[i*2] = bestA_ptr[i*2] + (rPref_ptr[i] * bestSlope_ptr[i*2]);
|
||||
c_ptr[(i*2) + 1] = bestA_ptr[(i*2) + 1] + (rPref_ptr[i] * bestSlope_ptr[(i*2) + 1]);
|
||||
|
||||
c_ptr[i*2] -= nml_ptr[i*2] * 1e-4f;
|
||||
c_ptr[(i*2) + 1] -= nml_ptr[(i*2) + 1] * 1e-4f;
|
||||
}
|
||||
});
|
||||
});
|
||||
q.wait();
|
||||
|
||||
//Get the computed data back into pointers we can use
|
||||
q.submit([&](handler& h) {h.memcpy(&positions[0], c_ptr, len_points * 2 * sizeof(float));});
|
||||
q.submit([&](handler& h) {h.memcpy(&velocities[0], v_ptr, len_points * 2 * sizeof(float));});
|
||||
q.wait();
|
||||
|
||||
free(c_ptr, q);
|
||||
free(d_ptr, q);
|
||||
free(v_ptr, q);
|
||||
free(ray_ptr, q);
|
||||
free(det_ptr, q);
|
||||
free(bestA_ptr, q);
|
||||
free(bestSlope_ptr, q);
|
||||
free(r_ptr, q);
|
||||
free(s_ptr, q);
|
||||
free(rPref_ptr, q);
|
||||
free(sPref_ptr, q);
|
||||
free(nml_ptr, q);
|
||||
free(dot_ptr, q);
|
||||
free(t_ptr,q);
|
||||
|
||||
}
|
||||
void moveParticles() {
|
||||
queue& q = q_shared();
|
||||
int len = positions.size();
|
||||
float *v_ptr = malloc_shared<float>(2 * len, q);
|
||||
float *p_ptr = malloc_shared<float>(2 * len, q);
|
||||
float *t_ptr = malloc_shared<float>(1, q);
|
||||
|
||||
q.submit([&](handler& h) {
|
||||
h.memcpy(p_ptr, &positions[0], len * 2 * sizeof(float));
|
||||
});
|
||||
q.wait();
|
||||
q.submit([&](handler& h) { h.memcpy(v_ptr, &velocities[0], len * 2 * sizeof(float)); } );
|
||||
q.wait();
|
||||
|
||||
q.submit([&](handler& h) { h.memcpy(t_ptr, &t, sizeof(float)); } );
|
||||
q.wait();
|
||||
|
||||
q.submit([&](handler& h) { h.parallel_for(len * 2, [=](id<1> i) {
|
||||
p_ptr[i] += v_ptr[i] * *t_ptr;
|
||||
}); });
|
||||
q.wait();
|
||||
|
||||
q.submit([&](handler& h) { h.memcpy(&positions[0], p_ptr, len * 2 * sizeof(float)); });
|
||||
q.wait();
|
||||
|
||||
q.submit([&](handler& h) { h.memcpy(&velocities[0], v_ptr, len * 2 * sizeof(float)); });
|
||||
q.wait();
|
||||
|
||||
free(p_ptr, q);
|
||||
free(v_ptr, q);
|
||||
free(t_ptr, q);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Polyparti::ParticleField::ParticleField() : colcode(std::make_unique<ColCode>()) { }
|
||||
Polyparti::ParticleField::~ParticleField() = default;
|
||||
Polyparti::ParticleField::ParticleField(const ParticleField& other)
|
||||
: colcode(std::make_unique<ColCode>(*other.colcode)) {}
|
||||
Polyparti::ParticleField::ParticleField(ParticleField&&) noexcept = default;
|
||||
Polyparti::ParticleField& Polyparti::ParticleField::operator=(ParticleField&& other) noexcept = default;
|
||||
Polyparti::ParticleField& Polyparti::ParticleField::operator=(const ParticleField& other) {
|
||||
if (this != &other) { *colcode = *other.colcode; }
|
||||
return *this;
|
||||
}
|
||||
|
||||
void Polyparti::ParticleField::addParticle(float x, float y, float vx, float vy) {
|
||||
colcode->positions.push_back({x, y});
|
||||
colcode->velocities.push_back({vx, vy});
|
||||
colcode->count++;
|
||||
}
|
||||
|
||||
void Polyparti::ParticleField::deleteParticle(int index) {
|
||||
colcode->positions.erase(colcode->positions.begin() + index);
|
||||
colcode->velocities.erase(colcode->velocities.begin() + index);
|
||||
colcode->count--;
|
||||
}
|
||||
|
||||
void Polyparti::ParticleField::updateField(std::vector<XYVector> verticies) {
|
||||
colcode->checkCollisions(verticies);
|
||||
colcode->moveParticles();
|
||||
colcode->fieldTime += colcode->t;
|
||||
if (colcode->dies) {
|
||||
if (colcode->lifeTime >= colcode->fieldTime) {
|
||||
colcode->color[3] -= colcode->decay;
|
||||
}
|
||||
if (colcode->color[3] <= 0) {
|
||||
colcode->dead = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const std::vector<XYVector>& Polyparti::ParticleField::getPositions() const {
|
||||
return colcode->positions;
|
||||
}
|
||||
|
||||
int Polyparti::ParticleField::getSize() {
|
||||
return colcode->positions.size();
|
||||
}
|
||||
|
||||
void Polyparti::ParticleField::setColor(std::string newColor) {
|
||||
colcode->color[3] = 255;
|
||||
if (newColor == "red" ) {
|
||||
colcode->color[0] = 255;
|
||||
colcode->color[1] = 0;
|
||||
colcode->color[2] = 0;
|
||||
} else if (newColor == "orange") {
|
||||
colcode->color[0] = 255;
|
||||
colcode->color[1] = 127;
|
||||
colcode->color[2] = 0;
|
||||
} else if (newColor == "yellow") {
|
||||
colcode->color[0] = 255;
|
||||
colcode->color[1] = 255;
|
||||
colcode->color[2] = 0;
|
||||
} else if (newColor == "green") {
|
||||
colcode->color[0] = 0;
|
||||
colcode->color[1] = 255;
|
||||
colcode->color[2] = 0;
|
||||
} else if (newColor == "blue") {
|
||||
colcode->color[0] = 0;
|
||||
colcode->color[1] = 0;
|
||||
colcode->color[2] = 255;
|
||||
} else if (newColor == "indigo") {
|
||||
colcode->color[0] = 31;
|
||||
colcode->color[1] = 0;
|
||||
colcode->color[2] = 127;
|
||||
} else if (newColor == "violet") {
|
||||
colcode->color[0] = 127;
|
||||
colcode->color[1] = 0;
|
||||
colcode->color[2] = 127;
|
||||
} else if (newColor == "cyan") {
|
||||
colcode->color[0] = 0;
|
||||
colcode->color[1] = 255;
|
||||
colcode->color[2] = 255;
|
||||
} else if (newColor == "darkgreen") {
|
||||
colcode->color[0] = 0;
|
||||
colcode->color[1] = 127;
|
||||
colcode->color[2] = 0;
|
||||
} else if (newColor == "magenta") {
|
||||
colcode->color[0] = 255;
|
||||
colcode->color[1] = 0;
|
||||
colcode->color[2] = 255;
|
||||
} else {
|
||||
colcode->color[0] = 255;
|
||||
colcode->color[1] = 255;
|
||||
colcode->color[2] = 255;
|
||||
}
|
||||
}
|
||||
|
||||
int* Polyparti::ParticleField::getColor() {
|
||||
return colcode->color;
|
||||
}
|
||||
|
||||
int Polyparti::ParticleField::getCount() {
|
||||
return colcode->count;
|
||||
}
|
||||
|
||||
void Polyparti::ParticleField::setInterval(const float interval) {
|
||||
colcode->t = interval;
|
||||
}
|
||||
|
||||
void Polyparti::ParticleField::setDecay(const float t, const float d) {
|
||||
if (t != 0) {
|
||||
colcode->dies = true;
|
||||
colcode->lifeTime = fabs(t);
|
||||
colcode->decay = static_cast<int>(fabs(d) * 255);
|
||||
}
|
||||
}
|
||||
|
||||
bool Polyparti::ParticleField::isDead() {
|
||||
return colcode->dead;
|
||||
}
|
||||
struct Polyparti::Room::ImplRoom {
|
||||
std::vector<XYVector> corners;
|
||||
XYVector midpoint;
|
||||
// std::vector<ParticleField> field;
|
||||
};
|
||||
Polyparti::Room::Room() : implRoom(std::make_unique<ImplRoom>()) {}
|
||||
|
||||
Polyparti::Room::Room(int w, int h) : Room() { screenWidth = w; screenHeight = h;}
|
||||
|
||||
Polyparti::Room::Room(int w, int h, int fps) : Room() {
|
||||
screenWidth = w;
|
||||
screenHeight = h;
|
||||
interval = 1.0f/fps;
|
||||
}
|
||||
Polyparti::Room::~Room() = default;
|
||||
Polyparti::Room::Room(const Room& other)
|
||||
: implRoom(std::make_unique<ImplRoom>(*other.implRoom)),
|
||||
info(other.info),
|
||||
field(other.field),
|
||||
x_min(other.x_min),
|
||||
x_max(other.x_max),
|
||||
y_min(other.y_min),
|
||||
y_max(other.y_max){}
|
||||
Polyparti::Room::Room(Room&& other) noexcept = default;
|
||||
Polyparti::Room& Polyparti::Room::operator=(const Room& other) {
|
||||
if (this != &other) {
|
||||
*implRoom = *other.implRoom;
|
||||
info = other.info;
|
||||
field = other.field;
|
||||
x_min = other.x_min;
|
||||
x_max = other.x_max;
|
||||
y_min = other.y_min;
|
||||
y_max = other.y_max;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
Polyparti::Room& Polyparti::Room::operator=(Room&& other) noexcept = default;
|
||||
|
||||
|
||||
void Polyparti::Room::addCorner(float x, float y) { implRoom->corners.push_back({x,y}); }
|
||||
|
||||
void Polyparti::Room::checkCorners() {
|
||||
if (implRoom->corners.front() != implRoom->corners.back()) { implRoom->corners.push_back(implRoom->corners.front()); }
|
||||
}
|
||||
|
||||
std::vector<XYVector> Polyparti::Room::getCorners() {
|
||||
return implRoom->corners;
|
||||
}
|
||||
void Polyparti::Room::loadRoom(std::string name) {
|
||||
std::ifstream roomfile;
|
||||
std::string line, item;
|
||||
bool relative = false;
|
||||
float a, b, tot_x = 0, tot_y = 0;
|
||||
int n = 0;
|
||||
char check;
|
||||
roomfile.open(name);
|
||||
if (roomfile.is_open()) {check = roomfile.get();}
|
||||
else { std::cout << "error" << std::endl;}
|
||||
|
||||
x_min = screenHeight;
|
||||
y_min = screenWidth;
|
||||
|
||||
if (check == 'r') { relative = true; }
|
||||
|
||||
if (roomfile.is_open()) {
|
||||
while (roomfile >> a >> b) {
|
||||
if (relative) { a *= screenWidth; b *= screenHeight; }
|
||||
addCorner(a,b);
|
||||
tot_x += a;
|
||||
tot_y += b;
|
||||
n++;
|
||||
|
||||
if ( a > x_max) {x_max = a;}
|
||||
if ( a < x_min) {x_min = a;}
|
||||
if ( b > y_max) {y_max = b;}
|
||||
if ( b < y_min) {y_min = b;}
|
||||
}
|
||||
} else {
|
||||
std::cout << "error: rooms/load.room not found" << '\n';
|
||||
}
|
||||
checkCorners();
|
||||
roomfile.close();
|
||||
|
||||
implRoom->midpoint[0] = tot_x / n;
|
||||
implRoom->midpoint[1] = tot_y / n;
|
||||
}
|
||||
|
||||
void Polyparti::Room::loadParticles(std::string name) {
|
||||
fieldInfo newEntry;
|
||||
std::ifstream partfile(name);
|
||||
bool relativeScreen = false;
|
||||
bool relativeRoom = false;
|
||||
int count;
|
||||
float x, y, deg_start, deg_end, life, decay;
|
||||
std::string color;
|
||||
|
||||
char check = partfile.get();
|
||||
if (check =='s') { relativeScreen = true;}
|
||||
else if (check == 'r') { relativeRoom = true; }
|
||||
|
||||
if (partfile.is_open()) {
|
||||
while (partfile >> count >> x >> y >> deg_start >> deg_end >> color) {
|
||||
if (relativeScreen) {
|
||||
x *= screenWidth;
|
||||
y *= screenHeight;
|
||||
} else if (relativeRoom) {
|
||||
x = implRoom->midpoint[0] + (x * (x_max - x_min) / 2);
|
||||
y = implRoom->midpoint[1] + (y * (y_max - y_min) / 2);
|
||||
}
|
||||
newEntry.count = count;
|
||||
newEntry.x = x;
|
||||
newEntry.y = y;
|
||||
newEntry.deg_start = deg_start;
|
||||
newEntry.deg_end = deg_end;
|
||||
newEntry.color = color;
|
||||
//newEntry.life = life;
|
||||
//newEntry.decayRate = decay;
|
||||
|
||||
this->info.push_back(newEntry);
|
||||
}
|
||||
}
|
||||
else {
|
||||
std::cout << "error: particles/load.prtc not found" << '\n';
|
||||
}
|
||||
|
||||
}
|
||||
void Polyparti::Room::initField(Polyparti::Room::fieldInfo info) {
|
||||
ParticleField newField;
|
||||
double rad = 4 * std::acos(0.0);
|
||||
info.deg_start = (info.deg_start / 360) * rad;
|
||||
info.deg_end = (info.deg_end/360) * rad;
|
||||
for (int i = 0; i < info.count; i++) {
|
||||
double angle = (float(i) / info.count) * (info.deg_end - info.deg_start);
|
||||
newField.addParticle(info.x, info.y, velocity * (std::cos(angle + info.deg_start)), velocity * (std::sin(angle + info.deg_start)));
|
||||
}
|
||||
newField.setColor(info.color);
|
||||
newField.setInterval(interval);
|
||||
newField.setDecay(info.life, info.decayRate);
|
||||
field.push_back(std::move(newField));
|
||||
}
|
||||
|
||||
void Polyparti::Room::rotateRoom(float degrees) {
|
||||
float rad = (degrees / 360) * 4 * std::acos(0.0);
|
||||
|
||||
/*float tot_x = 0, tot_y = 0;
|
||||
int n = implRoom->corners.size();
|
||||
for (auto& point : implRoom->corners) {
|
||||
tot_x += point[0];
|
||||
tot_y += point[1];
|
||||
}
|
||||
implRoom->midpoint[0] = tot_x / n;
|
||||
implRoom->midpoint[1] = tot_y / n;*/
|
||||
|
||||
for (auto& point : implRoom->corners) {
|
||||
float temp = point[0];
|
||||
point[0] = ((temp - implRoom->midpoint[0]) * std::cos(rad) - (point[1] - (implRoom->midpoint[1])) * std::sin(rad));
|
||||
point[1] = ((temp - implRoom->midpoint[0]) * std::sin(rad) + (point[1] - (implRoom->midpoint[1])) * std::cos(rad));
|
||||
point[0] += implRoom->midpoint[0];
|
||||
point[1] += implRoom->midpoint[1];
|
||||
}
|
||||
}
|
||||
|
||||
void Polyparti::Room::addFields() { for (auto& i: info) initField(i);}
|
||||
|
||||
void Polyparti::Room::updateFields() {
|
||||
for (auto& f : field) {
|
||||
f.updateField(implRoom->corners);
|
||||
}
|
||||
field.erase(std::remove_if(field.begin(), field.end(), [](auto& f) { return f.isDead();}), field.end());
|
||||
}
|
||||
|
||||
|
||||
|
||||
Polyparti::ParticleField& Polyparti::Room::getField(int index) { return field.at(index); }
|
||||
|
||||
void Polyparti::Room::adjustInterval(const float diff) {
|
||||
//float diff = 1.0 + pct;
|
||||
interval += diff;
|
||||
for (auto &f : field) {
|
||||
f.setInterval(diff);
|
||||
}
|
||||
}
|
||||
|
||||
void Polyparti::Room::reverseInterval() {
|
||||
interval = -interval;
|
||||
for (auto &f : field) {
|
||||
f.setInterval(interval);
|
||||
}
|
||||
}
|
||||
int Polyparti::Room::getFieldCount() {
|
||||
return field.size();
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
#pragma once
|
||||
#include <vector>
|
||||
#include <array>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
typedef std::array<float, 2> XYVector;
|
||||
|
||||
//enum Colors {pRED, pORANGE, pYELLOW, pGREEN, pBLUE, pINDIGO, pVIOLET};
|
||||
namespace Polyparti {
|
||||
/*inline static float interval = 1.0f / 60;
|
||||
inline static float velocity = 100;
|
||||
static int screenWidth, screenHeight;*/
|
||||
|
||||
class ParticleField {
|
||||
public:
|
||||
ParticleField();
|
||||
~ParticleField();
|
||||
ParticleField(const ParticleField& other);
|
||||
ParticleField(ParticleField&& other) noexcept;
|
||||
ParticleField& operator=(const ParticleField& other);
|
||||
ParticleField& operator=(ParticleField&& other) noexcept;
|
||||
|
||||
|
||||
void addParticle(float x, float y, float vx, float vy);
|
||||
void deleteParticle(int index);
|
||||
void updateField(std::vector<XYVector> verticies);
|
||||
const std::vector<XYVector>& getPositions() const;
|
||||
int getSize();
|
||||
void setColor(std::string newColor);
|
||||
int* getColor();
|
||||
void setCount(int count);
|
||||
int getCount();
|
||||
void setInterval(const float diff);
|
||||
void setDecay(const float t, const float d);
|
||||
bool isDead();
|
||||
|
||||
private:
|
||||
struct ColCode;
|
||||
std::unique_ptr<ColCode> colcode;
|
||||
};
|
||||
|
||||
class Room {
|
||||
private:
|
||||
struct ImplRoom;
|
||||
std::unique_ptr<ImplRoom> implRoom;
|
||||
struct fieldInfo {
|
||||
int count;
|
||||
float x, y, deg_start, deg_end, life, decayRate;
|
||||
int screenWidth, screenHeight;
|
||||
std::string color;
|
||||
};
|
||||
std::vector<fieldInfo> info;
|
||||
std::vector<ParticleField> field;
|
||||
float x_min = 0, x_max = 0, y_min = 0, y_max = 0;
|
||||
inline static float interval = 1.0f / 60;
|
||||
inline static float velocity = 90;
|
||||
inline static float screenWidth = 1920;
|
||||
inline static float screenHeight = 1080;
|
||||
public:
|
||||
//std::vector<ParticleField> field;
|
||||
|
||||
//std::vector<fieldInfo> info;
|
||||
int fieldCount = 0;
|
||||
|
||||
Room();
|
||||
Room(int w, int h);
|
||||
Room(int w, int h, int fps);
|
||||
~Room();
|
||||
Room(const Room& other);
|
||||
Room(Room&& other) noexcept;
|
||||
Room& operator=(const Room& other);
|
||||
Room& operator=(Room&& other) noexcept;
|
||||
|
||||
static void setFPS(const int fps) {
|
||||
interval = 1.0f / fps;
|
||||
}
|
||||
void addCorner(float x, float y);
|
||||
void checkCorners();
|
||||
std::vector<XYVector> getCorners(); //implement
|
||||
void loadRoom(std::string name);
|
||||
void loadParticles(std::string name);
|
||||
void rotateRoom(float degrees);
|
||||
void initField(fieldInfo info);
|
||||
void addFields();
|
||||
void updateFields();
|
||||
ParticleField& getField(int index);
|
||||
void adjustInterval(const float pct);
|
||||
void reverseInterval();
|
||||
int getFieldCount();
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,6 @@
|
||||
r
|
||||
0.5 0.1
|
||||
0.725 0.5
|
||||
0.5 0.9
|
||||
0.275 0.5
|
||||
0.5 0.1
|
||||
@@ -0,0 +1,8 @@
|
||||
r
|
||||
0.361979 0.0601852
|
||||
0.6479167 0.0601852
|
||||
0.790625 0.5
|
||||
0.6479167 0.9398148
|
||||
0.361979 0.9398148
|
||||
0.209375 0.5
|
||||
0.361979 0.0601852
|
||||
@@ -0,0 +1,5 @@
|
||||
r
|
||||
0.5 0.111615741
|
||||
0.754148958 0.894191667
|
||||
0.245851042 0.894191667
|
||||
0.5 0.111615741
|
||||
@@ -0,0 +1,6 @@
|
||||
r
|
||||
0.5 0.05
|
||||
0.75 0.5
|
||||
0.5 0.95
|
||||
0.25 0.5
|
||||
0.5 0.05
|
||||
@@ -0,0 +1,6 @@
|
||||
r
|
||||
0.1 0.1
|
||||
0.9 0.1
|
||||
0.9 0.9
|
||||
0.1 0.9
|
||||
0.1 0.1
|
||||
@@ -0,0 +1,6 @@
|
||||
r
|
||||
0 0
|
||||
1 0
|
||||
1 1
|
||||
0 1
|
||||
0 0
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user