From d1ee195260c3676eb822a0025167ea8a785ccfa5 Mon Sep 17 00:00:00 2001 From: Thomas Szepe Date: Sun, 11 Oct 2015 13:41:38 +0200 Subject: 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 --- source/gameengine/Ketsji/KX_GameActuator.cpp | 12 ++++++++++++ source/gameengine/Ketsji/KX_GameActuator.h | 1 + source/gameengine/Ketsji/KX_PythonInit.cpp | 1 + 3 files changed, 14 insertions(+) (limited to 'source/gameengine/Ketsji') 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 #include @@ -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); -- cgit v1.2.3