Image processing the frame buffer under OpenGL

  • Follow


Does anyone know the fastest way to perform image processing
on the frame buffer under OpenGL. I tried inserting the following
code into my render code so it would execute every frame, but the
performance hit on the frame rate was unacceptable ( and that
was without doing any image processing ).

   glReadPixels(0,0,vp.w,vp.h,GL_RGBA,GL_FLOAT,img);
   glDrawPixels(0,0,GL_RGBA,GL_FLOAT,img);

Basically I want to be to write real-time video effects code,
which involves processing each pixel in the frame.

Would fragment shaders help?


Mark




0
Reply Mark 10/2/2004 11:15:53 AM

Mark wrote:
> Does anyone know the fastest way to perform image processing
> on the frame buffer under OpenGL. I tried inserting the following
> code into my render code so it would execute every frame, but the
> performance hit on the frame rate was unacceptable ( and that
> was without doing any image processing ).
> 
>    glReadPixels(0,0,vp.w,vp.h,GL_RGBA,GL_FLOAT,img);
>    glDrawPixels(0,0,GL_RGBA,GL_FLOAT,img);
> 

Slooooow!

> Basically I want to be to write real-time video effects code,
> which involves processing each pixel in the frame.
> 
> Would fragment shaders help?
> 

Yes.

Put your image into a texture then use fragment shaders
to do whatever you want to it.



-- 
<\___/>          For email, remove my socks.
/ O O \
\_____/  FTB.    The Cheat is not dead!


0
Reply fungus 10/2/2004 1:45:00 PM


"Mark" <mswinson@REMOVETHISBITbtinternet.com> wrote in message
news:cjm2l9$9hb$1@hercules.btinternet.com...
> Does anyone know the fastest way to perform image processing
> on the frame buffer under OpenGL. I tried inserting the following
> code into my render code so it would execute every frame, but the
> performance hit on the frame rate was unacceptable ( and that
> was without doing any image processing ).
>
>    glReadPixels(0,0,vp.w,vp.h,GL_RGBA,GL_FLOAT,img);
>    glDrawPixels(0,0,GL_RGBA,GL_FLOAT,img);

That's slow because you are reading back from the graphics card into the
main memory over the AGP bus, which has a slow upstream.
And use GL_UNSIGNED_BYTE so no conversion is needed for RGBA data.

> Basically I want to be to write real-time video effects code,
> which involves processing each pixel in the frame.
>
> Would fragment shaders help?

Yes, put the RGB in a texture and use that in your pixel shader.


0
Reply John 10/5/2004 6:35:13 AM

2 Replies
321 Views

(page loaded in 0.052 seconds)

Similiar Articles:













7/23/2012 4:32:41 PM


Reply: