List of usage examples for org.lwjgl.opengl GL setCapabilities
public static void setCapabilities(@Nullable GLCapabilities caps)
From source file:com.google.gapid.widgets.GlComposite.java
License:Apache License
private void render(Runnable r, boolean swap) { canvas.setCurrent();/*from ww w . ja v a2s .c o m*/ GL.setCapabilities(caps); r.run(); if (swap) { canvas.swapBuffers(); } }
From source file:com.google.gapid.widgets.ScenePanel.java
License:Apache License
@Override protected void terminate() { setCurrent(); GL.setCapabilities(caps); renderer.terminate(); }
From source file:com.google.gapid.widgets.ScenePanel.java
License:Apache License
private void update(boolean render) { if (numSuspendedUpdates > 0) { isPendingRender |= render;//from w w w .ja va 2s. c om isPendingUpdate = true; return; } setCurrent(); GL.setCapabilities(caps); T newData = sceneData.getAndSet(null); if (newData != null) { scene.update(renderer, newData); } if (render) { scene.render(renderer); swapBuffers(); } }
From source file:com.grillecube.client.opengl.GLH.java
/** set the opengl context to the given window */ public static void glhSetContext(GLFWContext context) { Logger.get().log(Level.FINE, "OpenGL context set: " + context); // set current context GLFW.glfwMakeContextCurrent(context.getWindow().getPointer()); // create context capa context.createCapabilities();/*from w w w . j a va 2 s . c o m*/ // set current capa to use GL.setCapabilities(context.getCapabilities()); // singleton update theContext = context; // add the window to GLH objects so it is clean properly on program // termination GLH.glhAddObject(context.getWindow()); }
From source file:com.grillecube.engine.opengl.GLH.java
/** set the opengl context to the given window */ public static void glhSetContext(GLFWContext context) { Logger.get().log(Level.FINE, "OpenGL context set: " + context); // set current context GLFW.glfwMakeContextCurrent(context.getWindow().getPointer()); // create context capa context.createCapabilities();//from w ww .j av a 2 s . c o m // set current capa to use GL.setCapabilities(context.getCapabilities()); // singleton update _context = context; // add the window to GLH objects so it is clean properly on program // termination GLH.glhAddObject(context.getWindow()); }
From source file:org.lwjgl.demo.glfw.MultipleWindows.java
License:Open Source License
private static void demo() { glfwDefaultWindowHints();/*ww w. j av a 2 s . c o m*/ glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); Window[] windows = new Window[4]; AtomicInteger latch = new AtomicInteger(windows.length); for (int i = 0; i < windows.length; i++) { int windowIndex = i + 1; long handle = glfwCreateWindow(300, 200, "GLFW Demo - " + windowIndex, NULL, NULL); if (handle == NULL) { throw new IllegalStateException("Failed to create GLFW window"); } Window window = new Window(handle); glfwSetCursorEnterCallback(handle, (windowHnd, entered) -> { if (entered) { System.out.println("Mouse entered window: " + windowIndex); } }); glfwSetKeyCallback(handle, (windowHnd, key, scancode, action, mods) -> { if (key == GLFW_KEY_ESCAPE && action == GLFW_RELEASE) { Arrays.stream(windows).filter(Objects::nonNull) .forEach(w -> glfwSetWindowShouldClose(w.handle, true)); } }); glfwMakeContextCurrent(handle); window.capabilities = GL.createCapabilities(); glClearColor((i & 1), (i >> 1), (i == 1) ? 0.f : 1.f, 0.f); glfwShowWindow(handle); glfwSetWindowPos(handle, 100 + (i & 1) * 400, 100 + (i >> 1) * 400); windows[i] = window; } while (latch.get() != 0) { glfwPollEvents(); for (int i = 0; i < 4; i++) { Window window = windows[i]; if (window == null) { continue; } glfwMakeContextCurrent(window.handle); GL.setCapabilities(window.capabilities); glClear(GL_COLOR_BUFFER_BIT); glfwSwapBuffers(window.handle); if (glfwWindowShouldClose(window.handle)) { glfwFreeCallbacks(window.handle); glfwDestroyWindow(window.handle); windows[i] = null; latch.decrementAndGet(); } } } }
From source file:org.lwjgl.demo.system.jawt.LWJGLCanvas.java
License:Open Source License
@Override public void paint(Graphics g) { // Get the drawing surface JAWTDrawingSurface ds = JAWT_GetDrawingSurface(awt.GetDrawingSurface(), this); if (ds == null) { throw new IllegalStateException("awt->GetDrawingSurface() failed"); }//from w ww . j a v a 2 s. c o m try { // Lock the drawing surface int lock = JAWT_DrawingSurface_Lock(ds.Lock(), ds); if ((lock & JAWT_LOCK_ERROR) != 0) { throw new IllegalStateException("ds->Lock() failed"); } try { // Get the drawing surface info JAWTDrawingSurfaceInfo dsi = JAWT_DrawingSurface_GetDrawingSurfaceInfo(ds.GetDrawingSurfaceInfo(), ds); if (dsi == null) { throw new IllegalStateException("ds->GetDrawingSurfaceInfo() failed"); } try { // Get the platform-specific drawing info JAWTWin32DrawingSurfaceInfo dsi_win = JAWTWin32DrawingSurfaceInfo.create(dsi.platformInfo()); long hdc = dsi_win.hdc(); if (hdc != NULL) { if (hglrc == NULL) { createContext(dsi_win); gears.initGLState(); } else { if (!wglMakeCurrent(hdc, hglrc)) { throw new IllegalStateException("wglMakeCurrent() failed"); } GL.setCapabilities(caps); } glViewport(0, 0, getWidth(), getHeight()); float f = getHeight() / (float) getWidth(); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glFrustum(-1.0f, 1.0f, -f, f, 5.0f, 100.0f); glMatrixMode(GL_MODELVIEW); gears.renderLoop(); SwapBuffers(hdc); wglMakeCurrent(NULL, NULL); GL.setCapabilities(null); } } finally { // Free the drawing surface info JAWT_DrawingSurface_FreeDrawingSurfaceInfo(ds.FreeDrawingSurfaceInfo(), dsi); } } finally { // Unlock the drawing surface JAWT_DrawingSurface_Unlock(ds.Unlock(), ds); } } finally { // Free the drawing surface JAWT_FreeDrawingSurface(awt.FreeDrawingSurface(), ds); } repaint(); }