Skip to content

Commit

Permalink
Format tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
raysan5 committed Oct 9, 2023
1 parent a38afcf commit b55cf40
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 61 deletions.
10 changes: 5 additions & 5 deletions src/rcore.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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
Expand All @@ -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;

Expand Down
19 changes: 12 additions & 7 deletions src/rcore_android.c
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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
//----------------------------------------------------------------------------------
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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)
{
Expand All @@ -289,6 +293,7 @@ void CloseWindow(void)
eglTerminate(platform.device);
platform.device = EGL_NO_DISPLAY;
}
//--------------------------------------------------------------

#if defined(SUPPORT_EVENTS_AUTOMATION)
RL_FREE(events);
Expand Down Expand Up @@ -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;
}

Expand Down
25 changes: 12 additions & 13 deletions src/rcore_custom.c
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;

Expand Down
21 changes: 12 additions & 9 deletions src/rcore_desktop.c
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand All @@ -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;
}

Expand All @@ -1059,7 +1062,7 @@ int GetMonitorRefreshRate(int monitor)
refresh = vidmode->refreshRate;
}
else TRACELOG(LOG_WARNING, "GLFW: Failed to find selected monitor");

return refresh;
}

Expand All @@ -1082,9 +1085,9 @@ Vector2 GetWindowPosition(void)
{
int x = 0;
int y = 0;

glfwGetWindowPos(platform.handle, &x, &y);

return (Vector2){ (float)x, (float)y };
}

Expand Down
Loading

0 comments on commit b55cf40

Please sign in to comment.