any way to speed up drawing a masked pixmap?

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

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.