lhkbob, I’ve read your post several times and it is still out of my league but I’ll attempt to write down my thoughts and I hope your or others can correct me.
First of, let me tell you my current situation and what my intention is. I am using a GLJPanel to currently display a 3D vehicle at a desired orientation. Clearly I know how to do this and it works. Next I needed to be able to retrieve the projection of this 3D vehicle onto a 2D screen, so I used an Orthographic projection to draw my 3D scene. This gave me a true projection of the 3D vehicle of which I only care about the area of the screen that this projection takes up so I used a FBO to be able to retrieve the pixel data and to process/count the visible pixels and subtract those from the background pixels. This too works. Basically I have a display() method in which I draw the normal 3D scene using a Perspective projection, and whenever I hit a certain keyboard key it enables a boolean flag which is read during the display() call and then it calls a “screenshot” method that I have. This “screenshot” method simply enables the FBO, retrieves the pixel data and process it and then disables the FBO. Effectively, during the keyboard key press to activate screenshot the display() loop does the regular 3D display and publishes this to my GLJPanel, and in the background it does the FBO display and processing on the back buffer. I’m hope what I wrote above is correct and the terminology is correct … I know how to hack code together but I can’t explain it well.
So, the above is what I’ve been doing up till now. Right now I need to have a way to perform this “screenshot” functionality without having to have the 3D display active. I realize I’ll still have to create a 3D display so that the rendering can occur but I was searching for a way where the 3D display would either not be actively drawing to a window, or as a last resort, the 3D display would be hidden or minimized, etc. This last thing is got me to the current predicament. As I mentioned before, up till now I have a 3D display of my vehicle, and in the background it process the pixels of the vehicle projection. Well, the pixels are stored in a BufferedImage so I wanted to have a way for a user to view this image, and for the heck of it, have the user view the 3D scene as well…so I decided to create a tabbed pane display. I’ve attached a couple of screenshots to show you my current tool. The ‘3dview’ screenshot shows the 3D view with the vehicle in it, the ‘2dview’ screenshot is the projected view of the same vehicle.
What made me notice my current problem was that nothing would change in the 2D projection view when I changed the attitude values of the orientation of the vehicle. The values would be accepted, the calls to enable the screenshot boolean flag was made, the GLJPanel.display() method was called to try to force a redisplay but nothing happened…ie, the ‘screenshot’ method never got called from the renderer’s display() loop which means the display() method never got invoked. When I swtiched to the “Asset View” tab to see the 3D view of the vehicle, then the display() method was called and the resulting screenshot was processed. I’ll be honest, I don’t know what happens when you switch tabs where one tab contains a JOGL window. I don’t know if this causes the GL context of the display to go null but it doesn’t make sense that it would since when I bring up the 3D view tab it doesn’t call init() to recreate anything, so the GL context must still be valid?
Well, figuring that the GL context was still valid when in the 2d view/tab, I thought maybe I can ask the GLJPanel (which I can ‘canvas’) for the GL using canvas.getGL(), but simply making this call results in a NullPointerException. It is not that the result of ‘canvas.getGL()’ is null, but simply trying to make this call results in the exception…not sure if I’m doing something wrong here or not.
Ok, so now back to the lhkbob post…what I could gather from that post was that I need an valid GL context and one possible way is to use a GLCanvas since it has a sharable context and lhkbob seems to imply that you can have this context available without making the window visible…ok, but will I still have the same issue above where I try to getGL() and it gives me a null pointer exception? or will it work because I’d be using a GLCanvas instead of a GLJPanel? If I can get the GL then I can tell the FBO to retrieve the pixels and I can do my “screenshot” function.
As for the other comments…boy, I thought I understood them but I’m still trying to learn this so I’ll end this post right now before I say something really stupid.