NB Question : Attaching node in simpleUpdate -> Render States problems

Hi, I'm new to jME and used to using openGL, my problem is that I simply want to add a Quad to my rootNode, when I create and attach the Quad during simpleInitGame() everything is fine.



But when I use the same code (quad creation and attach) in simpleUpdate, the Quad is textured with the fpsNode font texture, and appears to have Depth test problems (every other object draws on top of it). This is true unless I have another object of my rootNode previously drawn in the queues.



I think I am missing something really obvious here. What is the difference between creating the Quad in simpleInitGame or in simpleUpdate ? Do I need to explicitly create all render states when I create the Quad in update ?



Thanks in advance.



Here is the code used to create and attach the Quad :


Quad test = new Quad("testQuad", 100,100);
test.setLightCombineMode(LightState.OFF);
//        test.setTextureBuffer(0, null);
test.setRenderQueueMode(Renderer.QUEUE_OPAQUE);
test.setDefaultColor(new ColorRGBA(0,1,0,1));
test.updateGeometricState(0, true);
rootNode.attachChild(test);



This is what I get when using the code in update (not good) :


And this is what I get when using the code in init (it's ok) :

You need to call rootNode.updateRenderstate() after adding new objects to the scene.

This is done for you already in SimpleGames internal init method.

Also creating a new Quad every update is a bad idea!



I realise you're probably just messing around trying things out, but it's always nice to get into good habits from the start  :slight_smile:

Woah ! What a quick answer !



Thank you a lot Core Dump, it works fine now … :wink:



@Gentleman Hal : Thanks for the reply, of course I'm not creating new Quads each frame update, the idea is just to test (with quads for now) dynamic insertion of object in the scene, took from a queue updated by another thread ;). So I create Quads only when there's something in the queue.



I plan to implement Sun Game Server later :).



Thanks again, have a nice day

Good luck with that. :slight_smile: