raylib icon indicating copy to clipboard operation
raylib copied to clipboard

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

Open hubastard opened this issue 1 year ago • 6 comments

Please, before submitting a new issue verify and check:

  • [x] I tested it on latest raylib version from master branch
  • [x] I checked there is no similar issue already reported
  • [x] I checked the documentation on the wiki
  • [x] 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

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

hubastard avatar May 13 '24 03:05 hubastard

Wow! Good catch! Why???

raysan5 avatar May 13 '24 10:05 raysan5

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

hubastard avatar May 13 '24 19:05 hubastard

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

CrackedPixel avatar Jun 20 '24 12:06 CrackedPixel

I was on a M1 MacBook without any external monitors.

hubastard avatar Jun 20 '24 12:06 hubastard

Has this been resolved?

CodingMadness avatar Sep 27 '24 20:09 CodingMadness

Has this been resolved?

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

MegaWatt123 avatar Oct 01 '24 10:10 MegaWatt123

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?

J-Siu avatar Nov 02 '24 12:11 J-Siu

@raysan5, this should probably be closed because the last comment was 2 weeks ago and the issue was fixed.

Mute124 avatar Nov 18 '24 23:11 Mute124

@Mute124 yeah, agree.

raysan5 avatar Nov 18 '24 23:11 raysan5

Sorry for the delay, but I just wanted to add that I tested again with the latest 5.5 release and the bug is fixed. Thanks

hubastard avatar Nov 20 '24 20:11 hubastard

@hubastard that's great! thanks for the feedback! 🙂

raysan5 avatar Nov 20 '24 20:11 raysan5