Skip to content

Commit bd36610

Browse files
committed
Some formatting
1 parent 7e3d6cb commit bd36610

File tree

9 files changed

+74
-59
lines changed

9 files changed

+74
-59
lines changed

src/config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
#define SUPPORT_CLIPBOARD_IMAGE 1
7676

7777
// NOTE: Clipboard image loading requires support for some image file formats
78-
// TODO: Those defines should probably be removed from here, I prefer to let the user manage them
78+
// TODO: Those defines should probably be removed from here, letting the user manage them
7979
#if defined(SUPPORT_CLIPBOARD_IMAGE)
8080
#ifndef SUPPORT_MODULE_RTEXTURES
8181
#define SUPPORT_MODULE_RTEXTURES 1

src/external/rlsw.h

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3668,9 +3668,9 @@ void swCopyFramebuffer(int x, int y, int w, int h, SWformat format, SWtype type,
36683668
x = sw_clampi(x, 0, w);
36693669
y = sw_clampi(y, 0, h);
36703670

3671-
if (x >= w || y >= h) return;
3671+
if ((x >= w) || (y >= h)) return;
36723672

3673-
if (x == 0 && y == 0 && w == RLSW.framebuffer.width && h == RLSW.framebuffer.height)
3673+
if ((x == 0) && (y == 0) && (w == RLSW.framebuffer.width) && (h == RLSW.framebuffer.height))
36743674
{
36753675
#if SW_COLOR_BUFFER_BITS == 32
36763676
if (pFormat == SW_PIXELFORMAT_UNCOMPRESSED_R8G8B8A8)
@@ -3695,17 +3695,15 @@ void swCopyFramebuffer(int x, int y, int w, int h, SWformat format, SWtype type,
36953695
case SW_PIXELFORMAT_UNCOMPRESSED_R8G8B8: sw_framebuffer_copy_to_R8G8B8(x, y, w, h, (uint8_t *)pixels); break;
36963696
case SW_PIXELFORMAT_UNCOMPRESSED_R5G5B5A1: sw_framebuffer_copy_to_R5G5B5A1(x, y, w, h, (uint16_t *)pixels); break;
36973697
case SW_PIXELFORMAT_UNCOMPRESSED_R4G4B4A4: sw_framebuffer_copy_to_R4G4B4A4(x, y, w, h, (uint16_t *)pixels); break;
3698-
case SW_PIXELFORMAT_UNCOMPRESSED_R8G8B8A8: sw_framebuffer_copy_to_R8G8B8A8(x, y, w, h, (uint8_t *)pixels); break;
3698+
//case SW_PIXELFORMAT_UNCOMPRESSED_R8G8B8A8: sw_framebuffer_copy_to_R8G8B8A8(x, y, w, h, (uint8_t *)pixels); break;
36993699
// Below: not implemented
37003700
case SW_PIXELFORMAT_UNCOMPRESSED_R32:
37013701
case SW_PIXELFORMAT_UNCOMPRESSED_R32G32B32:
37023702
case SW_PIXELFORMAT_UNCOMPRESSED_R32G32B32A32:
37033703
case SW_PIXELFORMAT_UNCOMPRESSED_R16:
37043704
case SW_PIXELFORMAT_UNCOMPRESSED_R16G16B16:
37053705
case SW_PIXELFORMAT_UNCOMPRESSED_R16G16B16A16:
3706-
default:
3707-
RLSW.errCode = SW_INVALID_ENUM;
3708-
break;
3706+
default: RLSW.errCode = SW_INVALID_ENUM; break;
37093707
}
37103708
}
37113709

@@ -4330,7 +4328,7 @@ void swVertex2f(float x, float y)
43304328
void swVertex2fv(const float *v)
43314329
{
43324330
const float v4[4] = { v[0], v[1], 0.0f, 1.0f };
4333-
sw_immediate_push_vertex(v, RLSW.current.color, RLSW.current.texcoord);
4331+
sw_immediate_push_vertex(v4, RLSW.current.color, RLSW.current.texcoord);
43344332
}
43354333

43364334
void swVertex3i(int x, int y, int z)
@@ -4348,7 +4346,7 @@ void swVertex3f(float x, float y, float z)
43484346
void swVertex3fv(const float *v)
43494347
{
43504348
const float v4[4] = { v[0], v[1], v[2], 1.0f };
4351-
sw_immediate_push_vertex(v, RLSW.current.color, RLSW.current.texcoord);
4349+
sw_immediate_push_vertex(v4, RLSW.current.color, RLSW.current.texcoord);
43524350
}
43534351

43544352
void swVertex4i(int x, int y, int z, int w)

src/platforms/rcore_desktop_glfw.c

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,28 +78,27 @@
7878
#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)
7979
#include <sys/time.h> // Required for: timespec, nanosleep(), select() - POSIX
8080

81-
#if defined(_GLFW_X11) || defined(_GLFW_WAYLAND)
81+
#if defined(_GLFW_X11) || defined(_GLFW_WAYLAND)
8282
// Set appropriate expose macros based on available backends
83-
#if defined(_GLFW_X11)
84-
#define GLFW_EXPOSE_NATIVE_X11
85-
#define Font X11Font // Hack to fix 'Font' name collision
83+
#if defined(_GLFW_X11)
84+
#define GLFW_EXPOSE_NATIVE_X11
85+
#define Font X11Font // Hack to fix 'Font' name collision
8686
// The definition and references to the X11 Font type will be replaced by 'X11Font'
8787
// Works as long as the current file consistently references any X11 Font as X11Font
8888
// Since it is never referenced (as of writing), this does not pose an issue
89-
#endif
89+
#endif
9090

91-
#if defined(_GLFW_WAYLAND)
92-
#define GLFW_EXPOSE_NATIVE_WAYLAND
93-
#endif
91+
#if defined(_GLFW_WAYLAND)
92+
#define GLFW_EXPOSE_NATIVE_WAYLAND
93+
#endif
9494

95-
#include "GLFW/glfw3native.h" // Include native header only once, regardless of how many backends are defined
95+
#include "GLFW/glfw3native.h" // Include native header only once, regardless of how many backends are defined
9696
// Required for: glfwGetX11Window() and glfwGetWaylandWindow()
97-
98-
#if defined(_GLFW_X11) // Clean up X11-specific hacks
99-
#undef Font // Revert hack and allow normal raylib Font usage
97+
#if defined(_GLFW_X11) // Clean up X11-specific hacks
98+
#undef Font // Revert hack and allow normal raylib Font usage
99+
#endif
100100
#endif
101101
#endif
102-
#endif
103102
#if defined(__APPLE__)
104103
#include <unistd.h> // Required for: usleep()
105104

src/platforms/rcore_desktop_win32.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -262,9 +262,9 @@ static bool DecoratedFromStyle(DWORD style)
262262
// Get window style from required flags
263263
static DWORD MakeWindowStyle(unsigned flags)
264264
{
265-
// We don't need this since we don't have any child windows, but I guess
266-
// it improves efficiency, plus, windows adds this flag automatically anyway
267-
// so it keeps our flags in sync with the OS
265+
// Flag is not needed because there are no child windows,
266+
// but supposedly it improves efficiency, plus, windows adds this
267+
// flag automatically anyway so it keeps flags in sync with the OS
268268
DWORD style = WS_CLIPSIBLINGS;
269269

270270
style |= (flags & FLAG_WINDOW_HIDDEN)? 0 : WS_VISIBLE;
@@ -1230,7 +1230,7 @@ void SwapScreenBuffer(void)
12301230
// Get elapsed time measure in seconds
12311231
double GetTime(void)
12321232
{
1233-
LARGE_INTEGER now;
1233+
LARGE_INTEGER now = 0;
12341234
QueryPerformanceCounter(&now);
12351235
return (double)(now.QuadPart - CORE.Time.base)/(double)platform.timerFrequency.QuadPart;
12361236
}
@@ -1987,7 +1987,7 @@ static void HandleKey(WPARAM wparam, LPARAM lparam, char state)
19871987
{
19881988
CORE.Input.Keyboard.currentKeyState[key] = state;
19891989

1990-
if ((key == KEY_ESCAPE) && (state == 1)) CORE.Window.shouldClose = 1;
1990+
if ((key == KEY_ESCAPE) && (state == 1)) CORE.Window.shouldClose = true;
19911991
}
19921992
else TRACELOG(LOG_WARNING, "INPUT: Unknown (or currently unhandled) virtual keycode %d (0x%x)", wparam, wparam);
19931993

src/raylib.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,13 @@
9999
#define __declspec(x) __attribute__((x))
100100
#endif
101101
#if defined(BUILD_LIBTYPE_SHARED)
102-
#define RLAPI __declspec(dllexport) // We are building the library as a Win32 shared library (.dll)
102+
#define RLAPI __declspec(dllexport) // Building the library as a Win32 shared library (.dll)
103103
#elif defined(USE_LIBTYPE_SHARED)
104-
#define RLAPI __declspec(dllimport) // We are using the library as a Win32 shared library (.dll)
104+
#define RLAPI __declspec(dllimport) // Using the library as a Win32 shared library (.dll)
105105
#endif
106106
#else
107107
#if defined(BUILD_LIBTYPE_SHARED)
108-
#define RLAPI __attribute__((visibility("default"))) // We are building as a Unix shared library (.so/.dylib)
108+
#define RLAPI __attribute__((visibility("default"))) // Building as a Unix shared library (.so/.dylib)
109109
#endif
110110
#endif
111111

@@ -157,7 +157,7 @@
157157
#error "C++11 or later is required. Add -std=c++11"
158158
#endif
159159

160-
// NOTE: We set some defines with some data types declared by raylib
160+
// NOTE: Set some defines with some data types declared by raylib
161161
// Other modules (raymath, rlgl) also require some of those types, so,
162162
// to be able to use those other modules as standalone (not depending on raylib)
163163
// this defines are very useful for internal check and avoid type (re)definitions

src/rcore.c

Lines changed: 42 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
* - Android (ARM, ARM64)
2929
* > PLATFORM_DESKTOP_WIN32 (Native Win32):
3030
* - Windows (Win32, Win64)
31+
* > PLATFORM_MEMORY
32+
* - Memory framebuffer output, using software renderer, no OS required
3133
* CONFIGURATION:
3234
* #define SUPPORT_DEFAULT_FONT (default)
3335
* Default font is loaded on window initialization to be available for the user to render simple text
@@ -92,12 +94,12 @@
9294
//----------------------------------------------------------------------------------
9395
#if (defined(__linux__) || defined(PLATFORM_WEB) || defined(PLATFORM_WEB_RGFW)) && (_XOPEN_SOURCE < 500)
9496
#undef _XOPEN_SOURCE
95-
#define _XOPEN_SOURCE 500 // Required for: readlink if compiled with c99 without gnu ext.
97+
#define _XOPEN_SOURCE 500 // Required for: readlink if compiled with c99 without GNU extensions
9698
#endif
9799

98100
#if (defined(__linux__) || defined(PLATFORM_WEB) || defined(PLATFORM_WEB_RGFW)) && (_POSIX_C_SOURCE < 199309L)
99101
#undef _POSIX_C_SOURCE
100-
#define _POSIX_C_SOURCE 199309L // Required for: CLOCK_MONOTONIC if compiled with c99 without gnu ext.
102+
#define _POSIX_C_SOURCE 199309L // Required for: CLOCK_MONOTONIC if compiled with c99 without GNU extensions
101103
#endif
102104

103105
#include "raylib.h" // Declares module functions
@@ -115,6 +117,9 @@
115117
#include <time.h> // Required for: time() [Used in InitTimer()]
116118
#include <math.h> // Required for: tan() [Used in BeginMode3D()], atan2f() [Used in LoadVrStereoConfig()]
117119

120+
#if defined(PLATFORM_MEMORY)
121+
#define SW_GL_FRAMEBUFFER_COPY_BGRA false
122+
#endif
118123
#define RLGL_IMPLEMENTATION
119124
#include "rlgl.h" // OpenGL abstraction layer to OpenGL 1.1, 3.3+ or ES2
120125

@@ -155,18 +160,18 @@
155160
#define MAX_PATH 260
156161
#endif
157162

158-
struct HINSTANCE__;
159-
#if defined(__cplusplus)
160-
extern "C" {
161-
#endif
162-
__declspec(dllimport) unsigned long __stdcall GetModuleFileNameA(struct HINSTANCE__ *hModule, char *lpFilename, unsigned long nSize);
163-
__declspec(dllimport) unsigned long __stdcall GetModuleFileNameW(struct HINSTANCE__ *hModule, wchar_t *lpFilename, unsigned long nSize);
164-
__declspec(dllimport) int __stdcall WideCharToMultiByte(unsigned int cp, unsigned long flags, const wchar_t *widestr, int cchwide, char *str, int cbmb, const char *defchar, int *used_default);
165-
__declspec(dllimport) unsigned int __stdcall timeBeginPeriod(unsigned int uPeriod);
166-
__declspec(dllimport) unsigned int __stdcall timeEndPeriod(unsigned int uPeriod);
167-
#if defined(__cplusplus)
168-
}
169-
#endif
163+
struct HINSTANCE__;
164+
#if defined(__cplusplus)
165+
extern "C" {
166+
#endif
167+
__declspec(dllimport) unsigned long __stdcall GetModuleFileNameA(struct HINSTANCE__ *hModule, char *lpFilename, unsigned long nSize);
168+
__declspec(dllimport) unsigned long __stdcall GetModuleFileNameW(struct HINSTANCE__ *hModule, wchar_t *lpFilename, unsigned long nSize);
169+
__declspec(dllimport) int __stdcall WideCharToMultiByte(unsigned int cp, unsigned long flags, const wchar_t *widestr, int cchwide, char *str, int cbmb, const char *defchar, int *used_default);
170+
__declspec(dllimport) unsigned int __stdcall timeBeginPeriod(unsigned int uPeriod);
171+
__declspec(dllimport) unsigned int __stdcall timeEndPeriod(unsigned int uPeriod);
172+
#if defined(__cplusplus)
173+
}
174+
#endif
170175
#elif defined(__linux__)
171176
#include <unistd.h>
172177
#elif defined(__FreeBSD__)
@@ -314,7 +319,8 @@ typedef struct CoreData {
314319
char currentKeyState[MAX_KEYBOARD_KEYS]; // Registers current frame key state
315320
char previousKeyState[MAX_KEYBOARD_KEYS]; // Registers previous frame key state
316321

317-
// NOTE: Since key press logic involves comparing prev vs cur key state, we need to handle key repeats specially
322+
// NOTE: Since key press logic involves comparing previous vs currrent key state,
323+
// key repeats needs to be handled specially
318324
char keyRepeatInFrame[MAX_KEYBOARD_KEYS]; // Registers key repeats for current frame
319325

320326
int keyPressedQueue[MAX_KEY_PRESSED_QUEUE]; // Input keys queue
@@ -547,6 +553,8 @@ const char *TextFormat(const char *text, ...); // Formatting of text with variab
547553
#include "platforms/rcore_drm.c"
548554
#elif defined(PLATFORM_ANDROID)
549555
#include "platforms/rcore_android.c"
556+
#elif defined(PLATFORM_MEMORY)
557+
#include "platforms/rcore_memory.c"
550558
#else
551559
// TODO: Include your custom platform backend!
552560
// i.e software rendering backend or console backend!
@@ -621,6 +629,8 @@ void InitWindow(int width, int height, const char *title)
621629
TRACELOG(LOG_INFO, "Platform backend: NATIVE DRM");
622630
#elif defined(PLATFORM_ANDROID)
623631
TRACELOG(LOG_INFO, "Platform backend: ANDROID");
632+
#elif defined(PLATFORM_MEMORY)
633+
TRACELOG(LOG_INFO, "Platform backend: MEMORY (No OS)");
624634
#else
625635
// TODO: Include your custom platform backend!
626636
// i.e software rendering backend or console backend!
@@ -2233,13 +2243,15 @@ const char *GetApplicationDirectory(void)
22332243

22342244
#if defined(_WIN32)
22352245
int len = 0;
2236-
#if defined(UNICODE)
2246+
2247+
#if defined(UNICODE)
22372248
unsigned short widePath[MAX_PATH];
22382249
len = GetModuleFileNameW(NULL, (wchar_t *)widePath, MAX_PATH);
22392250
len = WideCharToMultiByte(0, 0, (wchar_t *)widePath, len, appDir, MAX_PATH, NULL, NULL);
2240-
#else
2251+
#else
22412252
len = GetModuleFileNameA(NULL, appDir, MAX_PATH);
2242-
#endif
2253+
#endif
2254+
22432255
if (len > 0)
22442256
{
22452257
for (int i = len; i >= 0; --i)
@@ -2256,8 +2268,9 @@ const char *GetApplicationDirectory(void)
22562268
appDir[0] = '.';
22572269
appDir[1] = '\\';
22582270
}
2259-
2271+
22602272
#elif defined(__linux__)
2273+
22612274
unsigned int size = sizeof(appDir);
22622275
ssize_t len = readlink("/proc/self/exe", appDir, size);
22632276

@@ -2277,7 +2290,9 @@ const char *GetApplicationDirectory(void)
22772290
appDir[0] = '.';
22782291
appDir[1] = '/';
22792292
}
2293+
22802294
#elif defined(__APPLE__)
2295+
22812296
uint32_t size = sizeof(appDir);
22822297

22832298
if (_NSGetExecutablePath(appDir, &size) == 0)
@@ -2297,8 +2312,11 @@ const char *GetApplicationDirectory(void)
22972312
appDir[0] = '.';
22982313
appDir[1] = '/';
22992314
}
2315+
23002316
#elif defined(__FreeBSD__)
2301-
size_t size = sizeof(appDir);
2317+
2318+
size_t size = sizeof(appD
2319+
ir);
23022320
int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1};
23032321

23042322
if (sysctl(mib, 4, appDir, &size, NULL, 0) == 0)
@@ -2318,7 +2336,6 @@ const char *GetApplicationDirectory(void)
23182336
appDir[0] = '.';
23192337
appDir[1] = '/';
23202338
}
2321-
23222339
#endif
23232340

23242341
return appDir;
@@ -3748,20 +3765,20 @@ void InitTimer(void)
37483765
// High resolutions can also prevent the CPU power management system from entering power-saving modes
37493766
// Setting a higher resolution does not improve the accuracy of the high-resolution performance counter
37503767
#if defined(_WIN32) && defined(SUPPORT_WINMM_HIGHRES_TIMER) && !defined(SUPPORT_BUSY_WAIT_LOOP) && !defined(PLATFORM_DESKTOP_SDL)
3751-
timeBeginPeriod(1); // Setup high-resolution timer to 1ms (granularity of 1-2 ms)
3768+
timeBeginPeriod(1); // Setup high-resolution timer to 1ms (granularity of 1-2 ms)
37523769
#endif
37533770

37543771
#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__EMSCRIPTEN__)
37553772
struct timespec now = { 0 };
37563773

3757-
if (clock_gettime(CLOCK_MONOTONIC, &now) == 0) // Success
3774+
if (clock_gettime(CLOCK_MONOTONIC, &now) == 0) // Success
37583775
{
37593776
CORE.Time.base = (unsigned long long int)now.tv_sec*1000000000LLU + (unsigned long long int)now.tv_nsec;
37603777
}
37613778
else TRACELOG(LOG_WARNING, "TIMER: Hi-resolution timer not available");
37623779
#endif
37633780

3764-
CORE.Time.previous = GetTime(); // Get time as double
3781+
CORE.Time.previous = GetTime(); // Get time as double
37653782
}
37663783

37673784
// Set viewport for a provided width and height
@@ -3887,6 +3904,7 @@ static void ScanDirectoryFiles(const char *basePath, FilePathList *files, const
38873904
if ((strcmp(dp->d_name, ".") != 0) &&
38883905
(strcmp(dp->d_name, "..") != 0))
38893906
{
3907+
// Construct new path from our base path
38903908
#if defined(_WIN32)
38913909
int pathLength = snprintf(path, MAX_FILEPATH_LENGTH - 1, "%s\\%s", basePath, dp->d_name);
38923910
#else

src/rmodels.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5018,7 +5018,7 @@ static ModelAnimation *LoadModelAnimationsIQM(const char *fileName, int *animCou
50185018
animations[a].boneCount = iqmHeader->num_poses;
50195019
animations[a].bones = (BoneInfo *)RL_MALLOC(iqmHeader->num_poses*sizeof(BoneInfo));
50205020
animations[a].framePoses = (Transform **)RL_MALLOC(anim[a].num_frames*sizeof(Transform *));
5021-
memcpy(animations[a].name, fileDataPtr + iqmHeader->ofs_text + anim[a].name, 32); // I don't like this 32 here
5021+
memcpy(animations[a].name, fileDataPtr + iqmHeader->ofs_text + anim[a].name, 32);
50225022
TRACELOG(LOG_INFO, "IQM Anim %s", animations[a].name);
50235023
//animations[a].framerate = anim.framerate; // TODO: Use animation framerate data?
50245024

src/rtextures.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,7 +1099,7 @@ Image GenImageCellular(int width, int height, int tileSize)
10991099
}
11001100
}
11011101

1102-
// I made this up, but it seems to give good results at all tile sizes
1102+
// This approach seems to give good results at all tile sizes
11031103
int intensity = (int)(minDistance*256.0f/tileSize);
11041104
if (intensity > 255) intensity = 255;
11051105

@@ -4600,7 +4600,7 @@ void DrawTexturePro(Texture2D texture, Rectangle source, Rectangle dest, Vector2
46004600
// NOTE: Vertex position can be transformed using matrices
46014601
// but the process is way more costly than just calculating
46024602
// the vertex positions manually, like done above
4603-
// I leave here the old implementation for educational purposes,
4603+
// Old implementation is left here for educational purposes,
46044604
// just in case someone wants to do some performance test
46054605
/*
46064606
rlSetTexture(texture.id);

src/utils.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ FILE *android_fopen(const char *fileName, const char *mode)
451451
{
452452
if (mode[0] == 'w')
453453
{
454-
// fopen() is mapped to android_fopen() that only grants read access to
454+
// NOTE: fopen() is mapped to android_fopen() that only grants read access to
455455
// assets directory through AAssetManager but we want to also be able to
456456
// write data when required using the standard stdio FILE access functions
457457
// Ref: https://stackoverflow.com/questions/11294487/android-writing-saving-files-from-native-code-only

0 commit comments

Comments
 (0)