actually add vendor folder
This commit is contained in:
@@ -0,0 +1 @@
|
||||
/build
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
cmake_minimum_required(VERSION 3.14)
|
||||
project(raylib_cpp_example)
|
||||
|
||||
# raylib
|
||||
find_package(raylib QUIET)
|
||||
if (NOT raylib_FOUND)
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(
|
||||
raylib
|
||||
GIT_REPOSITORY https://github.com/raysan5/raylib.git
|
||||
GIT_TAG 5.0
|
||||
GIT_SHALLOW 1
|
||||
)
|
||||
FetchContent_MakeAvailable(raylib)
|
||||
endif()
|
||||
|
||||
# raylib-cpp
|
||||
find_package(raylib_cpp QUIET)
|
||||
if (NOT raylib_cpp_FOUND)
|
||||
if (NOT DEFINED RAYLIB_CPP_VERSION)
|
||||
set(RAYLIB_CPP_VERSION v5.0.2)
|
||||
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()
|
||||
|
||||
# This is the main part:
|
||||
set(SOURCES main.cpp)
|
||||
add_executable(${PROJECT_NAME} ${SOURCES})
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 11)
|
||||
target_link_libraries(${PROJECT_NAME} PUBLIC raylib raylib_cpp)
|
||||
|
||||
# Web Configurations
|
||||
if (${PLATFORM} STREQUAL "Web")
|
||||
# Tell Emscripten to build an example.html file.
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES SUFFIX ".html")
|
||||
|
||||
# Required linker flags for using Raylib with Emscripten
|
||||
target_link_options(${PROJECT_NAME} PRIVATE -sEXPORTED_FUNCTIONS=['_main','_malloc'] -sEXPORTED_RUNTIME_METHODS=ccall -sUSE_GLFW=3)
|
||||
endif()
|
||||
|
||||
# That's it! You should have an example executable that you can run. Have fun!
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
# raylib-cpp CMake Example Project
|
||||
|
||||
Use this template to build a [raylib-cpp](https://github.com/RobLoach/raylib-cpp) project using [CMake](https://cmake.org).
|
||||
|
||||
## Build
|
||||
|
||||
To build this project, make sure to have CMake installed locally.
|
||||
|
||||
### Desktop
|
||||
|
||||
```
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ..
|
||||
make
|
||||
```
|
||||
|
||||
### Web
|
||||
|
||||
```
|
||||
mkdir build
|
||||
cd build
|
||||
emcmake cmake .. -DPLATFORM=Web -DCMAKE_BUILD_TYPE=Release
|
||||
emmake make
|
||||
```
|
||||
|
||||
## Run
|
||||
|
||||
```
|
||||
./raylib-cpp-example
|
||||
```
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raylib-cpp [core] example - Basic window (adapted for HTML5 platform)
|
||||
*
|
||||
* This example is prepared to compile for PLATFORM_WEB, PLATFORM_DESKTOP and PLATFORM_RPI
|
||||
* As you will notice, code structure is slightly diferent to the other examples...
|
||||
* To compile it for PLATFORM_WEB just uncomment #define PLATFORM_WEB at beginning
|
||||
*
|
||||
* This example has been created using raylib-cpp (www.raylib.com)
|
||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||
*
|
||||
* Copyright (c) 2015 Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib-cpp.hpp"
|
||||
|
||||
#if defined(PLATFORM_WEB)
|
||||
#include <emscripten/emscripten.h>
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Global Variables Definition
|
||||
//----------------------------------------------------------------------------------
|
||||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module Functions Declaration
|
||||
//----------------------------------------------------------------------------------
|
||||
void UpdateDrawFrame(void); // Update and Draw one frame
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Main Enry Point
|
||||
//----------------------------------------------------------------------------------
|
||||
int main()
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
raylib::Window window(screenWidth, screenHeight, "raylib-cpp [core] example - basic window");
|
||||
|
||||
#if defined(PLATFORM_WEB)
|
||||
emscripten_set_main_loop(UpdateDrawFrame, 0, 1);
|
||||
#else
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!window.ShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
UpdateDrawFrame();
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module Functions Definition
|
||||
//----------------------------------------------------------------------------------
|
||||
void UpdateDrawFrame(void)
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
// TODO: Update your variables here
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
DrawText("Congrats! You created your first raylib-cpp window!", 160, 200, 20, LIGHTGRAY);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
Reference in New Issue
Block a user