Skip to content

Commit

Permalink
Fix issues with creating D3D context in newer NVIDIA drivers
Browse files Browse the repository at this point in the history
Those flags were all GL context creation flags, one of which overrides GL_NO_API and makes it create an unwanted GL context (which in newer NVIDIA drivers makes a corresponding D3D11 context for DXGI compat)
Also added some code to read the LUID from OpenGL
  • Loading branch information
comp500 committed Dec 24, 2023
1 parent 6d5ab3c commit a179a3e
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/main/java/link/infra/borderlessmining/dxgl/DXGLWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@
import org.lwjgl.glfw.Callbacks;
import org.lwjgl.glfw.GLFW;
import org.lwjgl.glfw.GLFWNativeWin32;
import org.lwjgl.opengl.EXTMemoryObject;
import org.lwjgl.opengl.EXTMemoryObjectWin32;
import org.lwjgl.opengl.GL32C;
import org.lwjgl.system.MemoryStack;

import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;

Expand Down Expand Up @@ -47,13 +51,6 @@ private static void setupWindowHints() {
// Reset hints; create window with no API
GLFW.glfwDefaultWindowHints();
GLFW.glfwWindowHint(GLFW.GLFW_CLIENT_API, GLFW.GLFW_NO_API);
// TODO: check what these do! (un-inline)
GLFW.glfwWindowHint(139265, 196609);
GLFW.glfwWindowHint(139275, 221185);
GLFW.glfwWindowHint(139266, 3);
GLFW.glfwWindowHint(139267, 2);
GLFW.glfwWindowHint(139272, 204801);
GLFW.glfwWindowHint(139270, 1);
}

public DXGLWindow(Window parent, DXGLWindowSettings settings) {
Expand All @@ -70,6 +67,11 @@ private static void featureTest() {
if (!exts.contains("GL_EXT_memory_object")) {
System.out.println("GL_EXT_memory_object not supported!");
}
try (MemoryStack stack = MemoryStack.stackPush()) {
ByteBuffer out = stack.calloc(EXTMemoryObjectWin32.GL_LUID_SIZE_EXT);
EXTMemoryObject.glGetUnsignedBytevEXT(EXTMemoryObjectWin32.GL_DEVICE_LUID_EXT, out);
// TODO: get this out, use to init d3d
}
}

public void setup(boolean initiallyFullscreen) {
Expand Down

0 comments on commit a179a3e

Please sign in to comment.