OpenGL 3.2 on Mac OS X trouble. jme 3.1 from github

Hi all, I’ve faced with opengl version problem on macbook pro (mac os x 10.10). When I specify in AppSettings opengl version 3, I have a following error:

Apr 23, 2015 12:37:13 PM com.jme3.system.JmeDesktopSystem initialize
INFO: Running on jMonkeyEngine 3.1.0 (snapshot-github)
 * Branch: master
 * Git Hash: 38e4580
 * Build Date: 2015-04-07
Apr 23, 2015 12:37:14 PM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: LWJGL 2.9.3 context running on thread jME3 Main
 * Graphics Adapter: null
 * Driver Version: null
 * Scaling Factor: 1
Apr 23, 2015 12:37:14 PM com.jme3.app.Application handleError
SEVERE: Failed to create display
java.lang.NullPointerException
	at com.jme3.renderer.opengl.GLRenderer.loadExtensions(GLRenderer.java:142)
	at com.jme3.renderer.opengl.GLRenderer.loadCapabilitiesCommon(GLRenderer.java:246)
	at com.jme3.renderer.opengl.GLRenderer.loadCapabilities(GLRenderer.java:474)
	at com.jme3.renderer.opengl.GLRenderer.initialize(GLRenderer.java:490)
	at com.jme3.system.lwjgl.LwjglContext.initContextFirstTime(LwjglContext.java:221)
	at com.jme3.system.lwjgl.LwjglContext.internalCreate(LwjglContext.java:266)
	at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:118)
	at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:212)
	at java.lang.Thread.run(Thread.java:745)

Apr 23, 2015 12:37:14 PM com.jme3.system.lwjgl.LwjglAbstractDisplay run
SEVERE: Display initialization failed. Cannot continue.

I read a lot of posts and still don’t understand why this problem is happening. Lwjgl library contains necessary attributes for mac os x opengl 3.2 support and specifying opengl 3 version in jme AppSettings should enable opengl core profile support… but :confounded:

I’ll appreciate any help.

I don’t know what profile jME/LWJGL tries to acquire but OSX only support 3.2 core profile. Maybe some code is asking for a 3.2 compatible profile - which will probably fail on most Macs.

I went trough this source (lwjgl 2 master at github) code and found out that in case of opengl 3.2 there is adding of necessary context attributes:

        ...
        if (gl32) {
	putAttrib(&attribs, 99); // NSOpenGLPFAOpenGLProfile
	putAttrib(&attribs, 0x3200); // NSOpenGLProfileVersion3_2Core
        } ...

which should enable opengl 3.2 on mac os x. Although somehow it doesn’t work in my case.

Hmm… I have similar exception on win7, when I explicitly set

settings.setRenderer(AppSettings.LWJGL_OPENGL3);

I have:

INFO: Running on jMonkeyEngine 3.1.0 (snapshot-github)
 * Branch: master
 * Git Hash: 60ed6b7
 * Build Date: 2015-04-15
апр 23, 2015 2:47:03 PM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: LWJGL 2.9.3 context running on thread jME3 Main
 * Graphics Adapter: igdumdim64
 * Driver Version: 10.18.10.4176
 * Scaling Factor: 1
апр 23, 2015 2:47:04 PM com.jme3.app.Application handleError
SEVERE: Failed to create display
java.lang.NullPointerException
	at com.jme3.renderer.opengl.GLRenderer.loadExtensions(GLRenderer.java:142)
	at com.jme3.renderer.opengl.GLRenderer.loadCapabilitiesCommon(GLRenderer.java:246)
	at com.jme3.renderer.opengl.GLRenderer.loadCapabilities(GLRenderer.java:474)
	at com.jme3.renderer.opengl.GLRenderer.initialize(GLRenderer.java:490)
	at com.jme3.system.lwjgl.LwjglContext.initContextFirstTime(LwjglContext.java:221)
	at com.jme3.system.lwjgl.LwjglContext.internalCreate(LwjglContext.java:266)
	at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:118)
	at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:212)
	at java.lang.Thread.run(Thread.java:745)

апр 23, 2015 2:47:04 PM com.jme3.system.lwjgl.LwjglAbstractDisplay run
SEVERE: Display initialization failed. Cannot continue.

Is there a reason you want to do this?

On OSX its needed to get GL3 support at all.

Enabling OpenGL3 support doesn’t actually do much, because jME3 doesn’t use any OpenGL3 features. It just uses OpenGL extensions on top of OpenGL2.
So even though you get an OpenGL 2.1 context from the hardware, you still get many OpenGL3 features.

The reason for this is that many GPUs out there don’t actually support OpenGL3, but they support many of its features via extensions.

I came up to this setting because with opengl 2.1 (by default on mac) I’m not able to compile glsl shaders 1.50 version. For example post processing water doesn’t work with opengl 2.1 =( so if I stay with opengl 2.1 I won’t be able to use shaders 1.50. I don’t want to refuse of mac os x support for my project, though it the simpliest way.

The water filter has a fallback to GLSL 1.2 which only requires OpenGL 2.1 support.

I had a shader compilation error during my jme app startup. It was caused by unsupported shader version (glsl 1.50). I can’t show exact error log here right now, because I left my mac at home.

Even if I will manage to use water filter with 1.20 shader, it still looks like a bug.

what version of JME do you use?
It should select the correct shader version based on the ogl caps.

jMonkeyEngine 3.1.0 (snapshot-github)

There was a bug for quite some time that had to do with technique selection, so it would choose the GLSL 1.5 technique even though it wasn’t supported by the hardware.
Also there was another bug with the GLSL 1.2 version of the shader that caused a visual glitch, this bug was also present in jME 3.0.
Both of those should be fixed in the latest jME 3.1 master.

I’ll post shader compilation error later today. It seems that these (or one of these) bugs are still present for mac os x =|

So as I understood I have 2 options (both not working :persevere: )

  1. use 2.1 opengl on mac os x (default) and rely on jme which should choose appropriate shader version for me.
  2. set opengl 3 version as renderer explicitly in AppSettings in order to enable shaders 1.50 on mac os x.

:anguished:

You also have the option to use master, as you are already using an old nightly.

But I use master

Did you pull and built recently? Because those issues are definitely fixed.

Hmm… My home jme build is about one month old. I’ll check fresh build in a few hours. And what about enabling ogl 3.2 on mac os?

Not sure how restrictive osx drivers are, but if they follow their strictness, it would at least be required to create and bind a VAO in a 3.2 core profile. Nothing impossible but not supported at current state.

I’ve checked latest build and there is no issue with auto detecting appropriate shader version for water filter =) Is it possible that issue with opengl 3 for mac os x will be fixed?)