Best way to prepare an Image

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

Best way to prepare an Image

Vasilij
Hello dear Community,

I have a problem and I hope you can put me to right way.
I make an application with JOGL but it does not run smoothly.

What i have done is:
in the init-Methode I load Images from Raspi. Its need a lot of Time, but it is not a problem. I use this images as backstage and they are always the same.
After init I make a Thread, that makes BuffferedImages. That BufferedImage should be placed in the middle of the screen.
In the draw method I make a texture from the BufferedImage and an VBO with vertices. I do this at this step because texture and VBO needs current GLContext. And that step take a lot of time.

I think the draw-method should paint and not calculate.


How can i do that in another way? - How can I prepare texture in a Thread? I have read there is some Solution: FBO, PBuffer, multilpe Context... something else?

In this repositories i don't see Threads:
https://github.com/xranby/jogl-demos/tree/master/src/demos/es2
http://jogamp.org/git/?p=jogl.git;a=tree;f=src/test/com/jogamp/opengl/test/junit/jogl/acore

And maybe you can write a little bit more words for solution and not only "use FBO" =)

Best Regards,
Vasilij
Reply | Threaded
Open this post in threaded view
|

Re: Best way to prepare an Image

Sven Gothel
Administrator
On 02/25/2014 06:13 PM, Vasilij [via jogamp] wrote:

> Hello dear Community,
>
> I have a problem and I hope you can put me to right way.
> I make an application with JOGL but it does not run smoothly.
>
> What i have done is:
> in the init-Methode I load Images from Raspi. Its need a lot of Time, but it
> is not a problem. I use this images as backstage and they are always the same.
> After init I make a Thread, that makes BuffferedImages. That BufferedImage
> should be placed in the middle of the screen.
> In the draw method I make a texture from the BufferedImage and an VBO with
> vertices. I do this at this step because texture and VBO needs current
> GLContext. And that step take a lot of time.
>
> I think the draw-method should paint and not calculate.
>
>
> How can i do that in another way? - How can I prepare texture in a Thread? I
> have read there is some Solution: FBO, PBuffer, multilpe Context... something
> else?
>
> In this repositories i don't see Threads:
> https://github.com/xranby/jogl-demos/tree/master/src/demos/es2
> http://jogamp.org/git/?p=jogl.git;a=tree;f=src/test/com/jogamp/opengl/test/junit/jogl/acore
>
> And maybe you can write a little bit more words for solution and not only "use
> FBO" =)
GLMediaPlayer's StreamWorker fetches textures off-thread
using a shared GL context.

This is probably what you want, create an image loader thread
using a shared context to prepare your textures.
Then you need to signal your other thread when the texture is available.

This has been discussed here multiple times :)

BTW .. RaspPi and BufferedImage ? The latter is an AWT class AFAIK.

~Sven




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

Re: Best way to prepare an Image

Vasilij
Hello Sven, hello all!

i can see the  GLMediaPlayer... but where is StreamWorker?? Is there one implementation or everyone should  implement its own StreamWorker in that way that you discribe in words before?

And yes, Bufferedimage is in AWT-Package. Is somethink wrong whit it? Does make it troubles?
Reply | Threaded
Open this post in threaded view
|

Re: Best way to prepare an Image

Sven Gothel
Administrator
On 02/26/2014 09:56 AM, Vasilij [via jogamp] wrote:
> Hello Sven, hello all!
>
> i can see the  GLMediaPlayer
> <https://github.com/xranby/jogl/blob/master/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java>...
> but where is StreamWorker??
Part of GLMediaPlayerImpl (implementing GLMediaPlayer).

> Is there one implementation or everyone should
>  implement its own StreamWorker in that way that you discribe in words before?
>
> And yes, Bufferedimage is in AWT-Package. Is somethink wrong whit it? Does
> make it troubles?

Why adding AWT dependency to a target where we don't support native onscreen
rendering w/ AWT yet ?
Why adding AWT as an requirement at all ?

TextureIO allows you to read and provide textures ..

~Sven



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

Re: Best way to prepare an Image

Vasilij
Yeah! I found GL MediaPlayer Impl! I should take a moment to understand it.
To Bufferedimage: it is not an requirement, it is a source. I must make it (paint it, produce it) in my Thread and then display it on screen.
I make GLBuffers.newDirectByteBuffer(byte[]) and i take bytearray from BufImage. With that buffer a make Texture in this way: gl.glTexImage2D(..,..,.. buffer).
With an example in GL MediaPlayer Impl I have a chance to make an GLContex current in a thread and  make texture.
Reply | Threaded
Open this post in threaded view
|

Re: Best way to prepare an Image

Vasilij
Thank you, Sven.
Your tip with StreamWorker is works for me.

Danke vielmals!