mirror of
https://github.com/raysan5/raylib.git
synced 2026-11-25 09:01:47 -05:00
Compare commits
4 Commits
1825891abc
...
82e087fb2d
| Author | SHA1 | Date | |
|---|---|---|---|
| 82e087fb2d | |||
| 3c3ffbba6e | |||
| 7a66ead764 | |||
| cfcfb2bbf9 |
@ -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 |
|
||||
|
||||
@ -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))
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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);
|
||||
|
||||
13
src/rcore.c
13
src/rcore.c
@ -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));
|
||||
|
||||
Reference in New Issue
Block a user