g
This commit is contained in:
parent
90ac688f3d
commit
42764b5dd6
4 changed files with 175 additions and 81 deletions
161
CMakeLists.txt
161
CMakeLists.txt
|
@ -5,8 +5,8 @@
|
||||||
cmake_minimum_required(VERSION 3.22)
|
cmake_minimum_required(VERSION 3.22)
|
||||||
|
|
||||||
project(sortiva
|
project(sortiva
|
||||||
LANGUAGES CXX
|
LANGUAGES CXX
|
||||||
VERSION 1.0.0
|
VERSION 1.0.0
|
||||||
)
|
)
|
||||||
|
|
||||||
# ========================================================
|
# ========================================================
|
||||||
|
@ -30,35 +30,35 @@ set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE) # Build static
|
||||||
# It then sets the folder property for the target.
|
# It then sets the folder property for the target.
|
||||||
|
|
||||||
function(put_targets_into_folder)
|
function(put_targets_into_folder)
|
||||||
set(oneValueArgs FOLDER)
|
set(oneValueArgs FOLDER)
|
||||||
set(multiValueArgs TARGETS)
|
set(multiValueArgs TARGETS)
|
||||||
cmake_parse_arguments(ARGS "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
cmake_parse_arguments(ARGS "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||||
|
|
||||||
foreach(target ${ARGS_TARGETS})
|
foreach(target ${ARGS_TARGETS})
|
||||||
# Check if target exists
|
# Check if target exists
|
||||||
if (NOT TARGET ${target})
|
if (NOT TARGET ${target})
|
||||||
message(FATAL_ERROR "${target} target not found")
|
message(FATAL_ERROR "${target} target not found")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Get the actual target (if it is aliased)
|
# Get the actual target (if it is aliased)
|
||||||
get_target_property(actual_target ${target} ALIASED_TARGET)
|
get_target_property(actual_target ${target} ALIASED_TARGET)
|
||||||
if (NOT actual_target)
|
if (NOT actual_target)
|
||||||
set(actual_target ${target})
|
set(actual_target ${target})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Set the folder property for the target
|
# Set the folder property for the target
|
||||||
set_target_properties(${actual_target} PROPERTIES FOLDER ${ARGS_FOLDER})
|
set_target_properties(${actual_target} PROPERTIES FOLDER ${ARGS_FOLDER})
|
||||||
endforeach()
|
endforeach()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
|
||||||
function(find_files var_name path)
|
function(find_files var_name path)
|
||||||
set(sources)
|
set(sources)
|
||||||
foreach(ext ${ARGN})
|
foreach(ext ${ARGN})
|
||||||
file(GLOB_RECURSE files "${path}/*.${ext}")
|
file(GLOB_RECURSE files "${path}/*.${ext}")
|
||||||
list(APPEND sources ${files})
|
list(APPEND sources ${files})
|
||||||
endforeach()
|
endforeach()
|
||||||
set(${var_name} ${${var_name}} ${sources} PARENT_SCOPE)
|
set(${var_name} ${${var_name}} ${sources} PARENT_SCOPE)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
# ========================================================
|
# ========================================================
|
||||||
|
@ -87,9 +87,9 @@ FetchContent_MakeAvailable(sol2)
|
||||||
|
|
||||||
# --- Add Lua
|
# --- Add Lua
|
||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
lua
|
lua
|
||||||
GIT_REPOSITORY "https://github.com/marovira/lua"
|
GIT_REPOSITORY "https://github.com/marovira/lua"
|
||||||
GIT_TAG "5.4.4"
|
GIT_TAG "5.4.4"
|
||||||
)
|
)
|
||||||
FetchContent_MakeAvailable(lua)
|
FetchContent_MakeAvailable(lua)
|
||||||
|
|
||||||
|
@ -103,11 +103,11 @@ set(SOL2_ENABLE_INSTALL OFF CACHE BOOL "" FORCE)
|
||||||
# that are shared among all targets.
|
# that are shared among all targets.
|
||||||
|
|
||||||
function(set_common_properties target)
|
function(set_common_properties target)
|
||||||
target_link_libraries(${target} PRIVATE sol2::sol2) # Link with Sol2
|
target_link_libraries(${target} PRIVATE sol2::sol2) # Link with Sol2
|
||||||
target_compile_definitions(${target} PRIVATE SOL_ALL_SAFETIES_ON=1)
|
target_compile_definitions(${target} PRIVATE SOL_ALL_SAFETIES_ON=1)
|
||||||
target_include_directories(${target} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include) # Include project headers
|
target_include_directories(${target} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include) # Include project headers
|
||||||
target_sources(${target} PRIVATE ${SVA_COMMON_FILES}) # Include common files
|
target_sources(${target} PRIVATE ${SVA_COMMON_FILES}) # Include common files
|
||||||
target_link_libraries(${target} PRIVATE lua::lua)
|
target_link_libraries(${target} PRIVATE lua::lua)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
# ========================================================
|
# ========================================================
|
||||||
|
@ -118,7 +118,7 @@ set(GUI_TARGET_NAME "${PROJECT_NAME}")
|
||||||
# --- Create GUI Executable
|
# --- Create GUI Executable
|
||||||
find_files(SVA_GUI_FILES "./src/" hpp cpp h c hxx cxx)
|
find_files(SVA_GUI_FILES "./src/" hpp cpp h c hxx cxx)
|
||||||
add_executable(${GUI_TARGET_NAME}
|
add_executable(${GUI_TARGET_NAME}
|
||||||
${SVA_GUI_FILES}
|
${SVA_GUI_FILES}
|
||||||
)
|
)
|
||||||
|
|
||||||
source_group(TREE ${PROJECT_SOURCE_DIR}/src/ PREFIX "Source" FILES ${SVA_GUI_FILES})
|
source_group(TREE ${PROJECT_SOURCE_DIR}/src/ PREFIX "Source" FILES ${SVA_GUI_FILES})
|
||||||
|
@ -127,53 +127,68 @@ source_group(TREE ${PROJECT_SOURCE_DIR}/src/ PREFIX "Source" FILES ${SVA_GUI_FIL
|
||||||
# RAYLIB
|
# RAYLIB
|
||||||
# ---------------
|
# ---------------
|
||||||
# Dependencies
|
# Dependencies
|
||||||
set(RAYLIB_VERSION 5.0)
|
set(RAYLIB_VERSION 5.5)
|
||||||
find_package(raylib ${RAYLIB_VERSION} QUIET) # QUIET or REQUIRED
|
find_package(raylib ${RAYLIB_VERSION} QUIET) # QUIET or REQUIRED
|
||||||
|
|
||||||
if (NOT raylib_FOUND) # If there's none, fetch and build raylib
|
if (NOT raylib_FOUND) # If there's none, fetch and build raylib
|
||||||
include(FetchContent)
|
include(FetchContent)
|
||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
raylib
|
raylib
|
||||||
DOWNLOAD_EXTRACT_TIMESTAMP OFF
|
DOWNLOAD_EXTRACT_TIMESTAMP OFF
|
||||||
URL https://github.com/raysan5/raylib/archive/refs/tags/${RAYLIB_VERSION}.tar.gz
|
URL https://github.com/raysan5/raylib/archive/refs/tags/${RAYLIB_VERSION}.tar.gz
|
||||||
)
|
)
|
||||||
FetchContent_GetProperties(raylib)
|
FetchContent_GetProperties(raylib)
|
||||||
if (NOT raylib_POPULATED) # Have we downloaded raylib yet?
|
if (NOT raylib_POPULATED) # Have we downloaded raylib yet?
|
||||||
set(FETCHCONTENT_QUIET NO)
|
set(FETCHCONTENT_QUIET NO)
|
||||||
FetchContent_MakeAvailable(raylib)
|
FetchContent_MakeAvailable(raylib)
|
||||||
set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) # don't build the supplied examples
|
set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) # don't build the supplied examples
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_link_libraries(${GUI_TARGET_NAME} PRIVATE raylib)
|
# raylib-cpp
|
||||||
|
find_package(raylib_cpp QUIET)
|
||||||
|
if (NOT raylib_cpp_FOUND)
|
||||||
|
if (NOT DEFINED RAYLIB_CPP_VERSION)
|
||||||
|
set(RAYLIB_CPP_VERSION next)
|
||||||
|
endif()
|
||||||
|
include(FetchContent)
|
||||||
|
FetchContent_Declare(
|
||||||
|
raylib_cpp
|
||||||
|
GIT_REPOSITORY https://github.com/RobLoach/raylib-cpp.git
|
||||||
|
GIT_TAG ${RAYLIB_CPP_VERSION}
|
||||||
|
)
|
||||||
|
FetchContent_MakeAvailable(raylib_cpp)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
target_link_libraries(${GUI_TARGET_NAME} PRIVATE raylib raylib_cpp)
|
||||||
|
|
||||||
# Checks if OSX and links appropriate frameworks (Only required on MacOS)
|
# Checks if OSX and links appropriate frameworks (Only required on MacOS)
|
||||||
if (APPLE)
|
if (APPLE)
|
||||||
target_link_libraries(${PROJECT_NAME} "-framework IOKit")
|
target_link_libraries(${PROJECT_NAME} "-framework IOKit")
|
||||||
target_link_libraries(${PROJECT_NAME} "-framework Cocoa")
|
target_link_libraries(${PROJECT_NAME} "-framework Cocoa")
|
||||||
target_link_libraries(${PROJECT_NAME} "-framework OpenGL")
|
target_link_libraries(${PROJECT_NAME} "-framework OpenGL")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set_common_properties(${GUI_TARGET_NAME})
|
set_common_properties(${GUI_TARGET_NAME})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
put_targets_into_folder(
|
put_targets_into_folder(
|
||||||
FOLDER "ThirdParty/raylib"
|
FOLDER "ThirdParty/raylib"
|
||||||
TARGETS
|
TARGETS
|
||||||
raylib uninstall
|
raylib raylib_cpp uninstall
|
||||||
)
|
)
|
||||||
|
|
||||||
put_targets_into_folder(
|
put_targets_into_folder(
|
||||||
FOLDER "ThirdParty/lua"
|
FOLDER "ThirdParty/lua"
|
||||||
TARGETS
|
TARGETS
|
||||||
lua lua_lib
|
lua lua_lib
|
||||||
)
|
)
|
||||||
|
|
||||||
put_targets_into_folder(
|
put_targets_into_folder(
|
||||||
FOLDER "ThirdParty/glfw"
|
FOLDER "ThirdParty/glfw"
|
||||||
TARGETS
|
TARGETS
|
||||||
glfw update_mappings
|
glfw update_mappings
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -182,17 +197,17 @@ put_targets_into_folder(
|
||||||
set(SVA_CREATE_INCLUDES_TARGET ON CACHE BOOL "Create an includes target")
|
set(SVA_CREATE_INCLUDES_TARGET ON CACHE BOOL "Create an includes target")
|
||||||
|
|
||||||
if(${SVA_CREATE_INCLUDES_TARGET})
|
if(${SVA_CREATE_INCLUDES_TARGET})
|
||||||
set(INCLUDES_TARGET_NAME "includes")
|
set(INCLUDES_TARGET_NAME "includes")
|
||||||
set(INCLUDE_FILES)
|
set(INCLUDE_FILES)
|
||||||
find_files(
|
find_files(
|
||||||
INCLUDE_FILES
|
INCLUDE_FILES
|
||||||
"include/"
|
"include/"
|
||||||
hpp h hxx
|
hpp h hxx
|
||||||
)
|
)
|
||||||
message(STATUS "Include files: ${INCLUDE_FILES}")
|
message(STATUS "Include files: ${INCLUDE_FILES}")
|
||||||
add_custom_target(${INCLUDES_TARGET_NAME}
|
add_custom_target(${INCLUDES_TARGET_NAME}
|
||||||
SOURCES
|
SOURCES
|
||||||
${INCLUDE_FILES}
|
${INCLUDE_FILES}
|
||||||
)
|
)
|
||||||
source_group(TREE ${PROJECT_SOURCE_DIR}/include/ PREFIX "Source" FILES ${INCLUDE_FILES})
|
source_group(TREE ${PROJECT_SOURCE_DIR}/include/ PREFIX "Source" FILES ${INCLUDE_FILES})
|
||||||
endif()
|
endif()
|
||||||
|
|
80
include/raylibs/raylib-cpp.hpp
Normal file
80
include/raylibs/raylib-cpp.hpp
Normal file
|
@ -0,0 +1,80 @@
|
||||||
|
/**
|
||||||
|
* [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 "./AutomationEventList.hpp"
|
||||||
|
#include "./BoundingBox.hpp"
|
||||||
|
#include "./Camera2D.hpp"
|
||||||
|
#include "./Camera3D.hpp"
|
||||||
|
#include "./Color.hpp"
|
||||||
|
#include "./FileData.hpp"
|
||||||
|
#include "./FileText.hpp"
|
||||||
|
#include "./Font.hpp"
|
||||||
|
#include "./Functions.hpp"
|
||||||
|
#include "./Gamepad.hpp"
|
||||||
|
#include "./Image.hpp"
|
||||||
|
#include "./Keyboard.hpp"
|
||||||
|
#include "./Material.hpp"
|
||||||
|
#include "./Matrix.hpp"
|
||||||
|
#include "./Mesh.hpp"
|
||||||
|
#include "./Model.hpp"
|
||||||
|
#include "./ModelAnimation.hpp"
|
||||||
|
#include "./Mouse.hpp"
|
||||||
|
#include "./Music.hpp"
|
||||||
|
#include "./Ray.hpp"
|
||||||
|
#include "./RayCollision.hpp"
|
||||||
|
#include "./RaylibException.hpp"
|
||||||
|
#include "./Rectangle.hpp"
|
||||||
|
#include "./RenderTexture.hpp"
|
||||||
|
#include "./Shader.hpp"
|
||||||
|
#include "./Sound.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 "./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_
|
|
@ -3,16 +3,10 @@
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#define RL_COLOR(COLOR) rl::##COLOR
|
|
||||||
|
|
||||||
namespace rl {
|
Sortiva::Sortiva() : wnd(1280, 720, "Sortiva", rl::FLAG_WINDOW_RESIZABLE | rl::FLAG_WINDOW_TRANSPARENT)
|
||||||
#include <raylib.h>
|
|
||||||
}
|
|
||||||
|
|
||||||
Sortiva::Sortiva()
|
|
||||||
{
|
{
|
||||||
rl::InitWindow(1280, 720, "Sortiva");
|
if (!wnd.IsWindowReady())
|
||||||
if (!rl::IsWindowReady())
|
|
||||||
{
|
{
|
||||||
printf("Window could not be initialized\n");
|
printf("Window could not be initialized\n");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
#include <raylib-cpp.hpp>
|
||||||
|
|
||||||
|
namespace rl = raylib;
|
||||||
|
|
||||||
class Sortiva final
|
class Sortiva final
|
||||||
{
|
{
|
||||||
|
@ -10,6 +14,7 @@ public:
|
||||||
|
|
||||||
void run();
|
void run();
|
||||||
private:
|
private:
|
||||||
|
rl::Window wnd;
|
||||||
int m_Width;
|
int m_Width;
|
||||||
int m_Height;
|
int m_Height;
|
||||||
bool m_Running;
|
bool m_Running;
|
||||||
|
|
Loading…
Reference in a new issue