當前位置: 首頁>>代碼示例>>Java>>正文


Java Display.setFullscreen方法代碼示例

本文整理匯總了Java中org.lwjgl.opengl.Display.setFullscreen方法的典型用法代碼示例。如果您正苦於以下問題:Java Display.setFullscreen方法的具體用法?Java Display.setFullscreen怎麽用?Java Display.setFullscreen使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.lwjgl.opengl.Display的用法示例。


在下文中一共展示了Display.setFullscreen方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setFullscreen

import org.lwjgl.opengl.Display; //導入方法依賴的package包/類
/**
 * Indicate whether we want to be in fullscreen mode. Note that the current
 * display mode must be valid as a fullscreen mode for this to work
 * 
 * @param fullscreen True if we want to be in fullscreen mode
 * @throws SlickException Indicates we failed to change the display mode
 */
public void setFullscreen(boolean fullscreen) throws SlickException {
	if (isFullscreen() == fullscreen) {
		return;
	}
	
	if (!fullscreen) {
		try {
			Display.setFullscreen(fullscreen);
		} catch (LWJGLException e) {
			throw new SlickException("Unable to set fullscreen="+fullscreen, e);
		}
	} else {
		setDisplayMode(width, height, fullscreen);
	}
	getDelta();
}
 
開發者ID:j-dong,項目名稱:trashjam2017,代碼行數:24,代碼來源:AppGameContainer.java

示例2: setResolution

import org.lwjgl.opengl.Display; //導入方法依賴的package包/類
public void setResolution(DisplayMode resolution, boolean fullscreen) {
	try {
		Display.setDisplayMode(resolution);
		this.resolution = resolution;
		if (fullscreen && resolution.isFullscreenCapable()) {
			Display.setFullscreen(true);
			this.fullScreen = fullscreen;
		}
	} catch (LWJGLException e) {
		e.printStackTrace();
	}
}
 
開發者ID:TheThinMatrix,項目名稱:LowPolyWater,代碼行數:13,代碼來源:Window.java

示例3: setInitialDisplayMode

import org.lwjgl.opengl.Display; //導入方法依賴的package包/類
private void setInitialDisplayMode() throws LWJGLException
{
    if (this.fullscreen)
    {
        Display.setFullscreen(true);
        DisplayMode displaymode = Display.getDisplayMode();
        this.displayWidth = Math.max(1, displaymode.getWidth());
        this.displayHeight = Math.max(1, displaymode.getHeight());
    }
    else
    {
        Display.setDisplayMode(new DisplayMode(this.displayWidth, this.displayHeight));
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:15,代碼來源:Minecraft.java

示例4: setInitialDisplayMode

import org.lwjgl.opengl.Display; //導入方法依賴的package包/類
private void setInitialDisplayMode() throws LWJGLException {
	if (this.fullscreen) {
		Display.setFullscreen(true);
		DisplayMode displaymode = Display.getDisplayMode();
		this.displayWidth = Math.max(1, displaymode.getWidth());
		this.displayHeight = Math.max(1, displaymode.getHeight());
	} else {
		Display.setDisplayMode(new DisplayMode(this.displayWidth, this.displayHeight));
	}
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:11,代碼來源:Minecraft.java

示例5: setResolution

import org.lwjgl.opengl.Display; //導入方法依賴的package包/類
public void setResolution(DisplayMode resolution, boolean fullscreen) {
    try {
        Display.setDisplayMode(resolution);
        this.resolution = resolution;
        if (fullscreen && resolution.isFullscreenCapable()) {
            Display.setFullscreen(true);
            this.fullScreen = fullscreen;
        }
    } catch (LWJGLException e) {
        e.printStackTrace();
    }
}
 
開發者ID:GryPLOfficial,項目名稱:EcoSystem-Official,代碼行數:13,代碼來源:Window.java

示例6: setFullscreen

import org.lwjgl.opengl.Display; //導入方法依賴的package包/類
public void setFullscreen(boolean fullscreen) throws SlickException {
   if (fullscreen == isFullscreen()) {
      return;
   }

   try {
      if (fullscreen) {
         // get current screen resolution
         int screenWidth = Display.getDisplayMode().getWidth();
         int screenHeight = Display.getDisplayMode().getHeight();

         // calculate aspect ratio
         float gameAspectRatio = (float) width / height;
         float screenAspectRatio = (float) screenWidth
               / screenHeight;

         int newWidth;
         int newHeight;

         // get new screen resolution to match aspect ratio

         if (gameAspectRatio >= screenAspectRatio) {
            newWidth = screenWidth;
            newHeight = (int) (height / ((float) width / screenWidth));
         } else {
            newWidth = (int) (width / ((float) height / screenHeight));
            newHeight = screenHeight;
         }

         // center new screen
         int xoffset = (screenWidth - newWidth) / 2;
         int yoffset = (screenHeight - newHeight) / 2;

         // scale game to match new resolution
         GL11.glViewport(xoffset, yoffset, newWidth, newHeight);

         enterOrtho();

         // fix input to match new resolution
         this.getInput().setOffset(
               -xoffset * (float) width / newWidth,
               -yoffset * (float) height / newHeight);

         this.getInput().setScale((float) width / newWidth,
               (float) height / newHeight);

         width = screenWidth;
         height = screenHeight;
         Display.setFullscreen(true);
      } else {
         // restore input
         this.getInput().setOffset(0, 0);
         this.getInput().setScale(1, 1);
         width = AppletGameContainer.this.getWidth();
         height = AppletGameContainer.this.getHeight();
         GL11.glViewport(0, 0, width, height);

         enterOrtho();

         Display.setFullscreen(false);
      }
   } catch (LWJGLException e) {
      Log.error(e);
   }

}
 
開發者ID:j-dong,項目名稱:trashjam2017,代碼行數:67,代碼來源:AppletGameContainer.java

示例7: toggleFullscreen

import org.lwjgl.opengl.Display; //導入方法依賴的package包/類
/**
 * Toggles fullscreen mode.
 */
public void toggleFullscreen()
{
    try
    {
        this.fullscreen = !this.fullscreen;
        this.gameSettings.fullScreen = this.fullscreen;

        if (this.fullscreen)
        {
            this.updateDisplayMode();
            this.displayWidth = Display.getDisplayMode().getWidth();
            this.displayHeight = Display.getDisplayMode().getHeight();

            if (this.displayWidth <= 0)
            {
                this.displayWidth = 1;
            }

            if (this.displayHeight <= 0)
            {
                this.displayHeight = 1;
            }
        }
        else
        {
            Display.setDisplayMode(new DisplayMode(this.tempDisplayWidth, this.tempDisplayHeight));
            this.displayWidth = this.tempDisplayWidth;
            this.displayHeight = this.tempDisplayHeight;

            if (this.displayWidth <= 0)
            {
                this.displayWidth = 1;
            }

            if (this.displayHeight <= 0)
            {
                this.displayHeight = 1;
            }
        }

        if (this.currentScreen != null)
        {
            this.resize(this.displayWidth, this.displayHeight);
        }
        else
        {
            this.updateFramebufferSize();
        }

        Display.setFullscreen(this.fullscreen);
        Display.setVSyncEnabled(this.gameSettings.enableVsync);
        this.updateDisplay();
    }
    catch (Exception exception)
    {
        logger.error((String)"Couldn\'t toggle fullscreen", (Throwable)exception);
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:62,代碼來源:Minecraft.java

示例8: toggleFullscreen

import org.lwjgl.opengl.Display; //導入方法依賴的package包/類
/**
 * Toggles fullscreen mode.
 */
public void toggleFullscreen() {
	try {
		this.fullscreen = !this.fullscreen;
		this.gameSettings.fullScreen = this.fullscreen;

		if (this.fullscreen) {
			this.updateDisplayMode();
			this.displayWidth = Display.getDisplayMode().getWidth();
			this.displayHeight = Display.getDisplayMode().getHeight();

			if (this.displayWidth <= 0) {
				this.displayWidth = 1;
			}

			if (this.displayHeight <= 0) {
				this.displayHeight = 1;
			}
		} else {
			Display.setDisplayMode(new DisplayMode(this.tempDisplayWidth, this.tempDisplayHeight));
			this.displayWidth = this.tempDisplayWidth;
			this.displayHeight = this.tempDisplayHeight;

			if (this.displayWidth <= 0) {
				this.displayWidth = 1;
			}

			if (this.displayHeight <= 0) {
				this.displayHeight = 1;
			}
		}

		if (this.currentScreen != null) {
			this.resize(this.displayWidth, this.displayHeight);
		} else {
			this.updateFramebufferSize();
		}

		Display.setFullscreen(this.fullscreen);
		Display.setVSyncEnabled(this.gameSettings.enableVsync);
		this.updateDisplay();
	} catch (Exception exception) {
		logger.error((String) "Couldn\'t toggle fullscreen", (Throwable) exception);
	}
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:48,代碼來源:Minecraft.java

示例9: toggleFullscreen

import org.lwjgl.opengl.Display; //導入方法依賴的package包/類
/**
 * Toggles fullscreen mode.
 */
public void toggleFullscreen()
{
    try
    {
        this.fullscreen = !this.fullscreen;
        this.gameSettings.fullScreen = this.fullscreen;

        if (this.fullscreen)
        {
            this.updateDisplayMode();
            this.displayWidth = Display.getDisplayMode().getWidth();
            this.displayHeight = Display.getDisplayMode().getHeight();

            if (this.displayWidth <= 0)
            {
                this.displayWidth = 1;
            }

            if (this.displayHeight <= 0)
            {
                this.displayHeight = 1;
            }
        }
        else
        {
            Display.setDisplayMode(new DisplayMode(this.tempDisplayWidth, this.tempDisplayHeight));
            this.displayWidth = this.tempDisplayWidth;
            this.displayHeight = this.tempDisplayHeight;

            if (this.displayWidth <= 0)
            {
                this.displayWidth = 1;
            }

            if (this.displayHeight <= 0)
            {
                this.displayHeight = 1;
            }
        }

        if (this.currentScreen != null)
        {
            this.resize(this.displayWidth, this.displayHeight);
        }
        else
        {
            this.updateFramebufferSize();
        }

        Display.setFullscreen(this.fullscreen);
        Display.setVSyncEnabled(this.gameSettings.enableVsync);
        this.updateDisplay();
    }
    catch (Exception exception)
    {
        LOGGER.error((String)"Couldn\'t toggle fullscreen", (Throwable)exception);
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:62,代碼來源:Minecraft.java


注:本文中的org.lwjgl.opengl.Display.setFullscreen方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。