handle custom platform
removed unecessary section removed external
This commit is contained in:
parent
0748dc2d1e
commit
0cc7828d97
|
|
@ -1,4 +1,13 @@
|
||||||
cmake_minimum_required(VERSION 3.0)
|
cmake_minimum_required(VERSION 3.0)
|
||||||
|
|
||||||
|
# Directory for easier includes
|
||||||
|
# Anywhere you see include(...) you can check <root>/cmake for that file
|
||||||
|
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
||||||
|
|
||||||
|
include(CustomPlatform)
|
||||||
|
|
||||||
|
custom_platform_include_if_exists("raylibPlatformCustomProjectConfig")
|
||||||
|
|
||||||
project(raylib)
|
project(raylib)
|
||||||
|
|
||||||
# Avoid excessive expansion of variables in conditionals. In particular, if
|
# Avoid excessive expansion of variables in conditionals. In particular, if
|
||||||
|
|
@ -18,9 +27,6 @@ cmake_policy(SET CMP0054 NEW)
|
||||||
# See https://cmake.org/cmake/help/latest/policy/CMP0063.html
|
# See https://cmake.org/cmake/help/latest/policy/CMP0063.html
|
||||||
cmake_policy(SET CMP0063 NEW)
|
cmake_policy(SET CMP0063 NEW)
|
||||||
|
|
||||||
# Directory for easier includes
|
|
||||||
# Anywhere you see include(...) you can check <root>/cmake for that file
|
|
||||||
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
|
||||||
|
|
||||||
# RAYLIB_IS_MAIN determines whether the project is being used from root
|
# RAYLIB_IS_MAIN determines whether the project is being used from root
|
||||||
# or if it is added as a dependency (through add_subdirectory for example).
|
# or if it is added as a dependency (through add_subdirectory for example).
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
include(CMakeDependentOption)
|
include(CMakeDependentOption)
|
||||||
include(EnumOption)
|
include(EnumOption)
|
||||||
|
|
||||||
enum_option(PLATFORM "Desktop;Web;Android;Raspberry Pi;DRM" "Platform to build for.")
|
enum_option(PLATFORM "Desktop;Web;Android;Raspberry Pi;DRM;Custom" "Platform to build for.")
|
||||||
|
|
||||||
enum_option(OPENGL_VERSION "OFF;4.3;3.3;2.1;1.1;ES 2.0;ES 3.0" "Force a specific OpenGL Version?")
|
enum_option(OPENGL_VERSION "OFF;4.3;3.3;2.1;1.1;ES 2.0;ES 3.0" "Force a specific OpenGL Version?")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ endif()
|
||||||
# This helps support the case where emsdk toolchain file is used
|
# This helps support the case where emsdk toolchain file is used
|
||||||
# either by setting it with -DCMAKE_TOOLCHAIN_FILE=<path_to_emsdk>/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake
|
# either by setting it with -DCMAKE_TOOLCHAIN_FILE=<path_to_emsdk>/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake
|
||||||
# or by using "emcmake cmake -B build -S ." as described in https://emscripten.org/docs/compiling/Building-Projects.html
|
# or by using "emcmake cmake -B build -S ." as described in https://emscripten.org/docs/compiling/Building-Projects.html
|
||||||
if(EMSCRIPTEN)
|
if(EMSCRIPTEN AND NOT ${PLATFORM} MATCHES "Custom")
|
||||||
SET(PLATFORM Web CACHE STRING "Forcing PLATFORM_WEB because EMSCRIPTEN was detected")
|
SET(PLATFORM Web CACHE STRING "Forcing PLATFORM_WEB because EMSCRIPTEN was detected")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
|
||||||
9
cmake/CustomPlatform.cmake
Normal file
9
cmake/CustomPlatform.cmake
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
macro(custom_platform_include_if_exists file)
|
||||||
|
if("${PLATFORM}" MATCHES "Custom")
|
||||||
|
if (EXISTS "${PLATFORM_CUSTOM_ROOT_DIR}/cmake/${file}.cmake")
|
||||||
|
include("${PLATFORM_CUSTOM_ROOT_DIR}/cmake/${file}.cmake")
|
||||||
|
else ()
|
||||||
|
message(STATUS "No file ${PLATFORM_CUSTOM_ROOT_DIR}/cmake/${file}.cmake detected... skipped")
|
||||||
|
endif ()
|
||||||
|
endif()
|
||||||
|
endmacro()
|
||||||
|
|
@ -91,6 +91,8 @@ elseif ("${PLATFORM}" MATCHES "DRM")
|
||||||
endif ()
|
endif ()
|
||||||
set(LIBS_PRIVATE ${GLESV2} ${EGL} ${DRM} ${GBM} atomic pthread m dl)
|
set(LIBS_PRIVATE ${GLESV2} ${EGL} ${DRM} ${GBM} atomic pthread m dl)
|
||||||
|
|
||||||
|
elseif ("${PLATFORM}" MATCHES "Custom")
|
||||||
|
set(PLATFORM_CPP "PLATFORM_CUSTOM")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
if (NOT ${OPENGL_VERSION} MATCHES "OFF")
|
if (NOT ${OPENGL_VERSION} MATCHES "OFF")
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ set(API_VERSION 450)
|
||||||
|
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
include(JoinPaths)
|
include(JoinPaths)
|
||||||
|
include(CustomPlatform)
|
||||||
|
|
||||||
# Sets build type if not set by now
|
# Sets build type if not set by now
|
||||||
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
||||||
|
|
@ -38,7 +39,7 @@ set(raylib_sources
|
||||||
)
|
)
|
||||||
|
|
||||||
# <root>/cmake/GlfwImport.cmake handles the details around the inclusion of glfw
|
# <root>/cmake/GlfwImport.cmake handles the details around the inclusion of glfw
|
||||||
if (NOT ${PLATFORM} MATCHES "Web")
|
if (NOT ${PLATFORM} MATCHES "Web" AND NOT ${PLATFORM} MATCHES "Custom")
|
||||||
include(GlfwImport)
|
include(GlfwImport)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
|
@ -47,6 +48,8 @@ endif ()
|
||||||
# Produces a variable LIBS_PRIVATE that will be used later
|
# Produces a variable LIBS_PRIVATE that will be used later
|
||||||
include(LibraryConfigurations)
|
include(LibraryConfigurations)
|
||||||
|
|
||||||
|
custom_platform_include_if_exists("raylibPlatformCustomLibraryConfig")
|
||||||
|
|
||||||
if (USE_AUDIO)
|
if (USE_AUDIO)
|
||||||
MESSAGE(STATUS "Audio Backend: miniaudio")
|
MESSAGE(STATUS "Audio Backend: miniaudio")
|
||||||
list(APPEND raylib_sources raudio.c)
|
list(APPEND raylib_sources raudio.c)
|
||||||
|
|
@ -105,6 +108,12 @@ target_include_directories(raylib
|
||||||
${OPENAL_INCLUDE_DIR}
|
${OPENAL_INCLUDE_DIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if("${PLATFORM}" MATCHES "Custom")
|
||||||
|
target_include_directories(raylib PUBLIC "${PLATFORM_CUSTOM_ROOT_DIR}/src")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
custom_platform_include_if_exists("raylibPlatformCustomTargetConfig")
|
||||||
|
|
||||||
# Copy the header files to the build directory for convenience
|
# Copy the header files to the build directory for convenience
|
||||||
file(COPY ${raylib_public_headers} DESTINATION "include")
|
file(COPY ${raylib_public_headers} DESTINATION "include")
|
||||||
|
|
||||||
|
|
|
||||||
12
src/rcore.c
12
src/rcore.c
|
|
@ -235,7 +235,11 @@ __declspec(dllimport) int __stdcall WideCharToMultiByte(unsigned int cp, unsigne
|
||||||
#define FLAG_TOGGLE(n, f) ((n) ^= (f))
|
#define FLAG_TOGGLE(n, f) ((n) ^= (f))
|
||||||
#define FLAG_CHECK(n, f) ((n) & (f))
|
#define FLAG_CHECK(n, f) ((n) & (f))
|
||||||
|
|
||||||
#if (defined(__linux__) || defined(PLATFORM_WEB)) && (_POSIX_C_SOURCE < 199309L)
|
#if defined(PLATFORM_CUSTOM)
|
||||||
|
#include "raylib_platform_custom.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (defined(__linux__) || defined(PLATFORM_WEB) || defined(PLATFORM_CUSTOM_CLOCK_MONOTONIC)) && (_POSIX_C_SOURCE < 199309L)
|
||||||
#undef _POSIX_C_SOURCE
|
#undef _POSIX_C_SOURCE
|
||||||
#define _POSIX_C_SOURCE 199309L // Required for: CLOCK_MONOTONIC if compiled with c99 without gnu ext.
|
#define _POSIX_C_SOURCE 199309L // Required for: CLOCK_MONOTONIC if compiled with c99 without gnu ext.
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -491,6 +495,8 @@ const char *TextFormat(const char *text, ...); // Formatting of tex
|
||||||
#include "platforms/rcore_drm.c"
|
#include "platforms/rcore_drm.c"
|
||||||
#elif defined(PLATFORM_ANDROID)
|
#elif defined(PLATFORM_ANDROID)
|
||||||
#include "platforms/rcore_android.c"
|
#include "platforms/rcore_android.c"
|
||||||
|
#elif defined(PLATFORM_CUSTOM)
|
||||||
|
#include "raylib_platform_custom.c"
|
||||||
#else
|
#else
|
||||||
// TODO: Include your custom platform backend!
|
// TODO: Include your custom platform backend!
|
||||||
// i.e software rendering backend or console backend!
|
// i.e software rendering backend or console backend!
|
||||||
|
|
@ -559,6 +565,8 @@ void InitWindow(int width, int height, const char *title)
|
||||||
TRACELOG(LOG_INFO, "Platform backend: NATIVE DRM");
|
TRACELOG(LOG_INFO, "Platform backend: NATIVE DRM");
|
||||||
#elif defined(PLATFORM_ANDROID)
|
#elif defined(PLATFORM_ANDROID)
|
||||||
TRACELOG(LOG_INFO, "Platform backend: ANDROID");
|
TRACELOG(LOG_INFO, "Platform backend: ANDROID");
|
||||||
|
#elif defined(PLATFORM_CUSTOM)
|
||||||
|
TRACELOG(LOG_INFO, PLATFORM_CUSTOM_BACKEND);
|
||||||
#else
|
#else
|
||||||
// TODO: Include your custom platform backend!
|
// TODO: Include your custom platform backend!
|
||||||
// i.e software rendering backend or console backend!
|
// i.e software rendering backend or console backend!
|
||||||
|
|
@ -3046,7 +3054,7 @@ void InitTimer(void)
|
||||||
// However, it can also reduce overall system performance, because the thread scheduler switches tasks more often.
|
// However, it can also reduce overall system performance, because the thread scheduler switches tasks more often.
|
||||||
// High resolutions can also prevent the CPU power management system from entering power-saving modes.
|
// High resolutions can also prevent the CPU power management system from entering power-saving modes.
|
||||||
// Setting a higher resolution does not improve the accuracy of the high-resolution performance counter.
|
// Setting a higher resolution does not improve the accuracy of the high-resolution performance counter.
|
||||||
#if defined(_WIN32) && defined(SUPPORT_WINMM_HIGHRES_TIMER) && !defined(SUPPORT_BUSY_WAIT_LOOP) && !defined(PLATFORM_DESKTOP_SDL)
|
#if defined(_WIN32) && defined(SUPPORT_WINMM_HIGHRES_TIMER) && !defined(SUPPORT_BUSY_WAIT_LOOP) && !defined(PLATFORM_DESKTOP_SDL) && !defined(PLATFORM_CUSTOM_DISABLE_HI_RES_TIMER)
|
||||||
timeBeginPeriod(1); // Setup high-resolution timer to 1ms (granularity of 1-2 ms)
|
timeBeginPeriod(1); // Setup high-resolution timer to 1ms (granularity of 1-2 ms)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -324,6 +324,10 @@
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// Types and Structures Definition
|
// Types and Structures Definition
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
#if defined(PLATFORM_CUSTOM)
|
||||||
|
#include "raylib_platform_custom.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#if (defined(__STDC__) && __STDC_VERSION__ >= 199901L) || (defined(_MSC_VER) && _MSC_VER >= 1800)
|
#if (defined(__STDC__) && __STDC_VERSION__ >= 199901L) || (defined(_MSC_VER) && _MSC_VER >= 1800)
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#elif !defined(__cplusplus) && !defined(bool) && !defined(RL_BOOL_TYPE)
|
#elif !defined(__cplusplus) && !defined(bool) && !defined(RL_BOOL_TYPE)
|
||||||
|
|
@ -818,7 +822,7 @@ RLAPI void rlLoadDrawQuad(void); // Load and draw a quad
|
||||||
#elif defined(GRAPHICS_API_OPENGL_ES2)
|
#elif defined(GRAPHICS_API_OPENGL_ES2)
|
||||||
// NOTE: OpenGL ES 2.0 can be enabled on PLATFORM_DESKTOP,
|
// NOTE: OpenGL ES 2.0 can be enabled on PLATFORM_DESKTOP,
|
||||||
// in that case, functions are loaded from a custom glad for OpenGL ES 2.0
|
// in that case, functions are loaded from a custom glad for OpenGL ES 2.0
|
||||||
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_DESKTOP_SDL)
|
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_DESKTOP_SDL) || defined(PLATFORM_CUSTOM_ENABLE_OPENGL_ES2)
|
||||||
#define GLAD_GLES2_IMPLEMENTATION
|
#define GLAD_GLES2_IMPLEMENTATION
|
||||||
#include "external/glad_gles2.h"
|
#include "external/glad_gles2.h"
|
||||||
#else
|
#else
|
||||||
|
|
@ -2281,7 +2285,7 @@ void rlLoadExtensions(void *loader)
|
||||||
|
|
||||||
#elif defined(GRAPHICS_API_OPENGL_ES2)
|
#elif defined(GRAPHICS_API_OPENGL_ES2)
|
||||||
|
|
||||||
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_DESKTOP_SDL)
|
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_DESKTOP_SDL) || defined(PLATFORM_CUSTOM_ENABLE_OPENGL_ES2)
|
||||||
// TODO: Support GLAD loader for OpenGL ES 3.0
|
// TODO: Support GLAD loader for OpenGL ES 3.0
|
||||||
if (gladLoadGLES2((GLADloadfunc)loader) == 0) TRACELOG(RL_LOG_WARNING, "GLAD: Cannot load OpenGL ES2.0 functions");
|
if (gladLoadGLES2((GLADloadfunc)loader) == 0) TRACELOG(RL_LOG_WARNING, "GLAD: Cannot load OpenGL ES2.0 functions");
|
||||||
else TRACELOG(RL_LOG_INFO, "GLAD: OpenGL ES 2.0 loaded successfully");
|
else TRACELOG(RL_LOG_INFO, "GLAD: OpenGL ES 2.0 loaded successfully");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user