本文整理匯總了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);
}
}
}
示例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);
}
示例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;
}
示例4: updateDisplay
import org.lwjgl.opengl.Display; //導入方法依賴的package包/類
public void updateDisplay()
{
this.mcProfiler.startSection("display_update");
Display.update();
this.mcProfiler.endSection();
this.checkWindowResize();
}
示例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();
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}