本文整理汇总了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);
}