Commit Graph

427 Commits

Author SHA1 Message Date
Ray
4b760091da REVIEWED: Window scaling with HighDPI on macOS #5059 2025-12-17 21:23:25 +01:00
Ray
6d562e5e87 REVIEWED: HiggDPI content scaling on changing monitors with different DPI #5335 #5356
Note that high-dpi awareness must be enabled by users and `CORE.Window.render` reports the scaled framebuffer size, while `CORE.Window.screen` reports the logical size.

`ToggleBorderlessWindow()` has also been reviewed to be consistent with scaling, if monitor physical display size is reported as 1920x1080 but there is a content scale of 1.5, then the borderless fullscreen window will be 1280x720, with the 1920x1080 framebuffer
2025-12-17 19:20:18 +01:00
Ray
9a337f3b3b ADDED: Support software renderer on Web, blitting framebuffer data directly to a 2d canvas
This improvement is just a prove of concept, at this moment `PLATFORM_WEB` is limited in terms of software rendering by `GLFW` that only allows creating a WebGL canvas context with `glfwCreateWindow()`.

We can skip that call but then some GLFW functionality is not available (windowing, inputs). The best solution is replacing GLFW completely by a pure Emscripten implementation for `PLATFORM_WEB`.
2025-12-14 19:52:18 +01:00
Ray
c96669e123 REVIEWED: Webpage reference comments starting with REF:, more consistent with TODO: and NOTE: comments 2025-12-13 13:03:41 +01:00
Ray
b465b4e2ea RENAMED: Variable names for consistency, textLength (length in bytes) vs textSize (measure in pixels) 2025-12-11 21:41:25 +01:00
Ray
2853b28d6d REVIEWED: Avoid program crash if GPU data is tried to be loaded before InitWindow() #4751
Following raylib design, a warning log message is shown and program can continue execution.
Some early return checks have been added on most  critical functions.
[rtext] Previous implementation checking `isGpuReady` cross-module variable is not needed any more, resulting in a more decoupled code, load failure is managed at rlgl level
2025-12-11 18:21:57 +01:00
Ray
2a566544d4 ADDED: Multiply security checks to avoid crashes on wrongly provided string data #4751
- REVIEWED: Checking `NULL` input on functions getting `const char *text`, to avoid crashes
- REVIEWED: `strcpy()` usage, prioritize `strncpy()` with limited copy to buffer size
- REPLACED: `strlen()` by `TextLength()` on [rtext] module
- REVIEWED: Replaced some early returns (but keeping others, for easier code following)
2025-12-11 12:59:55 +01:00
Ray
bc2057345b REVIEWED: GetRandomValue(), explained the new approach to get more uniform random values range 2025-12-10 09:30:18 +01:00
Marcos De La Torre
f2a900a60d [rcore] Fix modulo bias in GetRandomValue() (#5392)
* Fix modulo bias in GetRandomValue(); implement rejection sampling for uniformity

* Replace do-while with for-loop in GetRandomValue rejection sampling
2025-12-10 09:23:40 +01:00
Ray
91ac3cc707 FIX: LoadRandomSequence(), using GetRandomValue() #5393 2025-12-09 20:02:38 +01:00
Gregory Mitchell
be6007be93 fix: sha1 computation on messages longer than 31 bytes (#5397) 2025-12-09 19:18:43 +01:00
Connor O'Connor
944567651c replace sprintf with snprintf (#5382) 2025-12-02 22:49:55 +01:00
Connor O'Connor
1bbc8682f4 Fixed some typos and mispellings (#5381)
Specifically "occured" -> "occurred"
2025-12-02 22:48:06 +01:00
Ray
8f3cabcf76 Update rcore.c 2025-11-25 19:13:08 +01:00
Ray
bd36610f91 Some formatting 2025-11-24 15:37:28 +01:00
Ray
7e3d6cbfa8 Update rcore.c 2025-11-23 23:16:32 +01:00
Ray
17dc2bb474 Update rcore.c 2025-11-23 22:58:15 +01:00
Ray
aaa893f668 Update rcore.c 2025-11-23 22:58:10 +01:00
Ray
e1b9857b14 Some TODOs and format reviews 2025-11-23 21:40:39 +01:00
Ray
fcaea5b1a1 Remove trailing spaces 2025-11-11 17:39:53 +01:00
Ray
4e8b087ffe REVIEWED: ComputeSHA256() 2025-11-11 17:15:40 +01:00
Ray
0b4815b8fe WARNING: REMOVED: GIT recording option, added example 2025-11-09 13:43:08 +01:00
JohnnyCena123
5fbf67a630 [rcore] Use FLAG_* macros where possible (#5169)
* use FLAG_* macros where possible

* rename `FLAG_CHECK()` to `FLAG_IS_SET()`

* remove unnecessary equality checks

* fix issues

---------

Co-authored-by: Ray <raysan5@gmail.com>
2025-11-02 19:24:47 +01:00
Ray
0fbc4272d0 Remove trailing spaces 2025-10-26 18:22:23 +01:00
Jeffery Myers
12dc0d6675 Revert undesired change to rcore and restore correct win32 ifdef and max path (#5297)
Fixes #5293
also add comment for win32 platform.
2025-10-23 17:45:33 +02:00
Ray
ec06f9be37 Removed trailing spaces 2025-10-21 13:51:03 +02:00
Ray
ec3cb7045f Update rcore.c 2025-10-20 19:09:56 +02:00
Saksham Goyal
adfe2c1704 C++ compiler support v2 (#5252)
* Get C++ compilers working

* Fix Formatting
2025-10-15 19:11:44 +02:00
JohnnyCena123
17bc628fd9 [rcore] Add ComputeSHA256() function (#5264)
* [rcore] Add `ComputeSHA256()` function

* adjust function signatures

* review issues

* fix repeating 0

* fix mistake

* fixed macro

* remove undefs

* review styling mismatches

* rename `A0,1` to `SHA256_A0,1`

---------

Co-authored-by: CrackedPixel <5776225+CrackedPixel@users.noreply.github.com>
2025-10-15 19:07:41 +02:00
Jeffery Myers
7191749d66 [examples] Fix examples to work in MSVC (#5267)
* Fix warnings in many examples
Add examples to MSVC solution correctly

* fix CI error

---------

Co-authored-by: Ray <raysan5@gmail.com>
2025-10-15 19:02:52 +02:00
Jeffery Myers
aaf4c1d3ae always forward declare the windows stuff, prevents failure of rgfw in GCC. (#5269) 2025-10-15 00:18:48 +02:00
Thomas Anderson
2d7b66dd37 change free to RL_FREE (#5265) 2025-10-13 22:15:20 +02:00
JohnnyCena123
02b3e44f88 swap TraceLog to TRACELOG (#5226) 2025-10-02 14:13:07 +02:00
Ray
c264c86ee0 ADDED: Some useful functions for Files and Text management
// File management functions
 - int FileRename(const char *fileName, const char *fileRename); // Rename file (if exists)
 - iint FileRemove(const char *fileName);                         // Remove file (if exists)
 - iint FileCopy(const char *srcPath, const char *dstPath);       // Copy file from one path to another, dstPath created if it doesn't exist
 - iint FileMove(const char *srcPath, const char *dstPath);       // Move file from one directory to another, dstPath created if it doesn't exist
 - int FileTextReplace(const char *fileName, const char *search, const char *replacement); // Replace text in an existing file
 - iint FileTextFindIndex(const char *fileName, const char *search); // Find text in existing file

// Text management functions
 - const char *TextRemoveSpaces(const char *text);                                       // Remove text spaces, concat words
 - char *GetTextBetween(const char *text, const char *begin, const char *end);           // Get text between two strings
 - char *TextReplace(const char *text, const char *search, const char *replacement);     // Replace text string (WARNING: memory must be freed!)
 - char *TextReplaceBetween(const char *text, const char *begin, const char *end, const char *replacement); // Replace text between two specific strings (WARNING: memory must be freed!)
2025-09-18 15:34:09 +02:00
Ray
ed8f1a22d1 Remove trailing spaces 2025-09-14 18:07:58 +02:00
Ray
5a54fc12a2 REVIEWED: Prioritize calloc() calls than malloc() on some cases 2025-09-10 21:03:06 +02:00
Ray
446f015ac5 Review formating 2025-09-05 23:10:13 +02:00
Eike Decker
bd810368b0 Fixing base64 decoding error when input string is bad (#5170)
The following code would crash the previous version when calling MemFree:

	// 53 * A
        const char maliciousBase64Input[] = "AAAAAAAAAAAAAAAAAAAAAAAA"
		"AAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
        int decodedSize = 0;
        unsigned char *decodedData = DecodeDataBase64(
		maliciousBase64Input, &decodedSize);
        if (decodedData) {
		MemFree(decodedData);
        }

The reason is a lack of array bound checks in the decoding loop, which
corrupted here the heap (though this is platform dependent).

Adding the bound checks here prevents the memory corruption.

Tested with encoding random data of sizes 0-1023 and comparing it
with the decoded result.
2025-09-05 23:05:08 +02:00
Ray
ba046a5d60 REVIEWED: DecompressData(), fixed buffer copying 2025-09-04 10:44:20 +02:00
Ray
1777da9056 REVIEWED: Avoid realloc() calls, small security improvement 2025-09-01 20:37:23 +02:00
Jonathan Marler
f61c2c504d [rcore][win32] Adding native win32 backend (#4869)
* win32 backend

* [rcore][win32] use SwapBuffers instead of wglSwapLayerBuffers

I don't understand OpenGL well enough to know the difference between
SwapBuffers and wglSwapLayerBuffers but the former seems to double
my FPS (from 2000 to about 4000 in core_vr_simulator).

* [rcore][win32] stop lying to the OS about when our window is updated

Instead of calling BeginPaint/EndPaint in WM_PAINT which signals to the
OS that our window content is updated, now when we encounter the WM_PAINT
message instead we return back to the raylib application which will
trigger it to render a new frame. We've replaced the call to BeginPaint
and EndPaint with a call to ValidateRect in SwapBuffers, which, means
we're now correctly telling the OS when our window content is actually
up-to-date.

Note that this doesn't fix the window content not being updated during
a window resize/move beacuse thos have their own message loop which
doesn't return early when it's time to paint.

* [rcore][win32] fallback to finding functions from opengl32.dll

* [rcore][win32] fixes from review/for gcc

* [rcore][win32] incorporate style conventions

* [rcore][win32] workaround unused function error SetupFramebuffer

* [rcore][win32] re-enable sanitize flags check for MSAA_4X

* [rcore][win32] more style changes and remove old DPI cases

Added some more missing spaces after conditional statements.  Also
made unsupported MSAA_4X an assert instead of an abort and also
removed dpi-aware cases for older OS's.  More changes would be needed
to support those OS versions, namely, removing the dependency
on shcore.

* [rcore][win32] fixes for compling with w64devkit without -DUNICODE

* Update build.zig

* Update build.zig

---------

Co-authored-by: Ray <raysan5@gmail.com>
2025-08-31 12:13:21 +02:00
Ray
ecf032fe4f REVIEW: Avoid warning on fgets() return value 2025-08-31 12:11:48 +02:00
Ray
04a3ab0ca7 REVIEW: Added warning in case of no [rcore] backend defined 2025-08-24 11:23:15 +02:00
Ray
0dc4ba53dc Minor format tweak 2025-08-16 21:06:13 +02:00
Ray
a9970484f3 Remove trailing spaces 2025-08-14 20:37:18 +02:00
Ray
74339d2008 REVIEWED: IsFileExtension() 2025-08-13 10:43:33 +02:00
Ray
95e4494cfe ADDED: cursorLocked variable and review required code #4940 #4955 2025-08-12 11:33:58 +02:00
Ray
c6241b91a2 REVIEWED: IsFileExtension() to avoid other modules dependency #5071 2025-08-08 23:01:04 +02:00
Nikolas
7267c1c8a1 Make culling distances consistent across raylib 2025-08-05 00:15:52 +02:00
Jeffery Myers
bf536d68e1 Make GetRenderWidth and GetREnderHeight return the FBO size if one is active. 2025-08-02 08:37:11 -07:00