Posted by
Nosezeichen on
Oct 31, 2014; 1:32pm
URL: https://forum.jogamp.org/Offscreen-Rendering-with-GLCanvas-which-wasn-t-created-with-this-capability-tp4033474.html
Hi,
I'm struggling with a third Party JOGL-Application wich I want to integrate into my own jMonkeyEngine application.
Basically I want to enable offscreen-rendering with a GLCanvas wich was created without this capability. Is it somehow possible to change capabilities after creating a Canvas ? Or use some other hackish methods to render it anyhow ?
I had to implement an abstract method of the 3rd-Party app:
public void embedInContainer(Component jacanvas) {
// jacanvas is in fact an Object of type javax.media.opengl.awt.GLCanvas
/* Initialization */
// create JPanel and configure it
javax.swing.JPanel panel;
panel = new JPanel(new BorderLayout());
panel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
panel.setPreferredSize(size);
panel.setMinimumSize(size);
panel.setMaximumSize(size);
panel.setSize(size);
panel.setBounds(0, 0, size.width, size.height);
panel.setBackground(Color.red);
// Add the GLCanvas which is in the comp variable to the JPanel
panel.add(comp, BorderLayout.CENTER);
panel.setVisible(true);
// create JFrame and configure it
javax.swing.JFrame frame;
frame = new JFrame();
frame.setBackground(Color.WHITE);
frame.setUndecorated(true);
frame.setPreferredSize(size);
frame.setMinimumSize(size);
frame.setMaximumSize(size);
frame.setSize(size);
frame.setBounds(0, 0, size.width, size.height);
// Add the panel to the frame
frame.getContentPane().add(panel);
frame.pack();
frame.setVisible(true); // I can see the ouptut and can copy it to my buffer via glReadPixels
frame.setVisible(false); // I can't see output and buffer holds a black image (like I expected, because it's not an offscreen renderable)
}
When putting the GLCanvas to a visible frame the output of the 3rd-Party app is shown. When setting the frame invisible the GLCanvas doesnt become rendered at all (reading the rendered output into my buffer with glReadPixels delivers a black image).
The jframe and jpanel stuff is just to see if it works at all. I dont want to use them. I want to put the output of the 3rd party jogl app into a buffer so that i can use it as a texture later on.
I've allready posted my Problem in the jme-forum but no one seems to can help me.
Here is the Post with a code example and a description:
http://hub.jmonkeyengine.org/forum/topic/how-to-render-a-glcanvas-inside-jme3/Thank you!
Nosezeichen