SDL_Window *screen;
-void set_gamma(const Uint16 * gamma) {
+void set_gamma(float gamma) {
+#ifdef OLD_SDL1
SDL_SetWindowGammaRamp(screen,gamma, gamma, gamma);
+#endif
}
void quit()
#else
const char* icon_fname = "images/engine/icons/supertux.xpm";
#endif
- SDL_Window* icon;
+ SDL_Window* icon = 0;
try {
//icon = IMG_Load_RW(get_physfs_SDLRWops(icon_fname), true);
} catch (const std::runtime_error& err) {
- icon = 0;
log_warning << "Couldn't load icon '" << icon_fname << "': " << err.what() << std::endl;
}
if(icon != 0) {
update();
}
-/*
std::string
JoystickMenu::get_button_name(int button)
{
std::ostringstream name;
name << "Button " << button;
return name.str();
-}*/
+}
void
JoystickMenu::menu_action(MenuItem* item)
lightmap_uv_right(),
lightmap_uv_bottom()
{
+#ifdef OLD_SDL1
screen = SDL_GetVideoSurface();
+#endif
lightmap_width = SCREEN_WIDTH / LIGHTMAP_DIV;
lightmap_height = SCREEN_HEIGHT / LIGHTMAP_DIV;
// unfortunately only newer SDLs have these infos.
// This must be called before SDL_SetVideoMode() or it will return
// the window size instead of the desktop size.
+#ifdef OLD_SDL1
const SDL_VideoInfo *info = SDL_GetVideoInfo();
if (info)
{
- desktop_size = Size(info->current_w, info->current_h);
+ desktop_size = Size(info->current_w, info->current_h);
}
+#else
+ desktop_size = Size(1920, 1080);
+#endif
#endif
if(texture_manager != 0)
}
#endif
+#ifdef OLD_SDL1
SDL_GL_SetSwapInterval(SDL_GL_DOUBLEBUFFER, 1);
// FIXME: Hu? 16bit rendering?
SDL_GL_SetSwapInterval(5);
SDL_GL_SetSwapInterval(5);
SDL_GL_SetSwapInterval(5);
+#endif
if(g_config->use_fullscreen)
{
GLRenderer::flip()
{
assert_gl("drawing");
+#ifdef OLD_SDL1
SDL_GL_SwapWindow(screen)();
+#endif
}
void
GLRenderer::resize(int w, int h)
{
- // This causes the screen to go black, which is annoying, but seems
- // unavoidable with SDL at the moment
- SDL_CreateWindow(SDL_GL_CreateContext(w, h, 0, SDL_OPENGL | SDL_RESIZABLE));
+#ifdef OLD_SDL1
+ SDL_CreateWindow(SDL_GL_CreateContext(w, h, 0, SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE));
+#endif
g_config->window_size = Size(w, h);
SCREEN_HEIGHT = static_cast<int>(max_size.height);
}
+#ifdef OLD_SDL1
// Clear both buffers so that we get a clean black border without junk
glClear(GL_COLOR_BUFFER_BIT);
SDL_GL_SwapWindow(screen);
glClear(GL_COLOR_BUFFER_BIT);
SDL_GL_SwapWindow(screen);
+#endif
glViewport(std::max(0, (screen_size.width - new_size.width) / 2),
std::max(0, (screen_size.height - new_size.height) / 2),
// Only change video mode when its different from the current one
if (screen_size != size || fullscreen_active != fullscreen)
{
- int flags = SDL_OPENGL;
+ int flags = SDL_WINDOW_OPENGL;
if (fullscreen)
{
- flags |= SDL_FULLSCREEN;
+ flags |= SDL_WINDOW_FULLSCREEN;
}
else
{
- flags |= SDL_RESIZABLE;
+ flags |= SDL_WINDOW_RESIZABLE;
}
- if (SDL_Surface *screen = SDL_CreateWindow(SDL_GL_CreateContext( size.width, size.height, 0, flags)))
+#ifdef OLD_SDL1
+ if (SDL_Surface *screen = SDL_CreateWindow(size.width, size.height, 0, flags))
{
+ SDL_GL_CreateContext(screen);
screen_size = Size(screen->w, screen->h);
fullscreen_active = fullscreen;
}
msg << "Couldn't set video mode " << size.width << "x" << size.height << ": " << SDL_GetError();
throw std::runtime_error(msg.str());
}
+#endif
}
}
throw std::runtime_error("Couldn't create texture: out of memory");
}
- SDL_SetAlpha(image, 0, 0);
+ //SDL_SetAlpha(image, 0, 0);
SDL_BlitSurface(image, 0, convert, 0);
assert_gl("before creating texture");
dst_rect.y = (int) request.pos.y * numerator / denominator;
Uint8 alpha = 0;
+#ifdef OLD_SDL1
if(request.alpha != 1.0)
{
if(!transform->format->Amask)
transform = apply_alpha(transform, request.alpha);
}*/
}
+#endif
SDL_BlitSurface(transform, src_rect, screen, &dst_rect);
dst_rect.x = (int) request.pos.x * numerator / denominator;
dst_rect.y = (int) request.pos.y * numerator / denominator;
+#ifdef OLD_SDL1
Uint8 alpha = 0;
if(request.alpha != 1.0)
{
transform = apply_alpha(transform, request.alpha);
}*/
}
+#endif
SDL_BlitSurface(transform, &src_rect, screen, &dst_rect);
{
if(!transform->format->Amask)
{
+#ifdef OLD_SDL1
if(alpha == 255)
{
SDL_SetSurfaceAlphaMod(transform, 0);
{
SDL_SetSurfaceAlphaMod(transform, alpha);
}
+#endif
}
/*else
{
}
if(!src->format->Amask)
{
+#ifdef OLD_SDL1
if(src->flags & SDL_SRCALPHA)
{
SDL_SetAlpha(dst, SDL_SRCALPHA | SDL_RLEACCEL, src->format->alpha);
{
SDL_SetColorKey(dst, SDL_SRCCOLORKEY | SDL_RLEACCEL, src->format->colorkey);
}
+#endif
}
return dst;
}
}
if(!src->format->Amask)
{
+#ifdef OLD_SDL1
if(src->flags & SDL_SRCALPHA)
{
SDL_SetAlpha(dst, SDL_SRCALPHA | SDL_RLEACCEL, src->format->alpha);
{
SDL_SetColorKey(dst, SDL_SRCCOLORKEY | SDL_RLEACCEL, src->format->colorkey);
}
+#endif
}
return dst;
}
{
SDL_UnlockSurface(src);
}
+#ifdef OLD_SDL1
if(!src->format->Amask)
{
if(src->flags & SDL_SRCALPHA)
SDL_SetColorKey(dst, SDL_SRCCOLORKEY | SDL_RLEACCEL, src->format->colorkey);
}
}
+#endif
return dst;
}
mapped = *(Uint32 *)srcpixel;
break;
}
+#ifdef OLD_SDL1
if(src->format->Amask || !(src->flags & SDL_SRCCOLORKEY) || mapped != src->format->colorkey)
{
Uint8 r, g, b, a;
SDL_GetRGBA(mapped, src->format, &r, &g, &b, &a);
mapped = SDL_MapRGBA(dst->format, (r * red) >> 8, (g * green) >> 8, (b * blue) >> 8, a);
}
+#endif
switch(bpp) {
case 1:
*dstpixel = mapped;
}
if(!src->format->Amask)
{
+#ifdef OLD_SDL1
if(src->flags & SDL_SRCALPHA)
{
SDL_SetAlpha(dst, SDL_SRCALPHA | SDL_RLEACCEL, src->format->alpha);
{
SDL_SetColorKey(dst, SDL_SRCCOLORKEY | SDL_RLEACCEL, src->format->colorkey);
}
+#endif
}
return dst;
}
* "SDL_SetColorKey". */
SDL_Surface *optimize(SDL_Surface *src)
{
+#ifdef OLD_SDL1
bool have_transparent = false;
bool have_semi_trans = false;
bool have_opaque = false;
SDL_Surface *convert = SDL_DisplayFormat(dst);
SDL_FreeSurface(dst);
return convert;
+#else
+ return 0;
+#endif
} /* SDL_Surface *optimize */
} /* namespace */