Make screenshot of work display.

classic Classic list List threaded Threaded
37 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Make screenshot of work display.

Andriy
Hi, dear developer I need to create simple screenshoter using jogl, now I try to use jogl api, can any show me work screenshoter example?
Reply | Threaded
Open this post in threaded view
|

Re: Make screenshot of work display.

gouessej
Administrator
Reply | Threaded
Open this post in threaded view
|

Re: Make screenshot of work display.

Andriy
Thanks, I use this class but I have an error :

Exception in thread "main" javax.media.opengl.GLException: No OpenGL context current on this thread
        at javax.media.opengl.glu.gl2.GLUgl2.getCurrentGL2(GLUgl2.java:195)
        at com.jogamp.opengl.util.awt.Screenshot.readToBufferedImage(Screenshot.java:259)
        at webdesktops.server.capture.ScreenCapture.main(ScreenCapture.java:82)

I read at forum that

Its actually very simple to get a screenshot of ur JOGL renderings. Here's a small snippet that could be used inside (at the end) of the display() method of ur GLEventListener:

BufferedImage tScreenshot = Screenshot.readToBufferedImage(0,0, tScreenWidth, tScreenHeight, false);
File tScreenCaptureImageFile = new File(tFileName);
ImageIO.write(tScreenshot, "png", tScreenCaptureImageFile);

... or u can press the whole process in a single line
Reply | Threaded
Open this post in threaded view
|

Re: Make screenshot of work display.

gouessej
Administrator
Yes you must call readToBufferedImage only when the OpenGL context is current, for example in GLEventListener.display(), you cannot call it directly in your main method, you have to create a canvas, set a GLEventListener to it, use an animator and it will work fine.

Edit.: Maybe use an offscreen canvas.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Make screenshot of work display.

Sven Gothel
Administrator
On 09/11/2012 04:31 PM, gouessej [via jogamp] wrote:
> Yes you must call readToBufferedImage only when the OpenGL context is current,
> for example in GLEventListener.display(), you cannot call it directly in your
> main method, you have to create a canvas, set a GLEventListener to it, use an
> animator and it will work fine.

I recommend using GLReadBufferUtil as demonstrated in UITest's snapshot(..):
        gl.glFinish(); // just make sure rendering finished ..
        if(readBufferUtil.readPixels(gl, false)) {
            readBufferUtil.write(new File("snap.png"));
        }                

It benefits of being toolkit independent and works well w/ ES1, ES2
and desktop GL profiles.

UITest is our JUnit test super-class.

~Sven




signature.asc (907 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Make screenshot of work display.

Pixelapp
In reply to this post by gouessej
Oh my Gawd. I never knew this type of class existed. I thought the only class available was the Robot class.

Is this class fast? Can this class take 60 screen shots per second?
Reply | Threaded
Open this post in threaded view
|

Re: Make screenshot of work display.

Andriy
Robot class is slow, I test perfomence of this class, that's why I need a quick 24-32 fps screen method.  
Reply | Threaded
Open this post in threaded view
|

Re: Make screenshot of work display.

Andriy
In reply to this post by Sven Gothel
Sven if it isn't difficult can you please describe me hot I can do it from this Util,it's would be great. My task is to create desktop capture, that's why I need to create 24-32 fps screen grabber of desktop, can I do it by jogl???Sorry for bad English.
Reply | Threaded
Open this post in threaded view
|

Re: Make screenshot of work display.

Pixelapp
@Andriy we are almost trying to do the same thing.

Does anybody know if "Is this class fast? Can this class take 60 screen shots per second?".
Reply | Threaded
Open this post in threaded view
|

Re: Make screenshot of work display.

Andriy
It can do 10-20 screens per second, I try to test it and create video by java media framework, but it wasn't succ, may be I have mistake in test, but I download 3-d part java screen recorder base on jmf and robot class and try to capture real video, result was not well. Anybody know another method to get screen using java 24-30 screens per second???
Reply | Threaded
Open this post in threaded view
|

Re: Make screenshot of work display.

Pixelapp
"It can do 10-20 screens per second" Are you telling me that you can reach 10-20 frames per second with this http://jogamp.org/deployment/jogamp-next/javadoc/jogl/javadoc/com/jogamp/opengl/util/awt/Screenshot.html?

By the way, this is what I'm going to use for this task http://code.google.com/p/javacv/. However I was expecting an easier solution from this thread.
Reply | Threaded
Open this post in threaded view
|

Re: Make screenshot of work display.

Andriy
Pixelapp, may be I tell you wrong, my English isn't not well, I tell you about Robot class, it is slow, about JavaCV I don't know I didn't test it. May be you tell me solution for this problem, it's would be great and I'll be great thanks for you.
Reply | Threaded
Open this post in threaded view
|

Re: Make screenshot of work display.

Pixelapp
Oh ok. I know all about the robot class already.

I guess I'll have to test http://jogamp.org/deployment/jogamp-next/javadoc/jogl/javadoc/com/jogamp/opengl/util/awt/Screenshot.html. Unless someone is kind enough to tell me the speed of this class.
Reply | Threaded
Open this post in threaded view
|

Re: Make screenshot of work display.

Pixelapp
In reply to this post by Andriy
"May be you tell me solution for this problem, it's would be great and I'll be great thanks for you." I'm trying also to find the solution.
Reply | Threaded
Open this post in threaded view
|

Re: Make screenshot of work display.

Andriy
In reply to this post by Pixelapp
I want also to test this class, but I am new in jongl I can't enougth to create simple example to get desktop screenshot by this lib, if I do it I also to research it lib. That's why I need help from people who work with this lib and know it. I need simple example of desktop screenshot by this lib. May be I want a many from this lib, now if I undestand it help to create futures for 3-d,2-d graffic.
Reply | Threaded
Open this post in threaded view
|

Re: Make screenshot of work display.

Pixelapp
I'll test it out as soon as I have time.
Reply | Threaded
Open this post in threaded view
|

Re: Make screenshot of work display.

Andriy
Please if it isn't difficult send me your desktop screen grabber code????Or describe how to get desktop screenshot by jogl.
Reply | Threaded
Open this post in threaded view
|

Re: Make screenshot of work display.

Pixelapp
I'll just post it in this thread.

Just make sure to remind me later on.
Reply | Threaded
Open this post in threaded view
|

Re: Make screenshot of work display.

Andriy
Ok, write the best time to contact to you.
Reply | Threaded
Open this post in threaded view
|

Re: Make screenshot of work display.

Pixelapp
Write to this thread in about a week or less, it will show up on my desktop screen. . I read all my emails.
12