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


Java Display.update方法代码示例

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


在下文中一共展示了Display.update方法的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: 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

示例3: updateDisplay

import org.lwjgl.opengl.Display; //导入方法依赖的package包/类
public static void updateDisplay() {
	Display.sync(FPS);
	Display.update();
	long currentFrameTime = getCurrentTime();
	delta = (currentFrameTime - lastFrameTime) / 1000f; 
	lastFrameTime = currentFrameTime;
}
 
开发者ID:marcioz98,项目名称:MRCEngine,代码行数:8,代码来源:DisplayManager.java

示例4: updateDisplay

import org.lwjgl.opengl.Display; //导入方法依赖的package包/类
public void updateDisplay()
{
    this.mcProfiler.startSection("display_update");
    Display.update();
    this.mcProfiler.endSection();
    this.checkWindowResize();
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:8,代码来源:Minecraft.java

示例5: runloop

import org.lwjgl.opengl.Display; //导入方法依赖的package包/类
/**
 * The running game loop
 * 
 * @throws Exception Indicates a failure within the game's loop rather than the framework
 */
public void runloop() throws Exception {
   while (running) {
      int delta = getDelta();

      updateAndRender(delta);

      updateFPS();
      Display.update();
   }

   Display.destroy();
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:18,代码来源:AppletGameContainer.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: update

import org.lwjgl.opengl.Display; //导入方法依赖的package包/类
public static void update() {
	Display.sync(FPS_CAP);
	Display.update();
	long currentFrameTime = getCurrentTime();
	delta = (currentFrameTime - lastFrameTime) / 1000f;
	lastFrameTime = currentFrameTime;
}
 
开发者ID:TheThinMatrix,项目名称:OpenGL-Animation,代码行数:8,代码来源:DisplayManager.java

示例8: 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

示例9: 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

示例10: update

import org.lwjgl.opengl.Display; //导入方法依赖的package包/类
public void update(){
	Display.sync(FPS_CAP);
	Display.update();
	long currentFrameTime = getCurrentTime();
	delta = (currentFrameTime - lastFrameTime)/1000f;
	lastFrameTime = currentFrameTime;
}
 
开发者ID:TheThinMatrix,项目名称:OcclusionQueries,代码行数:8,代码来源:DisplayManager.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: VertexArrays

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

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

    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();

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

        // Allows usage of vertex and color arrays
        glEnableClientState(GL_VERTEX_ARRAY);
        glEnableClientState(GL_COLOR_ARRAY);

        // Shows OpenGL where to find our arrays
        glVertexPointer(vertexSize, 0, vertexData);
        glColorPointer(colorSize, 0, colorData);

        // Draws the arrays
        glDrawArrays(GL_TRIANGLES, 0, amountofVertices);

        // Closes it and disables it
        glDisableClientState(GL_VERTEX_ARRAY);
        glDisableClientState(GL_COLOR_ARRAY);

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

示例13: 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

示例14: main

import org.lwjgl.opengl.Display; //导入方法依赖的package包/类
public static void main(String[] args) {
	try {
		Display.setDisplayMode(new DisplayMode(640, 480));
		Display.setTitle("I don't get it");
		Display.create();
	} catch (LWJGLException e) {
		e.printStackTrace();
		Display.destroy();
		// exit code 1 : failure
		System.exit(1);
	}
	
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	glOrtho(0, 640, 480, 0, 1, -1);
	glMatrixMode(GL_MODELVIEW);
	
	while (!Display.isCloseRequested()) {
		// Clears a 2D Canvas.
		glClear(GL_COLOR_BUFFER_BIT);
		/* ">>" denotes a possibly modified piece of OpenGL documentation (http://www.opengl.org/sdk/docs/man/)
           >> glBegin and glEnd delimit the vertices that define a primitive or a group of like primitives.
           >> glBegin accepts a single argument that specifies how the vertices are interpreted.
           All upcoming vertex calls will be taken as points of a quadrilateral until glEnd is called. Since
           this primitive requires four vertices, we will have to call glVertex four times. */
		
		// glBegin() takes an integer as a parameter.
		// all of the set commands are constants
		// GL_POINTS, GL_LINES, GL_TRIANGLES, GL_QUADS, GL_TRIANGLE_STRIP, GL_TRIANGLE_FAN, and GL_POLYGONS
		// Don't use GL_QUADS or GL_POLYGONS, as they have been deprecated.
		glBegin(GL_QUADS);
		// >> glVertex commands are used within glBegin/glEnd pairs to specify point, line, and polygon vertices.
           // >> glColor sets the current color. (All subsequent calls to glVertex will be assigned this color)
           // >> The number after 'glVertex'/'glColor' indicates the amount of components. (xyzw/rgba)
           // >> The character after the number indicates the type of arguments.
           // >>      (for 'glVertex' = d: Double, f: Float, i: Integer)
           // >>      (for 'glColor'  = d: Double, f: Float, b: Signed Byte, ub: Unsigned Byte)

		// glVertex() takes its parameters as its location.
		// glColor() takes its parameters and makes it a color.
		
		glColor3f(1.0f, 0.0f, 0.0f);                    // Pure Green
           glVertex2i(0, 0);                               // Upper-left
           
           glColor3b((byte)0, (byte)127, (byte)0);         // Pure Red
           glVertex2d(640, 0);                             // Upper-right
           
           glColor3ub((byte)255, (byte)0, (byte)255);      // Purple
           glVertex2f(640.0f, 480.0f);                     // Bottom-right
           
           glColor3d(0, 0, 1);                             // Pure Blue
           glVertex2i(0, 480);                             // Bottom-left
           
		glEnd();
		
		// refresh display and poll input
		Display.update();
		// Maintain a 60fps frame rate
		Display.sync(60);
	}
	Display.destroy();
	// exit code 0 : success!
	System.exit(0);
}
 
开发者ID:nitrodragon,项目名称:lwjgl_collection,代码行数:65,代码来源:Ep3OpenGLRenderer.java

示例15: 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


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