Search code examples
video-capture

Direct screen pixel/framebuffer access


I'd like to try and create a program playing a game. I.e. "a bot".

I want to be able to directly access the pixels on the screen. I.e. have my program "see" a game and then "make a move"(or at least draw a picture of what move it would make).

Both Windows and Linux advice is appreciated, though my guess is that it should be easier to do on Linux.

I'm guessing this could be done with some X/Gnome call?
I'm not afraid of C, even complex samples are welcome.


Solution

  • SDL is a cross-platform library that allows you to directly access framebuffer pixels. You can learn about accessing the pixels on screen through the pixel access example on the documentation wiki.

    Generally speaking, bots don't see the game graphics but see the underlying data structure instead, unless you are trying to do something related to computer vision.