Remove PLATFORM_ checks from raylib header
Now header is truly multiplatform... Actually still a small pending check on XBOX gamepad controls that hopefully will be removed with next GLFW 3.3
This commit is contained in:
parent
02dd4d32b5
commit
24b12e5e23
2 changed files with 19 additions and 40 deletions
25
src/core.c
25
src/core.c
|
@ -279,10 +279,11 @@ static int renderOffsetY = 0; // Offset Y from render area (must b
|
||||||
static bool fullscreen = false; // Fullscreen mode (useful only for PLATFORM_DESKTOP)
|
static bool fullscreen = false; // Fullscreen mode (useful only for PLATFORM_DESKTOP)
|
||||||
static Matrix downscaleView; // Matrix to downscale view (in case screen size bigger than display size)
|
static Matrix downscaleView; // Matrix to downscale view (in case screen size bigger than display size)
|
||||||
|
|
||||||
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI) || defined(PLATFORM_WEB)
|
|
||||||
static const char *windowTitle; // Window text title...
|
|
||||||
static bool cursorOnScreen = false; // Tracks if cursor is inside client area
|
|
||||||
static bool cursorHidden = false; // Track if cursor is hidden
|
static bool cursorHidden = false; // Track if cursor is hidden
|
||||||
|
|
||||||
|
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI) || defined(PLATFORM_WEB)
|
||||||
|
static const char *windowTitle = NULL; // Window text title...
|
||||||
|
static bool cursorOnScreen = false; // Tracks if cursor is inside client area
|
||||||
static int screenshotCounter = 0; // Screenshots counter
|
static int screenshotCounter = 0; // Screenshots counter
|
||||||
|
|
||||||
// Register mouse states
|
// Register mouse states
|
||||||
|
@ -409,12 +410,13 @@ static void *GamepadThread(void *arg); // Mouse reading thread
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI) || defined(PLATFORM_WEB)
|
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI) || defined(PLATFORM_WEB)
|
||||||
// Initialize window and OpenGL context
|
// Initialize window and OpenGL context
|
||||||
void InitWindow(int width, int height, const char *title)
|
// NOTE: data parameter could be used to pass any kind of required data to the initialization
|
||||||
|
void InitWindow(int width, int height, void *data)
|
||||||
{
|
{
|
||||||
TraceLog(LOG_INFO, "Initializing raylib (v1.8.0)");
|
TraceLog(LOG_INFO, "Initializing raylib (v1.8.0)");
|
||||||
|
|
||||||
// Store window title (could be useful...)
|
// Input data is window title char data
|
||||||
windowTitle = title;
|
windowTitle = (char *)data;
|
||||||
|
|
||||||
// Init graphics device (display device and OpenGL context)
|
// Init graphics device (display device and OpenGL context)
|
||||||
InitGraphicsDevice(width, height);
|
InitGraphicsDevice(width, height);
|
||||||
|
@ -471,15 +473,17 @@ void InitWindow(int width, int height, const char *title)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PLATFORM_ANDROID)
|
#if defined(PLATFORM_ANDROID)
|
||||||
// Initialize Android activity
|
// Initialize window and OpenGL context (and Android activity)
|
||||||
void InitWindow(int width, int height, void *state)
|
// NOTE: data parameter could be used to pass any kind of required data to the initialization
|
||||||
|
void InitWindow(int width, int height, void *data)
|
||||||
{
|
{
|
||||||
TraceLog(LOG_INFO, "Initializing raylib (v1.8.0)");
|
TraceLog(LOG_INFO, "Initializing raylib (v1.8.0)");
|
||||||
|
|
||||||
screenWidth = width;
|
screenWidth = width;
|
||||||
screenHeight = height;
|
screenHeight = height;
|
||||||
|
|
||||||
app = (struct android_app *)state;
|
// Input data is android app pointer
|
||||||
|
app = (struct android_app *)data;
|
||||||
internalDataPath = app->activity->internalDataPath;
|
internalDataPath = app->activity->internalDataPath;
|
||||||
|
|
||||||
// Set desired windows flags before initializing anything
|
// Set desired windows flags before initializing anything
|
||||||
|
@ -508,7 +512,6 @@ void InitWindow(int width, int height, void *state)
|
||||||
//AConfiguration_getScreenSize(app->config);
|
//AConfiguration_getScreenSize(app->config);
|
||||||
//AConfiguration_getScreenLong(app->config);
|
//AConfiguration_getScreenLong(app->config);
|
||||||
|
|
||||||
//state->userData = &engine;
|
|
||||||
app->onAppCmd = AndroidCommandCallback;
|
app->onAppCmd = AndroidCommandCallback;
|
||||||
app->onInputEvent = AndroidInputCallback;
|
app->onInputEvent = AndroidInputCallback;
|
||||||
|
|
||||||
|
@ -709,7 +712,6 @@ int GetScreenHeight(void)
|
||||||
return screenHeight;
|
return screenHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(PLATFORM_ANDROID)
|
|
||||||
// Show mouse cursor
|
// Show mouse cursor
|
||||||
void ShowCursor()
|
void ShowCursor()
|
||||||
{
|
{
|
||||||
|
@ -772,7 +774,6 @@ void DisableCursor()
|
||||||
#endif
|
#endif
|
||||||
cursorHidden = true;
|
cursorHidden = true;
|
||||||
}
|
}
|
||||||
#endif // !defined(PLATFORM_ANDROID)
|
|
||||||
|
|
||||||
// Set background color (framebuffer clear color)
|
// Set background color (framebuffer clear color)
|
||||||
void ClearBackground(Color color)
|
void ClearBackground(Color color)
|
||||||
|
|
34
src/raylib.h
34
src/raylib.h
|
@ -72,20 +72,6 @@
|
||||||
#ifndef RAYLIB_H
|
#ifndef RAYLIB_H
|
||||||
#define RAYLIB_H
|
#define RAYLIB_H
|
||||||
|
|
||||||
// Choose your platform here or just define it at compile time: -DPLATFORM_DESKTOP
|
|
||||||
//#define PLATFORM_DESKTOP // Windows, Linux or OSX
|
|
||||||
//#define PLATFORM_ANDROID // Android device
|
|
||||||
//#define PLATFORM_RPI // Raspberry Pi
|
|
||||||
//#define PLATFORM_WEB // HTML5 (emscripten, asm.js)
|
|
||||||
|
|
||||||
// Security check in case no PLATFORM_* defined
|
|
||||||
#if !defined(PLATFORM_DESKTOP) && \
|
|
||||||
!defined(PLATFORM_ANDROID) && \
|
|
||||||
!defined(PLATFORM_RPI) && \
|
|
||||||
!defined(PLATFORM_WEB)
|
|
||||||
#define PLATFORM_DESKTOP
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(_WIN32) && defined(BUILD_LIBTYPE_SHARED)
|
#if defined(_WIN32) && defined(BUILD_LIBTYPE_SHARED)
|
||||||
#define RLAPI __declspec(dllexport) // We are building raylib as a Win32 shared library (.dll)
|
#define RLAPI __declspec(dllexport) // We are building raylib as a Win32 shared library (.dll)
|
||||||
#elif defined(_WIN32) && defined(USE_LIBTYPE_SHARED)
|
#elif defined(_WIN32) && defined(USE_LIBTYPE_SHARED)
|
||||||
|
@ -179,13 +165,11 @@
|
||||||
#define KEY_Y 89
|
#define KEY_Y 89
|
||||||
#define KEY_Z 90
|
#define KEY_Z 90
|
||||||
|
|
||||||
#if defined(PLATFORM_ANDROID)
|
// Android Physical Buttons
|
||||||
// Android Physical Buttons
|
#define KEY_BACK 4
|
||||||
#define KEY_BACK 4
|
#define KEY_MENU 82
|
||||||
#define KEY_MENU 82
|
#define KEY_VOLUME_UP 24
|
||||||
#define KEY_VOLUME_UP 24
|
#define KEY_VOLUME_DOWN 25
|
||||||
#define KEY_VOLUME_DOWN 25
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Mouse Buttons
|
// Mouse Buttons
|
||||||
#define MOUSE_LEFT_BUTTON 0
|
#define MOUSE_LEFT_BUTTON 0
|
||||||
|
@ -710,11 +694,7 @@ extern "C" { // Prevents name mangling of functions
|
||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Window-related functions
|
// Window-related functions
|
||||||
#if defined(PLATFORM_ANDROID)
|
RLAPI void InitWindow(int width, int height, void *data); // Initialize window and OpenGL context
|
||||||
RLAPI void InitWindow(int width, int height, void *state); // Initialize Android activity
|
|
||||||
#elif defined(PLATFORM_DESKTOP) || defined(PLATFORM_RPI) || defined(PLATFORM_WEB)
|
|
||||||
RLAPI void InitWindow(int width, int height, const char *title); // Initialize window and OpenGL context
|
|
||||||
#endif
|
|
||||||
RLAPI void CloseWindow(void); // Close window and unload OpenGL context
|
RLAPI void CloseWindow(void); // Close window and unload OpenGL context
|
||||||
RLAPI bool WindowShouldClose(void); // Check if KEY_ESCAPE pressed or Close icon pressed
|
RLAPI bool WindowShouldClose(void); // Check if KEY_ESCAPE pressed or Close icon pressed
|
||||||
RLAPI bool IsWindowMinimized(void); // Check if window has been minimized (or lost focus)
|
RLAPI bool IsWindowMinimized(void); // Check if window has been minimized (or lost focus)
|
||||||
|
@ -727,14 +707,12 @@ RLAPI void SetWindowMinSize(int width, int height); // Set window
|
||||||
RLAPI int GetScreenWidth(void); // Get current screen width
|
RLAPI int GetScreenWidth(void); // Get current screen width
|
||||||
RLAPI int GetScreenHeight(void); // Get current screen height
|
RLAPI int GetScreenHeight(void); // Get current screen height
|
||||||
|
|
||||||
#if !defined(PLATFORM_ANDROID)
|
|
||||||
// Cursor-related functions
|
// Cursor-related functions
|
||||||
RLAPI void ShowCursor(void); // Shows cursor
|
RLAPI void ShowCursor(void); // Shows cursor
|
||||||
RLAPI void HideCursor(void); // Hides cursor
|
RLAPI void HideCursor(void); // Hides cursor
|
||||||
RLAPI bool IsCursorHidden(void); // Check if cursor is not visible
|
RLAPI bool IsCursorHidden(void); // Check if cursor is not visible
|
||||||
RLAPI void EnableCursor(void); // Enables cursor (unlock cursor)
|
RLAPI void EnableCursor(void); // Enables cursor (unlock cursor)
|
||||||
RLAPI void DisableCursor(void); // Disables cursor (lock cursor)
|
RLAPI void DisableCursor(void); // Disables cursor (lock cursor)
|
||||||
#endif
|
|
||||||
|
|
||||||
// Drawing-related functions
|
// Drawing-related functions
|
||||||
RLAPI void ClearBackground(Color color); // Set background color (framebuffer clear color)
|
RLAPI void ClearBackground(Color color); // Set background color (framebuffer clear color)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue