Skip to content

Commit

Permalink
Implemented set_gamma()
Browse files Browse the repository at this point in the history
  • Loading branch information
Grumbel committed Jul 30, 2014
1 parent 68b566c commit 26b5a52
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/scripting/functions.cpp
Expand Up @@ -32,6 +32,7 @@
#include "supertux/tile.hpp"
#include "supertux/world.hpp"
#include "util/gettext.hpp"
#include "video/renderer.hpp"
#include "worldmap/tux.hpp"

#include "scripting/squirrel_util.hpp"
Expand Down Expand Up @@ -271,10 +272,9 @@ 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*/) {
#ifdef OLD_SDL1
SDL_SetWindowGammaRamp(screen,gamma, gamma, gamma);
#endif
void set_gamma(float gamma)
{
Renderer::instance()->set_gamma(gamma);
}

void quit()
Expand Down
8 changes: 8 additions & 0 deletions src/video/gl/gl_renderer.cpp
Expand Up @@ -640,4 +640,12 @@ GLRenderer::apply_video_mode(const Size& size, bool fullscreen)
}
}

void
GLRenderer::set_gamma(float gamma)
{
Uint16 ramp[256];
SDL_CalculateGammaRamp(gamma, ramp);
SDL_SetWindowGammaRamp(window, ramp, ramp, ramp);
}

/* EOF */
1 change: 1 addition & 0 deletions src/video/gl/gl_renderer.hpp
Expand Up @@ -129,6 +129,7 @@ class GLRenderer : public Renderer
void resize(int w, int h);
void apply_config();
void apply_video_mode(const Size& size, bool fullscreen);
void set_gamma(float gamma);
};

#endif
Expand Down
1 change: 1 addition & 0 deletions src/video/renderer.hpp
Expand Up @@ -52,6 +52,7 @@ class Renderer
virtual void flip() = 0;
virtual void resize(int w, int h) = 0;
virtual void apply_config() = 0;
virtual void set_gamma(float gamma) = 0;

static Renderer* instance() { assert(instance_); return instance_; }

Expand Down
8 changes: 8 additions & 0 deletions src/video/sdl/sdl_renderer.cpp
Expand Up @@ -414,4 +414,12 @@ SDLRenderer::resize(int, int)

}

void
SDLRenderer::set_gamma(float gamma)
{
Uint16 ramp[256];
SDL_CalculateGammaRamp(gamma, ramp);
SDL_SetWindowGammaRamp(window, ramp, ramp, ramp);
}

/* EOF */
1 change: 1 addition & 0 deletions src/video/sdl/sdl_renderer.hpp
Expand Up @@ -35,6 +35,7 @@ class SDLRenderer : public Renderer
void flip();
void resize(int w, int h);
void apply_config() {}
void set_gamma(float gamma);

SDL_Renderer* get_sdl_renderer() const { return renderer; };

Expand Down

0 comments on commit 26b5a52

Please sign in to comment.