Desktop GLES

Started by smith, November 27, 2015, 22:35:21

Previous topic - Next topic

smith

Hey,

Is it possible to use LWJGL3 to write GLES code for the desktop without having to use an emulator?
If you want to distribute to multiple platforms GLES appears the best choice but having to ship an emulator for the desktop is a non-starter.

I believe LibGDX uses a java land GLES wrapper for the desktop, could something similar be added for LWJGL?

smith

Trying out the PowerVR emulator just to see how it performs I can't get it working. I always get:

"There is no OpenGL ES context current in the current thread."

Looking at the GLES.java source I think the fallback string query is broken, should be != GL_NO_ERROR:

if ( invokeI(GetError) == GL_NO_ERROR && 3 <= (majorVersion = __buffer.intValue(0)) ) {
				// We're on an 3.0+ context.
				invokeIPV(GetIntegerv, GL_MINOR_VERSION, __buffer.address());
				minorVersion = __buffer.intValue(0);
			} else {
				// Fallback to the string query.
				long versionString = invokeIP(GetString, GL_VERSION);
				if ( invokeI(GetError) == GL_NO_ERROR )
					throw new IllegalStateException("There is no OpenGL ES context current in the current thread.");

				APIVersion version = apiParseVersion(memDecodeUTF8(versionString), "OpenGL ES");

				majorVersion = version.major;
				minorVersion = version.minor;
			}


spasi

That's a bug indeed, it will be fixed in the next nightly build. Thanks!

There is no single (cross-vendor, cross-platform) solution to using OpenGL ES on desktop:

- If you have an AMD GPU it's easy, download the OpenGL ES SDK and you can have a real EGL and OpenGL ES implementation. Make sure that the EGL/GLESv2 dlls are in %PATH% or java.library.path/org.lwjgl.librarypath.

- The OpenGL ES implementation in LWJGL assumes that EGL is also available. This is problematic but there is an easy workaround: GLES 2.0 everywhere (thanks to LWJGL3)

- If you have an Nvidia GPU, you can use glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API) with the above workaround even on Windows. Nvidia supports the WGL_EXT_create_context_es2_profile extension.

Kai

Quote from: spasi on November 28, 2015, 14:44:54
- If you have an Nvidia GPU, you can use glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API) with the above workaround even on Windows. Nvidia supports the WGL_EXT_create_context_es2_profile extension.
SWT now also has OpenGL ES support via Nvidia's WGL_EXT_create_context_es2_profile.
See: https://github.com/httpdigest/lwjgl3-swt/blob/master/test/org/lwjgl/opengl/swt/NvGLESDemo.java
But I dunno whether SWT's gtk backend actually works on OpenGL ES devices. Probably not.

However, using SWT allows to have some nice Eclipse RCP-style editor showing the rendered scene inside an editor/view together with some possible sliders/buttons/knobs to tweak things before uploading the app to an embedded device and then using GLFW for window management. :)

smith

Thanks for the advice, I'll give it a go.

Unfortunately it looks like we have to wait for Vulkan to get a proper cross-platform API.