Skip to content

Commit 562b133

Browse files
committed
Merge branch 'main' of https://github.com/fastjengine/FastJ
2 parents 59ab49b + d7f5b80 commit 562b133

File tree

2 files changed

+21
-10
lines changed

2 files changed

+21
-10
lines changed

src/main/java/tech/fastj/engine/FastJEngine.java

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,14 @@ public class FastJEngine {
3636

3737
/** Default engine value for "frames per second" of at least {@code 60}, depending on the monitor's refresh rate. */
3838
public static final int DefaultFPS = Math.max(DisplayUtil.getDefaultMonitorRefreshRate(), 60);
39+
3940
/** Default engine value for "updates per second" of {@code 60}. */
4041
public static final int DefaultUPS = 60;
42+
4143
/** Default engine value for the window resolution of the {@link Display} of {@code 1280*720}. */
4244
public static final Point DefaultWindowResolution = new Point(1280, 720);
43-
/** Default engine value for the internal resolution of the {@link Display} of {@code 1280*720}. */
45+
46+
/** Default engine value for the window resolution of the {@link Display} of {@code 1280*720}. */
4447
public static final Point DefaultInternalResolution = new Point(1280, 720);
4548

4649
// engine speed variables
@@ -188,18 +191,24 @@ public static void configureInternalResolution(Point internalResolution) {
188191
public static void configureHardwareAcceleration(HWAccel hardwareAcceleration) {
189192
runningCheck();
190193

191-
if (hardwareAcceleration.equals(HWAccel.Direct3D)) {
192-
if (System.getProperty("os.name").startsWith("Win")) {
193-
HWAccel.setHardwareAcceleration(HWAccel.Direct3D);
194-
hwAccel = hardwareAcceleration;
195-
} else {
196-
warning("This OS doesn't support Direct3D hardware acceleration. Configuration will be left at default.");
197-
configureHardwareAcceleration(HWAccel.Default);
198-
}
199-
} else {
194+
if (isSystemSupportingHA(hardwareAcceleration)) {
200195
HWAccel.setHardwareAcceleration(hardwareAcceleration);
201196
hwAccel = hardwareAcceleration;
197+
} else {
198+
warning(String.format("This OS doesn't support %s hardware acceleration. Configuration will be left at default.", hardwareAcceleration.name()));
199+
HWAccel.setHardwareAcceleration(HWAccel.Default);
200+
hwAccel = HWAccel.Default;
201+
}
202+
}
203+
204+
private static boolean isSystemSupportingHA(HWAccel hardwareAcceleration) {
205+
if (hardwareAcceleration.equals(HWAccel.Direct3D)) {
206+
return System.getProperty("os.name").startsWith("Win");
207+
}
208+
else if (hardwareAcceleration.equals(HWAccel.X11)) {
209+
return System.getProperty("os.name").startsWith("Linux");
202210
}
211+
return true;
203212
}
204213

205214
/**

src/main/java/tech/fastj/engine/HWAccel.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ public enum HWAccel {
1010
Direct3D("d3d", "transaccel", "ddforcevram"),
1111
/** Enables OpenGL hardware acceleration. */
1212
OpenGL("opengl"),
13+
/** Enables X11 hardware acceleration. */
14+
X11("xrender"),
1315
/** Leaves the configuration of hardware acceleration as the OS-decided default. */
1416
Default(),
1517
/** Disables all hardware acceleration. Instead, software rendering will be used. */

0 commit comments

Comments
 (0)