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
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`.
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
* Fix modulo bias in GetRandomValue(); implement rejection sampling for uniformity
* Replace do-while with for-loop in GetRandomValue rejection sampling
* 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>
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.
* 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>