GLBasic forum

Main forum => GLBasic - en => Topic started by: yaKC on 2018-May-16

Title: Faster alternatve to GetPixel
Post by: yaKC on 2018-May-16

I've been working on a game for a few years using GetPixel, however I'm stuck at around 60 checks max per frame as it's really slow, I read that it transfers the framebuffer everytime you use it. Is there anyway to use Lockbits, or Getpixels (multiple) so that i only need to transfer once? Or perhaps a way using OpenGL?I can use a 1 pixel sprite collsion as analternative with an image but this game really needs live info from the screen. not the whole screen just around a 32x32 area around the player.Thanks in advance if anyone has a solution :D

It all depends on your game, for what and how you are using this. But as Bigsofty mentioned you can use GrabSprite (don't know how fast it would be), Mem2Sprite and of course OpenGL either in GLB or inline C++. Don't remember now if any one made fast sprite2mem but as you can see in this topic about Mem2Sprite (https://www.glbasic.com/forum/index.php?topic=11107.0) using OpenGL can give you much better results. You can combine this with some other tricks - draw player and part of background to offscreen sprite then use Mem2Sprite and so on...