本文整理匯總了Java中org.lwjgl.opengl.Display.setVSyncEnabled方法的典型用法代碼示例。如果您正苦於以下問題:Java Display.setVSyncEnabled方法的具體用法?Java Display.setVSyncEnabled怎麽用?Java Display.setVSyncEnabled使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.lwjgl.opengl.Display
的用法示例。
在下文中一共展示了Display.setVSyncEnabled方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: start
import org.lwjgl.opengl.Display; //導入方法依賴的package包/類
/**
* Start the game container
*
* @throws Exception Failure to create display
*/
public void start() throws Exception {
Display.setParent(displayParent);
Display.setVSyncEnabled(true);
try {
createDisplay();
} catch (LWJGLException e) {
e.printStackTrace();
// failed to create Display, apply workaround (sleep for 1 second) and try again
Thread.sleep(1000);
createDisplay();
}
initGL();
displayParent.requestFocus();
container.runloop();
}
示例2: Window
import org.lwjgl.opengl.Display; //導入方法依賴的package包/類
protected Window(Context context, WindowBuilder settings) {
this.fpsCap = settings.getFpsCap();
try {
getSuitableFullScreenModes();
DisplayMode resolution = getStartResolution(settings);
Display.setInitialBackground(1, 1, 1);
this.aspectRatio = (float) resolution.getWidth() / resolution.getHeight();
setResolution(resolution, settings.isFullScreen());
if (settings.hasIcon()) {
Display.setIcon(settings.getIcon());
}
Display.setVSyncEnabled(settings.isvSync());
Display.setTitle(settings.getTitle());
Display.create(new PixelFormat().withDepthBits(24).withSamples(4), context.getAttribs());
GL11.glViewport(0, 0, resolution.getWidth(), resolution.getHeight());
} catch (LWJGLException e) {
e.printStackTrace();
}
}
示例3: Window
import org.lwjgl.opengl.Display; //導入方法依賴的package包/類
protected Window(Context context, WindowBuilder settings) {
this.fpsCap = settings.getFpsCap();
try {
getSuitableFullScreenModes();
DisplayMode resolution = getStartResolution(settings);
Display.setInitialBackground(0f, 0f, 0f);
this.aspectRatio = (float) resolution.getWidth() / resolution.getHeight();
setResolution(resolution, settings.isFullScreen());
if (settings.hasIcon()) {
Display.setIcon(settings.getIcon());
}
Display.setVSyncEnabled(settings.isvSync());
Display.setTitle(settings.getTitle());
Display.create(new PixelFormat().withDepthBits(24).withSamples(4), context.getAttribs());
GL11.glViewport(0, 0, resolution.getWidth(), resolution.getHeight());
} catch (LWJGLException e) {
e.printStackTrace();
}
}
示例4: initGL
import org.lwjgl.opengl.Display; //導入方法依賴的package包/類
/**
* Initialise the GL display
*
* @param width The width of the display
* @param height The height of the display
*/
private void initGL(int width, int height) {
try {
Display.setDisplayMode(new DisplayMode(width,height));
Display.create();
Display.setVSyncEnabled(true);
} catch (LWJGLException e) {
e.printStackTrace();
System.exit(0);
}
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glShadeModel(GL11.GL_SMOOTH);
GL11.glDisable(GL11.GL_DEPTH_TEST);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
GL11.glClearDepth(1);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glViewport(0,0,width,height);
GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glLoadIdentity();
GL11.glOrtho(0, width, height, 0, 1, -1);
GL11.glMatrixMode(GL11.GL_MODELVIEW);
}
示例5: 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);
}
}
示例6: updateVSync
import org.lwjgl.opengl.Display; //導入方法依賴的package包/類
public void updateVSync()
{
Display.setVSyncEnabled(this.enableVsync);
}
示例7: SmoothTransitions
import org.lwjgl.opengl.Display; //導入方法依賴的package包/類
private SmoothTransitions() {
// Of course, the default State is INTRO.
State state = State.INTRO;
try {
Display.setDisplayMode(new DisplayMode(640, 480));
Display.setTitle("LWJGL Template");
Display.setVSyncEnabled(true); // prevents tearing and choppy animation??
Display.create();
} catch (LWJGLException e) {
System.err.println("Display failed to initialize.");
System.exit(1);
}
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(1, 1, 1, 1, 1, -1);
glMatrixMode(GL_MODELVIEW);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// Fade in degrees (0 to 90)
float fade = 0f;
while (!Display.isCloseRequested()) {
// Clear
glClear(GL_COLOR_BUFFER_BIT);
switch(state) {
case FADING:
if (fade < 90) {
fade += 1.5f;
} else {
fade = 0;
glColor3f(0.5f, 0.5f, 1);
glRectf(-0.5f, -0.5f, 0.5f, 0.5f);
state = State.MAIN;
System.out.println("State changed: " + state);
break;
}
// Opacity = sin(fade)
glColor4d(0.5, 0.5, 1f, Math.sin(Math.toRadians(fade)));
// Draws rectangle
glRectf(-0.5f, -0.5f, 0.5f, 0.5f);
break;
case INTRO:
break;
case MAIN:
// Draw the fully opaque rectangle
glColor3f(0.5f, 0.5f, 1);
glRectf(-0.5f, -0.5f, 0.5f, 0.5f);
break;
}
while (Keyboard.next()) {
if (Keyboard.isKeyDown(Keyboard.KEY_RETURN)) {
switch (state) {
case FADING:
fade = 0;
state = State.MAIN;
System.out.println("State changed: " + state);
break;
case INTRO:
state = State.FADING;
System.out.println("State changed: " + state);
break;
case MAIN:
state = State.INTRO;
System.out.println("State changed: " + state);
break;
}
}
}
Display.update();
Display.sync(60);
}
Display.destroy();
System.exit(0);
}
示例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);
}
}
示例9: setVSync
import org.lwjgl.opengl.Display; //導入方法依賴的package包/類
/**
* Indicate whether the display should be synced to the
* vertical refresh (stops tearing)
*
* @param vsync True if we want to sync to vertical refresh
*/
public void setVSync(boolean vsync) {
this.vsync = vsync;
Display.setVSyncEnabled(vsync);
}