Skip to content

Commit e1b9857

Browse files
committed
Some TODOs and format reviews
1 parent cf5e84c commit e1b9857

File tree

16 files changed

+154
-191
lines changed

16 files changed

+154
-191
lines changed

src/config.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@
4949
#define SUPPORT_RPRAND_GENERATOR 1
5050
// Mouse gestures are directly mapped like touches and processed by gestures system
5151
#define SUPPORT_MOUSE_GESTURES 1
52-
// Reconfigure standard input to receive key inputs, works with SSH connection.
52+
// Reconfigure standard input to receive key inputs, works with SSH connection
5353
#define SUPPORT_SSH_KEYBOARD_RPI 1
54-
// Setting a higher resolution can improve the accuracy of time-out intervals in wait functions.
55-
// However, it can also reduce overall system performance, because the thread scheduler switches tasks more often.
54+
// Setting a higher resolution can improve the accuracy of time-out intervals in wait functions
55+
// However, it can also reduce overall system performance, because the thread scheduler switches tasks more often
5656
#define SUPPORT_WINMM_HIGHRES_TIMER 1
5757
// Use busy wait loop for timing sync, if not defined, a high-resolution timer is set up and used
5858
//#define SUPPORT_BUSY_WAIT_LOOP 1
@@ -225,7 +225,7 @@
225225

226226
// On font atlas image generation [GenImageFontAtlas()], add a 3x3 pixels white rectangle
227227
// at the bottom-right corner of the atlas. It can be useful to for shapes drawing, to allow
228-
// drawing text and shapes with a single draw call [SetShapesTexture()].
228+
// drawing text and shapes with a single draw call [SetShapesTexture()]
229229
#define SUPPORT_FONT_ATLAS_WHITE_REC 1
230230

231231
// Support conservative font atlas size estimation

src/external/rlsw.h

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@
145145
#define SW_MAX_TEXTURES 128
146146
#endif
147147

148-
// Under normal circumstances, clipping a polygon can add at most one vertex per clipping plane.
148+
// Under normal circumstances, clipping a polygon can add at most one vertex per clipping plane
149149
// Considering the largest polygon involved is a quadrilateral (4 vertices),
150150
// and that clipping occurs against both the frustum (6 planes) and the scissors (4 planes),
151151
// the maximum number of vertices after clipping is:
@@ -1530,7 +1530,7 @@ DEFINE_FRAMEBUFFER_COPY_BEGIN(R5G5B5A1, uint16_t)
15301530
uint8_t r5 = (color[0]*31 + 127)/255;
15311531
uint8_t g5 = (color[1]*31 + 127)/255;
15321532
uint8_t b5 = (color[2]*31 + 127)/255;
1533-
uint8_t a1 = color[3] >= 128 ? 1 : 0;
1533+
uint8_t a1 = (color[3] >= 128)? 1 : 0;
15341534

15351535
#if SW_GL_FRAMEBUFFER_COPY_BGRA
15361536
uint16_t pixel = (b5 << 11) | (g5 << 6) | (r5 << 1) | a1;
@@ -1661,7 +1661,7 @@ DEFINE_FRAMEBUFFER_BLIT_BEGIN(R5G5B5A1, uint16_t)
16611661
uint8_t r5 = (color[0]*31 + 127)/255;
16621662
uint8_t g5 = (color[1]*31 + 127)/255;
16631663
uint8_t b5 = (color[2]*31 + 127)/255;
1664-
uint8_t a1 = color[3] >= 128 ? 1 : 0;
1664+
uint8_t a1 = (color[3] >= 128)? 1 : 0;
16651665

16661666
#if SW_GL_FRAMEBUFFER_COPY_BGRA
16671667
uint16_t pixel = (b5 << 11) | (g5 << 6) | (r5 << 1) | a1;
@@ -1919,7 +1919,7 @@ static inline void sw_texture_sample_nearest(float *color, const sw_texture_t *t
19191919
static inline void sw_texture_sample_linear(float *color, const sw_texture_t *tex, float u, float v)
19201920
{
19211921
// TODO: With a bit more cleverness we could clearly reduce the
1922-
// number of operations here, but for now it works fine.
1922+
// number of operations here, but for now it works fine
19231923

19241924
float xf = (u*tex->width) - 0.5f;
19251925
float yf = (v*tex->height) - 0.5f;
@@ -2203,13 +2203,13 @@ static inline bool sw_polygon_clip(sw_vertex_t polygon[SW_MAX_CLIPPED_POLYGON_VE
22032203
//-------------------------------------------------------------------------------------------
22042204
static inline bool sw_triangle_face_culling(void)
22052205
{
2206-
// NOTE: Face culling is done before clipping to avoid unnecessary computations.
2206+
// NOTE: Face culling is done before clipping to avoid unnecessary computations
22072207
// To handle triangles crossing the w=0 plane correctly,
22082208
// we perform the winding order test in homogeneous coordinates directly,
2209-
// before the perspective division (division by w).
2209+
// before the perspective division (division by w)
22102210
// This test determines the orientation of the triangle in the (x,y,w) plane,
22112211
// which corresponds to the projected 2D winding order sign,
2212-
// even with negative w values.
2212+
// even with negative w values
22132213

22142214
// Preload homogeneous coordinates into local variables
22152215
const float *h0 = RLSW.vertexBuffer[0].homogeneous;
@@ -2221,7 +2221,7 @@ static inline bool sw_triangle_face_culling(void)
22212221
// This is the determinant of the matrix formed by the (x, y, w) components
22222222
// of the vertices, which correctly captures the winding order in homogeneous
22232223
// space and its relationship to the projected 2D winding order, even with
2224-
// negative w values.
2224+
// negative w values
22252225
// The determinant formula used here is:
22262226
// h0.x*(h1.y*h2.w - h2.y*h1.w) +
22272227
// h1.x*(h2.y*h0.w - h0.y*h2.w) +
@@ -2233,20 +2233,18 @@ static inline bool sw_triangle_face_culling(void)
22332233
h2[0]*(h0[1]*h1[3] - h1[1]*h0[3]);
22342234

22352235
// Discard the triangle if its winding order (determined by the sign
2236-
// of the homogeneous area/determinant) matches the culled direction.
2236+
// of the homogeneous area/determinant) matches the culled direction
22372237
// A positive hSgnArea typically corresponds to a counter-clockwise
22382238
// winding in the projected space when all w > 0.
22392239
// This test is robust for points with w > 0 or w < 0, correctly
2240-
// capturing the change in orientation when crossing the w=0 plane.
2240+
// capturing the change in orientation when crossing the w=0 plane
22412241

2242-
// The culling logic remains the same based on the signed area/determinant.
2242+
// The culling logic remains the same based on the signed area/determinant
22432243
// A value of 0 for hSgnArea means the points are collinear in (x, y, w)
22442244
// space, which corresponds to a degenerate triangle projection.
22452245
// Such triangles are typically not culled by this test (0 < 0 is false, 0 > 0 is false)
2246-
// and should be handled by the clipper if necessary.
2247-
return (RLSW.cullFace == SW_FRONT)
2248-
? (hSgnArea < 0) // Cull if winding is "clockwise" in the projected sense
2249-
: (hSgnArea > 0); // Cull if winding is "counter-clockwise" in the projected sense
2246+
// and should be handled by the clipper if necessary
2247+
return (RLSW.cullFace == SW_FRONT)? (hSgnArea < 0) : (hSgnArea > 0); // Cull if winding is "clockwise" : "counter-clockwise"
22502248
}
22512249

22522250
static inline void sw_triangle_clip_and_project(void)
@@ -2559,14 +2557,14 @@ static inline void sw_triangle_render(void)
25592557
//-------------------------------------------------------------------------------------------
25602558
static inline bool sw_quad_face_culling(void)
25612559
{
2562-
// NOTE: Face culling is done before clipping to avoid unnecessary computations.
2560+
// NOTE: Face culling is done before clipping to avoid unnecessary computations
25632561
// To handle quads crossing the w=0 plane correctly,
25642562
// we perform the winding order test in homogeneous coordinates directly,
2565-
// before the perspective division (division by w).
2563+
// before the perspective division (division by w)
25662564
// For a convex quad with vertices P0, P1, P2, P3 in sequential order,
25672565
// the winding order of the quad is the same as the winding order
25682566
// of the triangle P0 P1 P2. We use the homogeneous triangle
2569-
// winding test on this first triangle.
2567+
// winding test on this first triangle
25702568

25712569
// Preload homogeneous coordinates into local variables
25722570
const float *h0 = RLSW.vertexBuffer[0].homogeneous;
@@ -2578,11 +2576,11 @@ static inline bool sw_quad_face_culling(void)
25782576

25792577
// Compute a value proportional to the signed area of the triangle P0 P1 P2
25802578
// in the projected 2D plane, calculated directly using homogeneous coordinates
2581-
// BEFORE division by w.
2579+
// BEFORE division by w
25822580
// This is the determinant of the matrix formed by the (x, y, w) components
25832581
// of the vertices P0, P1, and P2. Its sign correctly indicates the winding order
25842582
// in homogeneous space and its relationship to the projected 2D winding order,
2585-
// even with negative w values.
2583+
// even with negative w values
25862584
// The determinant formula used here is:
25872585
// h0.x*(h1.y*h2.w - h2.y*h1.w) +
25882586
// h1.x*(h2.y*h0.w - h0.y*h2.w) +
@@ -2594,21 +2592,19 @@ static inline bool sw_quad_face_culling(void)
25942592
h2[0]*(h0[1]*h1[3] - h1[1]*h0[3]);
25952593

25962594
// Perform face culling based on the winding order determined by the sign
2597-
// of the homogeneous area/determinant of triangle P0 P1 P2.
2595+
// of the homogeneous area/determinant of triangle P0 P1 P2
25982596
// This test is robust for points with w > 0 or w < 0 within the triangle,
2599-
// correctly capturing the change in orientation when crossing the w=0 plane.
2597+
// correctly capturing the change in orientation when crossing the w=0 plane
26002598

26012599
// A positive hSgnArea typically corresponds to a counter-clockwise
2602-
// winding in the projected space when all w > 0.
2600+
// winding in the projected space when all w > 0
26032601
// A value of 0 for hSgnArea means P0, P1, P2 are collinear in (x, y, w)
2604-
// space, which corresponds to a degenerate triangle projection.
2602+
// space, which corresponds to a degenerate triangle projection
26052603
// Such quads might also be degenerate or non-planar. They are typically
26062604
// not culled by this test (0 < 0 is false, 0 > 0 is false)
26072605
// and should be handled by the clipper if necessary.
26082606

2609-
return (RLSW.cullFace == SW_FRONT)
2610-
? (hSgnArea < 0.0f) // Cull if winding is "clockwise" in the projected sense
2611-
: (hSgnArea > 0.0f); // Cull if winding is "counter-clockwise" in the projected sense
2607+
return (RLSW.cullFace == SW_FRONT)? (hSgnArea < 0.0f) : (hSgnArea > 0.0f); // Cull if winding is "clockwise" : "counter-clockwise"
26122608
}
26132609

26142610
static inline void sw_quad_clip_and_project(void)
@@ -4596,8 +4592,8 @@ void swDrawElements(SWdraw mode, int count, int type, const void *indices)
45964592

45974593
for (int i = 0; i < count; i++)
45984594
{
4599-
int index = indicesUb ? indicesUb[i] :
4600-
(indicesUs ? indicesUs[i] : indicesUi[i]);
4595+
int index = indicesUb? indicesUb[i] :
4596+
(indicesUs? indicesUs[i] : indicesUi[i]);
46014597

46024598
float u, v;
46034599
if (texcoords)

src/platforms/rcore_android.c

Lines changed: 19 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -623,10 +623,9 @@ double GetTime(void)
623623
}
624624

625625
// Open URL with default system browser (if available)
626-
// NOTE: This function is only safe to use if you control the URL given.
627-
// A user could craft a malicious string performing another action.
628-
// Only call this function yourself not with user input or make sure to check the string yourself.
629-
// Ref: https://github.com/raysan5/raylib/issues/686
626+
// NOTE: This function is only safe to use if you control the URL given
627+
// A user could craft a malicious string performing another action
628+
// Only call this function yourself not with user input or make sure to check the string yourself
630629
void OpenURL(const char *url)
631630
{
632631
// Security check to (partially) avoid malicious code
@@ -687,7 +686,7 @@ void SetMouseCursor(int cursor)
687686
TRACELOG(LOG_WARNING, "SetMouseCursor() not implemented on target platform");
688687
}
689688

690-
// Get physical key name.
689+
// Get physical key name
691690
const char *GetKeyName(int key)
692691
{
693692
TRACELOG(LOG_WARNING, "GetKeyName() not implemented on target platform");
@@ -748,9 +747,9 @@ void PollInputEvents(void)
748747
// Process this event
749748
if (platform.source != NULL) platform.source->process(platform.app, platform.source);
750749

751-
// NOTE: Allow closing the window in case a configuration change happened.
750+
// NOTE: Allow closing the window in case a configuration change happened
752751
// The android_main function should be allowed to return to its caller in order for the
753-
// Android OS to relaunch the activity.
752+
// Android OS to relaunch the activity
754753
if (platform.app->destroyRequested != 0)
755754
{
756755
CORE.Window.shouldClose = true;
@@ -829,13 +828,13 @@ int InitPlatform(void)
829828
// Wait for window to be initialized (display and context)
830829
while (!CORE.Window.ready)
831830
{
832-
// Process events until we reach TIMEOUT, which indicates no more events queued.
831+
// Process events until we reach TIMEOUT, which indicates no more events queued
833832
while ((pollResult = ALooper_pollOnce(0, NULL, &pollEvents, ((void **)&platform.source)) > ALOOPER_POLL_TIMEOUT))
834833
{
835834
// Process this event
836835
if (platform.source != NULL) platform.source->process(platform.app, platform.source);
837836

838-
// NOTE: It's highly likely destroyRequested will never be non-zero at the start of the activity lifecycle.
837+
// NOTE: It's highly likely destroyRequested will never be non-zero at the start of the activity lifecycle
839838
//if (platform.app->destroyRequested != 0) CORE.Window.shouldClose = true;
840839
}
841840
}
@@ -869,8 +868,9 @@ void ClosePlatform(void)
869868
platform.device = EGL_NO_DISPLAY;
870869
}
871870

872-
// NOTE: Reset global state in case the activity is being relaunched.
873-
if (platform.app->destroyRequested != 0) {
871+
// NOTE: Reset global state in case the activity is being relaunched
872+
if (platform.app->destroyRequested != 0)
873+
{
874874
CORE = (CoreData){0};
875875
platform = (PlatformData){0};
876876
}
@@ -925,7 +925,7 @@ static int InitGraphicsDevice(void)
925925
// Initialize the EGL device connection
926926
if (eglInitialize(platform.device, NULL, NULL) == EGL_FALSE)
927927
{
928-
// If all of the calls to eglInitialize returned EGL_FALSE then an error has occurred.
928+
// If all of the calls to eglInitialize returned EGL_FALSE then an error has occurred
929929
TRACELOG(LOG_WARNING, "DISPLAY: Failed to initialize EGL device");
930930
return -1;
931931
}
@@ -1081,21 +1081,6 @@ static void AndroidCommandCallback(struct android_app *app, int32_t cmd)
10811081

10821082
// Initialize random seed
10831083
SetRandomSeed((unsigned int)time(NULL));
1084-
1085-
// TODO: GPU assets reload in case of lost focus (lost context)
1086-
// NOTE: This problem has been solved just unbinding and rebinding context from display
1087-
/*
1088-
if (assetsReloadRequired)
1089-
{
1090-
for (int i = 0; i < assetCount; i++)
1091-
{
1092-
// TODO: Unload old asset if required
1093-
1094-
// Load texture again to pointed texture
1095-
(*textureAsset + i) = LoadTexture(assetPath[i]);
1096-
}
1097-
}
1098-
*/
10991084
}
11001085
}
11011086
} break;
@@ -1115,7 +1100,7 @@ static void AndroidCommandCallback(struct android_app *app, int32_t cmd)
11151100
case APP_CMD_TERM_WINDOW:
11161101
{
11171102
// Detach OpenGL context and destroy display surface
1118-
// NOTE 1: This case is used when the user exits the app without closing it. We detach the context to ensure everything is recoverable upon resuming.
1103+
// NOTE 1: This case is used when the user exits the app without closing it, context is detached to ensure everything is recoverable upon resuming
11191104
// NOTE 2: Detaching context before destroying display surface avoids losing our resources (textures, shaders, VBOs...)
11201105
// NOTE 3: In some cases (too many context loaded), OS could unload context automatically... :(
11211106
if (platform.device != EGL_NO_DISPLAY)
@@ -1179,8 +1164,8 @@ static GamepadButton AndroidTranslateGamepadButton(int button)
11791164
static int32_t AndroidInputCallback(struct android_app *app, AInputEvent *event)
11801165
{
11811166
// If additional inputs are required check:
1182-
// https://developer.android.com/ndk/reference/group/input
1183-
// https://developer.android.com/training/game-controllers/controller-input
1167+
// Ref: https://developer.android.com/ndk/reference/group/input
1168+
// Ref: https://developer.android.com/training/game-controllers/controller-input
11841169

11851170
int type = AInputEvent_getType(event);
11861171
int source = AInputEvent_getSource(event);
@@ -1290,7 +1275,7 @@ static int32_t AndroidInputCallback(struct android_app *app, AInputEvent *event)
12901275
{
12911276
// Let the OS handle input to avoid app stuck. Behaviour: CMD_PAUSE -> CMD_SAVE_STATE -> CMD_STOP -> CMD_CONFIG_CHANGED -> CMD_LOST_FOCUS
12921277
// Resuming Behaviour: CMD_START -> CMD_RESUME -> CMD_CONFIG_CHANGED -> CMD_CONFIG_CHANGED -> CMD_GAINED_FOCUS
1293-
// It seems like locking mobile, screen size (CMD_CONFIG_CHANGED) is affected.
1278+
// It seems like locking mobile, screen size (CMD_CONFIG_CHANGED) is affected
12941279
// NOTE: AndroidManifest.xml must have <activity android:configChanges="orientation|keyboardHidden|screenSize" >
12951280
// Before that change, activity was calling CMD_TERM_WINDOW and CMD_DESTROY when locking mobile, so that was not a normal behaviour
12961281
return 0;
@@ -1419,15 +1404,9 @@ static int32_t AndroidInputCallback(struct android_app *app, AInputEvent *event)
14191404
if (CORE.Input.Touch.pointCount > 0) CORE.Input.Touch.currentTouchState[MOUSE_BUTTON_LEFT] = 1;
14201405
else CORE.Input.Touch.currentTouchState[MOUSE_BUTTON_LEFT] = 0;
14211406

1422-
// Stores the previous position of touch[0] only while it's active to calculate the delta.
1423-
if (flags == AMOTION_EVENT_ACTION_MOVE)
1424-
{
1425-
CORE.Input.Mouse.previousPosition = CORE.Input.Mouse.currentPosition;
1426-
}
1427-
else
1428-
{
1429-
CORE.Input.Mouse.previousPosition = CORE.Input.Touch.position[0];
1430-
}
1407+
// Stores the previous position of touch[0] only while it's active to calculate the delta
1408+
if (flags == AMOTION_EVENT_ACTION_MOVE) CORE.Input.Mouse.previousPosition = CORE.Input.Mouse.currentPosition;
1409+
else CORE.Input.Mouse.previousPosition = CORE.Input.Touch.position[0];
14311410

14321411
// Map touch[0] as mouse input for convenience
14331412
CORE.Input.Mouse.currentPosition = CORE.Input.Touch.position[0];

src/platforms/rcore_desktop_glfw.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,9 +1220,9 @@ void PollInputEvents(void)
12201220

12211221
// Map touch position to mouse position for convenience
12221222
// WARNING: If the target desktop device supports touch screen, this behaviour should be reviewed!
1223-
// TODO: GLFW does not support multi-touch input just yet
1224-
// https://www.codeproject.com/Articles/668404/Programming-for-Multi-Touch
1225-
// https://docs.microsoft.com/en-us/windows/win32/wintouch/getting-started-with-multi-touch-messages
1223+
// TODO: GLFW does not support multi-touch input yet
1224+
// Ref: https://www.codeproject.com/Articles/668404/Programming-for-Multi-Touch
1225+
// Ref: https://docs.microsoft.com/en-us/windows/win32/wintouch/getting-started-with-multi-touch-messages
12261226
CORE.Input.Touch.position[0] = CORE.Input.Mouse.currentPosition;
12271227

12281228
// Check if gamepads are ready
@@ -1334,7 +1334,7 @@ void PollInputEvents(void)
13341334
// Function wrappers around RL_*alloc macros, used by glfwInitAllocator() inside of InitPlatform()
13351335
// We need to provide these because GLFWallocator expects function pointers with specific signatures
13361336
// Similar wrappers exist in utils.c but we cannot reuse them here due to declaration mismatch
1337-
// https://www.glfw.org/docs/latest/intro_guide.html#init_allocator
1337+
// Ref: https://www.glfw.org/docs/latest/intro_guide.html#init_allocator
13381338
static void *AllocateWrapper(size_t size, void *user)
13391339
{
13401340
(void)user;
@@ -1592,8 +1592,8 @@ int InitPlatform(void)
15921592
bool requestWindowedFullscreen = (CORE.Window.screen.height == 0) && (CORE.Window.screen.width == 0);
15931593

15941594
// Default to at least one pixel in size, as creation with a zero dimension is not allowed
1595-
int creationWidth = CORE.Window.screen.width != 0 ? CORE.Window.screen.width : 1;
1596-
int creationHeight = CORE.Window.screen.height != 0 ? CORE.Window.screen.height : 1;
1595+
int creationWidth = (CORE.Window.screen.width != 0)? CORE.Window.screen.width : 1;
1596+
int creationHeight = (CORE.Window.screen.height != 0)? CORE.Window.screen.height : 1;
15971597

15981598
platform.handle = glfwCreateWindow(creationWidth, creationHeight, (CORE.Window.title != 0)? CORE.Window.title : " ", NULL, NULL);
15991599
if (!platform.handle)

0 commit comments

Comments
 (0)