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

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

本文整理了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

void makeCurrent() {
  Gdx.graphics = graphics;
  Gdx.gl30 = graphics.getGL30();
  Gdx.gl20 = Gdx.gl30 != null ? Gdx.gl30 : graphics.getGL20();
  Gdx.gl = Gdx.gl30 != null ? Gdx.gl30 : Gdx.gl20;
  Gdx.input = input;
  GLFW.glfwMakeContextCurrent(windowHandle);
}

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

void makeCurrent() {
  Gdx.graphics = graphics;
  Gdx.gl30 = graphics.getGL30();
  Gdx.gl20 = Gdx.gl30 != null ? Gdx.gl30 : graphics.getGL20();
  Gdx.gl = Gdx.gl30 != null ? Gdx.gl30 : Gdx.gl20;
  Gdx.input = input;
  GLFW.glfwMakeContextCurrent(windowHandle);
}

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

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

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

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

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

glfwMakeContextCurrent(window);

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

glfwMakeContextCurrent(window);

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

@Override
public void releaseContext(final boolean force) {
  if (force || !SINGLE_THREADED_MODE) {
    GLFW.glfwMakeContextCurrent(0);
  }
}

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

@Override
public void releaseContext(final boolean force) {
  if (force || !SINGLE_THREADED_MODE) {
    GLFW.glfwMakeContextCurrent(0);
  }
}

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

@Override
public void makeCurrent(final boolean force) {
  if (force || !SINGLE_THREADED_MODE) {
    GLFW.glfwMakeContextCurrent(_windowId);
  }
}

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

@Override
public void makeCurrent(final boolean force) {
  if (force || !SINGLE_THREADED_MODE) {
    GLFW.glfwMakeContextCurrent(_windowId);
  }
}

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

@Override
public void contextReleaseCurrent()
{
 this.checkNotDestroyed();
 if (LOG.isTraceEnabled()) {
  final Thread t = Thread.currentThread();
  LOG.trace(
   "release current (thread {} {})", Long.valueOf(t.getId()), t.getName());
 }
 final long actual_current = GLFW.glfwGetCurrentContext();
 if (actual_current == this.context) {
  GLFW.glfwMakeContextCurrent(MemoryUtil.NULL);
 } else {
  final StringBuilder sb = new StringBuilder(128);
  sb.append("Attempted to release a context that is not current.");
  sb.append(System.lineSeparator());
  sb.append("Context: 0x");
  sb.append(Long.toHexString(this.context));
  sb.append(System.lineSeparator());
  sb.append("Current context: 0x");
  sb.append(Long.toHexString(actual_current));
  sb.append(System.lineSeparator());
  sb.append("Thread: ");
  sb.append(Thread.currentThread());
  sb.append(System.lineSeparator());
  final String m = sb.toString();
  LOG.error(m);
  throw new JCGLExceptionContextNotCurrent(m);
 }
}

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

@Override
public void contextReleaseCurrent()
{
 this.checkNotDestroyed();
 if (LWJGL3Context.LOG.isTraceEnabled()) {
  final Thread t = Thread.currentThread();
  LWJGL3Context.LOG.trace(
   "release current (thread {} {})", Long.valueOf(t.getId()), t.getName());
 }
 final long actual_current = GLFW.glfwGetCurrentContext();
 if (actual_current == this.context) {
  GLFW.glfwMakeContextCurrent(MemoryUtil.NULL);
 } else {
  final StringBuilder sb = new StringBuilder(128);
  sb.append("Attempted to release a context that is not current.");
  sb.append(System.lineSeparator());
  sb.append("Context: 0x");
  sb.append(Long.toHexString(this.context));
  sb.append(System.lineSeparator());
  sb.append("Current context: 0x");
  sb.append(Long.toHexString(actual_current));
  sb.append(System.lineSeparator());
  sb.append("Thread: ");
  sb.append(Thread.currentThread());
  sb.append(System.lineSeparator());
  final String m = sb.toString();
  LWJGL3Context.LOG.error(m);
  throw new JCGLExceptionContextNotCurrent(m);
 }
}

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

void makeCurrent() {
  Gdx.graphics = graphics;
  Gdx.gl30 = graphics.getGL30();
  Gdx.gl20 = Gdx.gl30 != null ? Gdx.gl30 : graphics.getGL20();
  Gdx.gl = Gdx.gl30 != null ? Gdx.gl30 : Gdx.gl20;
  Gdx.input = input;
  GLFW.glfwMakeContextCurrent(windowHandle);
}

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

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

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

GLFW.glfwMakeContextCurrent(MemoryUtil.NULL);
GLFW.glfwMakeContextCurrent(master);
GLFW.glfwMakeContextCurrent(MemoryUtil.NULL);
GLFW.glfwMakeContextCurrent(slave);
GLFW.glfwMakeContextCurrent(MemoryUtil.NULL);
GLFW.glfwMakeContextCurrent(master);

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

GLFW.glfwMakeContextCurrent(MemoryUtil.NULL);
GLFW.glfwMakeContextCurrent(master);
GLFW.glfwMakeContextCurrent(MemoryUtil.NULL);
GLFW.glfwMakeContextCurrent(slave);
GLFW.glfwMakeContextCurrent(MemoryUtil.NULL);
GLFW.glfwMakeContextCurrent(master);

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

public void async_init() {
  if(debug) {
    ec = GLFWErrorCallback.createPrint(System.err);
    GLFW.glfwSetErrorCallback(ec);
  }
  if(!GLFW.glfwInit()) throw new Error("glfwInit() failed!");
  GLFW.glfwWindowHint(GLFW.GLFW_OPENGL_DEBUG_CONTEXT, debug ? GLFW.GLFW_TRUE : GLFW.GLFW_DONT_CARE);
  GLFW.glfwWindowHint(GLFW.GLFW_STENCIL_BITS, 1);
  glfw_wnd = GLFW.glfwCreateWindow(width + 1, width + 1, "lwjgl-offscreen", 0, 0);
  GLFW.glfwMakeContextCurrent(glfw_wnd);
  GLFW.glfwSwapInterval(0);
  event_converter.registerCallbacks();
}

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

public void createWindow(String title) {
  window = glfwCreateWindow(width, height, title, fullscreen ? glfwGetPrimaryMonitor() : 0, 0);
  
  if (window == 0) throw new IllegalStateException("Failed to create window!");
  
  if (!fullscreen) {
    GLFWVidMode vid = glfwGetVideoMode(glfwGetPrimaryMonitor());
    glfwSetWindowPos(window, (vid.width() - width) / 2, (vid.height() - height) / 2);
  }
  
  glfwShowWindow(window);
  
  glfwMakeContextCurrent(window);
  
  input = new Input(window);
  setLocalCallbacks();
}

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

public void create()
{
  glfwWindowHint(GLFW_RESIZABLE, GL_TRUE);    
  glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);	
  glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);	
  glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);    
  
  setId(glfwCreateWindow(getWidth(), getHeight(), getTitle(), 0, 0));
  
  if(getId() == 0) {
    throw new RuntimeException("Failed to create window");
  }
  
  setIcon("textures/logo/oreon_lwjgl_icon32.png");
  
  glfwMakeContextCurrent(getId());
  glfwSwapInterval(0);
  GL.createCapabilities();
}

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

glfwMakeContextCurrent(windowHandle);

相关文章

GLFW类方法