raysan5/raylib

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

hubastard opened this issue · 2 comments

Please, before submitting a new issue verify and check:

  • I tested it on latest raylib version from master branch
  • I checked there is no similar issue already reported
  • I checked the documentation on the wiki
  • My code has no errors or misuse of raylib

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

bug_raylib_macos.mov

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;
}

Wow! Good catch! Why???

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