JME2 Crash with TextureRenderer

Hello,

I’m using the TextureRenderer to create and affect a red texture to a mesh. (with LWJGL)

Sphere sphere = new Sphere(“MySphere”, new Vector3f(5, 5, 0), 10, 10, 2);

TextureRenderer texRenderer = DisplaySystem.getDisplaySystem().createTextureRenderer(2, 2, TextureRenderer.Target.Texture2D);

texRenderer.setBackgroundColor(new ColorRGBA(1f, 0f, 0f, 1f));

Texture2D fakeTex = new Texture2D();

texRenderer.setupTexture(fakeTex);

TextureState texState = DisplaySystem.getDisplaySystem().getRenderer().createTextureState();

texState.setTexture(fakeTex);

sphere.setRenderState(texState);



here is the error:

at com.jme.renderer.lwjgl.LWJGLTextureRenderer.(LWJGLTextureRenderer.java:117)

at com.jme.renderer.lwjgl.LWJGLTextureRenderer.(LWJGLTextureRenderer.java:107)

at com.jme.system.lwjgl.LWJGLDisplaySystem.createTextureRenderer(LWJGLDisplaySystem.java:328)



public LWJGLTextureRenderer(int width, int height, int samples, LWJGLDisplaySystem display,

LWJGLRenderer parentRenderer) {

this.samplesUsed = samples;

this.display = display;

this.parentRenderer = parentRenderer;



if (!inited) {

supportsMultiSample = GLContext.getCapabilities().GL_EXT_framebuffer_multisample;/* this line 117 causes a crash I can’t trace*/

if (supportsMultiSample) {

IntBuffer buf = BufferUtils.createIntBuffer(16);

GL11.glGetInteger(EXTFramebufferMultisample.GL_MAX_SAMPLES_EXT, buf);

maxSamples = buf.get(0);

logger.log(Level.FINER, “FBO Max Samples: {0}”, maxSamples);

}

[…]



Has anyone an idea to resolve this issue? or another way to create a texture of the color I need and affect it to a mesh?

Are you running this code on the render thread?

No I’m running this code in one of my FPSGameState, I attach the mesh to the rootNode that’s all.

Is there any configuration or initiation in particular to do to allow the displaySytem to make a texturerenderer?

My work is too big and confidential to be given on the forum.

Can you post the full stack trace including the exception?

I don’t think it will be relevant:

java.lang.NullPointerException

at com.jme.renderer.lwjgl.LWJGLTextureRenderer.(LWJGLTextureRenderer.java:117)

at com.jme.renderer.lwjgl.LWJGLTextureRenderer.(LWJGLTextureRenderer.java:107)

at com.jme.system.lwjgl.LWJGLDisplaySystem.createTextureRenderer(LWJGLDisplaySystem.java:328)

at net.active3d.jme_engine.jmeui.states.A3DDebugMeshState.addTestMesh(A3DDebugMeshState.java:81)

at net.active3d.jme_engine.jmeui.states.scenetype.A3DEngineDefaultState.attachSceneNodeToRoot(A3DEngineDefaultState.java:188)

at net.active3d.jme_engine.jmeui.states.scenetype.A3DEngineDWGState.buildSceneGraphFromFile(A3DEngineDWGState.java:80)

at net.active3d.jme_engine.jmeui.canvas.A3DStandardCanvasGame$2.call(A3DStandardCanvasGame.java:338)

at net.active3d.jme_engine.jmeui.canvas.A3DStandardCanvasGame$2.call(A3DStandardCanvasGame.java:1)

at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)

at java.util.concurrent.FutureTask.run(FutureTask.java:138)

at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

at java.lang.Thread.run(Thread.java:619)



java.lang.NullPointerException

at com.jme.renderer.lwjgl.LWJGLTextureRenderer.(LWJGLTextureRenderer.java:117)

at com.jme.renderer.lwjgl.LWJGLTextureRenderer.(LWJGLTextureRenderer.java:107)

at com.jme.system.lwjgl.LWJGLDisplaySystem.createTextureRenderer(LWJGLDisplaySystem.java:328)

at net.active3d.jme_engine.jmeui.states.A3DDebugMeshState.addTestMesh(A3DDebugMeshState.java:81)

at net.active3d.jme_engine.jmeui.states.scenetype.A3DEngineDefaultState.attachSceneNodeToRoot(A3DEngineDefaultState.java:188)

at net.active3d.jme_engine.jmeui.states.scenetype.A3DEngineDWGState.buildSceneGraphFromFile(A3DEngineDWGState.java:80)

at net.active3d.jme_engine.jmeui.canvas.A3DStandardCanvasGame$2.call(A3DStandardCanvasGame.java:338)

at net.active3d.jme_engine.jmeui.canvas.A3DStandardCanvasGame$2.call(A3DStandardCanvasGame.java:1)

at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)

at java.util.concurrent.FutureTask.run(FutureTask.java:138)

at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

at java.lang.Thread.run(Thread.java:619)

I attach the mesh, which I affect the texture, to the rootnode of an A3DEngineGenericFPSState

You’re running the code in a separate thread (ThreadPoolExecutor), you cannot execute any methods of jME2 DisplaySystem outside of the rendering thread.

A3DStandardCanvasGame is an AbstractGame isn’t it the right thread?

I call the createMaterialState or the createTextureState of the displaysystem without any problem at the same spot

A3DStandardCanvasGame is a class, not a thread. You can still create threads from within it

So can you explain me which class and which method can call createTextureRenderer please?

Everything will be explained here

I work on a product for an architecture company. Can I expect a better answer?

Sure, if your company pays us. Since they pay you we are afraid you will have to do the bulk of the work, especially as you are using the old jME2. Life’s a bitch.

I was polite and just asking for some help.

So I expected another answer than “tape google in your navigator” from a professional.

I’m just disapointed and will work on my own on this matter.

The problem is that we can explain the ways and possible difficulties of the engine maybe but explaining (java) concurrency basics is way beyond the scope of forum support for the engine.

an answer like this is much more polite and professional than just giving a link to google (it’s like saying “hey you’re a noob, don’t expect an answer from my superior intellect”) at my age a “google” answer like this is not well appreciated.

Thanks.

I see but still, when you feel that the other person is more professional than yourself its probably a good idea to try and decipher as much info as possible about the answer he gave you, even if its short or seemingly above your level of understanding. In the case of Momoko’s answer, the hint that a class has nothing to do with threading means something and a bit of research on your side (maybe with the help of google :P) might have gotten you into a position where you would have seen the flaw in your thinking yourself, coming up with other solutions and (possibly) better questions to pose here.

And about the “lmgtfy” presentation… Well, if you just throw out a whole 3d engine for free the same way I guess throwing out a lmgtfy link instead of an elaborate answer like this is okay, the message that he loves us and likes to share with us already came across :wink:

Cheers,

Normen