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

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

Open bramtechs opened this issue 1 year ago • 3 comments

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

Desktop (please complete the following information):

  • OS: macOS 14.6 23G80 arm64
  • Device: MacBook Air M1 2020

Additional context

bramtechs avatar Aug 31 '24 23:08 bramtechs

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

bramtechs avatar Aug 31 '24 23:08 bramtechs

Hey here, I am trying run Raylib-J on my arm Mac, but I can't. It seems you got it running. How can I run it?

jetflag avatar Mar 23 '25 22:03 jetflag

@jetflag Just like with LWJGL make sure you pass -XstartOnFirstThread as a Java vm flag when running on MacOS. I've made a quick and dirty change to build.gradle that I just ran on my M1. Running the application/run task from IntelliJ should work. https://github.com/bramtechs/Raylib-J/tree/mac-get-started Please let me know if you have further issues. :)

bramtechs avatar Mar 25 '25 19:03 bramtechs