[SOLVED]How to get pixel values of the screen

[SOLVED]How to get pixel values of the screen

Postby verilogdc » 29 Oct 2015, 05:35

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?
Last edited by verilogdc on 01 Nov 2015, 02:06, edited 1 time in total.
verilogdc
 
Posts: 9
Joined: 22 Oct 2015, 16:39

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

Postby samuncle » 30 Oct 2015, 23:35

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.
Image
User avatar
samuncle
STK Moderator
 
Posts: 752
Joined: 16 Mar 2010, 21:28

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

Postby konstin » 31 Oct 2015, 22:10

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.
konstin
 
Posts: 37
Joined: 31 May 2014, 20:54

Who is online

Users browsing this forum: No registered users and 1 guest