From: Ryan Flegel Date: Mon, 16 Jun 2008 03:07:34 +0000 (+0000) Subject: Adjust gamma with set_gamma(float) scripting function. Must be fullscreen. X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=2d883ab3cc0a93f2162e2390dae2637f2e83c906;p=supertux.git Adjust gamma with set_gamma(float) scripting function. Must be fullscreen. SVN-Revision: 5575 --- diff --git a/src/scripting/functions.cpp b/src/scripting/functions.cpp index 4840ac986..95d860761 100644 --- a/src/scripting/functions.cpp +++ b/src/scripting/functions.cpp @@ -277,6 +277,10 @@ void camera() log_info << "Camera is at " << Sector::current()->camera->get_translation().x << "," << Sector::current()->camera->get_translation().y << std::endl; } +void set_gamma(float gamma) { + SDL_SetGamma(gamma, gamma, gamma); +} + void quit() { main_loop->quit(); diff --git a/src/scripting/functions.hpp b/src/scripting/functions.hpp index 34e5df964..b535c7303 100644 --- a/src/scripting/functions.hpp +++ b/src/scripting/functions.hpp @@ -186,6 +186,11 @@ void gotoend(); void camera(); /** + * adjust gamma + */ +void set_gamma(float gamma); + +/** * exit the game */ void quit(); diff --git a/src/scripting/wrapper.cpp b/src/scripting/wrapper.cpp index d3c8cf1af..f50fa6c00 100644 --- a/src/scripting/wrapper.cpp +++ b/src/scripting/wrapper.cpp @@ -3740,6 +3740,29 @@ static SQInteger camera_wrapper(HSQUIRRELVM vm) } +static SQInteger set_gamma_wrapper(HSQUIRRELVM vm) +{ + SQFloat arg0; + if(SQ_FAILED(sq_getfloat(vm, 2, &arg0))) { + sq_throwerror(vm, _SC("Argument 1 not a float")); + return SQ_ERROR; + } + + try { + Scripting::set_gamma(static_cast (arg0)); + + return 0; + + } catch(std::exception& e) { + sq_throwerror(vm, e.what()); + return SQ_ERROR; + } catch(...) { + sq_throwerror(vm, _SC("Unexpected exception while executing function 'set_gamma'")); + return SQ_ERROR; + } + +} + static SQInteger quit_wrapper(HSQUIRRELVM vm) { (void) vm; @@ -4433,6 +4456,12 @@ void register_supertux_wrapper(HSQUIRRELVM v) throw SquirrelError(v, "Couldn't register function 'camera'"); } + sq_pushstring(v, "set_gamma", -1); + sq_newclosure(v, &set_gamma_wrapper, 0); + if(SQ_FAILED(sq_createslot(v, -3))) { + throw SquirrelError(v, "Couldn't register function 'set_gamma'"); + } + sq_pushstring(v, "quit", -1); sq_newclosure(v, &quit_wrapper, 0); if(SQ_FAILED(sq_createslot(v, -3))) {