Java源码示例:com.badlogic.gdx.backends.lwjgl3.Lwjgl3Window
示例1
private boolean fullscreenMode() {
Lwjgl3Window window = ((Lwjgl3Graphics) Gdx.graphics).getWindow();
windowWidth = Gdx.graphics.getWidth();
windowHeight = Gdx.graphics.getHeight();
windowX = window.getPositionX();
windowY = window.getPositionY();
Graphics.Monitor monitor = Gdx.graphics.getMonitor();
Graphics.DisplayMode mode = getBestDisplayMode(monitor);
if (mode == null) return false;
if ("windowedBorderless".equals(((DropDownSetting) Settings.getSetting("client.graphics.fullscreen")).getSelected())) {
Gdx.graphics.setUndecorated(true);
Gdx.graphics.setResizable(false);
window.setPosition(monitor.virtualX, monitor.virtualY);
return Gdx.graphics.setWindowedMode(mode.width, mode.height);
} else {
return Gdx.graphics.setFullscreenMode(mode);
}
}
示例2
@Override
public void created ( Lwjgl3Window lwjgl3Window ) {
if (SPDSettings.fullscreen()){
lwjgl3Window.postRunnable( new Runnable() {
@Override
public void run () {
Gdx.graphics.setFullscreenMode( Gdx.graphics.getDisplayMode() );
}
} );
}
if (SPDSettings.windowMaximized()) {
lwjgl3Window.maximizeWindow();
}
}
示例3
private void resizeWindowFromScaleFactor(float newScaleFactor) {
final float scaleFactor = Math.max(newScaleFactor, 1f);
final Graphics.Monitor monitor = Gdx.graphics.getMonitor();
final Graphics.DisplayMode mode = getBestDisplayMode(monitor);
if (mode == null || fullscreen.isEnabled()) return;
// Client may not be setup yet, delaying to end of the frame ensures it is
Gdx.app.postRunnable(() -> {
int wantedMinWidth = (int) Math.min(MINIMUM_WINDOW_WIDTH * scaleFactor, mode.width * 0.8f);
int wantedMinHeight = (int) Math.min(MINIMUM_WINDOW_HEIGHT * scaleFactor, mode.height * 0.8f);
int resizeWidth = (int) (DEFAULT_WINDOW_WIDTH * scaleFactor);
int resizeHeight = (int) (DEFAULT_WINDOW_HEIGHT * scaleFactor);
Lwjgl3Window window = ((Lwjgl3Graphics) Gdx.graphics).getWindow();
if (resizeWidth > 0.8 * mode.width || resizeHeight > 0.8 * mode.height) {
// if window would almost fill screen, maximize
window.maximizeWindow();
} else if (resizeWidth >= Gdx.graphics.getWidth() && resizeHeight >= Gdx.graphics.getHeight()) {
// maintain center of window if possible without going off edge of screen
int posX = MathUtils.clamp(
window.getPositionX() - ((resizeWidth - Gdx.graphics.getWidth()) / 2),
monitor.virtualX + 32,
monitor.virtualX + mode.width - resizeWidth - 32);
int posY = MathUtils.clamp(
window.getPositionY() - ((resizeHeight - Gdx.graphics.getHeight()) / 2),
monitor.virtualY + 32,
monitor.virtualY + mode.height - resizeHeight - 32);
window.setPosition(posX, posY);
// first set minimum size to desired size to force expansion, then reset to desired minimum size
window.setSizeLimits(resizeWidth, resizeHeight, -1, -1);
}
window.setSizeLimits(wantedMinWidth, wantedMinHeight, -1, -1);
});
}
示例4
@Override
public void dragWindow(int x, int y) {
Lwjgl3Window window = ((Lwjgl3Graphics) Gdx.graphics).getWindow();
window.setPosition(x, y);
}
示例5
@Override
public void dragWindow(int x, int y) {
Lwjgl3Window window = ((Lwjgl3Graphics) Gdx.graphics).getWindow();
window.setPosition(x, y);
}