CreedVI / Raylib-J

Handmade Java binding for Raylib
zlib License
91 stars 15 forks source link

[MacOS] Game content is half the size on startup. (likely HIDPI related) #67

Open bramtechs opened 2 weeks ago

bramtechs commented 2 weeks ago

Describe the bug The game content is draw in the bottom-left at half the size. Moving the window fixes the problem.

To Reproduce Steps to reproduce the behavior:

  1. Open a window on Mac.

Expected behavior Game should take up the full window.

Code

package com.doomhowl.paint;

import com.raylib.java.Raylib;
import com.raylib.java.core.Color;
import com.raylib.java.shapes.Rectangle;

public class PaintGame {
    public static void main(String[] args) {
        Raylib rlj = new Raylib();
        rlj.core.InitWindow(800, 600, "Raylib-J Example");

        while (!rlj.core.WindowShouldClose()){
            rlj.core.BeginDrawing();
            rlj.core.ClearBackground(Color.WHITE);
            rlj.shapes.DrawRectangleLinesEx(new Rectangle(0, 0, rlj.core.GetScreenWidth(), rlj.core.GetScreenHeight()), 10.f, Color.RED);
            rlj.text.DrawText("Hello, World!", 800 - (rlj.text.MeasureText("Hello, World!", 20)/2), 300, 20, Color.DARKGRAY);
            rlj.core.EndDrawing();
        }
    }
}

Screenshots

bramtechs commented 2 weeks ago

Workaround is using SetWindowPosition before WindowShouldClose and after InitWindow

int monitor = rlj.core.GetCurrentMonitor();
rlj.core.SetWindowPosition(rlj.core.GetMonitorWidth(monitor) / 2 ,rlj.core.GetMonitorHeight(monitor) / 2);