Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MacOS Fullscreen Problem #263

Open
SoloByte opened this issue Aug 16, 2024 · 5 comments
Open

MacOS Fullscreen Problem #263

SoloByte opened this issue Aug 16, 2024 · 5 comments
Labels
help wanted Extra attention is needed question Further information is requested

Comments

@SoloByte
Copy link

SoloByte commented Aug 16, 2024

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();
    }
}
@chrisdill
Copy link
Collaborator

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

@chrisdill chrisdill added the question Further information is requested label Sep 10, 2024
@SoloByte
Copy link
Author

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

@chrisdill chrisdill added the help wanted Extra attention is needed label Oct 6, 2024
@JudgeGroovyman
Copy link

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

@SoloByte
Copy link
Author

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)

@JudgeGroovyman
Copy link

JudgeGroovyman commented Oct 31, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed question Further information is requested
Development

No branches or pull requests

3 participants