4 Commits

Author SHA1 Message Date
82e087fb2d [examples] Skip empty areas in tiled texture drawing (#6412)
Co-authored-by: yex743055-sudo <318559365+yex743055-sudo@users.noreply.github.com>
2026-11-13 10:55:39 +01:00
3c3ffbba6e [rcore] adding copy to clipboard on android (#6404)
* adding copy to clipboard

* remove uncessary exception check
2026-11-13 09:44:17 +01:00
7a66ead764 Update sola-raylib for raylib 6.2 support (#6411)
It recently shipped in crate version 6.4.0
https://github.com/brettchalupa/sola-raylib/releases/tag/v6.4.0
2026-11-13 09:42:51 +01:00
cfcfb2bbf9 [rcore] Make GetWindowScaleDPI() consistent on all backends (#6402)
* [rcore] Make `GetWindowScaleDPI()` consistent on all desktop and web backends

* Revert non-GLFW backend changes

This reverts commit 238899d328.

* Remove window flag checks in GetWindowScaleDPI

* Make GLFW match other backends; update uses of GetWindowScaleDPI()

* Keep GLFW scissor behavior unchanged; use render size in TakeScreenshot
2026-11-13 09:42:26 +01:00
5 changed files with 46 additions and 15 deletions

View File

@ -97,7 +97,7 @@ This is a set of recommendations and guidelines for binding authors, meant to he
| [raylibr](https://github.com/jeroenjanssens/raylibr) | auto | [R](https://www.r-project.org) | MIT |
| [raylib-ffi](https://github.com/ewpratten/raylib-ffi) | 5.5 | [Rust](https://www.rust-lang.org) | GPLv3 |
| [raylib-rs](https://github.com/raylib-rs/raylib-rs) | **6.0** | [Rust](https://www.rust-lang.org) | Zlib |
| [sola-raylib](https://github.com/brettchalupa/sola-raylib) | **6.0** | [Rust](https://www.rust-lang.org) | Zlib |
| [sola-raylib](https://github.com/brettchalupa/sola-raylib) | **6.2** | [Rust](https://www.rust-lang.org) | Zlib |
| [raylib-ruby](https://github.com/wilsonsilva/raylib-ruby) | 4.5 | [Ruby](https://www.ruby-lang.org) | Zlib |
| [racket-raylib](https://github.com/eutro/racket-raylib) | **6.0** | [Racket](https://racket-lang.org) | MIT/Apache-2.0 |
| [raylib-swift](https://github.com/STREGAsGate/Raylib) | 4.0 | [Swift](https://swift.org) | MIT |

View File

@ -176,6 +176,7 @@ void DrawTextureTiled(Texture2D texture, Rectangle source, Rectangle dest, Vecto
{
if ((texture.id <= 0) || (scale <= 0.0f)) return; // Wanna see a infinite loop?!...just delete this line!
if ((source.width == 0) || (source.height == 0)) return;
if ((dest.width <= 0.0f) || (dest.height <= 0.0f)) return; // Resizing can leave no space for tiles
int tileWidth = (int)(source.width*scale), tileHeight = (int)(source.height*scale);
if ((dest.width < tileWidth) && (dest.height < tileHeight))

View File

@ -583,9 +583,43 @@ Vector2 GetWindowScaleDPI(void)
}
// Set clipboard text content
// NOTE: Implementation based on https://stackoverflow.com/questions/76759222/how-to-copy-to-clipboard-on-android-via-jni
void SetClipboardText(const char *text)
{
TRACELOG(LOG_WARNING, "SetClipboardText() not implemented on target platform");
JNIEnv *env = NULL;
JavaVM *vm = platform.app->activity->vm;
jint result = (*vm)->AttachCurrentThread(vm, &env, NULL);
if (result != JNI_OK) {
TRACELOG(LOG_WARNING, "Failed to allocate a thread to set the clipboard text");
return;
}
jobject activity = platform.app->activity->clazz;
if (!activity) {
TRACELOG(LOG_WARNING, "Failed to get Android activity class reference");
(*vm)->DetachCurrentThread(vm);
return;
}
// ClipboardManager
jclass activityClass = (*env)->GetObjectClass(env, activity);
jmethodID getSystemService = (*env)->GetMethodID(env, activityClass, "getSystemService", "(Ljava/lang/String;)Ljava/lang/Object;");
jstring serviceName = (*env)->NewStringUTF(env, "clipboard");
jobject clipboard = (*env)->CallObjectMethod(env, activity, getSystemService, serviceName);
// ClipData
jclass clipDataClass = (*env)->FindClass(env, "android/content/ClipData");
jmethodID newPlainText = (*env)->GetStaticMethodID(env, clipDataClass, "newPlainText", "(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Landroid/content/ClipData;");
const char *windowTitle = (CORE.Window.title != NULL) ? CORE.Window.title : "raylib";
jstring label = (*env)->NewStringUTF(env, windowTitle);
jstring textString = (*env)->NewStringUTF(env, text);
jobject clip = (*env)->CallStaticObjectMethod(env, clipDataClass, newPlainText, label, textString);
// cm.setPrimaryClip(clip)
jclass clipboardClass = (*env)->FindClass(env, "android/content/ClipboardManager");
jmethodID setPrimaryClip = (*env)->GetMethodID(env, clipboardClass, "setPrimaryClip", "(Landroid/content/ClipData;)V");
(*env)->CallVoidMethod(env, clipboard, setPrimaryClip, clip);
(*vm)->DetachCurrentThread(vm);
}
// Get clipboard text content

View File

@ -764,7 +764,7 @@ void SetWindowSize(int width, int height)
CORE.Window.screen.height = height;
#if !defined(__APPLE__)
if (FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_HIGHDPI) && (glfwGetPlatform() != GLFW_PLATFORM_WAYLAND))
if (FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_HIGHDPI) && !FLAG_IS_SET(CORE.Window.flags, FLAG_FULLSCREEN_MODE) && (glfwGetPlatform() != GLFW_PLATFORM_WAYLAND))
{
Vector2 scaleDpi = GetWindowScaleDPI();
width = (int)roundf((float)width*scaleDpi.x);
@ -1070,10 +1070,7 @@ Vector2 GetWindowPosition(void)
Vector2 GetWindowScaleDPI(void)
{
Vector2 scale = { 1.0f, 1.0f };
if (FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_HIGHDPI) && !FLAG_IS_SET(CORE.Window.flags, FLAG_FULLSCREEN_MODE))
glfwGetWindowContentScale(platform.handle, &scale.x, &scale.y);
glfwGetWindowContentScale(platform.handle, &scale.x, &scale.y);
return scale;
}
@ -1790,6 +1787,8 @@ int InitPlatform(void)
{
// Set screen size to logical pixel size, considering content scaling
Vector2 scaleDpi = GetWindowScaleDPI();
if (FLAG_IS_SET(CORE.Window.flags, FLAG_FULLSCREEN_MODE)) scaleDpi = (Vector2){ 1.0f, 1.0f };
CORE.Window.render.width = (int)roundf(CORE.Window.screen.width*scaleDpi.x);
CORE.Window.render.height = (int)roundf(CORE.Window.screen.height*scaleDpi.y);
//TRACELOG(LOG_INFO, "DPI SCALING: %.2f, %.2f", scaleDpi.x, scaleDpi.y);

View File

@ -1090,11 +1090,12 @@ void BeginScissorMode(int x, int y, int width, int height)
#if defined(__APPLE__)
if (!CORE.Window.usingFbo)
{
Vector2 scale = GetWindowScaleDPI();
Vector2 scale = { 1.0f, 1.0f };
if (FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_HIGHDPI) && !FLAG_IS_SET(CORE.Window.flags, FLAG_FULLSCREEN_MODE)) scale = GetWindowScaleDPI();
rlScissor((int)(x*scale.x), (int)(GetScreenHeight()*scale.y - (((y + height)*scale.y))), (int)(width*scale.x), (int)(height*scale.y));
}
#else
if (!CORE.Window.usingFbo && FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_HIGHDPI))
if (!CORE.Window.usingFbo && FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_HIGHDPI) && !FLAG_IS_SET(CORE.Window.flags, FLAG_FULLSCREEN_MODE))
{
Vector2 scale = GetWindowScaleDPI();
rlScissor((int)(x*scale.x), (int)(CORE.Window.currentFbo.height - (y + height)*scale.y), (int)(width*scale.x), (int)(height*scale.y));
@ -1824,12 +1825,8 @@ void TakeScreenshot(const char *fileName)
// Security check to (partially) avoid malicious code
if (strchr(fileName, '\'') != NULL) { TRACELOG(LOG_WARNING, "SYSTEM: Provided fileName could be potentially malicious, avoid [\'] character"); return; }
// Apply content scaling if required
Vector2 scale = { 1.0f, 1.0f };
if (FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_HIGHDPI)) scale = GetWindowScaleDPI();
unsigned char *imgData = rlReadScreenPixels((int)((float)CORE.Window.render.width*scale.x), (int)((float)CORE.Window.render.height*scale.y));
Image image = { imgData, (int)((float)CORE.Window.render.width*scale.x), (int)((float)CORE.Window.render.height*scale.y), 1, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8 };
unsigned char *imgData = rlReadScreenPixels(CORE.Window.render.width, CORE.Window.render.height);
Image image = { imgData, CORE.Window.render.width, CORE.Window.render.height, 1, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8 };
char path[MAX_FILEPATH_LENGTH] = { 0 };
if (!IsPathAbsolute(fileName)) snprintf(path, MAX_FILEPATH_LENGTH, "%s", TextFormat("%s/%s", CORE.Storage.basePath, fileName));