Archived

This topic is now archived and is closed to further replies.

pango99

OpenGL Is it possible to using OpenGL to produce 2D image FX?

Recommended Posts

I plan to write my 2D image FX(such as "Erode","Noise","Blur",...) program using OpenGL just for saving CPU usage,but I am not sure whether OpenGL can implement it,and I am still finding some documents about using OpenGL to deal 2D processing.My idea is viable?Is there any 2D image FX code using OpenGL?

Share this post


Link to post
Share on other sites
I would say it is very possible. Just fire up Opengl and put it into Ortho mode (2d mode) and u can do all kinds of cool 2d stuff. Nehe has an article on ortho mode so u might want to check that out if ur not familiar with it. As for Image FX there are no real Opengl functions for doing them , I think they are done using mathematical operations to each pixel in the buffer where u are storing the image. So really image fx would be done in memory and u would just use Opengl to display it.

Share this post


Link to post
Share on other sites
I know many algorithms of 2D image FX is some matrix,and the GPU is faster than CPU to do matrix stull,so I want to can I transplant the calcualtion of FX to GPU and the way to implement it?

Share this post


Link to post
Share on other sites
The implementation will depend largely on the effect required.

______________________________________________________________
The Phoenix shall arise from the ashes... ThunderHawk -- ¦þ
MySite
______________________________________________________________

Share this post


Link to post
Share on other sites
quote:
Original post by santonel
I would say it is very possible. Just fire up Opengl and put it into Ortho mode (2d mode)


orthogonal projection is NOT 2d. there are still three axes and the way the scene is projected changes nothing about the fact that it is still 3d. just without perspective and therefore a lot easier to get from world coords to screen coords.

Share this post


Link to post
Share on other sites
quote:
Original post by pango99
I just want to know how to implement the custom matrix calculation in GPU?


I suppose you want to do a two-dimensional convolution when you say that. That would let you do effects such as blur and other filters.

do like this:
for every pixel in the filter-core, draw the image shifted by the position in the core, and multiply the intensity of the image with the current value in the filter. Divide this with the sum of the filter-core.

You will probably need a dx9-card to get enough precision. My explanation probably sucks as well but if you understand how regular convolution works you shouldn''t have any major problems implementing it on GL. It could be quite messy if you''re new to OpenGL and programming in general though..

Share this post


Link to post
Share on other sites