Format tweaks
This commit is contained in:
parent
a38afcf053
commit
b55cf40b91
7 changed files with 70 additions and 61 deletions
10
src/rcore.h
10
src/rcore.h
|
@ -133,18 +133,18 @@ typedef struct CoreData {
|
|||
|
||||
char **dropFilepaths; // Store dropped files paths pointers (provided by GLFW)
|
||||
unsigned int dropFileCount; // Count dropped files strings
|
||||
|
||||
|
||||
} Window;
|
||||
struct {
|
||||
const char *basePath; // Base path for data storage
|
||||
|
||||
|
||||
} Storage;
|
||||
struct {
|
||||
struct {
|
||||
int exitKey; // Default exit key
|
||||
char currentKeyState[MAX_KEYBOARD_KEYS]; // Registers current frame key state
|
||||
char previousKeyState[MAX_KEYBOARD_KEYS]; // Registers previous frame key state
|
||||
|
||||
|
||||
// NOTE: Since key press logic involves comparing prev vs cur key state, we need to handle key repeats specially
|
||||
char keyRepeatInFrame[MAX_KEYBOARD_KEYS]; // Registers key repeats for current frame.
|
||||
|
||||
|
@ -177,7 +177,7 @@ typedef struct CoreData {
|
|||
Vector2 position[MAX_TOUCH_POINTS]; // Touch position on screen
|
||||
char currentTouchState[MAX_TOUCH_POINTS]; // Registers current touch state
|
||||
char previousTouchState[MAX_TOUCH_POINTS]; // Registers previous touch state
|
||||
|
||||
|
||||
} Touch;
|
||||
struct {
|
||||
int lastButtonPressed; // Register last gamepad button pressed
|
||||
|
@ -199,7 +199,7 @@ typedef struct CoreData {
|
|||
double target; // Desired time for one frame, if 0 not applied
|
||||
unsigned long long int base; // Base time measure for hi-res timer (PLATFORM_ANDROID, PLATFORM_DRM)
|
||||
unsigned int frameCounter; // Frame counter
|
||||
|
||||
|
||||
} Time;
|
||||
} CoreData;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**********************************************************************************************
|
||||
*
|
||||
* rcore_android - Functions to manage window, graphics device and inputs
|
||||
* rcore_android - Functions to manage window, graphics device and inputs
|
||||
*
|
||||
* PLATFORM: ANDROID
|
||||
* - Android (ARM, ARM64)
|
||||
|
@ -48,13 +48,13 @@
|
|||
|
||||
#include "rcore.h"
|
||||
|
||||
//#include <android/sensor.h> // Required for: Android sensors functions (accelerometer, gyroscope, light...)
|
||||
#include <android/window.h> // Required for: AWINDOW_FLAG_FULLSCREEN definition and others
|
||||
#include <android_native_app_glue.h> // Required for: android_app struct and activity management
|
||||
#include <android/window.h> // Required for: AWINDOW_FLAG_FULLSCREEN definition and others
|
||||
//#include <android/sensor.h> // Required for: Android sensors functions (accelerometer, gyroscope, light...)
|
||||
#include <jni.h> // Required for: JNIEnv and JavaVM [Used in OpenURL()]
|
||||
|
||||
#include <EGL/egl.h> // Native platform windowing system interface
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Types and Structures Definition
|
||||
//----------------------------------------------------------------------------------
|
||||
|
@ -64,7 +64,7 @@ typedef struct {
|
|||
struct android_poll_source *source; // Android events polling source
|
||||
bool appEnabled; // Flag to detect if app is active ** = true
|
||||
bool contextRebindRequired; // Used to know context rebind required
|
||||
|
||||
|
||||
// Display data
|
||||
EGLDisplay device; // Native display device (physical screen connection)
|
||||
EGLSurface surface; // Surface to draw on, framebuffers (connected to context)
|
||||
|
@ -94,7 +94,7 @@ static GamepadButton AndroidTranslateGamepadButton(int button);
|
|||
// NOTE: Functions declaration is provided by raylib.h
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module Functions Definition
|
||||
// Module Functions Definition: Application
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// To allow easier porting to android, we allow the user to define a
|
||||
|
@ -188,6 +188,8 @@ void InitWindow(int width, int height, const char *title)
|
|||
CORE.Window.currentFbo.width = width;
|
||||
CORE.Window.currentFbo.height = height;
|
||||
|
||||
// Platform specific init window
|
||||
//--------------------------------------------------------------
|
||||
// Set desired windows flags before initializing anything
|
||||
ANativeActivity_setWindowFlags(platform.app->activity, AWINDOW_FLAG_FULLSCREEN, 0); //AWINDOW_FLAG_SCALED, AWINDOW_FLAG_DITHER
|
||||
|
||||
|
@ -269,6 +271,8 @@ void CloseWindow(void)
|
|||
timeEndPeriod(1); // Restore time period
|
||||
#endif
|
||||
|
||||
// Platform specific close window
|
||||
//--------------------------------------------------------------
|
||||
// Close surface, context and display
|
||||
if (platform.device != EGL_NO_DISPLAY)
|
||||
{
|
||||
|
@ -289,6 +293,7 @@ void CloseWindow(void)
|
|||
eglTerminate(platform.device);
|
||||
platform.device = EGL_NO_DISPLAY;
|
||||
}
|
||||
//--------------------------------------------------------------
|
||||
|
||||
#if defined(SUPPORT_EVENTS_AUTOMATION)
|
||||
RL_FREE(events);
|
||||
|
@ -586,7 +591,7 @@ double GetTime(void)
|
|||
unsigned long long int nanoSeconds = (unsigned long long int)ts.tv_sec*1000000000LLU + (unsigned long long int)ts.tv_nsec;
|
||||
|
||||
time = (double)(nanoSeconds - CORE.Time.base)*1e-9; // Elapsed time since InitTimer()
|
||||
|
||||
|
||||
return time;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**********************************************************************************************
|
||||
*
|
||||
* rcore_<platform> - Functions to manage window, graphics device and inputs
|
||||
* rcore_<platform> - Functions to manage window, graphics device and inputs
|
||||
*
|
||||
* PLATFORM: <PLATFORM>
|
||||
* - TODO: Define the target platform for the core
|
||||
|
@ -48,14 +48,14 @@
|
|||
|
||||
#include "rcore.h"
|
||||
|
||||
// TODO: Include the platform specific libraries
|
||||
|
||||
// TODO: Include the platform specific libraries
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Types and Structures Definition
|
||||
//----------------------------------------------------------------------------------
|
||||
typedef struct {
|
||||
// TODO: Define the platform specific variables required
|
||||
|
||||
|
||||
// Display data
|
||||
EGLDisplay device; // Native display device (physical screen connection)
|
||||
EGLSurface surface; // Surface to draw on, framebuffers (connected to context)
|
||||
|
@ -128,15 +128,15 @@ void InitWindow(int width, int height, const char *title)
|
|||
CORE.Input.Mouse.scale = (Vector2){ 1.0f, 1.0f };
|
||||
CORE.Input.Mouse.cursor = MOUSE_CURSOR_ARROW;
|
||||
CORE.Input.Gamepad.lastButtonPressed = 0; // GAMEPAD_BUTTON_UNKNOWN
|
||||
CORE.Window.eventWaiting = false;
|
||||
|
||||
CORE.Window.eventWaiting = false;
|
||||
CORE.Window.screen.width = width;
|
||||
CORE.Window.screen.height = height;
|
||||
CORE.Window.currentFbo.width = width;
|
||||
CORE.Window.currentFbo.height = height;
|
||||
|
||||
// TODO: Initialize window/display system
|
||||
|
||||
|
||||
// TODO: Initialize input events system
|
||||
|
||||
// TODO: Initialize assets manager
|
||||
|
@ -165,11 +165,10 @@ void CloseWindow(void)
|
|||
|
||||
rlglClose(); // De-init rlgl
|
||||
|
||||
#if defined(_WIN32) && defined(SUPPORT_WINMM_HIGHRES_TIMER) && !defined(SUPPORT_BUSY_WAIT_LOOP)
|
||||
timeEndPeriod(1); // Restore time period
|
||||
#endif
|
||||
|
||||
// TODO: Close surface, context and display
|
||||
// Platform specific close window
|
||||
//--------------------------------------------------------------
|
||||
// TODO.
|
||||
//--------------------------------------------------------------
|
||||
|
||||
#if defined(SUPPORT_EVENTS_AUTOMATION)
|
||||
RL_FREE(events);
|
||||
|
@ -467,7 +466,7 @@ double GetTime(void)
|
|||
unsigned long long int nanoSeconds = (unsigned long long int)ts.tv_sec*1000000000LLU + (unsigned long long int)ts.tv_nsec;
|
||||
|
||||
time = (double)(nanoSeconds - CORE.Time.base)*1e-9; // Elapsed time since InitTimer()
|
||||
|
||||
|
||||
return time;
|
||||
}
|
||||
|
||||
|
@ -610,7 +609,7 @@ void PollInputEvents(void)
|
|||
// Reset keys/chars pressed registered
|
||||
CORE.Input.Keyboard.keyPressedQueueCount = 0;
|
||||
CORE.Input.Keyboard.charPressedQueueCount = 0;
|
||||
|
||||
|
||||
// Reset key repeats
|
||||
for (int i = 0; i < MAX_KEYBOARD_KEYS; i++) CORE.Input.Keyboard.keyRepeatInFrame[i] = 0;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**********************************************************************************************
|
||||
*
|
||||
* rcore_desktop - Functions to manage window, graphics device and inputs
|
||||
* rcore_desktop - Functions to manage window, graphics device and inputs
|
||||
*
|
||||
* PLATFORM: DESKTOP
|
||||
* - Windows (Win32, Win64)
|
||||
|
@ -268,12 +268,15 @@ void CloseWindow(void)
|
|||
|
||||
rlglClose(); // De-init rlgl
|
||||
|
||||
// Platform specific close window
|
||||
//--------------------------------------------------------------
|
||||
glfwDestroyWindow(platform.handle);
|
||||
glfwTerminate();
|
||||
|
||||
#if defined(_WIN32) && defined(SUPPORT_WINMM_HIGHRES_TIMER) && !defined(SUPPORT_BUSY_WAIT_LOOP)
|
||||
timeEndPeriod(1); // Restore time period
|
||||
#endif
|
||||
//--------------------------------------------------------------
|
||||
|
||||
#if defined(SUPPORT_EVENTS_AUTOMATION)
|
||||
RL_FREE(events);
|
||||
|
@ -422,11 +425,11 @@ void ToggleBorderlessWindowed(void)
|
|||
const int monitor = GetCurrentMonitor();
|
||||
int monitorCount;
|
||||
GLFWmonitor **monitors = glfwGetMonitors(&monitorCount);
|
||||
|
||||
|
||||
if ((monitor >= 0) && (monitor < monitorCount))
|
||||
{
|
||||
const GLFWvidmode *mode = glfwGetVideoMode(monitors[monitor]);
|
||||
|
||||
|
||||
if (mode)
|
||||
{
|
||||
if (!IsWindowState(FLAG_BORDERLESS_WINDOWED_MODE))
|
||||
|
@ -1016,7 +1019,7 @@ int GetMonitorHeight(int monitor)
|
|||
else TRACELOG(LOG_WARNING, "GLFW: Failed to find video mode for selected monitor");
|
||||
}
|
||||
else TRACELOG(LOG_WARNING, "GLFW: Failed to find selected monitor");
|
||||
|
||||
|
||||
return height;
|
||||
}
|
||||
|
||||
|
@ -1029,7 +1032,7 @@ int GetMonitorPhysicalWidth(int monitor)
|
|||
|
||||
if ((monitor >= 0) && (monitor < monitorCount)) glfwGetMonitorPhysicalSize(monitors[monitor], &width, NULL);
|
||||
else TRACELOG(LOG_WARNING, "GLFW: Failed to find selected monitor");
|
||||
|
||||
|
||||
return width;
|
||||
}
|
||||
|
||||
|
@ -1042,7 +1045,7 @@ int GetMonitorPhysicalHeight(int monitor)
|
|||
|
||||
if ((monitor >= 0) && (monitor < monitorCount)) glfwGetMonitorPhysicalSize(monitors[monitor], NULL, &height);
|
||||
else TRACELOG(LOG_WARNING, "GLFW: Failed to find selected monitor");
|
||||
|
||||
|
||||
return height;
|
||||
}
|
||||
|
||||
|
@ -1059,7 +1062,7 @@ int GetMonitorRefreshRate(int monitor)
|
|||
refresh = vidmode->refreshRate;
|
||||
}
|
||||
else TRACELOG(LOG_WARNING, "GLFW: Failed to find selected monitor");
|
||||
|
||||
|
||||
return refresh;
|
||||
}
|
||||
|
||||
|
@ -1082,9 +1085,9 @@ Vector2 GetWindowPosition(void)
|
|||
{
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
|
||||
|
||||
glfwGetWindowPos(platform.handle, &x, &y);
|
||||
|
||||
|
||||
return (Vector2){ (float)x, (float)y };
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**********************************************************************************************
|
||||
*
|
||||
* rcore_drm - Functions to manage window, graphics device and inputs
|
||||
* rcore_drm - Functions to manage window, graphics device and inputs
|
||||
*
|
||||
* PLATFORM: DRM
|
||||
* - Raspberry Pi 0-5
|
||||
|
@ -81,7 +81,7 @@
|
|||
|
||||
typedef struct {
|
||||
pthread_t threadId; // Event reading thread id
|
||||
|
||||
|
||||
int fd; // File descriptor to the device it is assigned to
|
||||
int eventNum; // Number of 'event<N>' device
|
||||
Rectangle absRange; // Range of values for absolute pointing devices (touchscreens)
|
||||
|
@ -111,7 +111,7 @@ typedef struct {
|
|||
|
||||
// Input data
|
||||
InputEventWorker eventWorker[10]; // List of worker threads for every monitored "/dev/input/event<N>"
|
||||
|
||||
|
||||
// Keyboard data
|
||||
int defaultKeyboardMode; // Default keyboard mode
|
||||
bool eventKeyboardMode; // Keyboard in event mode
|
||||
|
@ -307,6 +307,8 @@ void CloseWindow(void)
|
|||
timeEndPeriod(1); // Restore time period
|
||||
#endif
|
||||
|
||||
// Platform specific close window
|
||||
//--------------------------------------------------------------
|
||||
if (platform.prevFB)
|
||||
{
|
||||
drmModeRmFB(platform.fd, platform.prevFB);
|
||||
|
@ -392,6 +394,7 @@ void CloseWindow(void)
|
|||
}
|
||||
|
||||
if (platform.gamepadThreadId) pthread_join(platform.gamepadThreadId, NULL);
|
||||
//--------------------------------------------------------------
|
||||
|
||||
#if defined(SUPPORT_EVENTS_AUTOMATION)
|
||||
RL_FREE(events);
|
||||
|
@ -603,12 +606,12 @@ int GetMonitorPhysicalHeight(int monitor)
|
|||
int GetMonitorRefreshRate(int monitor)
|
||||
{
|
||||
int refresh = 0;
|
||||
|
||||
|
||||
if ((platform.connector) && (platform.modeIndex >= 0))
|
||||
{
|
||||
refresh = platform.connector->modes[platform.modeIndex].vrefresh;
|
||||
}
|
||||
|
||||
|
||||
return refresh;
|
||||
}
|
||||
|
||||
|
@ -718,7 +721,7 @@ double GetTime(void)
|
|||
unsigned long long int nanoSeconds = (unsigned long long int)ts.tv_sec*1000000000LLU + (unsigned long long int)ts.tv_nsec;
|
||||
|
||||
time = (double)(nanoSeconds - CORE.Time.base)*1e-9; // Elapsed time since InitTimer()
|
||||
|
||||
|
||||
return time;
|
||||
}
|
||||
|
||||
|
@ -763,7 +766,7 @@ int GetGamepadAxisCount(int gamepad)
|
|||
int axisCount = 0;
|
||||
if (CORE.Input.Gamepad.ready[gamepad]) ioctl(platform.gamepadStreamFd[gamepad], JSIOCGAXES, &axisCount);
|
||||
CORE.Input.Gamepad.axisCount = axisCount;
|
||||
|
||||
|
||||
return CORE.Input.Gamepad.axisCount;
|
||||
}
|
||||
|
||||
|
@ -837,10 +840,10 @@ int GetTouchY(void)
|
|||
Vector2 GetTouchPosition(int index)
|
||||
{
|
||||
Vector2 position = { -1.0f, -1.0f };
|
||||
|
||||
|
||||
if (index < MAX_TOUCH_POINTS) position = CORE.Input.Touch.position[index];
|
||||
else TRACELOG(LOG_WARNING, "INPUT: Required touch point out of range (Max touch points: %i)", MAX_TOUCH_POINTS);
|
||||
|
||||
|
||||
return position;
|
||||
}
|
||||
|
||||
|
@ -856,7 +859,7 @@ void PollInputEvents(void)
|
|||
// Reset keys/chars pressed registered
|
||||
CORE.Input.Keyboard.keyPressedQueueCount = 0;
|
||||
CORE.Input.Keyboard.charPressedQueueCount = 0;
|
||||
|
||||
|
||||
// Reset key repeats
|
||||
for (int i = 0; i < MAX_KEYBOARD_KEYS; i++) CORE.Input.Keyboard.keyRepeatInFrame[i] = 0;
|
||||
|
||||
|
@ -979,14 +982,14 @@ static bool InitGraphicsDevice(int width, int height)
|
|||
}
|
||||
|
||||
TRACELOG(LOG_TRACE, "DISPLAY: Connectors found: %i", res->count_connectors);
|
||||
|
||||
|
||||
for (size_t i = 0; i < res->count_connectors; i++)
|
||||
{
|
||||
TRACELOG(LOG_TRACE, "DISPLAY: Connector index %i", i);
|
||||
|
||||
|
||||
drmModeConnector *con = drmModeGetConnector(platform.fd, res->connectors[i]);
|
||||
TRACELOG(LOG_TRACE, "DISPLAY: Connector modes detected: %i", con->count_modes);
|
||||
|
||||
|
||||
if ((con->connection == DRM_MODE_CONNECTED) && (con->encoder_id))
|
||||
{
|
||||
TRACELOG(LOG_TRACE, "DISPLAY: DRM mode connected");
|
||||
|
@ -1440,7 +1443,7 @@ static void ProcessKeyboard(void)
|
|||
}
|
||||
#endif // SUPPORT_SSH_KEYBOARD_RPI
|
||||
|
||||
// Initialise user input from evdev(/dev/input/event<N>)
|
||||
// Initialise user input from evdev(/dev/input/event<N>)
|
||||
// this means mouse, keyboard or gamepad devices
|
||||
static void InitEvdevInput(void)
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**********************************************************************************************
|
||||
*
|
||||
* rcore_web - Functions to manage window, graphics device and inputs
|
||||
* rcore_web - Functions to manage window, graphics device and inputs
|
||||
*
|
||||
* PLATFORM: WEB
|
||||
* - HTML5 (WebAssembly)
|
||||
|
@ -237,7 +237,7 @@ void InitWindow(int width, int height, const char *title)
|
|||
// emscripten_set_fullscreenchange_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, NULL, 1, EmscriptenResizeCallback);
|
||||
// Check Resize event (note this is done on the window since most browsers don't support this on #canvas)
|
||||
emscripten_set_resize_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, NULL, 1, EmscriptenResizeCallback);
|
||||
|
||||
|
||||
// Trigger this once to get initial window sizing
|
||||
EmscriptenResizeCallback(EMSCRIPTEN_EVENT_RESIZE, NULL, NULL);
|
||||
|
||||
|
@ -282,12 +282,11 @@ void CloseWindow(void)
|
|||
|
||||
rlglClose(); // De-init rlgl
|
||||
|
||||
// Platform specific close window
|
||||
//--------------------------------------------------------------
|
||||
glfwDestroyWindow(platform.handle);
|
||||
glfwTerminate();
|
||||
|
||||
#if defined(_WIN32) && defined(SUPPORT_WINMM_HIGHRES_TIMER) && !defined(SUPPORT_BUSY_WAIT_LOOP)
|
||||
timeEndPeriod(1); // Restore time period
|
||||
#endif
|
||||
//--------------------------------------------------------------
|
||||
|
||||
#if defined(SUPPORT_EVENTS_AUTOMATION)
|
||||
RL_FREE(events);
|
||||
|
@ -482,7 +481,7 @@ void SetWindowMinSize(int width, int height)
|
|||
{
|
||||
CORE.Window.screenMin.width = width;
|
||||
CORE.Window.screenMin.height = height;
|
||||
|
||||
|
||||
// Trigger the resize event once to update the window minimum width and height
|
||||
if ((CORE.Window.flags & FLAG_WINDOW_RESIZABLE) != 0) EmscriptenResizeCallback(EMSCRIPTEN_EVENT_RESIZE, NULL, NULL);
|
||||
}
|
||||
|
@ -1090,7 +1089,7 @@ static bool InitGraphicsDevice(int width, int height)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TRACELOG(LOG_WARNING, "SYSTEM: Closest fullscreen videomode: %i x %i", CORE.Window.display.width, CORE.Window.display.height);
|
||||
|
||||
// NOTE: ISSUE: Closest videomode could not match monitor aspect-ratio, for example,
|
||||
|
@ -1229,7 +1228,7 @@ static void WindowIconifyCallback(GLFWwindow *window, int iconified)
|
|||
// GLFW3 Window Maximize Callback, runs when window is maximized
|
||||
static void WindowMaximizeCallback(GLFWwindow *window, int maximized)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
// GLFW3 WindowFocus Callback, runs when window get/lose focus
|
||||
|
|
|
@ -5466,11 +5466,11 @@ static Model LoadVOX(const char *fileName)
|
|||
|
||||
int nbvertices = 0;
|
||||
int meshescount = 0;
|
||||
|
||||
|
||||
// Read vox file into buffer
|
||||
int dataSize = 0;
|
||||
unsigned char *fileData = LoadFileData(fileName, &dataSize);
|
||||
|
||||
|
||||
if (fileData == 0)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "MODEL: [%s] Failed to load VOX file", fileName);
|
||||
|
@ -5575,7 +5575,7 @@ static Model LoadM3D(const char *fileName)
|
|||
m3d_t *m3d = NULL;
|
||||
m3dp_t *prop = NULL;
|
||||
int i, j, k, l, n, mi = -2, vcolor = 0;
|
||||
|
||||
|
||||
int dataSize = 0;
|
||||
unsigned char *fileData = LoadFileData(fileName, &dataSize);
|
||||
|
||||
|
@ -5905,7 +5905,7 @@ static Model LoadM3D(const char *fileName)
|
|||
static ModelAnimation *LoadModelAnimationsM3D(const char *fileName, int *animCount)
|
||||
{
|
||||
ModelAnimation *animations = NULL;
|
||||
|
||||
|
||||
m3d_t *m3d = NULL;
|
||||
int i = 0, j = 0;
|
||||
*animCount = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue