Faster Grabimage Substitute?

BlitzMax Forums/BlitzMax Programming/Faster Grabimage Substitute?

AvestheFox(Posted 2012) [#1]
Is there a much more faster grabimage kind of substitute floating around out there in some random module that I don't know about?

I need to grab the play-field screen during a loop, but as we all know, grabimage, during a loop, runs rather.... slow... :P


Space_guy(Posted 2012) [#2]
Search for FBO in the forum. Its not perfect but it works quite well.


SLotman(Posted 2012) [#3]
Not much to be done about it. Video cards nowadays are optimized to write data to, not to read from.

The best approach would be using shaders, but still, it won't be so fast due to the hardware nature.


col(Posted 2012) [#4]
Hiya

In the sense of just 'grabbing the screen'...

I'm not sure how far your knowledge goes into OpenGL, but rendering can be 'redirected' to a texture to give you instant screen grab into a texture.
There's an example here which may/may not be what you need?

If you search forums for 'render to texture' it will gives you some 'useful' links.


AdamRedwoods(Posted 2012) [#5]
+1 FBOs.

the link from Col has what you need. you don't really need a shader with FBO's but keep in mind for FBO's alone you'll need at least opengl 1.5 and above.


AntonyWells(Posted 2012) [#6]
Max's built in grabimage, goes through a variety of software processing first.

Best bet is to stick to opengl drivers, then use glCopyImage etc using the raw texture handle. speed ups will be immense on gpu.

Let me know if you want a code sample.


AvestheFox(Posted 2012) [#7]
oh wow, I've left this thread for a day not expecting many replies.

Anyway... I figured out a better way of doing what I wanted to do. But still, thanks for all the suggestions and help! I'll check out everything just to see if I could use it for a future project or something :)

@AntonyWells: You could send me a sample code if you'd like to. It may come in handy.


AntonyWells(Posted 2012) [#8]
No prob, just installing OpenSuse&Blitz again atm, but in a few hours I'll post something for you. Maybe tomorrow morning.

It's fairly easy.

basically, just use glCopyImage2D rather than glTexImage2D


If you are only used to blitz code however, it will be confusing, so i'll write you a class and add it to code archives. Will find it useful myself anyway.


AntonyWells(Posted 2012) [#9]
Oh but yeah fbo is the way to go if you want to do things quickly as possible. they're fairly easy to use, and they let you render directly to a texture or depth map or even a cube map.


Again, you need to use gl max.

SetGraphicsDriver GlMax2DDriver()
Graphics 800,600
glewInit()


is a good start to the app. glewInit enables all opengl extensions in one go.


in other simple terms, do not use directx, or at the least, code it for both.


AntonyWells(Posted 2012) [#10]
Any thoughts GFK? For those not in the know GFK is our resident GOD. Ask unto him and ye shall receive.