raysan5 / raylib

A simple and easy-to-use library to enjoy videogames programming
http://www.raylib.com
zlib License
22.47k stars 2.26k forks source link

[rcore] Render issue when window is partially move outside of the monitor #3980

Open hubastard opened 5 months ago

hubastard commented 5 months ago

Please, before submitting a new issue verify and check:

Issue description

On MacOS when you drag the window slightly out of the monitor on the left, the rendering shrinks in half in the window, but only if there is a call to BeginTextureMode() in the render loop. If I remove the BeginTextureMode() from my render code, this issue does not happen. (See video below)

Environment

MacOS 14.3.1 (M1 - Apple Chip), OpenGL version 3

Issue Screenshot

https://github.com/raysan5/raylib/assets/69216913/aac54f10-539a-47b1-a3dc-d5f338150e74

Code Example

#include "raylib.h"

int main(void)
{
  const int windowWidth = 800;
  const int windowHeight = 450;

  InitWindow(windowWidth, windowHeight, "test");

  RenderTexture2D target = LoadRenderTexture(windowWidth, windowHeight);

  while (!WindowShouldClose())
  {
    BeginTextureMode(target);
    EndTextureMode();

    BeginDrawing();
    ClearBackground(BLACK);
    DrawRectangle(0, 0, windowWidth, windowHeight, RED);
    EndDrawing();
  }

  UnloadRenderTexture(target);
  CloseWindow();

  return 0;
}
raysan5 commented 5 months ago

Wow! Good catch! Why???

hubastard commented 5 months ago

I have a feeling that it's related to a DPI issue. The only thing that I notice is that when the window is centered in the screen GetWindowScaleDPI() returns 2.0 and when I drag it out of the screen it returns 1.0. That could explain why the render is half the size, but it doesn't explain why it works fine when you don't use BeginTextureMode() O.o

CrackedPixel commented 4 months ago

@hubastard do you have multiple monitors or just the one? trying to replicate this

hubastard commented 4 months ago

I was on a M1 MacBook without any external monitors.

CodingMadness commented 1 month ago

Has this been resolved?

MegaWatt123 commented 1 month ago

Has this been resolved?

I think so, I tried the code and didn't have any issue

J-Siu commented 17 hours ago

I tested this on my Macbook Air M2, MacOS 15.0.1.

Raylib is main branch, v5.5 base on raylib.h.

VSCode project is from raylib-quickstart.

https://github.com/user-attachments/assets/b15af7f0-995d-4a76-88ea-00ffa8270b48

I also tested with my external monitor connected and moved between monitors. Not seeing the issue.

@hubastard What raylib version and build option you using?