any way to speed up drawing a masked pixmap?

BlitzMax Forums/BlitzMax Beginners Area/any way to speed up drawing a masked pixmap?

koekjesbaby(Posted 2005) [#1]
somehow i get huge slowdowns if i draw a masked pixmap. if i just draw the pixmap in solidblend mode, my framerate stays very acceptable. pixmaps actually seem very slow in general, but since i can't grab a part of the screen, i have to use pixmaps...

any suggestions?

thanks!

(and if this has already been asked many times, i am sorry but the search function is disabled at the moment...)

ps. i miss buffers ;)


tonyg(Posted 2005) [#2]
What do you want to do with the pixmap?
You could convert it into an image...
image=loadimage(my_pixmap)
What is stopping you using grabimage/grabpixmap from the backbuffer?


koekjesbaby(Posted 2005) [#3]
i want to "damage" the pixmap (think scorched earth) and draw it over a background. i will try to convert it into an image but i can't imagine that it would make it any faster.

nothing is stopping me from using grabimage or grabpixmap, i am using grabpixmap. i can't understand why grabimage does not has a width and height argument.


Perturbatio(Posted 2005) [#4]
i can't understand why grabimage does not has a width and height argument.

because you create an image to be used with it before calling the command, so the image already has the dimensions set.


koekjesbaby(Posted 2005) [#5]
good point :)


Perturbatio(Posted 2005) [#6]
I thought so :)


tonyg(Posted 2005) [#7]
Images draw quicker than pixmaps.
If you don't change the image many times then it might be quicker to convert the pixmap to an image.
Depending on how you draw the damage you can either convert the image to a pixmap and use writepixel or draw the image, draw the damage, grab the damaged image into a newly created image or the original image.


ImaginaryHuman(Posted 2005) [#8]
For me images draw 10 times faster than pixmaps. I am sure it can be up to 50 times faster with the highest end graphics cards.

I presume you are making some kind of Scorched Earth type of game thing where you have some land that you want to deform in some way, removing parts when explosions happen and so on. And I presume you'll want to redraw the land each frame. What you could look into is setting up and using the openGL command glReadPixels(). It is slow, just like GrabPixmap and DrawPixmap are slow, but I believe you can get it to grab only a given rectangle from the screen and put it into a certain location in memory, ie in a pixmap, taking into account the overall pitch/width of the pixmap etc. You could draw an explosion on-screen and grab that area of the backbuffer into the relevant location on the pixmap.

If you want to get a bit more advanced you might think about setting up your own textures with direct OpenGL commands. That way you will get the reference handle to the texture. Then you can upload a PART of the pixmap to a PART of the existing texture/image, using glTexSubImage2D. It would probably be faster to just update the changed parts of the image/texture from a rectangle of the pixmap, rather than upload the entire pixmap (which is basically what DrawPixmap does). Then you could just DrawImage which will be faster overall. You could also use glCopyTexSubImage2D which grabs a rectangular portion of the backbuffer and puts it into an existing image/texture. I think it uses the CPU but it may be faster than saving it off to a pixmap and then re-uploading it.


klepto2(Posted 2005) [#9]
Do you mean something like this?

http://www.blitzbasic.com/Community/posts.php?topic=48169

If yes then you could test it and if the FPS results fulfil your needs I could post a small example abot how to do it.
The newer Version also supports already Background Images
and custom destroyable Terrain.