diff --git a/CMakeLists.txt b/CMakeLists.txt index 2c592aa..3438652 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,8 @@ project (raylib-cpp) option(BUILD_EXAMPLES "Examples" TRUE) set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) add_subdirectory(include) diff --git a/projects/CMake/CMakeLists.txt b/projects/CMake/CMakeLists.txt new file mode 100644 index 0000000..2590f83 --- /dev/null +++ b/projects/CMake/CMakeLists.txt @@ -0,0 +1,52 @@ +cmake_minimum_required(VERSION 3.11) # FetchContent is available in 3.11+ +project(example) + +find_package(raylib 2.0 QUIET) +if (NOT raylib_FOUND) + include(FetchContent) + FetchContent_Declare( + raylib + GIT_REPOSITORY https://github.com/raysan5/raylib.git + GIT_TAG 6f2f09947f5456cefb3d91d3f667f4d72fa55be6 + ) + FetchContent_GetProperties(raylib) + if (NOT raylib_POPULATED) # Have we downloaded raylib yet? + set(FETCHCONTENT_QUIET NO) + FetchContent_Populate(raylib) + set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) + set(BUILD_GAMES OFF CACHE BOOL "" FORCE) + set(BUILD_TESTING OFF CACHE BOOL "" FORCE) + add_subdirectory(${raylib_SOURCE_DIR} ${raylib_BINARY_DIR}) + endif() +endif() + +find_package(raylib-cpp 2.0 QUIET) +if (NOT raylib-cpp_FOUND) + include(FetchContent) + FetchContent_Declare( + raylib-cpp + GIT_REPOSITORY https://github.com/RobLoach/raylib-cpp.git + GIT_TAG de5e6184d043e9ae3e5a16836bc810b7485e95f2 + ) + FetchContent_GetProperties(raylib-cpp) + if (NOT raylib-cpp_POPULATED) # Have we downloaded raylib yet? + set(FETCHCONTENT_QUIET NO) + FetchContent_Populate(raylib-cpp) + set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) + set(BUILD_GAMES OFF CACHE BOOL "" FORCE) + set(BUILD_TESTING OFF CACHE BOOL "" FORCE) + add_subdirectory(${raylib-cpp_SOURCE_DIR} ${raylib-cpp_BINARY_DIR}) + endif() +endif() + +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +# This is the main part: +set(PROJECT_NAME core_basic_window) +set(PROJECT_SOURCES core_basic_window.cpp) +add_executable(${PROJECT_NAME} ${PROJECT_SOURCES}) +#set(raylib_VERBOSE 1) +target_link_libraries(${PROJECT_NAME} PUBLIC raylib raylib-cpp) + +# That's it! You should have an example executable that you can run. Have fun! diff --git a/projects/CMake/core_basic_window.cpp b/projects/CMake/core_basic_window.cpp new file mode 100644 index 0000000..9a78f1f --- /dev/null +++ b/projects/CMake/core_basic_window.cpp @@ -0,0 +1,58 @@ +/******************************************************************************************* +* +* raylib [core] example - Basic window +* +* Welcome to raylib! +* +* To test examples, just press F6 and execute raylib_compile_execute script +* Note that compiled executable is placed in the same folder as .c file +* +* You can find all basic examples on C:\raylib\raylib\examples folder or +* raylib official webpage: www.raylib.com +* +* Enjoy using raylib. :) +* +* This example has been created using raylib 1.0 (www.raylib.com) +* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) +* +* Copyright (c) 2014 Ramon Santamaria (@raysan5) +* +********************************************************************************************/ + +#include "raylib/raylib.hpp" + +int main() +{ + // Initialization + //-------------------------------------------------------------------------------------- + int screenWidth = 800; + int screenHeight = 450; + raylib::Color background(RAYWHITE); + raylib::Color textColor(LIGHTGRAY); + raylib::Window w(screenWidth, screenHeight, "raylib [core] example - basic window"); + + SetTargetFPS(60); + //-------------------------------------------------------------------------------------- + + // Main game loop + while (!w.ShouldClose()) // Detect window close button or ESC key + { + // Update + //---------------------------------------------------------------------------------- + // TODO: Update your variables here + //---------------------------------------------------------------------------------- + + // Draw + //---------------------------------------------------------------------------------- + BeginDrawing(); + + background.ClearBackground(); + + textColor.DrawText("Congrats! You created your first window!", 190, 200, 20); + + EndDrawing(); + //---------------------------------------------------------------------------------- + } + + return 0; +}