Skip to content

Commit 29896a2

Browse files
committed
REVIEWED: Some comments (Code Gardening)
1 parent a8c75f2 commit 29896a2

15 files changed

Lines changed: 131 additions & 132 deletions

src/external/rlsw.h

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,7 +1177,7 @@ static inline void sw_float_to_unorm8_simd(uint8_t dst[4], const float src[4])
11771177
static inline void sw_float_from_unorm8_simd(float dst[4], const uint8_t src[4])
11781178
{
11791179
#if defined(SW_HAS_NEON)
1180-
uint8x8_t bytes8 = vld1_u8(src); //< Read 8 bytes, faster, but let's hope we're not at the end of the page (unlikely)...
1180+
uint8x8_t bytes8 = vld1_u8(src); // Reading 8 bytes, faster, but let's hope not hitting the end of the page (unlikely)...
11811181
uint16x8_t bytes16 = vmovl_u8(bytes8);
11821182
uint32x4_t ints = vmovl_u16(vget_low_u16(bytes16));
11831183
float32x4_t floats = vcvtq_f32_u32(ints);
@@ -1224,8 +1224,8 @@ static inline uint32_t sw_half_to_float_ui(uint16_t h)
12241224
// denormal: flush to zero
12251225
r = (em < (1 << 10))? 0 : r;
12261226

1227-
// infinity/NaN; note that we preserve NaN payload as a byproduct of unifying inf/nan cases
1228-
// 112 is an exponent bias fixup; since we already applied it once, applying it twice converts 31 to 255
1227+
// NOTE: infinity/NaN; NaN payload is preserved as a byproduct of unifying inf/nan cases
1228+
// 112 is an exponent bias fixup; since it is already applied once, applying it twice converts 31 to 255
12291229
r += (em >= (31 << 10))? (112 << 23) : 0;
12301230

12311231
return s | r;
@@ -1252,7 +1252,7 @@ static inline uint16_t sw_half_from_float_ui(uint32_t ui)
12521252
// Overflow: infinity; 143 encodes exponent 16
12531253
h = (em >= (143 << 23))? 0x7c00 : h;
12541254

1255-
// NaN; note that we convert all types of NaN to qNaN
1255+
// NOTE: NaN; all types of NaN aree converted to qNaN
12561256
h = (em > (255 << 23))? 0x7e00 : h;
12571257

12581258
return (uint16_t)(s | h);
@@ -1918,8 +1918,8 @@ static inline void sw_texture_sample_nearest(float *color, const sw_texture_t *t
19181918

19191919
static inline void sw_texture_sample_linear(float *color, const sw_texture_t *tex, float u, float v)
19201920
{
1921-
// TODO: With a bit more cleverness we could clearly reduce the
1922-
// number of operations here, but for now it works fine
1921+
// TODO: With a bit more cleverness thee number of operations can
1922+
// be clearly reduced, but for now it works fine
19231923

19241924
float xf = (u*tex->width) - 0.5f;
19251925
float yf = (v*tex->height) - 0.5f;
@@ -1933,7 +1933,7 @@ static inline void sw_texture_sample_linear(float *color, const sw_texture_t *te
19331933
int x1 = x0 + 1;
19341934
int y1 = y0 + 1;
19351935

1936-
// NOTE: If the textures are POT we could avoid the division for SW_REPEAT
1936+
// NOTE: If the textures are POT, avoid the division for SW_REPEAT
19371937

19381938
if (tex->sWrap == SW_CLAMP)
19391939
{
@@ -1974,7 +1974,7 @@ static inline void sw_texture_sample_linear(float *color, const sw_texture_t *te
19741974
static inline void sw_texture_sample(float *color, const sw_texture_t *tex, float u, float v, float dUdx, float dUdy, float dVdx, float dVdy)
19751975
{
19761976
// Previous method: There is no need to compute the square root
1977-
// because using the squared value, the comparison remains `L2 > 1.0f*1.0f`
1977+
// because using the squared value, the comparison remains (L2 > 1.0f*1.0f)
19781978
//float du = sqrtf(dUdx*dUdx + dUdy*dUdy);
19791979
//float dv = sqrtf(dVdx*dVdx + dVdy*dVdy);
19801980
//float L = (du > dv)? du : dv;
@@ -2204,12 +2204,12 @@ static inline bool sw_polygon_clip(sw_vertex_t polygon[SW_MAX_CLIPPED_POLYGON_VE
22042204
static inline bool sw_triangle_face_culling(void)
22052205
{
22062206
// NOTE: Face culling is done before clipping to avoid unnecessary computations
2207-
// To handle triangles crossing the w=0 plane correctly,
2208-
// we perform the winding order test in homogeneous coordinates directly,
2209-
// before the perspective division (division by w)
2210-
// This test determines the orientation of the triangle in the (x,y,w) plane,
2211-
// which corresponds to the projected 2D winding order sign,
2212-
// even with negative w values
2207+
// To handle triangles crossing the w=0 plane correctly,
2208+
// the winding order test is performeed in homogeneous coordinates directly,
2209+
// before the perspective division (division by w)
2210+
// This test determines the orientation of the triangle in the (x,y,w) plane,
2211+
// which corresponds to the projected 2D winding order sign,
2212+
// even with negative w values
22132213

22142214
// Preload homogeneous coordinates into local variables
22152215
const float *h0 = RLSW.vertexBuffer[0].homogeneous;
@@ -2558,13 +2558,13 @@ static inline void sw_triangle_render(void)
25582558
static inline bool sw_quad_face_culling(void)
25592559
{
25602560
// NOTE: Face culling is done before clipping to avoid unnecessary computations
2561-
// To handle quads crossing the w=0 plane correctly,
2562-
// we perform the winding order test in homogeneous coordinates directly,
2563-
// before the perspective division (division by w)
2564-
// For a convex quad with vertices P0, P1, P2, P3 in sequential order,
2565-
// the winding order of the quad is the same as the winding order
2566-
// of the triangle P0 P1 P2. We use the homogeneous triangle
2567-
// winding test on this first triangle
2561+
// To handle quads crossing the w=0 plane correctly,
2562+
// the winding order test is performed in homogeneous coordinates directly,
2563+
// before the perspective division (division by w)
2564+
// For a convex quad with vertices P0, P1, P2, P3 in sequential order,
2565+
// the winding order of the quad is the same as the winding order
2566+
// of the triangle P0 P1 P2. The homogeneous triangle is used on
2567+
// winding test on this first triangle
25682568

25692569
// Preload homogeneous coordinates into local variables
25702570
const float *h0 = RLSW.vertexBuffer[0].homogeneous;
@@ -2649,7 +2649,7 @@ static inline bool sw_quad_is_axis_aligned(void)
26492649
{
26502650
// Reject quads with perspective projection
26512651
// The fast path assumes affine (non-perspective) quads,
2652-
// so we require all vertices to have homogeneous w = 1.0
2652+
// so it's required for all vertices to have homogeneous w = 1.0
26532653
for (int i = 0; i < 4; i++)
26542654
{
26552655
if (RLSW.vertexBuffer[i].homogeneous[3] != 1.0f) return false;
@@ -2721,7 +2721,7 @@ static inline void sw_quad_sort_cw(const sw_vertex_t* *output)
27212721

27222722
// TODO: REVIEW: Could a perfectly aligned quad, where one of the four points has a different depth,
27232723
// still appear perfectly aligned from a certain point of view?
2724-
// Because in that case, we would still need to perform perspective division for textures and colors...
2724+
// Because in that case, it's still needed to perform perspective division for textures and colors...
27252725
#define DEFINE_QUAD_RASTER_AXIS_ALIGNED(FUNC_NAME, ENABLE_TEXTURE, ENABLE_DEPTH_TEST, ENABLE_COLOR_BLEND) \
27262726
static inline void FUNC_NAME(void) \
27272727
{ \
@@ -3090,7 +3090,7 @@ static inline void FUNC_NAME(const sw_vertex_t *v0, const sw_vertex_t *v1) \
30903090
\
30913091
for (int i = 0; i < numPixels; i++) \
30923092
{ \
3093-
/* REVIEW: May require reviewing projection details */ \
3093+
/* TODO: REVIEW: May require reviewing projection details */ \
30943094
int px = (int)(x - 0.5f); \
30953095
int py = (int)(y - 0.5f); \
30963096
\
@@ -3721,7 +3721,7 @@ void swBlitFramebuffer(int xDst, int yDst, int wDst, int hDst, int xSrc, int ySr
37213721
ySrc = sw_clampi(ySrc, 0, hSrc);
37223722

37233723
// Check if the sizes are identical after clamping the source to avoid unexpected issues
3724-
// REVIEW: This repeats the operations if true, so we could make a copy function without these checks
3724+
// TODO: REVIEW: This repeats the operations if true, so a copy function can be made without these checks
37253725
if (xDst == xSrc && yDst == ySrc && wDst == wSrc && hDst == hSrc)
37263726
{
37273727
swCopyFramebuffer(xSrc, ySrc, wSrc, hSrc, format, type, pixels);

src/platforms/rcore_android.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,7 +1189,7 @@ static int32_t AndroidInputCallback(struct android_app *app, AInputEvent *event)
11891189
if (FLAG_IS_SET(source, AINPUT_SOURCE_JOYSTICK) ||
11901190
FLAG_IS_SET(source, AINPUT_SOURCE_GAMEPAD))
11911191
{
1192-
// For now we'll assume a single gamepad which we "detect" on its input event
1192+
// Assuming a single gamepad, "detected" on its input event
11931193
CORE.Input.Gamepad.ready[0] = true;
11941194

11951195
CORE.Input.Gamepad.axisState[0][GAMEPAD_AXIS_LEFT_X] = AMotionEvent_getAxisValue(
@@ -1256,7 +1256,7 @@ static int32_t AndroidInputCallback(struct android_app *app, AInputEvent *event)
12561256
FLAG_IS_SET(source, AINPUT_SOURCE_GAMEPAD)) &&
12571257
!FLAG_IS_SET(source, AINPUT_SOURCE_KEYBOARD))
12581258
{
1259-
// For now we'll assume a single gamepad which we "detect" on its input event
1259+
// Assuming a single gamepad, "detected" on its input event
12601260
CORE.Input.Gamepad.ready[0] = true;
12611261

12621262
GamepadButton button = AndroidTranslateGamepadButton(keycode);

src/platforms/rcore_desktop_glfw.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ void SetWindowIcon(Image image)
602602
icon[0].height = image.height;
603603
icon[0].pixels = (unsigned char *)image.data;
604604

605-
// NOTE 1: We only support one image icon
605+
// NOTE 1: Only one image icon supported
606606
// NOTE 2: The specified image data is copied before this function returns
607607
glfwSetWindowIcon(platform.handle, 1, icon);
608608
}
@@ -833,7 +833,7 @@ int GetCurrentMonitor(void)
833833
}
834834
else
835835
{
836-
// In case the window is between two monitors, we use below logic
836+
// In case the window is between two monitors, below logic is used
837837
// to try to detect the "current monitor" for that window, note that
838838
// this is probably an overengineered solution for a very side case
839839
// trying to match SDL behaviour
@@ -1186,7 +1186,7 @@ void SetMouseCursor(int cursor)
11861186
if (cursor == MOUSE_CURSOR_DEFAULT) glfwSetCursor(platform.handle, NULL);
11871187
else
11881188
{
1189-
// NOTE: We are relating internal GLFW enum values to our MouseCursor enum values
1189+
// NOTE: Mapping internal GLFW enum values to MouseCursor enum values
11901190
glfwSetCursor(platform.handle, glfwCreateStandardCursor(0x00036000 + cursor));
11911191
}
11921192
}
@@ -1247,7 +1247,7 @@ void PollInputEvents(void)
12471247
CORE.Input.Touch.position[0] = CORE.Input.Mouse.currentPosition;
12481248

12491249
// Check if gamepads are ready
1250-
// NOTE: We do it here in case of disconnection
1250+
// NOTE: Doing it here in case of disconnection
12511251
for (int i = 0; i < MAX_GAMEPADS; i++)
12521252
{
12531253
if (glfwJoystickPresent(i)) CORE.Input.Gamepad.ready[i] = true;
@@ -1263,7 +1263,7 @@ void PollInputEvents(void)
12631263
for (int k = 0; k < MAX_GAMEPAD_BUTTONS; k++) CORE.Input.Gamepad.previousButtonState[i][k] = CORE.Input.Gamepad.currentButtonState[i][k];
12641264

12651265
// Get current gamepad state
1266-
// NOTE: There is no callback available, so we get it manually
1266+
// NOTE: There is no callback available, getting it manually
12671267
GLFWgamepadstate state = { 0 };
12681268
int result = glfwGetGamepadState(i, &state); // This remaps all gamepads so they have their buttons mapped like an xbox controller
12691269
if (result == GLFW_FALSE) // No joystick is connected, no gamepad mapping or an error occurred
@@ -1359,8 +1359,8 @@ void PollInputEvents(void)
13591359
//----------------------------------------------------------------------------------
13601360
// Module Internal Functions Definition
13611361
//----------------------------------------------------------------------------------
1362-
// Function wrappers around RL_*alloc macros, used by glfwInitAllocator() inside of InitPlatform()
1363-
// We need to provide these because GLFWallocator expects function pointers with specific signatures
1362+
// Function wrappers around RL_*ALLOC macros, used by glfwInitAllocator() inside of InitPlatform()
1363+
// GLFWallocator expects function pointers with specific signatures to be provided
13641364
// REF: https://www.glfw.org/docs/latest/intro_guide.html#init_allocator
13651365
static void *AllocateWrapper(size_t size, void *user)
13661366
{
@@ -1742,7 +1742,7 @@ int InitPlatform(void)
17421742
for (int i = 0; i < MAX_GAMEPADS; i++)
17431743
{
17441744
// WARNING: If glfwGetJoystickName() is longer than MAX_GAMEPAD_NAME_LENGTH,
1745-
// we can get a not-NULL terminated string, so, we only copy up to (MAX_GAMEPAD_NAME_LENGTH - 1)
1745+
// only copying up to (MAX_GAMEPAD_NAME_LENGTH - 1)
17461746
if (glfwJoystickPresent(i))
17471747
{
17481748
CORE.Input.Gamepad.ready[i] = true;
@@ -1819,8 +1819,8 @@ static void FramebufferSizeCallback(GLFWwindow *window, int width, int height)
18191819
{
18201820
//TRACELOG(LOG_INFO, "GLFW3: Window framebuffer size callback called [%i,%i]", width, height);
18211821

1822-
// WARNING: On window minimization, callback is called,
1823-
// but we don't want to change internal screen values, it breaks things
1822+
// WARNING: On window minimization, callback is called with 0 values,
1823+
// but internal screen values should not be changed, it breaks things
18241824
if ((width == 0) || (height == 0)) return;
18251825

18261826
// Reset viewport and projection matrix for new size
@@ -1926,7 +1926,7 @@ static void WindowDropCallback(GLFWwindow *window, int count, const char **paths
19261926
{
19271927
if (count > 0)
19281928
{
1929-
// In case previous dropped filepaths have not been freed, we free them
1929+
// In case previous dropped filepaths have not been freed, free them
19301930
if (CORE.Window.dropFileCount > 0)
19311931
{
19321932
for (unsigned int i = 0; i < CORE.Window.dropFileCount; i++) RL_FREE(CORE.Window.dropFilepaths[i]);
@@ -1937,7 +1937,7 @@ static void WindowDropCallback(GLFWwindow *window, int count, const char **paths
19371937
CORE.Window.dropFilepaths = NULL;
19381938
}
19391939

1940-
// WARNING: Paths are freed by GLFW when the callback returns, we must keep an internal copy
1940+
// WARNING: Paths are freed by GLFW when the callback returns, keeping an internal copy
19411941
CORE.Window.dropFileCount = count;
19421942
CORE.Window.dropFilepaths = (char **)RL_CALLOC(CORE.Window.dropFileCount, sizeof(char *));
19431943

@@ -1954,7 +1954,7 @@ static void KeyCallback(GLFWwindow *window, int key, int scancode, int action, i
19541954
{
19551955
if (key < 0) return; // Security check, macOS fn key generates -1
19561956

1957-
// WARNING: GLFW could return GLFW_REPEAT, we need to consider it as 1
1957+
// WARNING: GLFW could return GLFW_REPEAT, it needs to be considered as 1
19581958
// to work properly with our implementation (IsKeyDown/IsKeyUp checks)
19591959
if (action == GLFW_RELEASE) CORE.Input.Keyboard.currentKeyState[key] = 0;
19601960
else if (action == GLFW_PRESS) CORE.Input.Keyboard.currentKeyState[key] = 1;
@@ -2079,7 +2079,7 @@ static void JoystickCallback(int jid, int event)
20792079
if (event == GLFW_CONNECTED)
20802080
{
20812081
// WARNING: If glfwGetJoystickName() is longer than MAX_GAMEPAD_NAME_LENGTH,
2082-
// we can get a not-NULL terminated string, so, we clean destination and only copy up to -1
2082+
// only copy up to (MAX_GAMEPAD_NAME_LENGTH -1) to destination string
20832083
memset(CORE.Input.Gamepad.name[jid], 0, MAX_GAMEPAD_NAME_LENGTH);
20842084
strncpy(CORE.Input.Gamepad.name[jid], glfwGetJoystickName(jid), MAX_GAMEPAD_NAME_LENGTH - 1);
20852085
}

0 commit comments

Comments
 (0)