当前位置: 首页>>代码示例>>Java>>正文


Java DisplayMode类代码示例

本文整理汇总了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);
}
 
开发者ID:Quillraven,项目名称:Protoman-vs-Megaman,代码行数:26,代码来源:VideoMenuPage.java

示例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;
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:26,代码来源:LwjglApplicationConfiguration.java

示例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()]);
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:25,代码来源:LwjglApplicationConfiguration.java

示例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;
		}
	}
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:17,代码来源:FullscreenTest.java

示例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();
}
 
开发者ID:tonysparks,项目名称:seventh,代码行数:24,代码来源:ClientMain.java

示例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();
		}
	});
}
 
开发者ID:lycying,项目名称:c2d-engine,代码行数:21,代码来源:JarExportableCmd.java

示例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;
}
 
开发者ID:BialJam,项目名称:M-M,代码行数:16,代码来源:SettingsController.java

示例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);
}
 
开发者ID:BialJam,项目名称:M-M,代码行数:8,代码来源:SettingsController.java

示例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;
}
 
开发者ID:BialJam,项目名称:M-M,代码行数:14,代码来源:FullscreenService.java

示例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);
    }
}
 
开发者ID:BialJam,项目名称:M-M,代码行数:8,代码来源:FullscreenService.java

示例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;
}
 
开发者ID:mganzarcik,项目名称:fabulae,代码行数:30,代码来源:GameOptionsPanel.java

示例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);
	}
}
 
开发者ID:nkarasch,项目名称:ChessGDX,代码行数:34,代码来源:GraphicsSettings.java

示例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);
		 }
	}
 
开发者ID:JayKEm,项目名称:Aftamath,代码行数:16,代码来源:Game.java

示例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");
       	}
       }
}
 
开发者ID:JayKEm,项目名称:Aftamath,代码行数:32,代码来源:Menu.java

示例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" ) );
}
 
开发者ID:infinity8,项目名称:Roguelike,代码行数:38,代码来源:LwjglApplicationChanger.java


注:本文中的com.badlogic.gdx.Graphics.DisplayMode类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。