Java Code Examples for org.lwjgl.opengl.Display#update()
The following examples show how to use
org.lwjgl.opengl.Display#update() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestUtils.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * 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); } } }
Example 2
Source File: Renderer.java From tribaltrouble with GNU General Public License v2.0 | 6 votes |
private final void initVisibleGL() { if (Settings.getSettings().fullscreen_depth_workaround) { IntBuffer dummy_buf = BufferUtils.createIntBuffer(1); GL11.glReadPixels(0, 0, 1, 1, GL11.GL_DEPTH_COMPONENT, GL11.GL_UNSIGNED_INT, dummy_buf); } FloatBuffer float_array = BufferUtils.createFloatBuffer(4); GL11.glEnable(GL11.GL_LIGHT0); float[] light_diff_color = {1.0f, 1.0f, 1.0f, 1.0f}; float_array.put(light_diff_color); float_array.rewind(); GL11.glLight(GL11.GL_LIGHT0, GL11.GL_DIFFUSE, float_array); GL11.glLightModeli(GL11.GL_LIGHT_MODEL_LOCAL_VIEWER, 1); float[] global_ambient = {0.65f, 0.65f, 0.65f, 1.0f}; float_array.put(global_ambient); float_array.rewind(); GL11.glLightModel(GL11.GL_LIGHT_MODEL_AMBIENT, float_array); float[] material_color = {1.0f, 1.0f, 1.0f, 1.0f}; float_array.put(material_color); float_array.rewind(); GL11.glMaterial(GL11.GL_FRONT_AND_BACK, GL11.GL_AMBIENT_AND_DIFFUSE, float_array); Display.update(); }
Example 3
Source File: DisplayManager.java From OpenGL-Animation with The Unlicense | 5 votes |
public static void update() { Display.sync(FPS_CAP); Display.update(); long currentFrameTime = getCurrentTime(); delta = (currentFrameTime - lastFrameTime) / 1000f; lastFrameTime = currentFrameTime; }
Example 4
Source File: LoadStage.java From FEMultiplayer with GNU General Public License v3.0 | 5 votes |
public static void render(){ int width = (int) (percent * 436); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); glClearDepth(1.0f); Renderer.drawString("default_med", "FE: Multiplayer is loading...", 22, 262, 0); String percentText = (int)(percent * 100) + "%"; int pwidth = FEResources.getBitmapFont("default_med").getStringWidth(percentText); Renderer.drawString("default_med", percentText, 458 - pwidth, 263, 0); Renderer.drawRectangle(20, 280, 460, 300, 0, Color.gray); Renderer.drawRectangle(22, 282, 22+width, 298, 0, Color.blue.darker()); Display.update(); }
Example 5
Source File: GLRenderer.java From amcgala with Educational Community License v2.0 | 5 votes |
@Override public void render() { DisplayList list = framework.getCurrentState(); glBegin(GL_LINES); for (LinePrimitive line : list.lines) { setColor(line.color.toAWTColor()); glVertex3f(line.v0.x, line.v0.y, line.v0.z); glVertex3f(line.v1.x, line.v1.y, line.v1.z); } glEnd(); glBegin(GL_TRIANGLES); for (TrianglePrimitive triangle : list.triangles) { setColor(triangle.color.toAWTColor()); glVertex3f(triangle.v0.x, triangle.v0.y, triangle.v0.z); glVertex3f(triangle.v1.x, triangle.v1.y, triangle.v1.z); glVertex3f(triangle.v2.x, triangle.v2.y, triangle.v2.z); } glEnd(); glBegin(GL_POINTS); for (PointPrimitive point : list.points) { setColor(point.color.toAWTColor()); Vertex3f v = point.point; glVertex3f(v.x, v.y, v.z); } glEnd(); // TODO Quads wieder hinzufuegen. Display.update(); }
Example 6
Source File: LwjglRasteriser.java From tectonicus with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void sync() { prevKeyStates.clear(); for (Integer i : keyCodeMap.values()) { prevKeyStates.put(i, Keyboard.isKeyDown(i)); } Display.update(); Display.sync(60); }
Example 7
Source File: FEMultiplayer.java From FEMultiPlayer-V2 with GNU General Public License v3.0 | 5 votes |
@Override public void loop() { while(!Display.isCloseRequested()) { final long time = System.nanoTime(); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); glClearDepth(1.0f); getInput(); final ArrayList<Message> messages = new ArrayList<>(); if(client != null){ synchronized (client.messagesLock) { messages.addAll(client.messages); for(Message m : messages) client.messages.remove(m); } } SoundStore.get().poll(0); glPushMatrix(); //Global resolution scale // Renderer.scale(scaleX, scaleY); currentStage.beginStep(messages); currentStage.onStep(); currentStage.processAddStack(); currentStage.processRemoveStack(); currentStage.render(); // FEResources.getBitmapFont("stat_numbers").render( // (int)(1.0f/getDeltaSeconds())+"", 440f, 0f, 0f); currentStage.endStep(); postRenderRunnables.runAll(); glPopMatrix(); Display.update(); Display.sync(FEResources.getTargetFPS()); timeDelta = System.nanoTime()-time; } AL.destroy(); Display.destroy(); if(client != null && client.isOpen()) client.quit(); }
Example 8
Source File: LoadStage.java From FEMultiPlayer-V2 with GNU General Public License v3.0 | 5 votes |
/** * Render. */ public static void render(){ int width = (int) (percent * 436); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); glClearDepth(1.0f); Renderer.drawString("default_med", "FE: Multiplayer is loading...", 22, 262, 0); String percentText = (int)(percent * 100) + "%"; int pwidth = FEResources.getBitmapFont("default_med").getStringWidth(percentText); Renderer.drawString("default_med", percentText, 458 - pwidth, 263, 0); Renderer.drawRectangle(20, 280, 460, 300, 0, Color.gray); Renderer.drawRectangle(22, 282, 22+width, 298, 0, Color.blue.darker()); Display.update(); }
Example 9
Source File: AppletGameContainer.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * 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(); }
Example 10
Source File: TwlTest.java From tablelayout with BSD 3-Clause "New" or "Revised" License | 5 votes |
public TwlTest () throws Exception { LWJGLRenderer renderer = new LWJGLRenderer(); ThemeManager theme = ThemeManager.createThemeManager(TwlTest.class.getResource("/widgets.xml"), renderer); Widget root = new Widget() { protected void layout () { layoutChildrenFullInnerArea(); } }; root.setTheme(""); GUI gui = new GUI(root, renderer); gui.setSize(); gui.applyTheme(theme); final HTMLTextAreaModel htmlText = new HTMLTextAreaModel(); TextArea textArea = new TextArea(htmlText); htmlText .setHtml("<div style='text-align:center'>TWL TextAreaTest</div>Lorem ipsum dolor sit amet, douchebagus joglus. Sed fermentum gravida turpis, sit amet gravida justo laoreet non. Donec ultrices suscipit metus a mollis. Mollis varius egestas quisque feugiat pellentesque mi, quis scelerisque velit bibendum eget. Nulla orci in enim nisl mattis varius dignissim fringilla.<br/><br/>Curabitur purus leo, ultricies ut cursus eget, adipiscing in quam. Duis non velit vel mauris vulputate fringilla et quis.<br/><br/>Suspendisse lobortis iaculis tellus id fermentum. Integer fermentum varius pretium. Nullam libero magna, mattis vel placerat ac, dignissim sed lacus. Mauris varius libero id neque auctor a auctor odio fringilla.<br/><br/><div>Mauris orci arcu, porta eget porttitor luctus, malesuada nec metus. Nunc fermentum viverra leo eu pretium. Curabitur vitae nibh massa, imperdiet egestas lectus. Nulla odio quam, lobortis eget fermentum non, faucibus ac mi. Morbi et libero nulla. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Aliquam sit amet rhoncus nulla. Morbi consectetur ante convallis ante tristique et porta ligula hendrerit. Donec rhoncus ornare augue, sit amet lacinia nulla auctor venenatis.</div><br/><div>Etiam semper egestas porta. Proin luctus porta faucibus. Curabitur sagittis, lorem nec imperdiet ullamcorper, sem risus consequat purus, non faucibus turpis lorem ut arcu. Nunc tempus lobortis enim vitae facilisis. Morbi posuere quam nec sem aliquam eleifend.</div>"); ScrollPane scrollPane = new ScrollPane(textArea); scrollPane.setFixed(ScrollPane.Fixed.HORIZONTAL); FPSCounter fpsCounter = new FPSCounter(4, 2); ProgressBar progressBar = new ProgressBar(); progressBar.setValue(0.4f); Table table = new Table(); table.addCell(scrollPane).expand().fill(); table.row(); table.addCell(fpsCounter).right(); table.row(); table.addCell(progressBar).fill(); root.add(table); while (!Display.isCloseRequested()) { GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); gui.update(); Display.update(); } }
Example 11
Source File: Window.java From 3DGameEngine with Apache License 2.0 | 4 votes |
public static void Render() { Display.update(); }
Example 12
Source File: GLProgram.java From LWJGL-OpenGL-Tutorials with BSD 3-Clause "New" or "Revised" License | 4 votes |
private void gameLoop() { try { init(); Utils.checkGLError("init"); resized(); Utils.checkGLError("resized"); long lastTime, lastFPS; lastTime = lastFPS = System.nanoTime(); int frames = 0; while(!shouldStop()) { long deltaTime = System.nanoTime() - lastTime; lastTime += deltaTime; if(Display.wasResized()) resized(); while(Keyboard.next()) { if(Keyboard.getEventKeyState()) keyPressed(Keyboard.getEventKey(), Keyboard.getEventCharacter()); else keyReleased(Keyboard.getEventKey(), Keyboard.getEventCharacter()); } update(deltaTime); Utils.checkGLError("update"); render(); Utils.checkGLError("render"); Display.update(); frames++; if(System.nanoTime() - lastFPS >= 1e9) { System.out.println("FPS: ".concat(String.valueOf(frames))); lastFPS += 1e9; frames = 0; } Display.sync(fps); } } catch(Throwable exc) { exc.printStackTrace(); } finally { destroy(); } }
Example 13
Source File: ProgressBar.java From tribaltrouble with GNU General Public License v2.0 | 4 votes |
private final void update() { Renderer.clearScreen(); gui.renderGUI(); network.tick(); Display.update(); }
Example 14
Source File: Test.java From tribaltrouble with GNU General Public License v2.0 | 4 votes |
public final static void main(String[] args) { try { Display.setDisplayMode(new DisplayMode(DISPLAY_WIDTH, DISPLAY_HEIGHT)); Display.create(); initGL(); // Load font InputStream font_is = Utils.makeURL("/fonts/tahoma.ttf").openStream(); java.awt.Font src_font = java.awt.Font.createFont(java.awt.Font.TRUETYPE_FONT, font_is); java.awt.Font font = src_font.deriveFont(14f); // Load text InputStreamReader text_is = new InputStreamReader(Utils.makeURL("/test_text.txt").openStream()); StringBuffer str_buffer = new StringBuffer(); int c = text_is.read(); do { str_buffer.append((char)c); c = text_is.read(); } while (c != -1); String str = str_buffer.toString(); // Build texture int[] pixels = new int[WIDTH*HEIGHT]; // ByteBuffer pixel_data = ByteBuffer.wrap(pixels); // NEW // pixelDataFromString(WIDTH, HEIGHT, str, font, pixels); // NEW IntBuffer pixel_data = BufferUtils.createIntBuffer(WIDTH*HEIGHT); // OLD pixel_data.put(pixels); // OLD pixel_data.rewind(); int texture_handle = createTexture(WIDTH, HEIGHT, pixel_data); FontRenderContext frc = g2d.getFontRenderContext(); AttributedString att_str = new AttributedString(str); att_str.addAttribute(TextAttribute.FONT, font); AttributedCharacterIterator iterator = att_str.getIterator(); LineBreakMeasurer measurer = new LineBreakMeasurer(iterator, frc); while (!Display.isCloseRequested()) { long start_time = System.currentTimeMillis(); for (int i = 0; i < 10; i++) { pixelDataFromString(WIDTH, HEIGHT, str, font, pixels, measurer); pixel_data.put(pixels); // OLD pixel_data.rewind(); //texture_handle = createTexture(WIDTH, HEIGHT, pixel_data); updateTexture(WIDTH, HEIGHT, pixel_data); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); GL11.glLoadIdentity(); // Background /* GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glColor4f(.1f, .1f, .1f, 1f); GL11.glBegin(GL11.GL_QUADS); GL11.glVertex3f(0f, DISPLAY_HEIGHT-RENDER_SIZE, 1f); GL11.glVertex3f(RENDER_SIZE, DISPLAY_HEIGHT-RENDER_SIZE, 1f); GL11.glVertex3f(RENDER_SIZE, DISPLAY_HEIGHT, 1f); GL11.glVertex3f(0f, DISPLAY_HEIGHT, 1f); GL11.glEnd(); */ // Text GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glColor4f(1f, 1f, 1f, 1f); GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(0f, 1f); GL11.glVertex3f(0f, DISPLAY_HEIGHT-RENDER_SIZE, 1f); GL11.glTexCoord2f(1f, 1f); GL11.glVertex3f(RENDER_SIZE, DISPLAY_HEIGHT-RENDER_SIZE, 1f); GL11.glTexCoord2f(1f, 0f); GL11.glVertex3f(RENDER_SIZE, DISPLAY_HEIGHT, 1f); GL11.glTexCoord2f(0f, 0f); GL11.glVertex3f(0f, DISPLAY_HEIGHT, 1f); GL11.glEnd(); Display.update(); } long total_time = System.currentTimeMillis() - start_time; System.out.println("total_time = " + total_time); } Display.destroy(); } catch (Exception t) { t.printStackTrace(); } }
Example 15
Source File: LwJglRenderingEngine.java From Gaalop with GNU Lesser General Public License v3.0 | 4 votes |
@Override public void run() { startEngine(); //long start = System.currentTimeMillis(); while (!Display.isCloseRequested()) { //System.out.println(System.currentTimeMillis()-start); //start = System.currentTimeMillis(); if (rendering.isNewDataSetAvailable()) { if (list != -1) GL11.glDeleteLists(list, 1); list = GL11.glGenLists(1); GL11.glNewList(list, GL11.GL_COMPILE); draw(rendering.getDataSet(), rendering.getVisibleObjects(), rendering.getLoadedPointClouds()); GL11.glEndList(); changed = true; } GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); // clear the screen GL11.glLoadIdentity(); // apply camPos before rotation GL11.glTranslatef(0.0f, 0.0f, -5.0f); // draw GLU.gluLookAt(camPos.x, camPos.y, camPos.z, // Position camPos.x + camDir.x, camPos.y + camDir.y, camPos.z + camDir.z, // Lookat camUp.x, camUp.y, camUp.z); // Up-direction // apply rotation GL11.glRotatef(camAngleX, 0, 1, 0); // window x axis rotates around up vector GL11.glRotatef(camAngleY, 1, 0, 0); // window y axis rotates around x //Render the scene if (list != -1) GL11.glCallList(list); pollInput(); Display.update(); if (recorder != null) { if (changed || firstFrame) { recorder.makeScreenshot(); changed = false; } firstFrame = false; Display.sync(25); // cap fps to 60fps } else Display.sync(60); } Display.destroy(); }
Example 16
Source File: SlytherClient.java From Slyther with MIT License | 4 votes |
@Override public void run() { double delta = 0; long previousTime = System.nanoTime(); long timer = System.currentTimeMillis(); int ups = 0; double nanoUpdates = 1000000000.0 / 30.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); setupDisplay(); boolean doResize = false; while (!Display.isCloseRequested()) { if (Display.wasResized() && doResize) { setupDisplay(); } doResize = true; long currentTime = System.nanoTime(); double currentTickDelta = (currentTime - previousTime) / nanoUpdates; delta += currentTickDelta; frameDelta = (frameDelta + currentTickDelta) % 1.0; previousTime = currentTime; while (delta >= 1) { update(); renderHandler.update(); delta--; ups++; } GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); GL11.glPushMatrix(); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); renderHandler.render(); fps++; if (System.currentTimeMillis() - timer > 1000) { int bytesPerSecond = 0; int packetsPerSecond = 0; if (networkManager != null) { bytesPerSecond = networkManager.bytesPerSecond; packetsPerSecond = networkManager.packetsPerSecond; networkManager.bytesPerSecond = 0; networkManager.packetsPerSecond = 0; } Display.setTitle("Slyther - FPS: " + fps + " - UPS: " + ups + " - BPS: " + bytesPerSecond + " - PPS: " + packetsPerSecond); fps = 0; timer += 1000; ups = 0; } GL11.glPopMatrix(); Display.sync(60); Display.update(); } if (networkManager != null && networkManager.isOpen()) { networkManager.closeConnection(ClientNetworkManager.SHUTDOWN_CODE, ""); } try { ConfigHandler.INSTANCE.saveConfig(CONFIGURATION_FILE, configuration); } catch (IOException e) { Log.error("Failed to save config"); Log.catching(e); } Display.destroy(); }
Example 17
Source File: Graphics.java From AnyaBasic with MIT License | 4 votes |
public void flip() { Display.update(); Display.sync(60); }
Example 18
Source File: Graphics.java From AnyaBasic with MIT License | 4 votes |
public void flip( int refreshRate ) { Display.update(); Display.sync(refreshRate); }
Example 19
Source File: ModelViewer.java From OpenRS with GNU General Public License v3.0 | 4 votes |
public static void main(String[] args) throws Exception { if (args.length < 1) { System.err.println("Usage: modelfile"); System.exit(1); } ModelList list = new ModelList(); try (Cache cache = new Cache(FileStore.open(Constants.CACHE_PATH))) { list.initialize(cache); } Model md = list.list(Integer.valueOf(args[0])); Display.setDisplayMode(new DisplayMode(800, 600)); Display.setTitle("Model Viewer"); Display.setInitialBackground((float) Color.gray.getRed() / 255f, (float) Color.gray.getGreen() / 255f, (float) Color.gray.getBlue() / 255f); Display.create(); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); double aspect = 1; double near = 1; // near should be chosen as far into the scene as // possible double far = 1000; double fov = 1; // 1 gives you a 90� field of view. It's // tan(fov_angle)/2. GL11.glFrustum(-aspect * near * fov, aspect * near * fov, -fov, fov, near, far); GL11.glCullFace(GL11.GL_BACK); long last = 0; while (!Display.isCloseRequested()) { // Clear the screen and depth buffer GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); GL11.glBegin(GL11.GL_TRIANGLES); for (int i = 0; i < md.faceCount; ++i) { int vertexA = md.triangleX[i]; int vertexB = md.triangleY[i]; int vertexC = md.triangleZ[i]; int vertexAx = md.vertexX[vertexA]; int vertexAy = md.vertexY[vertexA]; int vertexAz = md.vertexZ[vertexA]; int vertexBx = md.vertexX[vertexB]; int vertexBy = md.vertexY[vertexB]; int vertexBz = md.vertexZ[vertexB]; int vertexCx = md.vertexX[vertexC]; int vertexCy = md.vertexY[vertexC]; int vertexCz = md.vertexZ[vertexC]; short hsb = md.faceColor[i]; int rgb = hsbToRGB(hsb); Color c = new Color(rgb); // convert to range of 0-1 float rf = (float) c.getRed() / 255f; float gf = (float) c.getGreen() / 255f; float bf = (float) c.getBlue() / 255f; GL11.glColor3f(rf, gf, bf); GL11.glVertex3i(vertexAx, vertexAy, vertexAz - 50); GL11.glVertex3i(vertexBx, vertexBy, vertexBz - 50); GL11.glVertex3i(vertexCx, vertexCy, vertexCz - 50); } GL11.glEnd(); Display.update(); Display.sync(50); // fps long delta = System.currentTimeMillis() - last; last = System.currentTimeMillis(); Camera.create(); Camera.acceptInput(delta); Camera.apply(); } Display.destroy(); }
Example 20
Source File: DisplayManager.java From OpenGL-Tutorial-1 with The Unlicense | 2 votes |
/** * This method is used to update the display at the end of every frame. When * we have set up a rendering process this method will display whatever * we've been rendering onto the screen. The "sync" method is used here to * cap the frame rate. Without this the computer would just try to run the * game as fast as it possibly can, doing more work than it needs to. */ public static void updateDisplay() { Display.sync(FPS_CAP); Display.update(); }