[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] [pingus] 2 new revisions pushed by address@hidden on 2014-0
From: |
pingus |
Subject: |
[Pingus-CVS] [pingus] 2 new revisions pushed by address@hidden on 2014-07-26 19:58 GMT |
Date: |
Sat, 26 Jul 2014 19:58:44 +0000 |
feature/sdl2 created at c886ffa4557d
2 new revisions:
Revision: 88bb389c58b0
Author: Ingo Ruhnke <address@hidden>
Date: Sat Jul 26 18:07:52 2014 UTC
Log: Updated SConscript to SDL2
http://code.google.com/p/pingus/source/detail?r=88bb389c58b0
Revision: c886ffa4557d
Author: Ingo Ruhnke <address@hidden>
Date: Sat Jul 26 19:58:06 2014 UTC
Log: Started porting to SDL2, non working code is marked with '#ifdef
OLD_S...
http://code.google.com/p/pingus/source/detail?r=c886ffa4557d
==============================================================================
Revision: 88bb389c58b0
Author: Ingo Ruhnke <address@hidden>
Date: Sat Jul 26 18:07:52 2014 UTC
Log: Updated SConscript to SDL2
http://code.google.com/p/pingus/source/detail?r=88bb389c58b0
Modified:
/SConscript
=======================================
--- /SConscript Sat Jul 26 18:49:11 2014 UTC
+++ /SConscript Sat Jul 26 18:07:52 2014 UTC
@@ -23,26 +23,6 @@
Import('package_version')
-def CheckSDLLib(context, sdllib):
- """
- On some platforms, SDL does this ugly redefine-main thing, that can
- interact badly with CheckLibWithHeader.
- """
- lib = "SDL_%s" % sdllib
- context.Message('Checking for %s...' % lib)
- text = """
-#include "SDL.h"
-#include "%s.h"
-int main(int argc, char* argv[]) { return 0; }
-""" % lib
- context.AppendLIBS(lib)
- if context.BuildProg(text, ".cpp"):
- context.Result("failed")
- return False
- else:
- context.Result("ok")
- return True
-
def CheckIconv(context):
context.Message('Check how to call iconv...')
text = """
@@ -119,7 +99,6 @@
self.conf = self.env.Configure(custom_tests = {
'CheckMyProgram' : CheckMyProgram,
- 'CheckSDLLib': CheckSDLLib,
'CheckIconv': CheckIconv,
})
self.fatal_error = ""
@@ -200,13 +179,11 @@
self.fatal_error += " * library 'png' not found\n"
def configure_sdl(self):
- if self.conf.CheckMyProgram('sdl-config'):
- self.conf.env.ParseConfig("sdl-config --cflags --libs |
sed 's/-I/-isystem/g'")
- for sdllib in ['image', 'mixer']:
- if not self.conf.CheckSDLLib(sdllib):
- self.fatal_error += " * SDL library '%s' not
found\n" % sdllib
+ if self.conf.CheckMyProgram('pkg-config'):
+ self.conf.env.ParseConfig("pkg-config --cflags --libs sdl2
SDL2_image SDL2_mixer | sed 's/-I/-isystem/g'")
else:
if sys.platform == 'darwin':
+ # FIXME: This is old SDL1 code
# self.conf.env.StaticLibrary("sdlmain",
["src/macosx/SDLmain.m"], [ 'SDL' ])
self.conf.env.Append(optional_sources =
[ "src/macosx/SDLmain.m" ])
self.conf.env.Append(LINKFLAGS = [ '-framework', 'SDL',
==============================================================================
Revision: c886ffa4557d
Author: Ingo Ruhnke <address@hidden>
Date: Sat Jul 26 19:58:06 2014 UTC
Log: Started porting to SDL2, non working code is marked with '#ifdef
OLD_SDL1'
http://code.google.com/p/pingus/source/detail?r=c886ffa4557d
Modified:
/src/editor/inputbox.cpp
/src/editor/viewport.cpp
/src/engine/display/blitter.cpp
/src/engine/display/display.cpp
/src/engine/display/opengl/opengl_framebuffer.cpp
/src/engine/display/opengl/opengl_framebuffer.hpp
/src/engine/display/opengl/opengl_framebuffer_surface_impl.cpp
/src/engine/display/screenshot.cpp
/src/engine/display/sdl_framebuffer.cpp
/src/engine/display/sdl_framebuffer.hpp
/src/engine/display/sdl_framebuffer_surface_impl.cpp
/src/engine/display/surface.cpp
/src/engine/input/event.hpp
/src/engine/input/sdl_driver.cpp
/src/engine/input/sdl_driver.hpp
/src/engine/system/sdl_system.cpp
/src/pingus/collision_mask.cpp
/src/pingus/components/playfield.cpp
/src/pingus/config_manager.cpp
/src/pingus/global_event.cpp
/src/pingus/ground_map.cpp
=======================================
--- /src/editor/inputbox.cpp Mon Sep 12 20:59:47 2011 UTC
+++ /src/editor/inputbox.cpp Sat Jul 26 19:58:06 2014 UTC
@@ -73,11 +73,13 @@
}
else
{
+#ifdef OLD_SDL1
if (ev.keysym.unicode)
{
text += UTF8::encode_utf8(ev.keysym.unicode);
on_change(text);
}
+#endif
}
}
=======================================
--- /src/editor/viewport.cpp Wed Sep 28 00:39:07 2011 UTC
+++ /src/editor/viewport.cpp Sat Jul 26 19:58:06 2014 UTC
@@ -112,7 +112,7 @@
void
Viewport::on_primary_button_press(int x_, int y_)
{
- Uint8* keystate = SDL_GetKeyState(NULL);
+ const Uint8* keystate = SDL_GetKeyboardState(nullptr);
mouse_world_pos = screen2world(x_, y_);
mouse_screen_pos = Vector2i(x_, y_);
@@ -478,9 +478,11 @@
break;
default:
+#ifdef OLD_SDL1
log_debug("Viewport::on_key_pressed: " << ev.keysym.sym
<< " U+" << (boost::format("%04x") % ev.keysym.unicode)
<< " " << UTF8::encode_utf8(ev.keysym.unicode));
+#endif
break;
}
}
=======================================
--- /src/engine/display/blitter.cpp Sat Sep 10 15:01:46 2011 UTC
+++ /src/engine/display/blitter.cpp Sat Jul 26 19:58:06 2014 UTC
@@ -33,11 +33,13 @@
bpp = surface->format->BytesPerPixel;
if (bpp == 1) {
SDL_Color pal[256];
+#ifdef OLD_SDL1
Uint32 ckey;
- int useckey;
+ int useckey = 0;
useckey = surface->flags & SDL_SRCCOLORKEY;
- new_surface = SDL_CreateRGBSurface(SDL_SWSURFACE | (useckey ?
SDL_SRCCOLORKEY : 0), width, height, 8, 0, 0, 0, 0);
+#endif
+ new_surface = SDL_CreateRGBSurface(0, width, height, 8, 0, 0, 0, 0);
SDL_LockSurface(surface);
SDL_LockSurface(new_surface);
@@ -47,7 +49,9 @@
new_pitch = new_surface->pitch;
memcpy(pal, surface->format->palette->colors, sizeof(SDL_Color) * 256);
+#ifdef OLD_SDL1
ckey = surface->format->colorkey;
+#endif
for (i = 0; i < height; ++i) {
x = i * new_pitch;
@@ -60,10 +64,12 @@
SDL_UnlockSurface(surface);
SDL_UnlockSurface(new_surface);
+#ifdef OLD_SDL1
SDL_SetPalette(new_surface, SDL_LOGPAL | SDL_PHYSPAL, pal, 0, 256);
if (useckey) {
SDL_SetColorKey(new_surface, SDL_SRCCOLORKEY | SDL_RLEACCEL, ckey);
}
+#endif
} else {
int ix, iy;
float fx, fy, fz;
@@ -181,7 +187,7 @@
SDL_Surface*
Blitter::create_surface_rgba(int w, int h)
{
- return SDL_CreateRGBSurface(SDL_SWSURFACE | SDL_SRCALPHA, w, h, 32,
+ return SDL_CreateRGBSurface(0, w, h, 32,
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
0xff000000, 0x00ff0000, 0x0000ff00,
0x000000ff
#else
@@ -193,7 +199,7 @@
SDL_Surface*
Blitter::create_surface_rgb(int w, int h)
{
- return SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 24,
+ return SDL_CreateRGBSurface(0, w, h, 24,
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
0xff000000, 0x00ff0000, 0x0000ff00,
0x00000000
#else
@@ -205,26 +211,14 @@
SDL_Surface*
Blitter::create_surface_from_format(SDL_Surface* surface, int w, int h)
{
- Uint32 flags = 0;
- if (surface->flags & SDL_SWSURFACE)
- flags |= SDL_SWSURFACE;
-
- if (surface->flags & SDL_HWSURFACE)
- flags |= SDL_HWSURFACE;
-
- if (surface->flags & SDL_SRCCOLORKEY)
- flags |= SDL_SRCCOLORKEY;
-
- if (surface->flags & SDL_SRCALPHA)
- flags |= SDL_SRCALPHA;
-
- SDL_Surface* new_surface = SDL_CreateRGBSurface(flags, w, h,
+ SDL_Surface* new_surface = SDL_CreateRGBSurface(0, w, h,
surface->format->BitsPerPixel,
surface->format->Rmask,
surface->format->Gmask,
surface->format->Bmask,
surface->format->Amask);
+#ifdef OLD_SDL1
if (surface->flags & SDL_SRCALPHA)
SDL_SetAlpha(new_surface, SDL_SRCALPHA, surface->format->alpha);
@@ -234,6 +228,7 @@
if (surface->flags & SDL_SRCCOLORKEY)
SDL_SetColorKey(new_surface, SDL_SRCCOLORKEY,
surface->format->colorkey);
+#endif
return new_surface;
}
=======================================
--- /src/engine/display/display.cpp Mon Nov 28 13:44:37 2011 UTC
+++ /src/engine/display/display.cpp Sat Jul 26 19:58:06 2014 UTC
@@ -153,7 +153,8 @@
Size
Display::find_closest_fullscreen_video_mode(const Size& size)
{
- SDL_Rect** modes = SDL_ListModes(NULL, SDL_FULLSCREEN);
+#ifdef OLD_SDL1
+ SDL_Rect** modes = SDL_ListModes(NULL, SDL_WINDOW_FULLSCREEN);
if (modes == static_cast<SDL_Rect**>(0))
{ // No resolutions at all available, bad
@@ -186,7 +187,9 @@
return best_fit;
}
-
+#else
+ return Size(800, 600);
+#endif
}
struct SortBySize
@@ -200,6 +203,7 @@
std::vector<Size>
Display::get_fullscreen_video_modes()
{
+#ifdef OLD_SDL1
std::vector<Size> video_modes;
SDL_Rect** modes = SDL_ListModes(NULL, SDL_FULLSCREEN);
@@ -238,6 +242,9 @@
std::sort(video_modes.begin(), video_modes.end(), SortBySize());
return video_modes;
+#else
+ return std::vector<Size>{{800, 600}};
+#endif
}
/* EOF */
=======================================
--- /src/engine/display/opengl/opengl_framebuffer.cpp Fri Oct 14 02:34:13
2011 UTC
+++ /src/engine/display/opengl/opengl_framebuffer.cpp Sat Jul 26 19:58:06
2014 UTC
@@ -16,16 +16,22 @@
#include "engine/display/opengl/opengl_framebuffer.hpp"
+#include <SDL.h>
#include <sstream>
#include <stdexcept>
#include "engine/display/opengl/opengl_framebuffer_surface_impl.hpp"
OpenGLFramebuffer::OpenGLFramebuffer() :
- screen(),
+ m_window(),
cliprect_stack()
{
}
+
+OpenGLFramebuffer::~OpenGLFramebuffer()
+{
+ SDL_DestroyWindow(m_window);
+}
FramebufferSurface
OpenGLFramebuffer::create_surface(const Surface& surface)
@@ -36,25 +42,25 @@
void
OpenGLFramebuffer::set_video_mode(const Size& size, bool fullscreen, bool
resizable)
{
- int flags = SDL_OPENGL;
+ int flags = SDL_WINDOW_OPENGL;
if (fullscreen)
{
- flags |= SDL_FULLSCREEN;
+ flags |= SDL_WINDOW_FULLSCREEN;
}
else if (resizable)
{
- flags |= SDL_RESIZABLE;
+ flags |= SDL_WINDOW_RESIZABLE;
}
- int bpp = 0; // auto-detect
- screen = SDL_SetVideoMode(size.width, size.height, bpp, flags);
-
- if(screen == 0)
+ m_window = SDL_CreateWindow("Pingus",
+ SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
+ size.width, size.height,
+ flags);
+ if(m_window == 0)
{
std::ostringstream msg;
- msg << "Couldn't set video mode (" << size.width << "x" << size.height
- << "-" << bpp << "bpp): " << SDL_GetError();
+ msg << "Couldn't set video mode (" << size.width << "x" << size.height
<< "): " << SDL_GetError();
throw std::runtime_error(msg.str());
}
@@ -82,19 +88,19 @@
bool
OpenGLFramebuffer::is_fullscreen() const
{
- return screen->flags & SDL_FULLSCREEN;
+ return SDL_GetWindowFlags(m_window) & SDL_WINDOW_FULLSCREEN;
}
bool
OpenGLFramebuffer::is_resizable() const
{
- return screen->flags & SDL_RESIZABLE;
+ return SDL_GetWindowFlags(m_window) & SDL_WINDOW_RESIZABLE;
}
void
OpenGLFramebuffer::flip()
{
- SDL_GL_SwapBuffers();
+ SDL_GL_SwapWindow(m_window);
}
void
@@ -116,7 +122,7 @@
}
glScissor(cliprect_stack.back().left,
- screen->h - cliprect_stack.back().bottom,
+ get_size().height - cliprect_stack.back().bottom,
cliprect_stack.back().get_width(),
cliprect_stack.back().get_height());
}
@@ -247,7 +253,9 @@
Size
OpenGLFramebuffer::get_size() const
{
- return Size(screen->w, screen->h);
+ Size s;
+ SDL_GetWindowSize(m_window, &s.width, &s.height);
+ return s;
}
/* EOF */
=======================================
--- /src/engine/display/opengl/opengl_framebuffer.hpp Fri Oct 14 02:03:23
2011 UTC
+++ /src/engine/display/opengl/opengl_framebuffer.hpp Sat Jul 26 19:58:06
2014 UTC
@@ -22,11 +22,12 @@
class OpenGLFramebuffer : public Framebuffer
{
private:
- SDL_Surface* screen;
+ SDL_Window* m_window;
std::vector<Rect> cliprect_stack;
public:
OpenGLFramebuffer();
+ ~OpenGLFramebuffer();
FramebufferSurface create_surface(const Surface& surface);
=======================================
--- /src/engine/display/opengl/opengl_framebuffer_surface_impl.cpp Tue Oct
11 19:03:30 2011 UTC
+++ /src/engine/display/opengl/opengl_framebuffer_surface_impl.cpp Sat Jul
26 19:58:06 2014 UTC
@@ -50,7 +50,9 @@
m_texture_size.width,
m_texture_size.height, 32,
0x000000ff, 0x0000ff00,
0x00ff0000, 0xff000000);
#endif
+#ifdef OLD_SDL1
SDL_SetAlpha(src, 0, 0);
+#endif
SDL_BlitSurface(src, 0, convert, 0);
GLenum sdl_format;
=======================================
--- /src/engine/display/screenshot.cpp Mon Sep 19 15:09:02 2011 UTC
+++ /src/engine/display/screenshot.cpp Sat Jul 26 19:58:06 2014 UTC
@@ -34,10 +34,12 @@
Screenshot::make_screenshot()
{
std::string filename = get_filename();
+#ifdef OLD_SDL1
log_info(_("Screenshot: Saving screenshot to: ") << filename);
save(SDL_GetVideoSurface(), filename);
+#endif
log_info(_("Screenshot: Screenshot is done."));
-
+
return filename;
}
@@ -47,7 +49,7 @@
std::unique_ptr<uint8_t[]> buffer(new uint8_t[surface->w * surface->h *
3]);
#ifdef HAVE_OPENGL
- if(surface->flags & SDL_OPENGL)
+ if(surface->flags & SDL_WINDOW_OPENGL)
{
glPixelStorei(GL_PACK_ALIGNMENT, 1);
glReadPixels(0, 0, surface->w, surface->h, GL_RGB, GL_UNSIGNED_BYTE,
buffer.get());
=======================================
--- /src/engine/display/sdl_framebuffer.cpp Sat Jul 26 18:49:29 2014 UTC
+++ /src/engine/display/sdl_framebuffer.cpp Sat Jul 26 19:58:06 2014 UTC
@@ -138,7 +138,10 @@
SDLFramebuffer::SDLFramebuffer() :
- screen(0),
+ m_window(nullptr),
+ m_renderer(nullptr),
+ m_screen(nullptr),
+ m_texture(nullptr),
cliprect_stack()
{
}
@@ -156,6 +159,7 @@
void
SDLFramebuffer::draw_surface(const FramebufferSurface& surface, const
Vector2i& pos)
{
+#ifdef OLD_SDL1
SDLFramebufferSurfaceImpl* impl =
dynamic_cast<SDLFramebufferSurfaceImpl*>(surface.get_impl());
SDL_Surface* src = impl->get_surface();
@@ -166,11 +170,13 @@
dstrect.h = 0;
SDL_BlitSurface(src, NULL, screen, &dstrect);
+#endif
}
void
SDLFramebuffer::draw_surface(const FramebufferSurface& surface, const
Rect& srcrect, const Vector2i& pos)
{
+#ifdef OLD_SDL1
SDLFramebufferSurfaceImpl* impl =
dynamic_cast<SDLFramebufferSurfaceImpl*>(surface.get_impl());
SDL_Surface* src = impl->get_surface();
@@ -187,11 +193,13 @@
sdlsrcrect.h = static_cast<Uint16>(srcrect.get_height());
SDL_BlitSurface(src, &sdlsrcrect, screen, &dstrect);
+#endif
}
void
SDLFramebuffer::draw_line(const Vector2i& pos1, const Vector2i& pos2,
const Color& color)
{
+#ifdef OLD_SDL1
int x, y, xlen, ylen, incr;
int sx = pos1.x;
int sy = pos1.y;
@@ -321,6 +329,7 @@
}
SDL_UnlockSurface(screen);
}
+#endif
}
void
@@ -338,6 +347,7 @@
void
SDLFramebuffer::fill_rect(const Rect& rect_, const Color& color)
{
+#ifdef OLD_SDL1
Rect rect = rect_;
rect.normalize();
@@ -350,7 +360,7 @@
srcrect.w = static_cast<Uint16>(rect.get_width());
srcrect.h = static_cast<Uint16>(rect.get_height());
- SDL_FillRect(screen, &srcrect, SDL_MapRGB(screen->format, color.r,
color.g, color.b));
+ SDL_FillRect(m_screen, &srcrect, SDL_MapRGB(screen->format, color.r,
color.g, color.b));
}
else if (color.a != 0)
{
@@ -358,7 +368,7 @@
int clipx1, clipx2, clipy1, clipy2;
SDL_Rect cliprect;
- SDL_GetClipRect(screen, &cliprect);
+ SDL_GetClipRect(m_screen, &cliprect);
clipx1 = cliprect.x;
clipx2 = cliprect.x + cliprect.w - 1;
clipy1 = cliprect.y;
@@ -384,12 +394,15 @@
}
SDL_UnlockSurface(screen);
}
+#endif
}
void
SDLFramebuffer::flip()
{
+#ifdef OLD_SDL1
SDL_Flip(screen);
+#endif
}
void
@@ -407,13 +420,17 @@
sdl_rects.push_back(sdl_rect);
}
- SDL_UpdateRects(screen, static_cast<int>(sdl_rects.size()),
const_cast<SDL_Rect*>(&*sdl_rects.begin()));
+#ifdef OLD_SDL1
+ SDL_UpdateRects(m_screen, static_cast<int>(sdl_rects.size()),
const_cast<SDL_Rect*>(&*sdl_rects.begin()));
+#endif
}
Size
SDLFramebuffer::get_size() const
{
- return Size(screen->w, screen->h);
+ Size s;
+ SDL_GetWindowSize(m_window, &s.width, &s.height);
+ return s;
}
void
@@ -423,32 +440,46 @@
if (fullscreen)
{
- flags |= SDL_FULLSCREEN;
+ flags |= SDL_WINDOW_FULLSCREEN;
}
else if (resizable)
{
- flags |= SDL_RESIZABLE;
+ flags |= SDL_WINDOW_RESIZABLE;
}
- screen = SDL_SetVideoMode(size.width, size.height, 0, flags);
-
- if (screen == NULL)
+ m_window = SDL_CreateWindow("Pingus",
+ SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
+ size.width, size.height,
+ flags);
+ if(m_window == 0)
{
- log_error("Unable to set video mode: " << SDL_GetError());
- exit(1);
+ std::ostringstream msg;
+ msg << "Couldn't set video mode (" << size.width << "x" << size.height
<< "): " << SDL_GetError();
+ throw std::runtime_error(msg.str());
}
+
+ m_renderer = SDL_CreateRenderer(m_window, -1, SDL_RENDERER_ACCELERATED);
+ m_screen = SDL_CreateRGBSurface(0, size.width, size.height, 32,
+ 0x00FF0000,
+ 0x0000FF00,
+ 0x000000FF,
+ 0xFF000000);
+ m_texture = SDL_CreateTexture(m_renderer,
+ SDL_PIXELFORMAT_ARGB8888,
+ SDL_TEXTUREACCESS_STREAMING,
+ size.width, size.height);
}
bool
SDLFramebuffer::is_fullscreen() const
{
- return screen->flags & SDL_FULLSCREEN;
+ return SDL_GetWindowFlags(m_window) & SDL_WINDOW_FULLSCREEN;
}
bool
SDLFramebuffer::is_resizable() const
{
- return screen->flags & SDL_RESIZABLE;
+ return SDL_GetWindowFlags(m_window) & SDL_WINDOW_RESIZABLE;
}
void
@@ -466,7 +497,7 @@
}
cliprect_stack.push_back(sdl_rect);
- SDL_SetClipRect(screen, &cliprect_stack.back());
+ SDL_SetClipRect(m_screen, &cliprect_stack.back());
}
void
@@ -474,9 +505,9 @@
{
cliprect_stack.pop_back();
if (cliprect_stack.empty())
- SDL_SetClipRect(screen, NULL);
+ SDL_SetClipRect(m_screen, NULL);
else
- SDL_SetClipRect(screen, &cliprect_stack.back());
+ SDL_SetClipRect(m_screen, &cliprect_stack.back());
}
/* EOF */
=======================================
--- /src/engine/display/sdl_framebuffer.hpp Fri Oct 14 02:03:23 2011 UTC
+++ /src/engine/display/sdl_framebuffer.hpp Sat Jul 26 19:58:06 2014 UTC
@@ -22,7 +22,10 @@
class SDLFramebuffer : public Framebuffer
{
private:
- SDL_Surface* screen;
+ SDL_Window* m_window;
+ SDL_Renderer* m_renderer;
+ SDL_Surface* m_screen;
+ SDL_Texture* m_texture;
std::vector<SDL_Rect> cliprect_stack;
public:
=======================================
--- /src/engine/display/sdl_framebuffer_surface_impl.cpp Sat Sep 17
21:42:25 2011 UTC
+++ /src/engine/display/sdl_framebuffer_surface_impl.cpp Sat Jul 26
19:58:06 2014 UTC
@@ -19,10 +19,12 @@
SDLFramebufferSurfaceImpl::SDLFramebufferSurfaceImpl(SDL_Surface* src) :
surface()
{
+#ifdef OLD_SDL1
if (src->format->Amask != 0 || (src->flags & SDL_SRCCOLORKEY))
surface = SDL_DisplayFormatAlpha(src);
else
surface = SDL_DisplayFormat(src);
+#endif
}
SDLFramebufferSurfaceImpl::~SDLFramebufferSurfaceImpl()
=======================================
--- /src/engine/display/surface.cpp Fri May 10 02:38:07 2013 UTC
+++ /src/engine/display/surface.cpp Sat Jul 26 19:58:06 2014 UTC
@@ -87,18 +87,22 @@
}
else
{
+#ifdef OLD_SDL1
impl->surface = SDL_CreateRGBSurface(SDL_SWSURFACE | SDL_SRCCOLORKEY,
width, height, 8,
0, 0, 0 ,0);
SDL_SetColorKey(impl->surface, SDL_SRCCOLORKEY, colorkey);
+#endif
}
+#ifdef OLD_SDL1
SDL_SetColors(impl->surface, palette->colors, 0, palette->ncolors);
+#endif
}
Surface::Surface(int width, int height) :
impl(new SurfaceImpl())
{
- impl->surface = SDL_CreateRGBSurface(SDL_SWSURFACE | SDL_SRCALPHA,
width, height, 32,
+ impl->surface = SDL_CreateRGBSurface(0, width, height, 32,
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
0xff000000, 0x00ff0000, 0x0000ff00,
0x000000ff
#else
@@ -295,6 +299,7 @@
Color
Surface::get_pixel(int x, int y) const
{
+#ifdef OLD_SDL1
Uint8 *p = static_cast<Uint8 *>(get_surface()->pixels) + y *
get_surface()->pitch + x * get_surface()->format->BytesPerPixel;
Uint32 pixel;
@@ -340,6 +345,9 @@
Color color;
SDL_GetRGBA(pixel, get_surface()->format, &color.r, &color.g, &color.b,
&color.a);
return color;
+#else
+ return Color();
+#endif
}
Surface
@@ -386,6 +394,7 @@
Surface
Surface::clone() const
{
+#ifdef OLD_SDL1
SDL_Surface* new_surface =
Blitter::create_surface_from_format(impl->surface,
impl->surface->w, impl->surface->h);
if (impl->surface->flags & SDL_SRCALPHA)
@@ -401,6 +410,9 @@
}
return Surface(std::shared_ptr<SurfaceImpl>(new
SurfaceImpl(new_surface)));
+#else
+ return Surface();
+#endif
}
Surface
@@ -487,7 +499,9 @@
Surface::convert_to_rgba() const
{
SDL_Surface* surface = Blitter::create_surface_rgba(impl->surface->w,
impl->surface->h);
+#ifdef OLD_SDL1
SDL_SetAlpha(impl->surface, 0, 0);
+#endif
SDL_BlitSurface(impl->surface, NULL, surface, NULL);
return Surface(surface);
}
@@ -496,7 +510,9 @@
Surface::convert_to_rgb() const
{
SDL_Surface* surface = Blitter::create_surface_rgb(impl->surface->w,
impl->surface->h);
+#ifdef OLD_SDL1
SDL_SetAlpha(impl->surface, 0, 0);
+#endif
SDL_BlitSurface(impl->surface, NULL, surface, NULL);
return Surface(surface);
}
@@ -504,7 +520,11 @@
bool
Surface::has_colorkey() const
{
+#ifdef OLD_SDL1
return impl->surface->flags & SDL_SRCCOLORKEY;
+#else
+ return false;
+#endif
}
bool
@@ -516,6 +536,7 @@
void
Surface::print(std::ostream& out)
{
+#ifdef OLD_SDL1
out << boost::format("Pointer: 0x%p\n"
"Rmask: 0x%08x\n"
"Gmask: 0x%08x\n"
@@ -557,6 +578,7 @@
out << std::endl;
SDL_UnlockSurface(impl->surface);
}
+#endif
}
/* EOF */
=======================================
--- /src/engine/input/event.hpp Tue Oct 11 21:42:55 2011 UTC
+++ /src/engine/input/event.hpp Sat Jul 26 19:58:06 2014 UTC
@@ -98,7 +98,7 @@
struct KeyboardEvent
{
bool state;
- SDL_keysym keysym;
+ SDL_Keysym keysym;
};
struct Event
=======================================
--- /src/engine/input/sdl_driver.cpp Fri Oct 21 17:14:13 2011 UTC
+++ /src/engine/input/sdl_driver.cpp Sat Jul 26 19:58:06 2014 UTC
@@ -33,6 +33,7 @@
string2key(),
joystick_handles()
{
+#ifdef OLD_SDL1
for (int i = 0; i < SDLK_LAST; ++i)
{
char* key_name = SDL_GetKeyName(static_cast<SDLKey>(i));
@@ -41,6 +42,7 @@
// FIXME: Make the keynames somewhere user visible so that users can
use them
log_debug("Key: '" << key_name << "'");
}
+#endif
}
SDLDriver::~SDLDriver()
@@ -228,13 +230,15 @@
for(std::vector<PointerBinding>::iterator i =
pointer_bindings.begin();
i != pointer_bindings.end(); ++i)
{
- i->binding->set_pos(Vector2f(event.motion.x, event.motion.y));
+ i->binding->set_pos(Vector2f(static_cast<float>(event.motion.x),
+
static_cast<float>(event.motion.y)));
}
for(std::vector<ScrollerBinding>::iterator i =
scroller_bindings.begin();
i != scroller_bindings.end(); ++i)
{
- i->binding->set_delta(Vector2f(event.motion.xrel,
event.motion.yrel));
+
i->binding->set_delta(Vector2f(static_cast<float>(event.motion.xrel),
+
static_cast<float>(event.motion.yrel)));
}
break;
@@ -253,8 +257,16 @@
}
break;
- case SDL_VIDEORESIZE:
- Display::resize(Size(event.resize.w, event.resize.h));
+ case SDL_WINDOWEVENT:
+ switch(event.window.event)
+ {
+ case SDL_WINDOWEVENT_RESIZED:
+ Display::resize(Size(event.window.data1, event.window.data2));
+ break;
+
+ default:
+ break;
+ }
break;
case SDL_KEYDOWN:
=======================================
--- /src/engine/input/sdl_driver.hpp Fri Nov 6 19:58:03 2009 UTC
+++ /src/engine/input/sdl_driver.hpp Sat Jul 26 19:58:06 2014 UTC
@@ -55,7 +55,7 @@
struct KeyboardButtonBinding {
Button* binding;
- SDLKey key;
+ SDL_Keycode key;
};
struct ScrollerBinding {
@@ -74,7 +74,7 @@
std::vector<JoystickAxisBinding> joystick_axis_bindings;
Keyboard* keyboard_binding;
- typedef std::map<std::string, SDLKey> String2Key;
+ typedef std::map<std::string, SDL_Keycode> String2Key;
String2Key string2key;
typedef std::map<int, SDL_Joystick*> JoystickHandles;
=======================================
--- /src/engine/system/sdl_system.cpp Fri Oct 21 16:49:36 2011 UTC
+++ /src/engine/system/sdl_system.cpp Sat Jul 26 19:58:06 2014 UTC
@@ -43,14 +43,11 @@
void
SDLSystem::create_window(FramebufferType framebuffer_type, const Size&
size, bool fullscreen, bool resizable)
{
+#ifdef OLD_SDL1
SDL_WM_SetCaption("Pingus " VERSION, "Pingus " VERSION);
SDL_WM_SetIcon(IMG_Load(Pathname("images/icons/pingus.png",
Pathname::DATA_PATH).get_sys_path().c_str()), 0);
-
+#endif
Display::create_window(framebuffer_type, size, fullscreen, resizable);
-
- SDL_EnableUNICODE(1);
-
- SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY,
SDL_DEFAULT_REPEAT_INTERVAL);
}
/* EOF */
=======================================
--- /src/pingus/collision_mask.cpp Thu Sep 8 10:21:46 2011 UTC
+++ /src/pingus/collision_mask.cpp Sat Jul 26 19:58:06 2014 UTC
@@ -73,6 +73,7 @@
if (sdl_surface->format->palette)
{
+#ifdef OLD_SDL1
uint8_t* source = static_cast<uint8_t*>(sdl_surface->pixels);
if (sdl_surface->flags & SDL_SRCCOLORKEY)
{ // surface with transparent areas
@@ -89,6 +90,7 @@
{ // completly opaque surface
memset(buffer.get(), 1, width*height);
}
+#endif
}
else if (sdl_surface->format->BitsPerPixel == 24)
{
=======================================
--- /src/pingus/components/playfield.cpp Sat Oct 22 20:52:30 2011 UTC
+++ /src/pingus/components/playfield.cpp Sat Jul 26 19:58:06 2014 UTC
@@ -139,6 +139,7 @@
}
}
+#ifdef OLD_SDL1
if (globals::auto_scrolling && (Display::is_fullscreen() ||
SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_ON))
{
scroll_speed = static_cast<int>(800 * delta);
@@ -161,6 +162,7 @@
state.set_pos(state.get_pos() + Vector2i(0, scroll_speed));
}
}
+#endif
}
void
@@ -214,6 +216,7 @@
if (globals::developer_mode)
{ // Some fun stuff that lets you draw directly on the level
+#ifdef OLD_SDL1
Uint8 *keystate = SDL_GetKeyState(NULL);
if (keystate[SDLK_DELETE])
{
@@ -241,6 +244,7 @@
p.y - mask.get_height()/2,
Groundtype::GP_BRIDGE);
}
+#endif
}
}
=======================================
--- /src/pingus/config_manager.cpp Fri Oct 21 13:58:08 2011 UTC
+++ /src/pingus/config_manager.cpp Sat Jul 26 19:58:06 2014 UTC
@@ -185,7 +185,7 @@
if (v != get_mouse_grab())
{
- SDL_WM_GrabInput(v ? SDL_GRAB_ON : SDL_GRAB_OFF);
+ SDL_SetWindowGrab(SDL_GL_GetCurrentWindow(), static_cast<SDL_bool>(v));
on_mouse_grab_change(v);
}
@@ -195,7 +195,7 @@
bool
ConfigManager::get_mouse_grab() const
{
- return (SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_ON);
+ return SDL_GetWindowGrab(SDL_GL_GetCurrentWindow());
}
void
=======================================
--- /src/pingus/global_event.cpp Sat Oct 22 23:59:53 2011 UTC
+++ /src/pingus/global_event.cpp Sat Jul 26 19:58:06 2014 UTC
@@ -33,7 +33,7 @@
void
GlobalEvent::on_button_press(const SDL_KeyboardEvent& event)
{
- Uint8* keystate = SDL_GetKeyState(NULL);
+ const Uint8* keystate = SDL_GetKeyboardState(nullptr);
switch (event.keysym.sym)
{
@@ -100,10 +100,12 @@
case SDLK_k:
if (globals::developer_mode)
{
+#ifdef OLD_SDL1
log_info("Low level screen clear triggered");
SDL_Surface* screen = SDL_GetVideoSurface();
SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 255, 255,
0));
SDL_Flip(screen);
+#endif
}
break;
=======================================
--- /src/pingus/ground_map.cpp Thu Dec 29 14:59:36 2011 UTC
+++ /src/pingus/ground_map.cpp Sat Jul 26 19:58:06 2014 UTC
@@ -201,6 +201,7 @@
GroundMap::put_alpha_surface(Surface provider, Surface sprovider,
int x_pos, int y_pos, int real_x_arg, int
real_y_arg)
{
+#ifdef OLD_SDL1
if (sprovider.get_surface()->format->BitsPerPixel != 8 &&
sprovider.get_surface()->format->BitsPerPixel != 24 &&
sprovider.get_surface()->format->BitsPerPixel != 32)
@@ -293,6 +294,7 @@
sprovider.unlock();
provider.unlock();
+#endif
}
void
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] [pingus] 2 new revisions pushed by address@hidden on 2014-07-26 19:58 GMT,
pingus <=