[SOLVED] Netbeans RCP + JMonkey : display is active but content does not appear :-€

Hi every one, i’m searching for a while and thinking that solution is so simple that i can not find it… need hollidays ? :slight_smile:



So i’m currently writing a modeler based on JMonkey3 engine and Netbeans RCP. I’m ussing a ribbon, action to opening the editor, i’m started from SceneViewerTopComponent available in the JMonkey platform (need to tell that @normen made a fantastic job in the JMonkey platform) , this i what is looking like :



http://i.imgur.com/llTia.jpg



So, i’ve got a SceneApplication class which inherits from Application which create and start the canvas (which would be starting rendering automatically when canvas is displayed regarding Application class source code) :



[java]

protected Node rootNode = new Node("RootNode");



public static SceneApplication getApplication() {

if (application == null) {

application = new SceneApplication();

}

return application;

}



protected SceneApplication() {



try {

AppSettings newSetting = new AppSettings(true);

newSetting.setFrameRate(30);

newSetting.setRenderer(AppSettings.LWJGL_OPENGL_ANY);

setSettings(newSetting);

setPauseOnLostFocus(false);

createCanvas();

startCanvas(true);



} catch (Exception | Error e) {

Exceptions.printStackTrace(e);

}

}

[/java]



in this class i’ve got an OpenScene method which is called by an action :



[java]

public void openScene() {

closeScene();

java.awt.EventQueue.invokeLater(new Runnable() {

public void run() {

enqueue(new Callable() {

public Object call() throws Exception {



// hardcoded scene for test

AmbientLight al = new AmbientLight();

al.setColor(ColorRGBA.White.mult(1.3f));

rootNode.addLight(al);



Material grayMat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");

grayMat.getAdditionalRenderState().setWireframe(true);

grayMat.setColor("Color", ColorRGBA.Gray);

Geometry grid = new Geometry("grid", new Grid(20, 20, 1.0f));

grid.setMaterial(grayMat);

grid.setLocalTranslation(-10, 0, -10);

rootNode.attachChild(grid);



Box b = new Box(Vector3f.ZERO, 1, 1, 1);

Geometry geom = new Geometry("Box", b);

Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");

mat.setColor("Color", ColorRGBA.Blue);

geom.setMaterial(mat);

//end hardcoded region



rootNode.attachChild(geom);



cam.setLocation(new Vector3f(0, 0, 10));



System.out.println("Framerate: " + String.valueOf(getContext().getTimer().getFrameRate()));



return null;

}

});

}

});

}

[/java]



action do this stuff :



[java]

MyViewerTopComponent viewer = new MyViewerTopComponent();

viewer.open();

viewer.requestActive();

viewer.OpenScene();

[/java]



In my TopComponent (Netbeans RCP window), i’ve got a jPanel and the Canvas is added to JPanel, i’ve forced panel and canvas size to 640x480 to

be sure display zone will be fine (and this is the case because i can see a black rectangle at execution time in the TopComponent.



here, you can find to Jmonkey output + a framerate information (seems to be 0 but maybe i dont read value in the right place :



INFO [com.jme3.system.JmeSystem]: Running on jMonkeyEngine 3.0.0 Beta
INFO [com.jme3.system.Natives]: Extraction Directory: "my project directory"
INFO [com.jme3.system.lwjgl.LwjglDisplay]: MAIN: Creating OGL thread.
INFO [com.jme3.system.lwjgl.LwjglAbstractDisplay]: Using LWJGL 2.8.3
INFO [com.jme3.system.lwjgl.LwjglDisplay]: OGL: Pbuffer has been created
INFO [com.jme3.renderer.lwjgl.LwjglRenderer]: Caps: [FrameBuffer, FrameBufferMRT, FrameBufferMultisample, TextureMultisample, OpenGL20, OpenGL21, OpenGL30, OpenGL31, OpenGL32, ARBprogram, GLSL100, GLSL110, GLSL120, GLSL130, GLSL140, GLSL150, VertexTextureFetch, TextureArray, TextureBuffer, FloatTexture, FloatColorBuffer, FloatDepthBuffer, PackedFloatTexture, SharedExponentTexture, PackedFloatColorBuffer, TextureCompressionLATC, NonPowerOfTwoTextures, MeshInstancing, VertexBufferArray]
INFO [com.jme3.system.lwjgl.LwjglContext]: Adapter: aticfx64
INFO [com.jme3.system.lwjgl.LwjglContext]: Driver Version: null
INFO [com.jme3.system.lwjgl.LwjglContext]: Vendor: ATI Technologies Inc.
INFO [com.jme3.system.lwjgl.LwjglContext]: OpenGL Version: 4.2.11399 Compatibility Profile Context
INFO [com.jme3.system.lwjgl.LwjglContext]: Renderer: ATI Radeon HD 5700 Series
INFO [com.jme3.system.lwjgl.LwjglContext]: GLSL Ver: 4.20
INFO [com.jme3.system.lwjgl.LwjglTimer]: Timer resolution: 1 000 ticks per second
INFO [com.jme3.system.lwjgl.LwjglDisplay]: EDT: Telling OGL to create display ..
INFO [com.jme3.asset.AssetManager]: DesktopAssetManager created.
INFO [com.jme3.renderer.Camera]: Camera created (W: 640, H: 480)
INFO [com.jme3.renderer.Camera]: Camera created (W: 640, H: 480)
Panel dimensions=width:640, height:480
Canvas dimensions=width:640, height:480
INFO [com.jme3.audio.lwjgl.LwjglAudioRenderer]: AudioRenderer supports 64 channels
INFO [com.jme3.audio.lwjgl.LwjglAudioRenderer]: Audio effect extension version: 1.0
INFO [com.jme3.audio.lwjgl.LwjglAudioRenderer]: Audio max auxilary sends: 4
INFO [com.jme3.system.lwjgl.LwjglDisplay]: OGL: Creating display ..
INFO [com.jme3.system.lwjgl.LwjglDisplay]: OGL: Waiting for canvas to become displayable..
INFO [com.jme3.system.lwjgl.LwjglDisplay]: OGL: Creating display context ..
INFO [com.jme3.renderer.lwjgl.LwjglRenderer]: Deleting objects and invalidating state
INFO [com.jme3.system.lwjgl.LwjglDisplay]: OGL: Display is active!
INFO [com.jme3.scene.Node]: RootNode (Node): All children removed.
INFO [com.jme3.material.MaterialDef]: Loaded material definition: Unshaded
INFO [com.jme3.scene.Node]: Child (grid) attached to this node (RootNode)
INFO [com.jme3.scene.Node]: Child (Box) attached to this node (RootNode)
Framerate: 0.0



So it's seems that open gl display is ready, but nothing appears, if someone could help me to burn the tree in center of my eye i will appreciate !

see you ! ++

How much of the SDK code did you copy? Some configuration line for the renderer might disable it if you just copy/pasted it to your application. As some things about how the SDK runs the OpenGL window can be configured the setup routines might contain more things than actually apply.

yep you’re right, some things are missing because i dont want just to copy but learn from minimal content and adding just the needed stuff to my project needs. In the SDK code some flags are used (from the configuration panel) to deal with canvas creation / used depending using open gl1 or heavyweight lwjgl canvas… but in the SDK platform works fine without checking theses options.



i need to give it a try ! maybe that my minimal approach is too minimal !



thanks for your help, i will provide feedback to close this thread when it will be successful (with details) hope this will help other people to engage in tooling around the jmonkey engine !

If its about development tools, the SDK has API’s for several things so you can create plugins for the SDK specifically so you don’t need to open your own window: https://wiki.jmonkeyengine.org/legacy/doku.php/sdk:development

Solved, you definitively push me on the right way (until it’s not the motorway :roll: ).



Ok so init process was too minimal for my SceneApplication class AND need to init canvas with “AwtPanelsContext” AND need to start from SceneViewerTopComponent (and not SceneComposerTopComponent as i started from…) AND need to start the rendering thread manually.



So lot of dummies errors,i will describe the solution to help other Guys who want to create their own modeler (in my case it’s standalone application because i will working on a specific domain tooling, not dedicated to video game creation, it’s the reason why i dont writing plugin for the SDK, just need the engine and the basics swing wrapping).



Right now, the solution 8) :



In my SceneApplication class, i use a custom render based on Awt AND Start the rendering thread :



[java]

newSetting.setCustomRenderer(AwtPanelsContext.class);

start();

[/java]



the complete process is as following assuming you manage extra bool config variables available from the netbeans configuration panel (as you can see in the OpenGL configuration panel available in the JM3 SDK via “Toolsoptions” :



[java]

protected SceneApplication() {

try {

useCanvas = “true”.equals(NbPreferences.forModule(Installer.class).get(“use_lwjgl_canvas”, “false”));

AppSettings newSetting = new AppSettings(true);

newSetting.setFrameRate(30);

if (“true”.equals(NbPreferences.forModule(Installer.class).get(“use_opengl_1”, “false”))) {

newSetting.setRenderer(AppSettings.LWJGL_OPENGL_ANY);

}

if (!useCanvas) {

newSetting.setCustomRenderer(AwtPanelsContext.class);

}

setSettings(newSetting);

setPauseOnLostFocus(false);



if (useCanvas) {

createCanvas();

startCanvas(true);

}

if (!useCanvas) {

start();

}



} catch (Exception | Error e) {

Exceptions.printStackTrace(e);

}

}

[/java]



ok, after that, the dummy thing is to forget to override the “initialize()” and “update()” of the Application class… -.- -.- -.- -.- -.- -.- :cry: dont forget it, it works better with it… hum !



and to finish, your “TopComponent” needs to get the canvas (before adding it to a panel) with the “getMainPanel()” method of your SceneApplication class which would be as follow (with panel is a private AwtPanel):



[java]

public Component getMainPanel() {

if (useCanvas) {

return ((JmeCanvasContext) getContext()).getCanvas();

} else {

if (panel == null) {

panel = ((AwtPanelsContext) getContext()).createPanel(PaintMode.Accelerated);

((AwtPanelsContext) getContext()).setInputSource(panel);

attachPanel();

}

return panel;

}

}



private void attachPanel() {

enqueue(new Callable() {



public Object call() throws Exception {

panel.attachTo(true, viewPort, overlayView, guiViewPort);

return null;

}

});

}

[/java]



and that’s the result !:







thank you again @normen for your active support, i appreciate and your work help jmonkey to be more popular day after day… and involve people in moving from UDK to Jme3 8) 8) 8) :slight_smile: