Page 1 of 1

[SOLVED]How to get pixel values of the screen

PostPosted: 29 Oct 2015, 05:35
by verilogdc
Hi,

I'm implementing a feature which requires to get the pixel values of the screen when a user push a buttom in racing, for each time step.
There might be a piece of code like that:
{l Code}: {l Select All Code}
for each time step
{
    if (keyboradInput[0] == "<-") {
        driveLeft();
    }
    if (keyboradInput[0] == "<-" && keyboradInput[1]=="^") {
        driveLeft();
        accelerate();
    }
    ...
}


Then I can add a line:
{l Code}: {l Select All Code}
for each time step
{
    if (keyboradInput[0] == "<-") {
        driveLeft();
    }
    if (keyboradInput[0] == "<-" && keyboradInput[1]=="^") {
        [R G B] = screenShot();
        driveLeft();
        accelerate();
    }
    ...
}


So, my questions are
1. Where is the code like the above, reading inputs and driving the kart?
2. Is there a API like screenShot, to get the pixel values of the current frame?

Re: How to get pixel values of the screen for each time step

PostPosted: 30 Oct 2015, 23:35
by samuncle
Hum

could you clarify why do you need the pixel value for each frame ? It can quickly slow down the game :3. Depending on what you want to achieve there might be an issue.

Re: How to get pixel values of the screen for each time step

PostPosted: 31 Oct 2015, 22:10
by konstin
This might sound very harsh, but to write code in a project as big as STK you need to learn to find things on your own. I admit that this is sometimes difficult because there are many different coding styles and few documentation, but simple trying out some possibilities normally yields the right solution.

Re 1: Mainly in rc/input/input_manager.cpp
Re 2: Searching for "screenshot" points to the src/graphics/irr_driver.cpp line 2068. I don't know what exactly you're doing (which you should include in a question) but you'll propably need to do OpenGL calls to get a reasonable performance.