Java Code Examples for org.lwjgl.glfw.GLFW#glfwSwapBuffers()
The following examples show how to use
org.lwjgl.glfw.GLFW#glfwSwapBuffers() .
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: DesktopMini2DxGame.java From mini2Dx with Apache License 2.0 | 5 votes |
void createWindow(Lwjgl3Mini2DxWindow window, Lwjgl3ApplicationConfiguration config, long sharedContext) { long windowHandle = createGlfwWindow(config, sharedContext); window.create(windowHandle); window.setVisible(config.initialVisible); for (int i = 0; i < 2; i++) { GL11.glClearColor(config.initialBackgroundColor.r, config.initialBackgroundColor.g, config.initialBackgroundColor.b, config.initialBackgroundColor.a); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); GLFW.glfwSwapBuffers(windowHandle); } }
Example 2
Source File: Lwjgl3Mini2DxGraphics.java From mini2Dx with Apache License 2.0 | 5 votes |
@Override public void invoke(long windowHandle, final int width, final int height) { updateFramebufferInfo(); if (!window.isListenerInitialized()) { return; } window.makeCurrent(); gl20.glViewport(0, 0, width, height); window.getListener().resize(getWidth(), getHeight()); window.getListener().render(); GLFW.glfwSwapBuffers(windowHandle); }
Example 3
Source File: OpenGLExampleManual.java From LWJGUI with MIT License | 4 votes |
public static void main(String[] args) { // Restarts the JVM if necessary on the first thread to ensure Mac compatibility if (LWJGUIUtil.restartJVMOnFirstThread(true, args)) return; // Initialize GLFW if ( !glfwInit() ) throw new IllegalStateException("Unable to initialize GLFW"); // Create a standard opengl 3.2 window. You can do this yourself. long handle = LWJGUIUtil.createOpenGLCoreWindow("Hello World", WIDTH, HEIGHT, true, false); // Initialize lwjgui for this window Window window = WindowManager.generateWindow(handle); window.setWindowAutoClear(false); // We must call glClear ourselves. window.show(); // Display window if it's invisible. // Add some components addComponents(window.getScene()); // Initialize OpenGL information initializeOpenGL(); // Game Loop while (!GLFW.glfwWindowShouldClose(handle)) { // Tick window manager for any input or windowing commands WindowManager.update(); // Clear back buffer glClearColor(0,0,0,1); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); // Render OpenGL renderOpenGL(); // Render GUI window.render(); // Swap buffers GLFW.glfwSwapBuffers(handle); } // Clear global window resources WindowManager.dispose(); // Stop GLFW glfwTerminate(); }
Example 4
Source File: Window.java From mars-sim with GNU General Public License v3.0 | 4 votes |
public void swapBuffers() { GLFW.glfwSwapBuffers(window); }
Example 5
Source File: GLFWContextCreator.java From settlers-remake with MIT License | 4 votes |
public void async_swapbuffers() { GLFW.glfwSwapBuffers(glfw_wnd); }
Example 6
Source File: Lwjgl3Mini2DxWindow.java From mini2Dx with Apache License 2.0 | 4 votes |
boolean update(Lwjgl3Mini2DxConfig config) { if(!listenerInitialized) { initializeListener(); } synchronized(runnables) { executedRunnables.addAll(runnables); runnables.clear(); } for(Runnable runnable: executedRunnables) { runnable.run(); } boolean shouldRender = executedRunnables.size > 0 || graphics.isContinuousRendering(); executedRunnables.clear(); synchronized (this) { shouldRender |= requestRendering && !iconified; requestRendering = false; } final float targetTimestepSeconds = config.targetTimestepSeconds(); final long targetTimestepNanos = config.targetTimestepNanos(); final long time = System.nanoTime(); if(lastFrameTime == -1L) { lastFrameTime = time; } if (shouldRender) { graphics.update(); long deltaNanos = time - lastFrameTime; if(deltaNanos > config.maximumTimestepNanos()) { deltaNanos = config.maximumTimestepNanos(); } accumulator += deltaNanos; while (accumulator >= targetTimestepNanos) { if(config.capUpdatesPerSecond && Mdx.platformUtils.getUpdatesThisSecond() >= config.targetFPS) { Mdx.platformUtils.markUpdateBegin(); accumulator -= targetTimestepNanos; continue; } Mdx.platformUtils.markUpdateBegin(); input.update(); if (!iconified) input.update(); listener.update(targetTimestepSeconds); Mdx.platformUtils.markUpdateEnd(); accumulator -= targetTimestepNanos; } listener.interpolate((accumulator * 1f) / (targetTimestepNanos * 1f)); Mdx.platformUtils.markRenderBegin(); listener.render(); Mdx.platformUtils.markRenderEnd(); GLFW.glfwSwapBuffers(windowHandle); } lastFrameTime = time; if(config.errorOnFrameDrop) { if(Mdx.platformUtils.getUpdatesPerSecond() < config.targetFPS) { if(lastFrameDropWarning != Mdx.platformUtils.getUpdatesPerSecond()) { lastFrameDropWarning = Mdx.platformUtils.getUpdatesPerSecond(); Mdx.log.error("mini2Dx", "WARN: " + (config.targetFPS - Mdx.platformUtils.getUpdatesPerSecond()) + " frames dropped."); } } else { lastFrameDropWarning = -1; } } if (!iconified) input.prepareNext(); return shouldRender; }