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


Java Display.sync方法代码示例

本文整理汇总了Java中org.lwjgl.opengl.Display.sync方法的典型用法代码示例。如果您正苦于以下问题:Java Display.sync方法的具体用法?Java Display.sync怎么用?Java Display.sync使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.lwjgl.opengl.Display的用法示例。


在下文中一共展示了Display.sync方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: start

import org.lwjgl.opengl.Display; //导入方法依赖的package包/类
/**
 * Start the test 
 */
public void start() {
	initGL(800,600);
	init();
	
	while (true) {
		update();
		GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
		render();
		
		Display.update();
		Display.sync(100);

		if (Display.isCloseRequested()) {
			System.exit(0);
		}
	}
}
 
开发者ID:j-dong,项目名称:trashjam2017,代码行数:21,代码来源:TestUtils.java

示例2: update

import org.lwjgl.opengl.Display; //导入方法依赖的package包/类
public void update(GameContainer container, int delta)
		throws SlickException {
	if (!paused) {
		ypos += delta * 0.002 * systemMove;
		if (ypos > 300) {
			ypos = -300;
		}
		if (ypos < -300) {
			ypos = 300;
		}

		for (int i = 0; i < emitters.size(); i++) {
			((ConfigurableEmitter) emitters.get(i)).replayCheck();
		}
		for (int i = 0; i < delta; i++) {
			system.update(1);
		}
	}

	Display.sync(100);
}
 
开发者ID:j-dong,项目名称:trashjam2017,代码行数:22,代码来源:ParticleGame.java

示例3: main

import org.lwjgl.opengl.Display; //导入方法依赖的package包/类
public static void main(String[] args) {
	try {
		Display.setDisplayMode(new DisplayMode(640, 480));
		Display.setTitle("A Fresh New Display");
		Display.create();
	} catch (LWJGLException e) {
		e.printStackTrace();
		Display.destroy();
		System.exit(1);
	}
	while (!Display.isCloseRequested()) {
		// render code
		// input handling code
		 
		// refresh display and poll input
		Display.update();
		// Maintain a 60fps frame rate
		Display.sync(60);
	}
	Display.destroy();
	System.exit(0);
}
 
开发者ID:nitrodragon,项目名称:lwjgl_collection,代码行数:23,代码来源:Display2.java

示例4: Boot

import org.lwjgl.opengl.Display; //导入方法依赖的package包/类
public Boot() {

		try {
			Display.setDisplayMode(new DisplayMode(640, 480));
			Display.setTitle("Minecraft 2D");
			Display.create();
		} catch (LWJGLException e) {
			e.printStackTrace();
		}

		grid = new BlockGrid();
		grid.setAt(10, 10, selection);

		glMatrixMode(GL_PROJECTION);
		glLoadIdentity();
		glOrtho(0, 640, 480, 0, 1, -1);
		glMatrixMode(GL_MODELVIEW);
		glEnable(GL_TEXTURE_2D);
		glEnable(GL_BLEND);
		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

		while (!Display.isCloseRequested()) {
			// Render Code here
			glClear(GL_COLOR_BUFFER_BIT);
			input();
			grid.draw();
			drawSelectionBox();

			Display.update();
			Display.sync(60);
		}
		Display.destroy();
		System.exit(0);
	}
 
开发者ID:nitrodragon,项目名称:lwjgl_collection,代码行数:35,代码来源:Boot.java

示例5: AltBoot

import org.lwjgl.opengl.Display; //导入方法依赖的package包/类
public AltBoot() {
    
	try {
        Display.setDisplayMode(new DisplayMode(640, 480));
        Display.setTitle("Minecraft 2D");
        Display.create();
    } catch (LWJGLException e) {
        e.printStackTrace();
    }
    
	grid = new BlockGrid();
	grid.setAt(10, 10, BlockType.STONE);
	
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0, 640, 480, 0, 1, -1);
    glMatrixMode(GL_MODELVIEW);
    glEnable(GL_TEXTURE_2D);
    
    while (!Display.isCloseRequested()) {
        // Render Code here
        glClear(GL_COLOR_BUFFER_BIT);
        input();
        grid.draw();
        Display.update();
        Display.sync(60);
    }
    Display.destroy();
    System.exit(0);
}
 
开发者ID:nitrodragon,项目名称:lwjgl_collection,代码行数:31,代码来源:AltBoot.java

示例6: TimersAndBasicAnimation

import org.lwjgl.opengl.Display; //导入方法依赖的package包/类
private TimersAndBasicAnimation() {
    
	try {
        Display.setDisplayMode(new DisplayMode(640, 480));
        Display.setTitle("Timer");
        Display.create();
    } catch (LWJGLException e) {
        e.printStackTrace();
    }
    
	int x = 100;
	int y = 100;
	int dx = 3;
	int dy = 3;
	
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0, 640, 480, 0, 1, -1);
    glMatrixMode(GL_MODELVIEW);
    
    lastFrame = getTime();

    while (!Display.isCloseRequested()) {
        // Render Code here
        glClear(GL_COLOR_BUFFER_BIT);
        
        int delta = getDelta();
        
        x += delta * dx * 0.1;
        y += delta * dy * 0.1;
        
        glRecti(x, y, x + 30, y + 30);
        
        Display.update();
        Display.sync(60);
    }
    Display.destroy();
    System.exit(0);
}
 
开发者ID:nitrodragon,项目名称:lwjgl_collection,代码行数:40,代码来源:TimersAndBasicAnimation.java

示例7: updateDisplay

import org.lwjgl.opengl.Display; //导入方法依赖的package包/类
public static void updateDisplay() {
	Display.sync(FPS_CAP);
	Display.update();
}
 
开发者ID:DevipriyaSarkar,项目名称:Terrain,代码行数:5,代码来源:DisplayManager.java

示例8: ImmediateMode

import org.lwjgl.opengl.Display; //导入方法依赖的package包/类
private ImmediateMode() {

        try {
            Display.setDisplayMode(new DisplayMode(640, 480));
            Display.setTitle("Immediate Mode");
            Display.create();
        } catch (LWJGLException e) {
            e.printStackTrace();
        }

        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        glOrtho(0, 640, 480, 0, 1, -1);
        glMatrixMode(GL_MODELVIEW);

        while (!Display.isCloseRequested()) {
            // Render Code here
            glClear(GL_COLOR_BUFFER_BIT);

            glBegin(GL_QUADS); // Denotes Immediate Mode
            glVertex2i(400, 400);
            glVertex2i(450, 400);
            glVertex2i(450, 450);
            glVertex2i(400, 450);
            glEnd(); // Denotes Immediate Mode

            glBegin(GL_LINES); // Denotes Immediate Mode
            glVertex2i(400, 400);
            glVertex2i(400, 800);
            glEnd(); // Denotes Immediate Mode

            glBegin(GL_TRIANGLES);
            glColor3f(100, 0,0);
            glVertex2f(-50.5f, -50.5f);
            glColor3f(0, 1,0);
            glVertex2f(50.5f, -50.5f);
            glColor3f(0, 0,1);
            glVertex2f(50.5f, 50.5f);
            glEnd();

            Display.update();
            Display.sync(60);
        }
        Display.destroy();
        System.exit(0);
    }
 
开发者ID:nitrodragon,项目名称:lwjgl_collection,代码行数:47,代码来源:ImmediateMode.java

示例9: update

import org.lwjgl.opengl.Display; //导入方法依赖的package包/类
public void update() {
	Display.sync(fpsCap);
	Display.update();
}
 
开发者ID:TheThinMatrix,项目名称:LowPolyWater,代码行数:5,代码来源:Window.java

示例10: run

import org.lwjgl.opengl.Display; //导入方法依赖的package包/类
public void run()
{
	long cycles = 0;
	long currentTime = 0;
	long lastTime = 0;
	int delta = 0;

	LoadResources();

	lastTime = game.getTime();

	int SleepThreshold = 0;

	while (java2DEngine.Running == true)
	{
		currentTime = game.getTime();
		delta = (int) (currentTime - lastTime);
		lastTime = currentTime;

		cycles = delta / GameEngine.MaxDelta;
		for (int i = 0; i < cycles; i++)
		{
			updateGame((int) GameEngine.MaxDelta, currentTime);
		}
		updateGame((int) (delta % GameEngine.MaxDelta), currentTime);

		drawGame();

		try
		{
			SleepThreshold++;
			if (SleepThreshold >= 3)
			{
				Thread.sleep(1);
				SleepThreshold = 0;
			}
		}
		catch (Exception e)
		{

		}

		if (game.gameOptions.displayLimitFPS == true)
		{
			Display.sync(GameEngine.TargetFPS);
		}
	}
}
 
开发者ID:TheRemote,项目名称:Spark,代码行数:49,代码来源:Java2DGame.java

示例11: VertexBufferObject

import org.lwjgl.opengl.Display; //导入方法依赖的package包/类
private VertexBufferObject() {
    try {
        Display.setDisplayMode(new DisplayMode(640, 480));
        Display.setTitle("VBO Rendering");
        Display.create();
    } catch (LWJGLException e) {
        e.printStackTrace();
    }

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(1, 1, 1, 1, 1, -1);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    final int amountOfVertices = 3;
    final int vertexSize = 2;
    final int colorSize = 3;

    FloatBuffer vertexData = BufferUtils.createFloatBuffer(amountOfVertices * vertexSize);
    vertexData.put(new float[]{-0.5f, -0.5f, 0.5f, -0.5f, 0.5f, 0.5f, 0.5f});
    vertexData.flip();

    FloatBuffer colorData = BufferUtils.createFloatBuffer(amountOfVertices * colorSize);
    colorData.put(new float[]{-0.5f, -0.5f, 0.5f, -0.5f, 0.5f, 0.5f, 0.5f});
    colorData.flip();

    int vboVertexHandle = glGenBuffers();
    glBindBuffer(GL_ARRAY_BUFFER, vboVertexHandle);
    glBufferData(GL_ARRAY_BUFFER, vertexData, GL_STATIC_DRAW);
    glBindBuffer(GL_ARRAY_BUFFER, 0);

    int vboColorHandle = glGenBuffers();
    glBindBuffer(GL_ARRAY_BUFFER, vboColorHandle);
    glBufferData(GL_ARRAY_BUFFER, colorData, GL_STATIC_DRAW);
    glBindBuffer(GL_ARRAY_BUFFER, 0);

    while (!Display.isCloseRequested()) {
        glClear(GL_COLOR_BUFFER_BIT);

        glBindBuffer(GL_ARRAY_BUFFER, vboVertexHandle);
        glVertexPointer(vertexSize, GL_FLOAT, 0, 0L);

        glBindBuffer(GL_ARRAY_BUFFER, vboColorHandle);
        glVertexPointer(colorSize, GL_FLOAT, 0, 0L);

        glEnableClientState(GL_VERTEX_ARRAY);
        glEnableClientState(GL_COLOR_ARRAY);
        glDrawArrays(GL_TRIANGLES, 0, 1);
        glDisableClientState(GL_VERTEX_ARRAY);
        glDisableClientState(GL_COLOR_ARRAY);

        Display.update();
        Display.sync(60);

    }
    glDeleteBuffers(vboVertexHandle);
    glDeleteBuffers(vboColorHandle);

    Display.destroy();
    System.exit(0);
}
 
开发者ID:nitrodragon,项目名称:lwjgl_collection,代码行数:63,代码来源:VertexBufferObject.java

示例12: main

import org.lwjgl.opengl.Display; //导入方法依赖的package包/类
public static void main(String[] args) {
    try {
        Display.setDisplayMode(new DisplayMode(640, 480));
        Display.setTitle("Coordinate Systems");
        Display.create();
    } catch (LWJGLException e) {
        e.printStackTrace();
        Display.destroy();
        System.exit(1);
    }

    // Initialization code OpenGL
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(1, 1, 1, 1, 1, -1);
    // glOrtho(left, right, bottom, top, zNear, zFar)
    // left = left edge
    // right = offset between right and left edges (NOT PIXELS, UNITS)
    // bottom = offset between top and bottom edges (NOT PIXELS, UNITS)
    // up = top edge
    // zNear, zFar = depth for z-axis // Set to 1, -1 for 2D things
    glMatrixMode(GL_MODELVIEW);

    while (!Display.isCloseRequested()) {
        // Render

        glClear(GL_COLOR_BUFFER_BIT);
        glPointSize(10);
        glBegin(GL_POINTS);
        	glColor3d(0.0, 1.0, 0.0); // Color : GREEN
        	glVertex2f(0, 0); // spaces away from center
        	glColor3d(1.0, 0.0, 0.0); // Color : RED
        	glVertex2f(-1, 0); // spaces away from center
        	glVertex2f(1, 0); // spaces away from center
        	glVertex2f(-1, 0); // spaces away from center
        	glVertex2f(0, 1); // spaces away from center
        	glVertex2f(0, -1); // spaces away from center
        	glColor3d(0.0, 1.0, 1.0); // Color : CYAN
        	glVertex2f(1, 1); // spaces away from center
        	glVertex2f(-1, 1); // spaces away from center
        	glVertex2f(-1, -1); // spaces away from center
        	glVertex2f(1, -1); // spaces away from center
        glEnd();

        Display.update();
        Display.sync(60);
    }

    Display.destroy();
    System.exit(0);
}
 
开发者ID:nitrodragon,项目名称:lwjgl_collection,代码行数:52,代码来源:CoordinateSystems.java

示例13: update

import org.lwjgl.opengl.Display; //导入方法依赖的package包/类
public void update() {
    Display.sync(fpsCap);
    Display.update();
}
 
开发者ID:GryPLOfficial,项目名称:EcoSystem-Official,代码行数:5,代码来源:Window.java

示例14: UsingEntities

import org.lwjgl.opengl.Display; //导入方法依赖的package包/类
public UsingEntities() {
    
	try {
        Display.setDisplayMode(new DisplayMode(640, 480));
        Display.setTitle("LWJGL Template");
        Display.create();
    } catch (LWJGLException e) {
        e.printStackTrace();
    }
	// init entities
	
	MoveableEntity box = new Box(100, 100, 50, 50);
	Entity point = new Point(10, 10);
    
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0, 640, 480, 0, 1, -1);
    glMatrixMode(GL_MODELVIEW);
    
    lastFrame = getTime();

    while (!Display.isCloseRequested()) {
        // Render Code here
    	
    	point.setLocation(Mouse.getX(), 480 - Mouse.getY() - 1);
    	
        glClear(GL_COLOR_BUFFER_BIT);
        
        int delta = getDelta();
        box.update(delta);
        point.update(delta);
        
        if (box.intersects(point)) {
        	box.setDX(0.2);
        }
        
        point.draw();
        box.draw();
        
        Display.update();
        Display.sync(60);
    }
    Display.destroy();
    System.exit(0);
}
 
开发者ID:nitrodragon,项目名称:lwjgl_collection,代码行数:46,代码来源:UsingEntities.java

示例15: DisplayList

import org.lwjgl.opengl.Display; //导入方法依赖的package包/类
private DisplayList() {
    try {
        Display.setDisplayMode(new DisplayMode(640, 480));
        Display.setTitle("Display Lists");
        Display.create();
    } catch (LWJGLException e) {
        e.printStackTrace();
    }

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(1, 1, 1, 1, 1, -1);
    glMatrixMode(GL_MODELVIEW);

    int displayListHandle = glGenLists(1);

    glNewList(displayListHandle, GL_COMPILE);
        glBegin(GL_TRIANGLES);
            glColor3f(1, 0,0);
            glVertex2f(-0.5f, -0.5f);
            glColor3f(0, 1,0);
            glVertex2f(0.5f, -0.5f);
            glColor3f(0, 0,1);
            glVertex2f(0.5f, 0.5f);
        glEnd();
    glEndList();

    while (!Display.isCloseRequested()) {
        // Render Code here
        glClear(GL_COLOR_BUFFER_BIT);

        glCallList(displayListHandle);

        Display.update();
        Display.sync(60);
    }
    glDeleteLists(displayListHandle, 1);

    Display.destroy();
    System.exit(0);
}
 
开发者ID:nitrodragon,项目名称:lwjgl_collection,代码行数:42,代码来源:DisplayList.java


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