handle custom platform
This commit is contained in:
parent
0748dc2d1e
commit
30ccc969de
4 changed files with 3514 additions and 10 deletions
38
external/examples/example_for_custom_platform_1/CMakeLists.txt
vendored
Normal file
38
external/examples/example_for_custom_platform_1/CMakeLists.txt
vendored
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
cmake_minimum_required(VERSION 3.0)
|
||||
|
||||
# This should be absolute to where raylib lives
|
||||
set(RAYLIB_ROOT_DIR "${CMAKE_CURRENT_LIST_DIR}/../../..")
|
||||
|
||||
if(PLATFORM STREQUAL "Custom")
|
||||
set(PLATFORM_CUSTOM_ROOT_DIR "${CMAKE_CURRENT_LIST_DIR}/../../custom_platforms/custom_platform_1")
|
||||
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --profiling-funcs -s USE_GLFW=3 -s ASSERTIONS=1 -s WASM=1 -s ASYNCIFY -s SAFE_HEAP=1")
|
||||
endif()
|
||||
|
||||
project(example_for_custom_platform_1 LANGUAGES CXX)
|
||||
|
||||
set(target "example_for_custom_platform_1")
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
|
||||
#######################################################
|
||||
# adding raylib
|
||||
# Note: raylib is bundled in this project but could
|
||||
# easily be fetched instead
|
||||
#######################################################
|
||||
add_subdirectory("${RAYLIB_ROOT_DIR}" raylib EXCLUDE_FROM_ALL)
|
||||
|
||||
#######################################################
|
||||
# Main executable
|
||||
#######################################################
|
||||
add_executable(${target} main.cpp)
|
||||
target_link_libraries(${target} PUBLIC raylib)
|
||||
|
||||
if(PLATFORM STREQUAL "Custom")
|
||||
set(CMAKE_EXECUTABLE_SUFFIX ".html")
|
||||
set(EMSDK "$ENV{EMSDK}" CACHE PATH "Location of the emscript sdk")
|
||||
if("${EMSDK}" STREQUAL "")
|
||||
message(FATAL_ERROR "Make sure you define the variable EMSDK (either as an environment variable or as a CMake -DEMSDK=... option).")
|
||||
endif()
|
||||
target_include_directories(${target} PUBLIC "${EMSDK}/emscripten/main/cache/sysroot/include")
|
||||
endif()
|
||||
28
external/examples/example_for_custom_platform_1/main.cpp
vendored
Normal file
28
external/examples/example_for_custom_platform_1/main.cpp
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
#include "raylib.h"
|
||||
|
||||
static char BUF[1024];
|
||||
|
||||
int main()
|
||||
{
|
||||
double width = 850;
|
||||
double height = 450;
|
||||
|
||||
SetConfigFlags(FLAG_WINDOW_RESIZABLE);
|
||||
InitWindow((int) width, (int) height, "raylib custom platform 1 (web)");
|
||||
|
||||
SetTargetFPS(60);
|
||||
|
||||
while (!WindowShouldClose())
|
||||
{
|
||||
BeginDrawing();
|
||||
ClearBackground(RAYWHITE);
|
||||
DrawText("Congrats! You created your first window!", 10, 40, 20, LIGHTGRAY);
|
||||
DrawLine(0, 0, GetScreenWidth(), GetScreenHeight(), RED);
|
||||
DrawFPS(10, 70);
|
||||
EndDrawing();
|
||||
}
|
||||
|
||||
CloseWindow();
|
||||
|
||||
return 0;
|
||||
}
|
||||
30
external/examples/example_for_custom_platform_2/CMakeLists.txt
vendored
Normal file
30
external/examples/example_for_custom_platform_2/CMakeLists.txt
vendored
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
cmake_minimum_required(VERSION 3.0)
|
||||
|
||||
# This should be absolute to where raylib lives
|
||||
set(RAYLIB_ROOT_DIR "${CMAKE_CURRENT_LIST_DIR}/../../..")
|
||||
|
||||
if(PLATFORM STREQUAL "Custom")
|
||||
# custom_platform_2 requires GLFW_ROOT_DIR to be set
|
||||
set(GLFW_ROOT_DIR "${RAYLIB_ROOT_DIR}/src/external/glfw")
|
||||
set(PLATFORM_CUSTOM_ROOT_DIR "${CMAKE_CURRENT_LIST_DIR}/../../custom_platforms/custom_platform_2")
|
||||
endif()
|
||||
|
||||
project(example_for_custom_platform_2 LANGUAGES CXX)
|
||||
|
||||
set(target "example_for_custom_platform_2")
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
|
||||
#######################################################
|
||||
# adding raylib
|
||||
# Note: raylib is bundled in this project but could
|
||||
# easily be fetched instead
|
||||
#######################################################
|
||||
add_subdirectory("${RAYLIB_ROOT_DIR}" raylib EXCLUDE_FROM_ALL)
|
||||
|
||||
#######################################################
|
||||
# Main executable
|
||||
#######################################################
|
||||
add_executable(${target} main.cpp)
|
||||
target_link_libraries(${target} PUBLIC raylib)
|
||||
|
||||
28
external/examples/example_for_custom_platform_2/main.cpp
vendored
Normal file
28
external/examples/example_for_custom_platform_2/main.cpp
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
#include "raylib.h"
|
||||
|
||||
static char BUF[1024];
|
||||
|
||||
int main()
|
||||
{
|
||||
double width = 850;
|
||||
double height = 450;
|
||||
|
||||
SetConfigFlags(FLAG_WINDOW_RESIZABLE);
|
||||
InitWindow((int) width, (int) height, "raylib custom platform 1 (web)");
|
||||
|
||||
SetTargetFPS(60);
|
||||
|
||||
while (!WindowShouldClose())
|
||||
{
|
||||
BeginDrawing();
|
||||
ClearBackground(RAYWHITE);
|
||||
DrawText("Congrats! You created your first window!", 10, 40, 20, LIGHTGRAY);
|
||||
DrawLine(0, 0, GetScreenWidth(), GetScreenHeight(), RED);
|
||||
DrawFPS(10, 70);
|
||||
EndDrawing();
|
||||
}
|
||||
|
||||
CloseWindow();
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
Reference in a new issue