當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。