diff options
author | Thomas Szepe <HG1_public@gmx.net> | 2015-10-11 14:41:38 +0300 |
---|---|---|
committer | Thomas Szepe <HG1_public@gmx.net> | 2015-10-11 14:41:38 +0300 |
commit | d1ee195260c3676eb822a0025167ea8a785ccfa5 (patch) | |
tree | ff802b3305d64fa02dd85f2f0bca51c2522703f5 /source/gameengine | |
parent | 3748bbf2d9e4dfa611e6a94b5497a0a7a376211d (diff) |
BGE: Adding a screenshot function to game actuator
Extending the existing game actuator with a screenshot function, to give also non programmers the ability to take screenshots in the BGE.
Reviewers: lordloki, campbellbarton, moguri
Reviewed By: lordloki, moguri
Subscribers: lordloki, Genome36
Projects: #game_engine
Differential Revision: https://developer.blender.org/D651
Diffstat (limited to 'source/gameengine')
-rw-r--r-- | source/gameengine/Converter/KX_ConvertActuators.cpp | 6 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_GameActuator.cpp | 12 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_GameActuator.h | 1 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_PythonInit.cpp | 1 |
4 files changed, 20 insertions, 0 deletions
diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index 3b36e094a75..c6c36c26728 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -806,6 +806,12 @@ void BL_ConvertActuators(const char* maggiename, mode = KX_GameActuator::KX_GAME_LOADCFG; break; } + case ACT_GAME_SCREENSHOT: + { + mode = KX_GameActuator::KX_GAME_SCREENSHOT; + filename = gameact->filename; + break; + } default: ; /* flag error */ } diff --git a/source/gameengine/Ketsji/KX_GameActuator.cpp b/source/gameengine/Ketsji/KX_GameActuator.cpp index a23af680104..f1bd253f8b3 100644 --- a/source/gameengine/Ketsji/KX_GameActuator.cpp +++ b/source/gameengine/Ketsji/KX_GameActuator.cpp @@ -41,6 +41,7 @@ #include "KX_Scene.h" #include "KX_KetsjiEngine.h" #include "KX_PythonInit.h" /* for config load/saving */ +#include "RAS_ICanvas.h" #include <stdio.h> #include <stdlib.h> @@ -204,6 +205,17 @@ bool KX_GameActuator::Update() break; #endif // WITH_PYTHON } + case KX_GAME_SCREENSHOT: + { + RAS_ICanvas *canvas = m_ketsjiengine->GetCanvas(); + if (canvas) { + canvas->MakeScreenShot(m_filename); + } + else { + printf("KX_GAME_SCREENSHOT error: Rasterizer not available"); + } + break; + } default: ; /* do nothing? this is an internal error !!! */ } diff --git a/source/gameengine/Ketsji/KX_GameActuator.h b/source/gameengine/Ketsji/KX_GameActuator.h index 0c1c4f0c277..57472836bb2 100644 --- a/source/gameengine/Ketsji/KX_GameActuator.h +++ b/source/gameengine/Ketsji/KX_GameActuator.h @@ -59,6 +59,7 @@ protected: KX_GAME_QUIT, KX_GAME_SAVECFG, KX_GAME_LOADCFG, + KX_GAME_SCREENSHOT, KX_GAME_MAX }; diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 2fef74ca33d..48d8be55120 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -1804,6 +1804,7 @@ PyMODINIT_FUNC initGameLogicPythonBinding() KX_MACRO_addTypesToDict(d, KX_GAME_QUIT, KX_GameActuator::KX_GAME_QUIT); KX_MACRO_addTypesToDict(d, KX_GAME_SAVECFG, KX_GameActuator::KX_GAME_SAVECFG); KX_MACRO_addTypesToDict(d, KX_GAME_LOADCFG, KX_GameActuator::KX_GAME_LOADCFG); + KX_MACRO_addTypesToDict(d, KX_GAME_SCREENSHOT, KX_GameActuator::KX_GAME_SCREENSHOT); /* Scene Actuator Modes */ KX_MACRO_addTypesToDict(d, KX_SCENE_RESTART, KX_SceneActuator::KX_SCENE_RESTART); |