Raylib-cs icon indicating copy to clipboard operation
Raylib-cs copied to clipboard

MacOS Fullscreen Problem

Open SoloByte opened this issue 1 year ago • 2 comments
trafficstars

Issue description

When entering macOS fullscreen (clicking green button in the top left of the window or fn + F) only 1/ 4 of the screen is rendered. BeginTextureMode() and EndTextureMode() cause this problem. When you comment out the Begin/EndTextureMode() block in the code example the problem disappears. I have tested it with raylib master, raylib cs, and raylib cslo and only raylib cs has this problem.

This only happens in "macOS Fullscreen mode" and not with ToggleFullscreen() or ToggleBorderlessWindowed().

Environment

MacBook Pro M2 macOS Sonoma 14.5

Issue screenshot

Green Button

Screenshot 2024-08-16 at 08 11 30

Problem

Screenshot 2024-08-16 at 08 11 03

How it looks with Begin/EndTextureMode() commented out.

Screenshot 2024-08-16 at 08 12 41

Code example

using System.Numerics;
using Raylib_cs;

namespace RaylibCs;

public static class Program
{
    static void Main(string[] args)
    {
        const int width = 400;
        const int heigth = 400;
        
        Raylib.SetWindowState(ConfigFlags.Msaa4xHint);
        
        Raylib.InitWindow(width, heigth, "Raylib Cs");
        
        Raylib.SetWindowState(ConfigFlags.ResizableWindow);
        Raylib.ClearWindowState(ConfigFlags.VSyncHint);
        Raylib.SetTargetFPS(60);
        
        
        var renderTexture = Raylib.LoadRenderTexture(width, heigth);
        var sourceRect = new Rectangle(0, 0, width, -heigth);
        var origin = new Vector2(0, 0);
        var circleColor = Color.Red;
        
        while (!Raylib.WindowShouldClose())
        {
            float dt = Raylib.GetFrameTime();
            var mousePos = Raylib.GetMousePosition();
            
//Comment out -------
            Raylib.BeginTextureMode(renderTexture);
            Raylib.ClearBackground(new Color(0, 0, 0, 0));
            
            Raylib.DrawCircle(200, 200, 25, circleColor);
            
            Raylib.EndTextureMode();
//-------------------

            Raylib.BeginDrawing();
            Raylib.ClearBackground(Color.Black);
            var destRect = new Rectangle(0, 0, Raylib.GetScreenWidth(), Raylib.GetScreenHeight());
            
            Raylib.DrawRectangleLinesEx(destRect, 5f, circleColor);
            Raylib.DrawTexturePro(renderTexture.Texture, sourceRect, destRect, origin, 0f, Color.White);
            
            Raylib.DrawCircleV(mousePos, 5, circleColor);
            
            Raylib.EndDrawing();
        }
        
        
        Raylib.UnloadRenderTexture(renderTexture);
        Raylib.CloseWindow();
    }
}

SoloByte avatar Aug 16 '24 06:08 SoloByte

Do you get the issue using raylib 5.0 instead of raylib master?

rgebee avatar Sep 10 '24 16:09 rgebee

I have just tested the 5.0 release of raylib and it works fine as well, no issue with the fullscreen.

SoloByte avatar Sep 11 '24 05:09 SoloByte

I have a clue: If you install the app 'display menu' it will change your screen to an exact resolution instead of a systemwide scaling and then when you go fullscreen it scales properly to fullscreen size.

Before: Before After: After

I have had this exact problem with games before and this was a workaround for that too.

Its like when any of these are selected in your display preferences then its doing some kind of scaling in macos that messes this code up Screenshot 2024-10-29 at 8 03 59 AM

But when you use Display Menu it deselects these "convenience" options and forces the screen to an exact resolution Screenshot 2024-10-29 at 8 02 32 AM

I recognize that isn't a solution to the problem just a clue/workaround-in-some-cases. good luck

JudgeGroovyman avatar Oct 29 '24 13:10 JudgeGroovyman

Thanks for the detailed information :)

I am curious why Begin/EndTextureMode cause this and why they only cause it in the raylib cs bindings? (and not raylib or raylib cslo)

SoloByte avatar Oct 30 '24 05:10 SoloByte

Thanks for the detailed information :)

I am curious why Begin/EndTextureMode cause this and why they only cause it in the raylib cs bindings? (and not raylib or raylib cslo)

You are welcome. I am also curious about this. It doesn't add up. Perhaps theres some setting somewhere that is slightly different.

If you think of anything I could try to get it working let me know.

JudgeGroovyman avatar Oct 31 '24 18:10 JudgeGroovyman

Is this still an issue since raylib-cs 7.0.0 as that now uses raylib 5.5?

rgebee avatar Apr 16 '25 17:04 rgebee

I just tested it with raylib cs 7.0.1 and the problem seems to be fixed. It now looks correct when entering fullscreen with and without Begin/EndTextureMode() :)

I have not tested it with external monitors.

SoloByte avatar Apr 18 '25 08:04 SoloByte