Exception from OpenGL3 when AppSettings are OpenGL2

Hi,

I have a project that I need to run on a virtual machine.
The virtual machine, virtual box, supports OpenGL2.1
In my jmonkey project I set the AppSettings to use LWJGL_OPENGL2

settings.setRenderer(AppSettings.LWJGL_OPENGL2);

The problem is that when the jmonkey project runs on the VM it always throws an exception
What is strange is that the exception is because of an attempt to bind to an OpenGL3 function …

mar 22, 2017 10:05:42 PM com.jme3.app.LegacyApplication handleError SEVERE: Uncaught exception thrown in Thread[jME3 Main,5,main] java.lang.IllegalStateException: Function is not supported at org.lwjgl.BufferChecks.checkFunctionAddress(BufferChecks.java:58) at org.lwjgl.opengl.GL30.glBindFragDataLocation(GL30.java:941) at com.jme3.renderer.lwjgl.LwjglGL.glBindFragDataLocation(LwjglGL.java:472) at com.jme3.renderer.opengl.GLRenderer.updateShaderData(GLRenderer.java:1282) at com.jme3.renderer.opengl.GLRenderer.setShader(GLRenderer.java:1335) at com.jme3.material.logic.MultiPassLightingLogic.render(MultiPassLightingLogic.java:166) at com.jme3.material.Technique.render(Technique.java:166) at com.jme3.material.Material.render(Material.java:970) at com.jme3.renderer.RenderManager.renderGeometry(RenderManager.java:614) at com.jme3.renderer.queue.RenderQueue.renderGeometryList(RenderQueue.java:266) at com.jme3.renderer.queue.RenderQueue.renderQueue(RenderQueue.java:305) at com.jme3.renderer.RenderManager.renderViewPortQueues(RenderManager.java:877) at com.jme3.renderer.RenderManager.flushQueue(RenderManager.java:779) at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:1108) at com.jme3.renderer.RenderManager.render(RenderManager.java:1158) at com.jme3.app.SimpleApplication.update(SimpleApplication.java:253) at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:151) at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:197) at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:232) at java.lang.Thread.run(Unknown Source)

I have the same problem with both 3.1 stable and 3.2prealpha
I have also tried without using AppSettings with the same result

Any suggestions?
What else would be useful to help debug the problem?

I have tried a test project that simply loads a model and tries to display the model
The TestBlender project from jmonkey
The model was created in Blender 2.78

package test;

import com.jme3.app.SimpleApplication;
import com.jme3.asset.BlenderKey;
import com.jme3.asset.ModelKey;
import com.jme3.light.DirectionalLight;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.scene.Spatial;
import com.jme3.scene.plugins.blender.BlenderLoader;
import com.jme3.system.AppSettings;

public class TestBlender extends SimpleApplication
{

	@Override
	public void simpleInitApp() 
	{
	     viewPort.setBackgroundColor(ColorRGBA.DarkGray);

        //load model with packed images
	    assetManager.registerLoader(BlenderLoader.class, "blend");
	    BlenderKey keyAsset = new BlenderKey("Train.blend");
        Spatial train = assetManager.loadModel(keyAsset);
        rootNode.attachChild(train);

        // sunset light
        DirectionalLight dl = new DirectionalLight();
        dl.setDirection(new Vector3f(-0.1f,-0.7f,1).normalizeLocal());
        dl.setColor(new ColorRGBA(0.44f, 0.30f, 0.20f, 1.0f));
        rootNode.addLight(dl);

        // skylight
        dl = new DirectionalLight();
        dl.setDirection(new Vector3f(-0.6f,-1,-0.6f).normalizeLocal());
        dl.setColor(new ColorRGBA(0.10f, 0.22f, 0.44f, 1.0f));
        rootNode.addLight(dl);

        // white ambient light
        dl = new DirectionalLight();
        dl.setDirection(new Vector3f(1, -0.5f,-0.1f).normalizeLocal());
        dl.setColor(new ColorRGBA(0.80f, 0.70f, 0.80f, 1.0f));
        rootNode.addLight(dl);		
        
        return;
	}
	
    @Override
    public void simpleUpdate(float tpf)
    {
    	return;
    }

	public static void main(String[] args) 
	{
        AppSettings settings = new AppSettings(true);
        settings.setWidth(640);
        settings.setHeight(480);
        settings.setRenderer(AppSettings.LWJGL_OPENGL2);
        
		TestBlender blenderImport = new TestBlender();
		blenderImport.setSettings(settings);
		blenderImport.start();
	}
}

Many thanks if anyone has a solution

Best regards

Martin

You can try 3.0 (stable), maybe it is indeed a bug in the engine but noone had opengl2 to notice it :stuck_out_tongue:

@nehon maybe that happend due to Single Pass Lighting?

Hi @Darkchaos

Thank you for the reply
I thought of the same thing, just after posting
With jmonkeyplatform 3.0.10 I have a different exception

C:\xxxxxx>java -jar TestBlender.jar
mar 23, 2017 8:30:35 AM com.jme3.system.JmeDesktopSystem initialize
INFO: Running on jMonkeyEngine 3.0.10
mar 23, 2017 8:30:39 AM com.jme3.system.Natives extractNativeLibs
INFO: Extraction Directory: C:\xxxxxx
OpenGL Warning: State tracker is being re-initialized..

OpenGL Warning: Assertion failed: g_pAvailableContexts[ctx->id] == ctx=0, file D
:\tinderbox\add-5.1\src\VBox\GuestHost\OpenGL\state_tracker\state_init.c, line 4
43
OpenGL Warning: freeing context 1ba50020, id(0) not being in the context list
OpenGL Warning: State tracker is being re-initialized..

OpenGL Warning: Assertion failed: g_pAvailableContexts[ctx->id] == ctx=0, file D
:\tinderbox\add-5.1\src\VBox\GuestHost\OpenGL\state_tracker\state_init.c, line 4
43
OpenGL Warning: freeing context 1bc10020, id(0) not being in the context list
mar 23, 2017 8:30:47 AM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: Lwjgl 2.9.0 context running on thread LWJGL Renderer Thread
mar 23, 2017 8:30:47 AM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: Adapter: VBoxDisp
mar 23, 2017 8:30:47 AM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: Driver Version: 5.1.18.14002
mar 23, 2017 8:30:47 AM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: Vendor: Humper
mar 23, 2017 8:30:47 AM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: OpenGL Version: 2.1 Chromium 1.9
mar 23, 2017 8:30:47 AM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: Renderer: Chromium
mar 23, 2017 8:30:47 AM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: GLSL Ver: 4.00 - Build 9.17.10.3040
mar 23, 2017 8:30:49 AM com.jme3.asset.AssetConfig loadText
WARNING: Cannot find loader com.jme3.audio.plugins.OGGLoader
mar 23, 2017 8:30:49 AM com.jme3.asset.AssetConfig loadText
WARNING: Cannot find loader com.jme3.scene.plugins.ogre.MeshLoader
mar 23, 2017 8:30:49 AM com.jme3.asset.AssetConfig loadText
WARNING: Cannot find loader com.jme3.scene.plugins.ogre.SkeletonLoader
mar 23, 2017 8:30:49 AM com.jme3.asset.AssetConfig loadText
WARNING: Cannot find loader com.jme3.scene.plugins.ogre.MaterialLoader
mar 23, 2017 8:30:49 AM com.jme3.asset.AssetConfig loadText
WARNING: Cannot find loader com.jme3.scene.plugins.ogre.SceneLoader
mar 23, 2017 8:30:50 AM com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread
INFO: Audio Device: OpenAL Soft
mar 23, 2017 8:30:50 AM com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread
INFO: Audio Vendor: OpenAL Community
mar 23, 2017 8:30:50 AM com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread
INFO: Audio Renderer: OpenAL Soft
mar 23, 2017 8:30:50 AM com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread
INFO: Audio Version: 1.1 ALSOFT 1.15.1
mar 23, 2017 8:30:50 AM com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread
INFO: AudioRenderer supports 64 channels
mar 23, 2017 8:30:50 AM com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread
INFO: Audio effect extension version: 1.0
mar 23, 2017 8:30:50 AM com.jme3.audio.lwjgl.LwjglAudioRenderer initInThread
INFO: Audio max auxilary sends: 4
mar 23, 2017 8:30:56 AM com.jme3.app.Application handleError
SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
com.jme3.renderer.RendererException: Image format 'ABGR8' is unsupported by the
video hardware.
        at com.jme3.renderer.lwjgl.TextureUtil.getImageFormatWithError(TextureUtil.java:220)
        at com.jme3.renderer.lwjgl.TextureUtil.uploadTexture(TextureUtil.java:231)
        at com.jme3.renderer.lwjgl.LwjglRenderer.updateTexImageData(LwjglRenderer.java:1913)
        at com.jme3.renderer.lwjgl.LwjglRenderer.setTexture(LwjglRenderer.java:1936)
        at com.jme3.material.MatParamTexture.apply(MatParamTexture.java:86)
        at com.jme3.material.Material.render(Material.java:1088)
        at com.jme3.renderer.RenderManager.renderGeometry(RenderManager.java:523)
        at com.jme3.renderer.queue.RenderQueue.renderGeometryList(RenderQueue.java:322)
        at com.jme3.renderer.queue.RenderQueue.renderQueue(RenderQueue.java:371)
        at com.jme3.renderer.RenderManager.renderViewPortQueues(RenderManager.java:788)
        at com.jme3.renderer.RenderManager.flushQueue(RenderManager.java:719)
        at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:983)
        at com.jme3.renderer.RenderManager.render(RenderManager.java:1035)
        at com.jme3.app.SimpleApplication.update(SimpleApplication.java:252)
        at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:151)
        at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:185)
        at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:228)
        at java.lang.Thread.run(Unknown Source)

Best regards

Martin

… and another thought @Darkchaos … if I downloaded the master branch just to build the engine, could you point me at where the code would need to be patched to prevent the original problem? Any tips? Would it be a humungous change over lots of different files of is it fairly contained?

Technically you only need something like: If not openGL3.3 or later, use a different shader. The problem here is the different shader itself which does not use w/e is unsupported.

Maybe it already is there but the check is not fired. I would check com.jme3.material.logic.MultiPassLightingLogic.render(MultiPassLightingLogic.java:166) for that.

For the 3.0 Problem: Try a different texture, Try to leave the Texture out in general and such things.

When saving a PNG file, some software allows you to specify bitdepths and such, maybe you also need to get rid of the alpha parameter, however:

It feels like your virtual gpu is basic/has a bad openGL support, I don’t know if it isn’t easier to switch the virtual machine and try your luck there.

Apart from that there is no real reason to use a virtual box when you have jMonkey actually: We support Windows, Linux, Mac OS, Android and technically even iOS. The only thing which might be a bit problematic is the raspberryPi, however you could install android on it and use the android build I guess.

I’ve tried looking into building lwjgl3 for arm64 however this might be some work. For lwjgl2 there are already tutorials about “porting minecraft to the raspberryPi”.

So: Why do you need a virtualbox could help here.

Hi @Darkchaos,

Thank you for the reply, I am downloading the master branch to see if I can tweak something appropriately.

To answer your other points.
The virtual machine {Virtual Box} is dictated by the release envronment.
I am using jmonkey to create a 3D frontend to some large data sets
And it is the system that generates and manages the data that resides on the VM

Sadly OpenGL support for VMs is very cranky
Originally I tried Microsoft Virtual PC but that has minimal OpenGL support
Doing some research I saw that Virtual Box has OpenGL2
But like you I kind of think it might be patchy
It will be interesting to see if I can clear up the error, or if this just pushes the problem somewhere else

I am a lazy programmer http://threevirtues.com/ so the model and textures are all in the Blender file
And I just load this as an asset
I try to avoid separating anything and concentrate on getting the data connection working

Thanks for your help

Martin