views:

452

answers:

1

Hello, 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.

+1  A: 

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.

Firas Assaad
Doesn't this only work for surfaces I've created?I'd like to be able to access the pixels of the entire screen, GUI toolkits and all.Is it possible with SDL to get that as a surface?
x10
No, I don't think you can do that in SDL. You'll need platform specific code. On windows you could get a handle to the desktop window with GetDesktopWindow() and then copy it to a bitmap for reading, but I'm not sure how you can directly write to the frame buffer.
Firas Assaad