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

Problems with Monitor functions #273

Open
1 task
dsoronda opened this issue Oct 9, 2024 · 3 comments
Open
1 task

Problems with Monitor functions #273

dsoronda opened this issue Oct 9, 2024 · 3 comments
Labels
help wanted Extra attention is needed

Comments

@dsoronda
Copy link

dsoronda commented Oct 9, 2024

Before submitting a new issue, please verify and check:

  • The issue is specific to Raylib-cs and not raylib
  • [ x] I checked there is no similar issue already reported
  • [ x] My code has no errors or misuse of Raylib-cs

Issue description

  • I have two monitors and Window is displayed on center first monitor(the left one rotated 90 degrees to 1080x1920). I want to display window on Primary display (the right one).

Note, X11 sees right one at offset of 1080p.

Environment

Ubuntu 24.04, X11 KDE desktop, Dotnet 8, Raylib-cs v6.1.1, Nvidia 3080 Ti Driver Version: 550.107.02 CUDA Version: 12.4

Code example

Console.WriteLine($"Found {Raylib.GetMonitorCount()} monitors");
var current = Raylib.GetCurrentMonitor();
Console.WriteLine($"Current {current} monitor");
Console.WriteLine($"Refresh {Raylib.GetMonitorRefreshRate(current)} HZ");

var position = Raylib.GetWindowPosition();
Console.WriteLine($"position {position.X} x {position.Y} ");

outputs

Found 0 monitors
Current 0 monitor
WARNING: GLFW: Failed to find selected monitor
Refresh 0 HZ
position 0 x 0 
@chrisdill chrisdill added the help wanted Extra attention is needed label Oct 16, 2024
@JupiterRider
Copy link
Contributor

Hey @dsoronda ,
you maybe need to call Raylib.InitWindow first.

@dsoronda
Copy link
Author

ok. I assumed that I first need to know monitor count before displaying Window.

Still there are issues.
I'm testing on Kbuntu 24.10 with KDE6 and Wayland on Nvidia 3080 TI.

I have two monitors,

  • On left Dell 1200x1920 60HZ (monitor is rotated by 90 degres)
  • On right 32" ultrawide 3440x1440 120 Hz whic is primary one
using Raylib_cs;

Raylib.InitWindow( 800, 600, "Hello World" ); // displays window on left (non primary monitor)

var monitorCount = Raylib.GetMonitorCount();
Console.WriteLine( $"Found {monitorCount} monitors" );

for (var counter = 0; counter < monitorCount; counter++) {

    var monitorWidth = Raylib.GetMonitorWidth( counter );
    var monitorHeight = Raylib.GetMonitorHeight( counter );
    var refreshRate = Raylib.GetMonitorRefreshRate( counter);
     Console.WriteLine( $"[{counter}] {monitorWidth} x {monitorHeight} {refreshRate} Hz" );
    
    // var primaryMonitorName = Raylib.GetMonitorName( counter );    // requires UNSAFE 
}

var position = Raylib.GetWindowPosition();

Console.WriteLine( $"position {position.X} x {position.Y} " );  // position 0 x 0 (should be mid of first window , not 0x0)

Thread.Sleep( 5000 );
Raylib.CloseWindow();

which outputs:

INFO: Initializing raylib 5.0
INFO: Platform backend: DESKTOP (GLFW)
INFO: Supported raylib modules:
INFO:     > rcore:..... loaded (mandatory)
INFO:     > rlgl:...... loaded (mandatory)
INFO:     > rshapes:... loaded (optional)
INFO:     > rtextures:. loaded (optional)
INFO:     > rtext:..... loaded (optional)
INFO:     > rmodels:... loaded (optional)
INFO:     > raudio:.... loaded (optional)
INFO: DISPLAY: Device initialized successfully
INFO:     > Display size: 3440 x 1440 // this is my primary monitor
INFO:     > Screen size:  800 x 600
INFO:     > Render size:  800 x 600
INFO:     > Viewport offsets: 0, 0
INFO: GLAD: OpenGL extensions loaded successfully
INFO: GL: Supported extensions count: 401
INFO: GL: OpenGL device information:
INFO:     > Vendor:   NVIDIA Corporation
INFO:     > Renderer: NVIDIA GeForce RTX 3080 Ti/PCIe/SSE2
INFO:     > Version:  3.3.0 NVIDIA 560.35.03
INFO:     > GLSL:     3.30 NVIDIA via Cg compiler
INFO: GL: VAO extension detected, VAO functions loaded successfully
INFO: GL: NPOT textures extension detected, full NPOT textures supported
INFO: GL: DXT compressed textures supported
INFO: GL: ETC2/EAC compressed textures supported
INFO: PLATFORM: DESKTOP (GLFW): Initialized successfully
INFO: TEXTURE: [ID 1] Texture loaded successfully (1x1 | R8G8B8A8 | 1 mipmaps)
INFO: TEXTURE: [ID 1] Default texture loaded successfully
INFO: SHADER: [ID 1] Vertex shader compiled successfully
INFO: SHADER: [ID 2] Fragment shader compiled successfully
INFO: SHADER: [ID 3] Program shader loaded successfully
INFO: SHADER: [ID 3] Default shader loaded successfully
INFO: RLGL: Render batch vertex buffers loaded successfully in RAM (CPU)
INFO: RLGL: Render batch vertex buffers loaded successfully in VRAM (GPU)
INFO: RLGL: Default OpenGL state initialized successfully
INFO: TEXTURE: [ID 2] Texture loaded successfully (128x128 | GRAY_ALPHA | 1 mipmaps)
INFO: FONT: Default font loaded successfully (224 glyphs)
Found 2 monitors
[0] 3440 x 1440 120 Hz
[1] 1200 x 1920 60 Hz
position 0 x 0
INFO: TEXTURE: [ID 2] Unloaded texture data from VRAM (GPU)
INFO: SHADER: [ID 3] Default shader unloaded successfully
INFO: TEXTURE: [ID 1] Default texture unloaded successfully
INFO: Window closed successfully

Found 2 monitors
[0] 3440 x 1440 120 Hz // i assume this one is primary since index is 0
[1] 1200 x 1920 60 Hz
position 0 x 0 // this is wrong... Raylib Window is displayed on center of screen 1 (left one)

raylib_problem

@JupiterRider
Copy link
Contributor

I can't find any issues in Raylib-cs or raylib itself:
https://github.com/chrisdill/raylib-cs/blob/master/Raylib-cs/interop/Raylib.cs#L199
https://github.com/raysan5/raylib/blob/5.0/src/platforms/rcore_desktop.c#L936

Seems like a GLFW problem:
glfw/glfw#1532

Hey says:

EDIT 3: This issue only appears when multiple monitors are connected and they do not all use the same resolution. At first, I thought it was using the resolution of the TV since it was the right most monitor (the monitor with the resolution of 1024x768 was positioned below it). However, this is not the case. Even when the television is unplugged and only the 768p monitor is plugged in, the value that must be added to get the correct resolution when the window is not on the primary monitor is 1920, rather than 1024.

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
Projects
None yet
Development

No branches or pull requests

3 participants