本文整理汇总了Java中com.badlogic.gdx.Graphics.DisplayMode类的典型用法代码示例。如果您正苦于以下问题:Java DisplayMode类的具体用法?Java DisplayMode怎么用?Java DisplayMode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DisplayMode类属于com.badlogic.gdx.Graphics包,在下文中一共展示了DisplayMode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initialize
import com.badlogic.gdx.Graphics.DisplayMode; //导入依赖的package包/类
@Override
public void initialize() {
currentMode = Integer.parseInt(GameUtils.getCfgPreferenceValue(GameConstants.PREFERENCE_KEY_WIDTH));
availableResolutions43 = new TreeMap<Integer, Integer>();
availableResolutions43.put(currentMode, Integer.parseInt(GameUtils.getCfgPreferenceValue(GameConstants.PREFERENCE_KEY_HEIGHT)));
DisplayMode[] displayModes = Gdx.graphics.getDisplayModes();
// store all remaining 4:3 resolutions
final double aspect43 = 4.0 / 3.0;
for (DisplayMode mode : displayModes) {
// get current game resolution mode
double aspect = 1.0 * mode.width / mode.height;
if (aspect == aspect43 && !availableResolutions43.containsKey(mode.width)) {
availableResolutions43.put(mode.width, mode.height);
}
}
boolean fullscreen = Boolean.parseBoolean(GameUtils.getCfgPreferenceValue(GameConstants.PREFERENCE_KEY_FULLSCREEN));
addOption(GameUtils.getLocalizedLabel("MainMenu.option.settings.video.fullscreen"), true, MegamanConstants.MENU_OFFSET_TOP, 0, 0, 0);
addOption("" + fullscreen, false, skin.get("menu_suboption", LabelStyle.class), 0, 0, MegamanConstants.MENU_PADDING_BETWEEN_OPTIONS / 2, 0);
addOption(GameUtils.getLocalizedLabel("MainMenu.option.settings.video.windowSize"), !fullscreen, !fullscreen ? skin.get("default", LabelStyle.class) : skin.get("menu_option_disabled", LabelStyle.class), 0, 0, 0, 0);
addOption("" + currentMode + " x " + availableResolutions43.get(currentMode), false, skin.get("menu_suboption", LabelStyle.class), 0, 0, MegamanConstants.MENU_PADDING_BETWEEN_OPTIONS / 2, 0);
addOption(GameUtils.getLocalizedLabel("MainMenu.option.back"), true, 0, 0, 0, 0);
}
示例2: setFromDisplayMode
import com.badlogic.gdx.Graphics.DisplayMode; //导入依赖的package包/类
/** Sets the r, g, b and a bits per channel based on the given {@link DisplayMode} and sets the fullscreen flag to true.
* @param mode */
public void setFromDisplayMode (DisplayMode mode) {
this.width = mode.width;
this.height = mode.height;
if (mode.bitsPerPixel == 16) {
this.r = 5;
this.g = 6;
this.b = 5;
this.a = 0;
}
if (mode.bitsPerPixel == 24) {
this.r = 8;
this.g = 8;
this.b = 8;
this.a = 0;
}
if (mode.bitsPerPixel == 32) {
this.r = 8;
this.g = 8;
this.b = 8;
this.a = 8;
}
this.fullscreen = true;
}
示例3: getDisplayModes
import com.badlogic.gdx.Graphics.DisplayMode; //导入依赖的package包/类
public static DisplayMode[] getDisplayModes () {
GraphicsEnvironment genv = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice device = genv.getDefaultScreenDevice();
java.awt.DisplayMode desktopMode = device.getDisplayMode();
java.awt.DisplayMode[] displayModes = device.getDisplayModes();
ArrayList<DisplayMode> modes = new ArrayList<DisplayMode>();
int idx = 0;
for (java.awt.DisplayMode mode : displayModes) {
boolean duplicate = false;
for (int i = 0; i < modes.size(); i++) {
if (modes.get(i).width == mode.getWidth() && modes.get(i).height == mode.getHeight()
&& modes.get(i).bitsPerPixel == mode.getBitDepth()) {
duplicate = true;
break;
}
}
if (duplicate) continue;
if (mode.getBitDepth() != desktopMode.getBitDepth()) continue;
modes.add(new LwjglApplicationConfigurationDisplayMode(mode.getWidth(), mode.getHeight(), mode.getRefreshRate(), mode
.getBitDepth()));
}
return modes.toArray(new DisplayMode[modes.size()]);
}
示例4: render
import com.badlogic.gdx.Graphics.DisplayMode; //导入依赖的package包/类
@Override
public void render () {
Gdx.gl.glClearColor((float)Math.random(), 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
if (Gdx.input.justTouched()) {
if (fullscreen) {
Gdx.graphics.setDisplayMode(480, 320, false);
fullscreen = false;
} else {
DisplayMode desktopDisplayMode = Gdx.graphics.getDesktopDisplayMode();
Gdx.graphics.setDisplayMode(desktopDisplayMode.width, desktopDisplayMode.height, true);
fullscreen = true;
}
}
}
示例5: findBestDimensions
import com.badlogic.gdx.Graphics.DisplayMode; //导入依赖的package包/类
/**
* Attempts to find the best display mode
* @param config
* @return the best display mode
* @throws Exception
*/
private static DisplayMode findBestDimensions(VideoConfig config) throws Exception {
if(config.isPresent()) {
int width = config.getWidth();
int height = config.getHeight();
DisplayMode[] modes = LwjglApplicationConfiguration.getDisplayModes();
for(DisplayMode mode : modes) {
if(mode.width == width && mode.height == height) {
return mode;
}
}
}
return LwjglApplicationConfiguration.getDesktopDisplayMode();
}
示例6: process
import com.badlogic.gdx.Graphics.DisplayMode; //导入依赖的package包/类
/**
* This command only run on desktop . Add this , you can export the project
* into a jar to run it
*/
public static final void process(){
final EngineCallback callback = Engine.getEngineCallback();
Engine.setEngineCallback(new EngineCallback() {
@Override
public void preLoad(DisplayMode mode, String[] assets) {
//the sort is important , do not change it
Engine.getAliasResourceManager().setLoopLoader(new LoopLoaderJar());
callback.preLoad(mode, assets);
}
@Override
public void postLoad() {
callback.postLoad();
}
});
}
示例7: getDisplayModes
import com.badlogic.gdx.Graphics.DisplayMode; //导入依赖的package包/类
/** @return array of serialized display modes' names. */
@LmlAction("displayModes")
public Array<String> getDisplayModes() {
final ObjectSet<String> alreadyAdded = GdxSets.newSet(); // Removes duplicates.
final Array<String> displayModes = GdxArrays.newArray(); // Keeps display modes sorted.
for (final DisplayMode mode : fullscreenService.getDisplayModes()) {
final String modeName = fullscreenService.serialize(mode);
if (alreadyAdded.contains(modeName)) {
continue; // Same size already added.
}
displayModes.add(modeName);
alreadyAdded.add(modeName);
}
return displayModes;
}
示例8: setFullscreenMode
import com.badlogic.gdx.Graphics.DisplayMode; //导入依赖的package包/类
/** @param actor its ID must match name of a display mode. */
@LmlAction("setFullscreen")
public void setFullscreenMode(final Actor actor) {
final String modeName = LmlUtilities.getActorId(actor);
final DisplayMode mode = fullscreenService.deserialize(modeName);
fullscreenService.setFullscreen(mode);
}
示例9: deserialize
import com.badlogic.gdx.Graphics.DisplayMode; //导入依赖的package包/类
/** @param displayMode serialized display mode. See {@link #serialize(DisplayMode)}.
* @return mode instance or null with selected size is not supported. */
public DisplayMode deserialize(final String displayMode) {
final String[] sizes = Strings.split(displayMode, 'x');
final int width = Integer.parseInt(sizes[0]);
final int height = Integer.parseInt(sizes[1]);
for (final DisplayMode mode : Gdx.graphics.getDisplayModes()) {
if (mode.width == width && mode.height == height) {
return mode;
}
}
return null;
}
示例10: setFullscreen
import com.badlogic.gdx.Graphics.DisplayMode; //导入依赖的package包/类
/** @param displayMode must support fullscreen mode. */
public void setFullscreen(final DisplayMode displayMode) {
if (Gdx.graphics.setFullscreenMode(displayMode)) {
// Explicitly trying to resize the application listener to fully support all platforms:
Gdx.app.getApplicationListener().resize(displayMode.width, displayMode.height);
}
}
示例11: findFullscreenDisplayMode
import com.badlogic.gdx.Graphics.DisplayMode; //导入依赖的package包/类
private DisplayMode findFullscreenDisplayMode(Resolution resolution) {
DisplayMode[] modes = Gdx.graphics.getDisplayModes();
DisplayMode monitorDisplayMode = Gdx.graphics.getDisplayMode();
DisplayMode foundDisplayMode = null;
int freq = 0;
for (int i = 0; i < modes.length; i++) {
DisplayMode current = modes[i];
if ((current.width == resolution.getWidth()) && (current.height == resolution.getHeight())) {
if ((foundDisplayMode == null) || (current.refreshRate >= freq)) {
if ((foundDisplayMode == null) || (current.bitsPerPixel > foundDisplayMode.bitsPerPixel)) {
foundDisplayMode = current;
freq = foundDisplayMode.refreshRate;
}
}
// if we've found a match for bpp and frequence against the
// original display mode then it's probably best to go for this one
// since it's most likely compatible with the monitor
if ((current.bitsPerPixel == monitorDisplayMode.bitsPerPixel)
&& (current.refreshRate == monitorDisplayMode.refreshRate)) {
foundDisplayMode = current;
break;
}
}
}
return foundDisplayMode;
}
示例12: setGraphics
import com.badlogic.gdx.Graphics.DisplayMode; //导入依赖的package包/类
/**
* Sets the window display mode to match the options set in preferences in
* preferences. This is called at launch.
*/
public static void setGraphics() {
Preferences pref = Gdx.app.getPreferences(GameCore.TITLE);
int width = pref.getInteger(PreferenceStrings.DISPLAY_WIDTH);
int height = pref.getInteger(PreferenceStrings.DISPLAY_HEIGHT);
boolean fullscreen = pref.getBoolean(PreferenceStrings.FULLSCREEN);
boolean vSync = pref.getBoolean(PreferenceStrings.VSYNC);
if (width != 0 && height != 0) {
if(fullscreen) {
DisplayMode usable = Gdx.graphics.getDisplayMode();
for(DisplayMode displayMode : Gdx.graphics.getDisplayModes()){
if(displayMode.width == width && displayMode.height == height){
usable = displayMode;
break;
}
}
Gdx.graphics.setFullscreenMode(usable);
} else {
Gdx.graphics.setWindowedMode(width, height);
}
Gdx.graphics.setVSync(vSync);
} else {
if(fullscreen) {
Gdx.graphics.setFullscreenMode(Gdx.graphics.getDisplayMode());
} else {
Gdx.graphics.setWindowedMode(1280, 720);
}
Gdx.graphics.setVSync(vSync);
}
}
示例13: render
import com.badlogic.gdx.Graphics.DisplayMode; //导入依赖的package包/类
public void render() {
gsm.update(STEP);
gsm.render();
MyInput.update();
// System.out.println("managed textures: "+Texture.getNumManagedTextures());
if (Gdx.input.isKeyPressed(Input.Keys.F5)) {
fullscreen = !fullscreen;
DisplayMode currentMode = Gdx.graphics.getDesktopDisplayMode();
if(fullscreen)
Gdx.graphics.setDisplayMode(currentMode.width, currentMode.height, fullscreen);
else
Gdx.graphics.setDisplayMode(width, height, fullscreen);
}
}
示例14: changeWindowMode
import com.badlogic.gdx.Graphics.DisplayMode; //导入依赖的package包/类
public void changeWindowMode(){
Game.fullscreen = !Game.fullscreen;
DisplayMode currentMode = Gdx.graphics.getDesktopDisplayMode();
MenuObj m = null;
for(MenuObj[] l : objs){
for(MenuObj obj : l){
if(obj==null) continue;
if(obj.getText()==null) continue;
if(obj.getText().equals("WINDOWED") ||
obj.getText().equals("FULLSCREEN")){
m = obj;
break;
}
}
if(m!=null) break;
}
if(Game.fullscreen){
Gdx.graphics.setDisplayMode(currentMode.width, currentMode.height, Game.fullscreen);
if(m!=null) {
m.setText("FULLSCREEN");
//move text
}
} else {
Gdx.graphics.setDisplayMode(Game.width, Game.height, Game.fullscreen);
if(m!=null) {
m.setText("WINDOWED");
}
}
}
示例15: updateApplication
import com.badlogic.gdx.Graphics.DisplayMode; //导入依赖的package包/类
@Override
public void updateApplication( Preferences pref )
{
System.setProperty( "org.lwjgl.opengl.Window.undecorated", "" + pref.getBoolean( "borderless" ) );
int width = pref.getInteger( "resolutionX" );
int height = pref.getInteger( "resolutionY" );
boolean fullscreen = pref.getBoolean( "fullscreen" );
Global.TargetResolution[0] = width;
Global.TargetResolution[1] = height;
Global.FPS = pref.getInteger( "fps" );
Global.AnimationSpeed = 1.0f / pref.getFloat( "animspeed" );
Global.MovementTypePathfind = pref.getBoolean( "pathfindMovement" );
Global.MusicVolume = pref.getFloat( "musicVolume" );
Global.AmbientVolume = pref.getFloat( "ambientVolume" );
Global.EffectVolume = pref.getFloat( "effectVolume" );
Global.updateVolume();
for ( Controls.Keys key : Controls.Keys.values() )
{
Global.Controls.setKeyMap( key, pref.getInteger( key.toString() ) );
}
if (fullscreen)
{
DisplayMode mode = Gdx.graphics.getDisplayMode();
Gdx.graphics.setFullscreenMode( mode );
}
else
{
Gdx.graphics.setWindowedMode( width, height );
}
//Gdx.graphics.setVSync( pref.getBoolean( "vSync" ) );
}