org.lwjgl.glfw.GLFW.glfwMakeContextCurrent()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(7.8k)|赞(0)|评价(0)|浏览(368)

本文整理了Java中org.lwjgl.glfw.GLFW.glfwMakeContextCurrent()方法的一些代码示例,展示了GLFW.glfwMakeContextCurrent()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GLFW.glfwMakeContextCurrent()方法的具体详情如下:
包路径:org.lwjgl.glfw.GLFW
类名称:GLFW
方法名:glfwMakeContextCurrent

GLFW.glfwMakeContextCurrent介绍

[英]Makes the OpenGL or OpenGL ES context of the specified window current on the calling thread. A context must only be made current on a single thread at a time and each thread can have only a single current context at a time.

When moving a context between threads, you must make it non-current on the old thread before making it current on the new one.

By default, making a context non-current implicitly forces a pipeline flush. On machines that support GL_KHR_context_flush_control, you can control whether a context performs this flush by setting the #GLFW_CONTEXT_RELEASE_BEHAVIORwindow hint.

The specified window must have an OpenGL or OpenGL ES context. Specifying a window without a context will generate a #GLFW_NO_WINDOW_CONTEXT error.

This function may be called from any thread.
[中]

代码示例

代码示例来源:origin: libgdx/libgdx

  1. void makeCurrent() {
  2. Gdx.graphics = graphics;
  3. Gdx.gl30 = graphics.getGL30();
  4. Gdx.gl20 = Gdx.gl30 != null ? Gdx.gl30 : graphics.getGL20();
  5. Gdx.gl = Gdx.gl30 != null ? Gdx.gl30 : Gdx.gl20;
  6. Gdx.input = input;
  7. GLFW.glfwMakeContextCurrent(windowHandle);
  8. }

代码示例来源:origin: libgdx/libgdx

  1. void makeCurrent() {
  2. Gdx.graphics = graphics;
  3. Gdx.gl30 = graphics.getGL30();
  4. Gdx.gl20 = Gdx.gl30 != null ? Gdx.gl30 : graphics.getGL20();
  5. Gdx.gl = Gdx.gl30 != null ? Gdx.gl30 : Gdx.gl20;
  6. Gdx.input = input;
  7. GLFW.glfwMakeContextCurrent(windowHandle);
  8. }

代码示例来源:origin: libgdx/libgdx

  1. Lwjgl3Window.setIcon(windowHandle, config.windowIconPaths, config.windowIconFileType);
  2. GLFW.glfwMakeContextCurrent(windowHandle);
  3. GLFW.glfwSwapInterval(config.vSyncEnabled ? 1 : 0);
  4. GL.createCapabilities();

代码示例来源:origin: libgdx/libgdx

  1. Lwjgl3Window.setIcon(windowHandle, config.windowIconPaths, config.windowIconFileType);
  2. GLFW.glfwMakeContextCurrent(windowHandle);
  3. GLFW.glfwSwapInterval(config.vSyncEnabled ? 1 : 0);
  4. GL.createCapabilities();

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

  1. glfwMakeContextCurrent(window);

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

  1. glfwMakeContextCurrent(window);

代码示例来源:origin: Renanse/Ardor3D

  1. @Override
  2. public void releaseContext(final boolean force) {
  3. if (force || !SINGLE_THREADED_MODE) {
  4. GLFW.glfwMakeContextCurrent(0);
  5. }
  6. }

代码示例来源:origin: Renanse/Ardor3D

  1. @Override
  2. public void releaseContext(final boolean force) {
  3. if (force || !SINGLE_THREADED_MODE) {
  4. GLFW.glfwMakeContextCurrent(0);
  5. }
  6. }

代码示例来源:origin: Renanse/Ardor3D

  1. @Override
  2. public void makeCurrent(final boolean force) {
  3. if (force || !SINGLE_THREADED_MODE) {
  4. GLFW.glfwMakeContextCurrent(_windowId);
  5. }
  6. }

代码示例来源:origin: Renanse/Ardor3D

  1. @Override
  2. public void makeCurrent(final boolean force) {
  3. if (force || !SINGLE_THREADED_MODE) {
  4. GLFW.glfwMakeContextCurrent(_windowId);
  5. }
  6. }

代码示例来源:origin: com.io7m.jcanephora/com.io7m.jcanephora.lwjgl3

  1. @Override
  2. public void contextReleaseCurrent()
  3. {
  4. this.checkNotDestroyed();
  5. if (LOG.isTraceEnabled()) {
  6. final Thread t = Thread.currentThread();
  7. LOG.trace(
  8. "release current (thread {} {})", Long.valueOf(t.getId()), t.getName());
  9. }
  10. final long actual_current = GLFW.glfwGetCurrentContext();
  11. if (actual_current == this.context) {
  12. GLFW.glfwMakeContextCurrent(MemoryUtil.NULL);
  13. } else {
  14. final StringBuilder sb = new StringBuilder(128);
  15. sb.append("Attempted to release a context that is not current.");
  16. sb.append(System.lineSeparator());
  17. sb.append("Context: 0x");
  18. sb.append(Long.toHexString(this.context));
  19. sb.append(System.lineSeparator());
  20. sb.append("Current context: 0x");
  21. sb.append(Long.toHexString(actual_current));
  22. sb.append(System.lineSeparator());
  23. sb.append("Thread: ");
  24. sb.append(Thread.currentThread());
  25. sb.append(System.lineSeparator());
  26. final String m = sb.toString();
  27. LOG.error(m);
  28. throw new JCGLExceptionContextNotCurrent(m);
  29. }
  30. }

代码示例来源:origin: com.io7m.jcanephora/io7m-jcanephora-lwjgl3

  1. @Override
  2. public void contextReleaseCurrent()
  3. {
  4. this.checkNotDestroyed();
  5. if (LWJGL3Context.LOG.isTraceEnabled()) {
  6. final Thread t = Thread.currentThread();
  7. LWJGL3Context.LOG.trace(
  8. "release current (thread {} {})", Long.valueOf(t.getId()), t.getName());
  9. }
  10. final long actual_current = GLFW.glfwGetCurrentContext();
  11. if (actual_current == this.context) {
  12. GLFW.glfwMakeContextCurrent(MemoryUtil.NULL);
  13. } else {
  14. final StringBuilder sb = new StringBuilder(128);
  15. sb.append("Attempted to release a context that is not current.");
  16. sb.append(System.lineSeparator());
  17. sb.append("Context: 0x");
  18. sb.append(Long.toHexString(this.context));
  19. sb.append(System.lineSeparator());
  20. sb.append("Current context: 0x");
  21. sb.append(Long.toHexString(actual_current));
  22. sb.append(System.lineSeparator());
  23. sb.append("Thread: ");
  24. sb.append(Thread.currentThread());
  25. sb.append(System.lineSeparator());
  26. final String m = sb.toString();
  27. LWJGL3Context.LOG.error(m);
  28. throw new JCGLExceptionContextNotCurrent(m);
  29. }
  30. }

代码示例来源:origin: com.badlogicgames.gdx/gdx-backend-lwjgl3

  1. void makeCurrent() {
  2. Gdx.graphics = graphics;
  3. Gdx.gl30 = graphics.getGL30();
  4. Gdx.gl20 = Gdx.gl30 != null ? Gdx.gl30 : graphics.getGL20();
  5. Gdx.gl = Gdx.gl30 != null ? Gdx.gl30 : Gdx.gl20;
  6. Gdx.input = input;
  7. GLFW.glfwMakeContextCurrent(windowHandle);
  8. }

代码示例来源:origin: sriharshachilakapati/SilenceEngine

  1. /**
  2. * <p> This method makes the OpenGL context of this window current on the calling thread. A context can only be made
  3. * current on a single thread at a time and each thread can have only a single current context at a time.</p>
  4. *
  5. * <p> By default, making a context non-current implicitly forces a pipeline flush. On machines that support
  6. * {@code GL_KHR_context_flush_control}, you can control whether a context performs this flush by setting the
  7. * {@code GLFW_CONTEXT_RELEASE_BEHAVIOR} window hint.</p>
  8. */
  9. public void makeCurrent()
  10. {
  11. glfwMakeContextCurrent(handle);
  12. if (windowCapabilities == null)
  13. windowCapabilities = GL.createCapabilities();
  14. else
  15. GL.setCapabilities(windowCapabilities);
  16. }

代码示例来源:origin: com.io7m.jcanephora/com.io7m.jcanephora.lwjgl3

  1. GLFW.glfwMakeContextCurrent(MemoryUtil.NULL);
  2. GLFW.glfwMakeContextCurrent(master);
  3. GLFW.glfwMakeContextCurrent(MemoryUtil.NULL);
  4. GLFW.glfwMakeContextCurrent(slave);
  5. GLFW.glfwMakeContextCurrent(MemoryUtil.NULL);
  6. GLFW.glfwMakeContextCurrent(master);

代码示例来源:origin: com.io7m.jcanephora/io7m-jcanephora-lwjgl3

  1. GLFW.glfwMakeContextCurrent(MemoryUtil.NULL);
  2. GLFW.glfwMakeContextCurrent(master);
  3. GLFW.glfwMakeContextCurrent(MemoryUtil.NULL);
  4. GLFW.glfwMakeContextCurrent(slave);
  5. GLFW.glfwMakeContextCurrent(MemoryUtil.NULL);
  6. GLFW.glfwMakeContextCurrent(master);

代码示例来源:origin: jsettlers/settlers-remake

  1. public void async_init() {
  2. if(debug) {
  3. ec = GLFWErrorCallback.createPrint(System.err);
  4. GLFW.glfwSetErrorCallback(ec);
  5. }
  6. if(!GLFW.glfwInit()) throw new Error("glfwInit() failed!");
  7. GLFW.glfwWindowHint(GLFW.GLFW_OPENGL_DEBUG_CONTEXT, debug ? GLFW.GLFW_TRUE : GLFW.GLFW_DONT_CARE);
  8. GLFW.glfwWindowHint(GLFW.GLFW_STENCIL_BITS, 1);
  9. glfw_wnd = GLFW.glfwCreateWindow(width + 1, width + 1, "lwjgl-offscreen", 0, 0);
  10. GLFW.glfwMakeContextCurrent(glfw_wnd);
  11. GLFW.glfwSwapInterval(0);
  12. event_converter.registerCallbacks();
  13. }

代码示例来源:origin: WarmfulDevelopment/LWJGL-3-Tutorial

  1. public void createWindow(String title) {
  2. window = glfwCreateWindow(width, height, title, fullscreen ? glfwGetPrimaryMonitor() : 0, 0);
  3. if (window == 0) throw new IllegalStateException("Failed to create window!");
  4. if (!fullscreen) {
  5. GLFWVidMode vid = glfwGetVideoMode(glfwGetPrimaryMonitor());
  6. glfwSetWindowPos(window, (vid.width() - width) / 2, (vid.height() - height) / 2);
  7. }
  8. glfwShowWindow(window);
  9. glfwMakeContextCurrent(window);
  10. input = new Input(window);
  11. setLocalCallbacks();
  12. }

代码示例来源:origin: fynnfluegge/oreon-engine

  1. public void create()
  2. {
  3. glfwWindowHint(GLFW_RESIZABLE, GL_TRUE);
  4. glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
  5. glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
  6. glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
  7. setId(glfwCreateWindow(getWidth(), getHeight(), getTitle(), 0, 0));
  8. if(getId() == 0) {
  9. throw new RuntimeException("Failed to create window");
  10. }
  11. setIcon("textures/logo/oreon_lwjgl_icon32.png");
  12. glfwMakeContextCurrent(getId());
  13. glfwSwapInterval(0);
  14. GL.createCapabilities();
  15. }

代码示例来源:origin: lwjglgamedev/lwjglbook

  1. glfwMakeContextCurrent(windowHandle);

相关文章

GLFW类方法