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

Started by
6 comments, last by pango99 20 years, 9 months ago
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?
fsdf
Advertisement
May be Vertex/Pixel Shaders?

"C lets you shoot yourself in the foot rather easily. C++ allows you to reuse the bullet!"
Member of the Shove Pouya Off A Cliff club, SPOAC. (If you wish to join, add this line to your signature.)Member of "Un-Ban nes8bit" association, UNA (to join put this in your sig)"C lets you shoot yourself in the foot rather easily. C++ allows you to reuse the bullet!"
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.
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?
fsdf
The implementation will depend largely on the effect required.

______________________________________________________________
The Phoenix shall arise from the ashes... ThunderHawk -- ¦þ
MySite
______________________________________________________________
______________________________________________________________________________________The Phoenix shall arise from the ashes... ThunderHawk -- ¦þ"So. Any n00bs need some pointers? I have a std::vector<n00b*> right here..." - ZahlmanMySite | Forum FAQ | File Formats______________________________________________________________________________________
I just want to know how to implement the custom matrix calculation in GPU?
fsdf
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.

f@dzhttp://festini.device-zero.de
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..

This topic is closed to new replies.

Advertisement