[CLOSED] glfwGetPrimaryMonitor() returning NULL (3.0.0a build 59)

Started by gravityfox, August 15, 2015, 17:40:58

Previous topic - Next topic

gravityfox

After setting up a workspace in IDEA and adding the library, i copy-pasted the code from getting started (which already had an issue but that was easily fixable), but upon running the code I got this error:
Exception in thread "main" java.lang.NullPointerException
	at org.lwjgl.system.Checks.checkPointer(Checks.java:79)
	at org.lwjgl.glfw.GLFW.glfwGetVideoMode(GLFW.java:797)
	at foxy.code.opengl.MainClass.init(MainClass.java:75)
	at foxy.code.opengl.MainClass.run(MainClass.java:28)
	at foxy.code.opengl.MainClass.main(MainClass.java:117)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)


It appears that glfwGetPrimaryMonitor() is returning a NULL value, and nothing is being printed to the glfw error callback.

I am using:
- 3.0.0a build 59 (Release)
- Windows 10
- Intel HD Graphics 4000

Not sure what would be causing this. Perhaps i need an updated version for windows 10? That doesn't seem right though...

EDIT: I just tried the latest stable build (3.0.0b-b9) and the latest nightly build (3.0.0b-b15), and they both give me the same error.

spasi

The getting started sample code indeed assumes that glfwGetPrimaryMonitor() returns a non-NULL value. This is obviously not the case for your system. It's not a Windows 10 problem, it works fine for me.

The code that detects monitors is here, it doesn't generate a GLFW error if no monitors are found. Another GLFW user seems to be having the same issue, a workaround is mentioned: "Deleting his two monitors and letting the system install them back fully resolved the issue".

gravityfox

Your advice resolved that issue, but allow me to provide a bit of context first.
I'm using a Sony VAIO laptop that shipped with Windows 8.
Due to a hard drive failure, I reinstalled Windows 8.1 from scratch.

Apparently the driver installs from Sony's website installed broken drivers for my monitor. After deleting the driver and the device and letting it repopulate, not only does the glfw function work properly, but my monitor brightness is settable again.

So yay... sorta... I'm getting this error now:
Exception in thread "main" java.lang.IllegalStateException: There is no OpenGL context current in the current thread.
	at org.lwjgl.opengl.GL.getCapabilities(GL.java:164)
	at org.lwjgl.opengl.GL11.getInstance(GL11.java:1390)
	at org.lwjgl.opengl.GL11.glClearColor(GL11.java:1830)
	at foxy.code.opengl.MainClass.loop(MainClass.java:101)
	at foxy.code.opengl.MainClass.run(MainClass.java:29)
	at foxy.code.opengl.MainClass.main(MainClass.java:117)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)


I'm completely baffled at this one.

SHC

Since you are using 3.0.0a, did you call GLContext.createFromCurrent() after making the context of the window current with glfwMakeContextCurrent(window) ?

int windowID = // create the window here
glfwMakeContextCurrent(windowID);

GLContext.createFromCurrent();


That should solve the issue. If you are using 3.0.0b, then you should use GL.createCapabilities() instead of GLContext.createFromCurrent(). Hope this helps.

gravityfox

That worked. Thank you, although the getting started code should be edited to reflect these changes...