[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] [pingus] 25 new revisions pushed by address@hidden on 2014-
From: |
pingus |
Subject: |
[Pingus-CVS] [pingus] 25 new revisions pushed by address@hidden on 2014-09-11 21:58 GMT |
Date: |
Thu, 11 Sep 2014 22:01:41 +0000 |
feature/sdl2 moved from 862843448f9e to 270ad4e4cf39
25 new revisions:
Revision: d1fd6dde04dd
Author: Ingo Ruhnke <address@hidden>
Date: Sat Jul 26 18:07:52 2014 UTC
Log: Updated SConscript to SDL2
https://code.google.com/p/pingus/source/detail?r=d1fd6dde04dd
Revision: 8f5942ad2e26
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...
https://code.google.com/p/pingus/source/detail?r=8f5942ad2e26
Revision: ff6df2f69887
Author: Ingo Ruhnke <address@hidden>
Date: Sat Jul 26 21:37:49 2014 UTC
Log: Implemented basic drawing operations for SDL2
https://code.google.com/p/pingus/source/detail?r=ff6df2f69887
Revision: 7601e520e518
Author: Ingo Ruhnke <address@hidden>
Date: Sat Jul 26 21:47:15 2014 UTC
Log: Added cleanup to SDLFramebuffer and fixed clipping
https://code.google.com/p/pingus/source/detail?r=7601e520e518
Revision: ad5599b4822d
Author: Ingo Ruhnke <address@hidden>
Date: Sat Jul 26 23:54:13 2014 UTC
Log: Fixed crashing due to scancode/keycode mixup
https://code.google.com/p/pingus/source/detail?r=ad5599b4822d
Revision: 724a09bc5a1d
Author: Ingo Ruhnke <address@hidden>
Date: Sat Jul 26 23:58:44 2014 UTC
Log: Enable BLEND render mode, fixed incorrect color on rect and line
drawi...
https://code.google.com/p/pingus/source/detail?r=724a09bc5a1d
Revision: ca13c9472f31
Author: Ingo Ruhnke <address@hidden>
Date: Sun Jul 27 00:17:46 2014 UTC
Log: Fixed another scancode/keycode issue
https://code.google.com/p/pingus/source/detail?r=ca13c9472f31
Revision: 00c92cc70fe3
Author: Ingo Ruhnke <address@hidden>
Date: Sun Jul 27 00:18:02 2014 UTC
Log: Fixed window title and icon
https://code.google.com/p/pingus/source/detail?r=00c92cc70fe3
Revision: d4df127a2cfb
Author: Ingo Ruhnke <address@hidden>
Date: Sun Jul 27 00:20:22 2014 UTC
Log: Copy all surface flags in Blitter::create_surface_from_format()
https://code.google.com/p/pingus/source/detail?r=d4df127a2cfb
Revision: 670e41e94395
Author: Ingo Ruhnke <address@hidden>
Date: Sun Jul 27 00:38:16 2014 UTC
Log: Fixed up some colorkey handling
https://code.google.com/p/pingus/source/detail?r=670e41e94395
Revision: efa6d5294172
Author: Ingo Ruhnke <address@hidden>
Date: Sun Jul 27 02:14:18 2014 UTC
Log: Some fixes to fullscreen mode, somewhat incomplete
https://code.google.com/p/pingus/source/detail?r=efa6d5294172
Revision: 47bc68215b24
Author: Ingo Ruhnke <address@hidden>
Date: Sun Jul 27 04:14:52 2014 UTC
Log: Added missing <sstream>
https://code.google.com/p/pingus/source/detail?r=47bc68215b24
Revision: 04f0e083a599
Author: Ingo Ruhnke <address@hidden>
Date: Sun Jul 27 15:23:11 2014 UTC
Log: Removed some unused code
https://code.google.com/p/pingus/source/detail?r=04f0e083a599
Revision: 84a2b4fd67ea
Author: Ingo Ruhnke <address@hidden>
Date: Sun Jul 27 16:32:00 2014 UTC
Log: Fixed screenshoting for SDLFramebuffer, removed HAVE_OPENGL define
https://code.google.com/p/pingus/source/detail?r=84a2b4fd67ea
Revision: 6430553e4cee
Author: Ingo Ruhnke <address@hidden>
Date: Sun Jul 27 16:36:35 2014 UTC
Log: Use SDL_GetRendererOutputSize() instead of window size for
screenshots
https://code.google.com/p/pingus/source/detail?r=6430553e4cee
Revision: 39ab90dc1037
Author: Ingo Ruhnke <address@hidden>
Date: Sun Jul 27 17:18:40 2014 UTC
Log: Swapped Screenshot subpixels around
https://code.google.com/p/pingus/source/detail?r=39ab90dc1037
Revision: eac5e3ce0967
Author: Ingo Ruhnke <address@hidden>
Date: Sun Jul 27 18:10:17 2014 UTC
Log: Implemented mouse grab stuff for SDLFramebuffer
https://code.google.com/p/pingus/source/detail?r=eac5e3ce0967
Revision: cc9ee03e5e4a
Author: Ingo Ruhnke <address@hidden>
Date: Sun Jul 27 19:17:47 2014 UTC
Log: Implemented SDL2 text/unicode handling
https://code.google.com/p/pingus/source/detail?r=cc9ee03e5e4a
Revision: 8f04a8edc92e
Author: Ingo Ruhnke <address@hidden>
Date: Sun Jul 27 19:22:52 2014 UTC
Log: Fixed another scancode/keycode mixup
https://code.google.com/p/pingus/source/detail?r=8f04a8edc92e
Revision: faf08734aa8c
Author: Ingo Ruhnke <address@hidden>
Date: Sun Jul 27 19:32:36 2014 UTC
Log: Fixed keyboard->button mapping
https://code.google.com/p/pingus/source/detail?r=faf08734aa8c
Revision: 5dbbef7d71ab
Author: Ingo Ruhnke <address@hidden>
Date: Mon Jul 28 01:18:22 2014 UTC
Log: Updated logmich
https://code.google.com/p/pingus/source/detail?r=5dbbef7d71ab
Revision: 1ba48a022bcc
Author: Ingo Ruhnke <address@hidden>
Date: Mon Jul 28 01:21:27 2014 UTC
Log: Updated TODO
https://code.google.com/p/pingus/source/detail?r=1ba48a022bcc
Revision: 6b9a23120481
Author: Ingo Ruhnke <address@hidden>
Date: Mon Jul 28 02:04:20 2014 UTC
Log: Added GL context creation, fixed alpha value issue that made
surfaces ...
https://code.google.com/p/pingus/source/detail?r=6b9a23120481
Revision: 7a70d0dc4c26
Author: Ingo Ruhnke <address@hidden>
Date: Mon Jul 28 02:04:49 2014 UTC
Log: Some incomplete work on fullscreen mode switching
https://code.google.com/p/pingus/source/detail?r=7a70d0dc4c26
Revision: 270ad4e4cf39
Author: Ingo Ruhnke <address@hidden>
Date: Thu Sep 11 21:54:14 2014 UTC
Log: Stuff
https://code.google.com/p/pingus/source/detail?r=270ad4e4cf39
==============================================================================
Revision: d1fd6dde04dd
Author: Ingo Ruhnke <address@hidden>
Date: Sat Jul 26 18:07:52 2014 UTC
Log: Updated SConscript to SDL2
https://code.google.com/p/pingus/source/detail?r=d1fd6dde04dd
Modified:
/SConscript
=======================================
--- /SConscript Sun Jul 27 03:01:44 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: 8f5942ad2e26
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'
https://code.google.com/p/pingus/source/detail?r=8f5942ad2e26
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 Sun Jul 27 03:58:39 2014 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_);
=======================================
--- /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 Sun Jul 27 03:58:39 2014 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
@@ -184,7 +185,9 @@
return best_fit;
}
-
+#else
+ return Size(800, 600);
+#endif
}
struct SortBySize
@@ -198,6 +201,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);
@@ -236,6 +240,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 Sun Jul 27 03:58:39 2014 UTC
+++ /src/engine/display/screenshot.cpp Sat Jul 26 19:58:06 2014 UTC
@@ -34,10 +34,13 @@
Screenshot::make_screenshot()
{
std::string filename = get_filename();
+
log_info("Screenshot: Saving screenshot to: %1%", filename);
+#ifdef OLD_SDL1
save(SDL_GetVideoSurface(), filename);
+#endif
log_info("Screenshot: Screenshot is done.");
-
+
return filename;
}
@@ -47,7 +50,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 Sun Jul 27 03:58:39 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: %1%", 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 Sun Jul 27 03:58:39 2014 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 Sun Jul 27 03:58:39 2014 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: '%1%'", 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 Sun Jul 27 03:58:39 2014 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 Sun Jul 27 03:58:39 2014 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 Sun Jul 27 03:58:39 2014 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 Sun Jul 27 03:58:39 2014 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 Sun Jul 27 03:58:39 2014 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
==============================================================================
Revision: ff6df2f69887
Author: Ingo Ruhnke <address@hidden>
Date: Sat Jul 26 21:37:49 2014 UTC
Log: Implemented basic drawing operations for SDL2
https://code.google.com/p/pingus/source/detail?r=ff6df2f69887
Modified:
/src/engine/display/blitter.cpp
/src/engine/display/opengl/opengl_framebuffer_surface_impl.cpp
/src/engine/display/sdl_framebuffer.cpp
/src/engine/display/sdl_framebuffer_surface_impl.cpp
/src/engine/display/sdl_framebuffer_surface_impl.hpp
/src/engine/display/surface.cpp
/src/engine/input/core_driver.cpp
/src/engine/input/sdl_driver.cpp
=======================================
--- /src/engine/display/blitter.cpp Sat Jul 26 19:58:06 2014 UTC
+++ /src/engine/display/blitter.cpp Sat Jul 26 21:37:49 2014 UTC
@@ -32,7 +32,7 @@
bpp = surface->format->BytesPerPixel;
if (bpp == 1) {
- SDL_Color pal[256];
+ SDL_Palette* pal = SDL_AllocPalette(256);
#ifdef OLD_SDL1
Uint32 ckey;
int useckey = 0;
@@ -48,7 +48,7 @@
new_pixels = static_cast<unsigned char*>(new_surface->pixels);
new_pitch = new_surface->pitch;
- memcpy(pal, surface->format->palette->colors, sizeof(SDL_Color) * 256);
+ memcpy(pal->colors, surface->format->palette->colors,
sizeof(SDL_Color) * 256);
#ifdef OLD_SDL1
ckey = surface->format->colorkey;
#endif
@@ -64,8 +64,8 @@
SDL_UnlockSurface(surface);
SDL_UnlockSurface(new_surface);
+ SDL_SetSurfacePalette(new_surface, pal);
#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);
}
@@ -75,7 +75,7 @@
float fx, fy, fz;
unsigned char *p1, *p2, *p3, *p4;
- new_surface = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height,
surface->format->BitsPerPixel,
+ new_surface = SDL_CreateRGBSurface(0, width, height,
surface->format->BitsPerPixel,
surface->format->Rmask,
surface->format->Gmask, surface->format->Bmask, surface->format->Amask);
SDL_LockSurface(surface);
@@ -220,7 +220,7 @@
#ifdef OLD_SDL1
if (surface->flags & SDL_SRCALPHA)
- SDL_SetAlpha(new_surface, SDL_SRCALPHA, surface->format->alpha);
+ SDL_SetSurfaceAlphaMod(new_surface, SDL_SRCALPHA,
surface->format->alpha);
if (surface->format->palette)
SDL_SetPalette(new_surface, SDL_LOGPAL,
surface->format->palette->colors,
=======================================
--- /src/engine/display/opengl/opengl_framebuffer_surface_impl.cpp Sat Jul
26 19:58:06 2014 UTC
+++ /src/engine/display/opengl/opengl_framebuffer_surface_impl.cpp Sat Jul
26 21:37:49 2014 UTC
@@ -42,17 +42,15 @@
// Convert the src surface to a format usable for upload to OpenGL
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- SDL_Surface* convert = SDL_CreateRGBSurface(SDL_SWSURFACE,
+ SDL_Surface* convert = SDL_CreateRGBSurface(0,
m_texture_size.width,
m_texture_size.height, 32,
0xff000000, 0x00ff0000,
0x0000ff00, 0x000000ff);
#else
- SDL_Surface* convert = SDL_CreateRGBSurface(SDL_SWSURFACE,
+ SDL_Surface* convert = SDL_CreateRGBSurface(0,
m_texture_size.width,
m_texture_size.height, 32,
0x000000ff, 0x0000ff00,
0x00ff0000, 0xff000000);
#endif
-#ifdef OLD_SDL1
- SDL_SetAlpha(src, 0, 0);
-#endif
+ SDL_SetSurfaceAlphaMod(src, 0);
SDL_BlitSurface(src, 0, convert, 0);
GLenum sdl_format;
=======================================
--- /src/engine/display/sdl_framebuffer.cpp Sat Jul 26 19:58:06 2014 UTC
+++ /src/engine/display/sdl_framebuffer.cpp Sat Jul 26 21:37:49 2014 UTC
@@ -153,38 +153,35 @@
FramebufferSurface
SDLFramebuffer::create_surface(const Surface& surface)
{
- return FramebufferSurface(new
SDLFramebufferSurfaceImpl(surface.get_surface()));
+ return FramebufferSurface(new SDLFramebufferSurfaceImpl(m_renderer,
surface.get_surface()));
}
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();
+ SDL_Texture* texture = impl->get_texture();
SDL_Rect dstrect;
dstrect.x = static_cast<Sint16>(pos.x);
dstrect.y = static_cast<Sint16>(pos.y);
- dstrect.w = 0;
- dstrect.h = 0;
+ dstrect.w = surface.get_width();
+ dstrect.h = surface.get_height();
- SDL_BlitSurface(src, NULL, screen, &dstrect);
-#endif
+ SDL_RenderCopy(m_renderer, texture, nullptr, &dstrect);
}
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();
+ SDL_Texture* texture = impl->get_texture();
SDL_Rect dstrect;
dstrect.x = static_cast<Sint16>(pos.x);
dstrect.y = static_cast<Sint16>(pos.y);
- dstrect.w = 0;
- dstrect.h = 0;
+ dstrect.w = srcrect.get_width();
+ dstrect.h = srcrect.get_height();
SDL_Rect sdlsrcrect;
sdlsrcrect.x = static_cast<Sint16>(srcrect.left);
@@ -192,144 +189,17 @@
sdlsrcrect.w = static_cast<Uint16>(srcrect.get_width());
sdlsrcrect.h = static_cast<Uint16>(srcrect.get_height());
- SDL_BlitSurface(src, &sdlsrcrect, screen, &dstrect);
-#endif
+ SDL_RenderCopy(m_renderer, texture, &sdlsrcrect, &dstrect);
}
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;
- int dx = pos2.x;
- int dy = pos2.y;
- draw_pixel_func draw_pixel;
- int clipx1, clipx2, clipy1, clipy2;
- SDL_Rect rect;
-
- SDL_GetClipRect(screen, &rect);
- clipx1 = rect.x;
- clipx2 = rect.x + rect.w - 1;
- clipy1 = rect.y;
- clipy2 = rect.y + rect.h - 1;
-
- // vertical line
- if (sx == dx) {
- if (sx < clipx1 || sx > clipx2 || (sy < clipy1 && dy < clipy1) || (sy
clipy2 && dy > clipy2)) {
- return;
- }
- clip(sy, clipy1, clipy2);
- clip(dy, clipy1, clipy2);
- if (sy < dy) {
- draw_vline(screen, sx, sy, dy - sy + 1, color);
- } else {
- draw_vline(screen, dx, dy, sy - dy + 1, color);
- }
- return;
- }
-
- // horizontal
- if (sy == dy) {
- if (sy < clipy1 || sy > clipy2 || (sx < clipx1 && dx < clipx1) || (sx
clipx2 && dx > clipx2)) {
- return;
- }
- clip(sx, clipx1, clipx2);
- clip(dx, clipx1, clipx2);
- if (sx < dx) {
- draw_hline(screen, sx, sy, dx - sx + 1, color);
- } else {
- draw_hline(screen, dx, dy, sx - dx + 1, color);
- }
- return;
- }
-
- draw_pixel = get_draw_pixel(screen);
- if (!draw_pixel) {
- return;
- }
-
- // exchange coordinates
- if (sy > dy) {
- int t = dx;
- dx = sx;
- sx = t;
- t = dy;
- dy = sy;
- sy = t;
- }
- ylen = dy - sy;
-
- if (sx > dx) {
- xlen = sx - dx;
- incr = -1;
- } else {
- xlen = dx - sx;
- incr = 1;
- }
-
- y = sy;
- x = sx;
-
- if (xlen > ylen) {
- if (sx > dx) {
- int t = sx;
- sx = dx;
- dx = t;
- y = dy;
- }
-
- int p = (ylen << 1) - xlen;
-
- SDL_LockSurface(screen);
- for (x = sx; x < dx; ++x) {
- if (x >= clipx1 && x <= clipx2 && y >= clipy1 && y <= clipy2) {
- draw_pixel(screen, x, y, color);
- }
- if (p >= 0) {
- y += incr;
- p += (ylen - xlen) << 1;
- } else {
- p += (ylen << 1);
- }
- }
- SDL_UnlockSurface(screen);
- return;
- }
-
- if (ylen > xlen) {
- int p = (xlen << 1) - ylen;
-
- SDL_LockSurface(screen);
- for (y = sy; y < dy; ++y) {
- if (x >= clipx1 && x <= clipx2 && y >= clipy1 && y <= clipy2) {
- draw_pixel(screen, x, y, color);
- }
- if (p >= 0) {
- x += incr;
- p += (xlen - ylen) << 1;
- } else {
- p += (xlen << 1);
- }
- }
- SDL_UnlockSurface(screen);
- return;
- }
-
- // Draw a diagonal line
- if (ylen == xlen) {
- SDL_LockSurface(screen);
- while (y != dy) {
- if (x >= clipx1 && x <= clipx2 && y >= clipy1 && y <= clipy2) {
- draw_pixel(screen, x, y, color);
- }
- x += incr;
- ++y;
- }
- SDL_UnlockSurface(screen);
- }
-#endif
+ SDL_SetRenderDrawColor(m_renderer,
+ color.r, color.b, color.g, color.a);
+ SDL_RenderDrawLine(m_renderer,
+ pos1.x, pos1.y,
+ pos2.x, pos2.y);
}
void
@@ -338,91 +208,42 @@
Rect rect = rect_;
rect.normalize();
- draw_line(Vector2i(rect.left, rect.top), Vector2i(rect.right-1,
rect.top), color);
- draw_line(Vector2i(rect.left, rect.bottom-1), Vector2i(rect.right-1,
rect.bottom-1), color);
- draw_line(Vector2i(rect.left, rect.top), Vector2i(rect.left,
rect.bottom-1), color);
- draw_line(Vector2i(rect.right-1, rect.top), Vector2i(rect.right-1,
rect.bottom-1), color);
+ SDL_Rect sdl_rect;
+ sdl_rect.x = rect.left;
+ sdl_rect.y = rect.top;
+ sdl_rect.w = rect.get_width();
+ sdl_rect.h = rect.get_height();
+
+ SDL_SetRenderDrawColor(m_renderer, color.r, color.b, color.g, color.a);
+ SDL_RenderDrawRect(m_renderer, &sdl_rect);
}
void
SDLFramebuffer::fill_rect(const Rect& rect_, const Color& color)
{
-#ifdef OLD_SDL1
Rect rect = rect_;
rect.normalize();
-
- if (color.a == 255)
- {
- SDL_Rect srcrect;
- srcrect.x = static_cast<Sint16>(rect.left);
- srcrect.y = static_cast<Sint16>(rect.top);
- srcrect.w = static_cast<Uint16>(rect.get_width());
- srcrect.h = static_cast<Uint16>(rect.get_height());
+ SDL_Rect sdl_rect;
+ sdl_rect.x = rect.left;
+ sdl_rect.y = rect.top;
+ sdl_rect.w = rect.get_width();
+ sdl_rect.h = rect.get_height();
- SDL_FillRect(m_screen, &srcrect, SDL_MapRGB(screen->format, color.r,
color.g, color.b));
- }
- else if (color.a != 0)
- {
- int top, bottom, left, right;
- int clipx1, clipx2, clipy1, clipy2;
- SDL_Rect cliprect;
-
- SDL_GetClipRect(m_screen, &cliprect);
- clipx1 = cliprect.x;
- clipx2 = cliprect.x + cliprect.w - 1;
- clipy1 = cliprect.y;
- clipy2 = cliprect.y + cliprect.h - 1;
-
- if (rect.right < clipx1 || rect.left > clipx2 || rect.bottom < clipy1 |
| rect.top > clipy2)
- return;
-
- top = rect.top < clipy1 ? clipy1 : rect.top;
- bottom = rect.bottom > clipy2 ? clipy2 : rect.bottom-1;
- left = rect.left < clipx1 ? clipx1 : rect.left;
- right = rect.right > clipx2 ? clipx2 : rect.right-1;
-
- draw_pixel_func draw_pixel = get_draw_pixel(screen);
- if (!draw_pixel)
- return;
-
- SDL_LockSurface(screen);
- for (int y = top; y <= bottom; ++y) {
- for (int x = left; x <= right; ++x) {
- draw_pixel(screen, x, y, color);
- }
- }
- SDL_UnlockSurface(screen);
- }
-#endif
+ SDL_SetRenderDrawColor(m_renderer, color.r, color.b, color.g, color.a);
+ SDL_RenderFillRect(m_renderer, &sdl_rect);
}
void
SDLFramebuffer::flip()
{
-#ifdef OLD_SDL1
- SDL_Flip(screen);
-#endif
+ SDL_RenderPresent(m_renderer);
}
void
SDLFramebuffer::update_rects(const std::vector<Rect>& rects)
{
- std::vector<SDL_Rect> sdl_rects;
-
- for(std::vector<Rect>::const_iterator i = rects.begin(); i !=
rects.end(); ++i)
- {
- SDL_Rect sdl_rect;
- sdl_rect.x = static_cast<Sint16>(i->left);
- sdl_rect.y = static_cast<Sint16>(i->top);
- sdl_rect.w = static_cast<Uint16>(i->get_width());
- sdl_rect.h = static_cast<Uint16>(i->get_height());
- sdl_rects.push_back(sdl_rect);
- }
-
-#ifdef OLD_SDL1
- SDL_UpdateRects(m_screen, static_cast<int>(sdl_rects.size()),
const_cast<SDL_Rect*>(&*sdl_rects.begin()));
-#endif
+ flip();
}
Size
=======================================
--- /src/engine/display/sdl_framebuffer_surface_impl.cpp Sat Jul 26
19:58:06 2014 UTC
+++ /src/engine/display/sdl_framebuffer_surface_impl.cpp Sat Jul 26
21:37:49 2014 UTC
@@ -16,20 +16,16 @@
#include "engine/display/sdl_framebuffer_surface_impl.hpp"
-SDLFramebufferSurfaceImpl::SDLFramebufferSurfaceImpl(SDL_Surface* src) :
- surface()
+SDLFramebufferSurfaceImpl::SDLFramebufferSurfaceImpl(SDL_Renderer*
renderer, SDL_Surface* src) :
+ m_texture(SDL_CreateTextureFromSurface(renderer, src)),
+ m_width(src->w),
+ m_height(src->h)
{
-#ifdef OLD_SDL1
- if (src->format->Amask != 0 || (src->flags & SDL_SRCCOLORKEY))
- surface = SDL_DisplayFormatAlpha(src);
- else
- surface = SDL_DisplayFormat(src);
-#endif
}
SDLFramebufferSurfaceImpl::~SDLFramebufferSurfaceImpl()
{
- SDL_FreeSurface(surface);
+ SDL_DestroyTexture(m_texture);
}
/* EOF */
=======================================
--- /src/engine/display/sdl_framebuffer_surface_impl.hpp Sat Sep 17
21:42:25 2011 UTC
+++ /src/engine/display/sdl_framebuffer_surface_impl.hpp Sat Jul 26
21:37:49 2014 UTC
@@ -22,16 +22,18 @@
class SDLFramebufferSurfaceImpl : public FramebufferSurfaceImpl
{
private:
- SDL_Surface* surface;
-
+ SDL_Texture* m_texture;
+ int m_width;
+ int m_height;
+
public:
- SDLFramebufferSurfaceImpl(SDL_Surface* src);
+ SDLFramebufferSurfaceImpl(SDL_Renderer* renderer, SDL_Surface* src);
~SDLFramebufferSurfaceImpl();
- int get_width() const { return surface->w; }
- int get_height() const { return surface->h; }
+ int get_width() const { return m_width;; }
+ int get_height() const { return m_height; }
- SDL_Surface* get_surface() const { return surface; }
+ SDL_Texture* get_texture() const { return m_texture; }
private:
SDLFramebufferSurfaceImpl(const SDLFramebufferSurfaceImpl&);
=======================================
--- /src/engine/display/surface.cpp Sat Jul 26 19:58:06 2014 UTC
+++ /src/engine/display/surface.cpp Sat Jul 26 21:37:49 2014 UTC
@@ -82,21 +82,17 @@
{
if (colorkey == -1)
{
- impl->surface = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 8,
+ impl->surface = SDL_CreateRGBSurface(0, width, height, 8,
0, 0, 0 ,0);
}
else
{
-#ifdef OLD_SDL1
- impl->surface = SDL_CreateRGBSurface(SDL_SWSURFACE | SDL_SRCCOLORKEY,
width, height, 8,
+ impl->surface = SDL_CreateRGBSurface(0, width, height, 8,
0, 0, 0 ,0);
- SDL_SetColorKey(impl->surface, SDL_SRCCOLORKEY, colorkey);
-#endif
+ SDL_SetColorKey(impl->surface, SDL_TRUE, colorkey);
}
-#ifdef OLD_SDL1
- SDL_SetColors(impl->surface, palette->colors, 0, palette->ncolors);
-#endif
+ SDL_SetSurfacePalette(impl->surface, palette);
}
Surface::Surface(int width, int height) :
@@ -394,25 +390,17 @@
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)
- {
- Uint8 alpha = impl->surface->format->alpha;
- SDL_SetAlpha(impl->surface, 0, 0);
- SDL_BlitSurface(impl->surface, NULL, new_surface, NULL);
- SDL_SetAlpha(impl->surface, SDL_SRCALPHA, alpha);
- }
- else
- {
- SDL_BlitSurface(impl->surface, NULL, new_surface, NULL);
- }
-
+ SDL_BlendMode blend_mode;
+ SDL_GetSurfaceBlendMode(impl->surface, &blend_mode);
+
+ SDL_SetSurfaceBlendMode(impl->surface, SDL_BLENDMODE_NONE);
+ SDL_BlitSurface(impl->surface, NULL, new_surface, NULL);
+
+ SDL_SetSurfaceBlendMode(impl->surface, blend_mode);
+
return Surface(std::shared_ptr<SurfaceImpl>(new
SurfaceImpl(new_surface)));
-#else
- return Surface();
-#endif
}
Surface
@@ -499,9 +487,6 @@
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);
}
@@ -510,9 +495,6 @@
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);
}
=======================================
--- /src/engine/input/core_driver.cpp Mon Sep 5 20:21:49 2011 UTC
+++ /src/engine/input/core_driver.cpp Sat Jul 26 21:37:49 2014 UTC
@@ -183,23 +183,23 @@
void update(float delta_t)
{
- up->update(delta_t);
- down->update(delta_t);
- left->update(delta_t);
- right->update(delta_t);
+ if (up) up->update(delta_t);
+ if (down) down->update(delta_t);
+ if (left) left->update(delta_t);
+ if (right) right->update(delta_t);
delta.x = delta.y = 0.0f;
- if (left->get_state() == BUTTON_PRESSED)
+ if (left && left->get_state() == BUTTON_PRESSED)
delta.x += speed * delta_t;
- if (right->get_state() == BUTTON_PRESSED)
+ if (right && right->get_state() == BUTTON_PRESSED)
delta.x += -speed * delta_t;
- if (up->get_state() == BUTTON_PRESSED)
+ if (up && up->get_state() == BUTTON_PRESSED)
delta.y += speed * delta_t;
- if (down->get_state() == BUTTON_PRESSED)
+ if (down && down->get_state() == BUTTON_PRESSED)
delta.y += -speed * delta_t;
notify_parent();
=======================================
--- /src/engine/input/sdl_driver.cpp Sat Jul 26 19:58:06 2014 UTC
+++ /src/engine/input/sdl_driver.cpp Sat Jul 26 21:37:49 2014 UTC
@@ -33,16 +33,14 @@
string2key(),
joystick_handles()
{
-#ifdef OLD_SDL1
- for (int i = 0; i < SDLK_LAST; ++i)
+ for (int i = 0; i < SDL_NUM_SCANCODES; ++i)
{
- char* key_name = SDL_GetKeyName(static_cast<SDLKey>(i));
- string2key[key_name] = static_cast<SDLKey>(i);
+ const char* key_name = SDL_GetKeyName(static_cast<SDL_Keycode>(i));
+ string2key[key_name] = static_cast<SDL_Keycode>(i);
// FIXME: Make the keynames somewhere user visible so that users can
use them
log_debug("Key: '%1%'", key_name);
}
-#endif
}
SDLDriver::~SDLDriver()
==============================================================================
Revision: 7601e520e518
Author: Ingo Ruhnke <address@hidden>
Date: Sat Jul 26 21:47:15 2014 UTC
Log: Added cleanup to SDLFramebuffer and fixed clipping
https://code.google.com/p/pingus/source/detail?r=7601e520e518
Modified:
/src/engine/display/sdl_framebuffer.cpp
=======================================
--- /src/engine/display/sdl_framebuffer.cpp Sat Jul 26 21:37:49 2014 UTC
+++ /src/engine/display/sdl_framebuffer.cpp Sat Jul 26 21:47:15 2014 UTC
@@ -148,6 +148,10 @@
SDLFramebuffer::~SDLFramebuffer()
{
+ SDL_DestroyTexture(m_texture);
+ SDL_FreeSurface(m_screen);
+ SDL_DestroyRenderer(m_renderer);
+ SDL_DestroyWindow(m_window);
}
FramebufferSurface
@@ -318,7 +322,7 @@
}
cliprect_stack.push_back(sdl_rect);
- SDL_SetClipRect(m_screen, &cliprect_stack.back());
+ SDL_RenderSetClipRect(m_renderer, &cliprect_stack.back());
}
void
@@ -326,9 +330,9 @@
{
cliprect_stack.pop_back();
if (cliprect_stack.empty())
- SDL_SetClipRect(m_screen, NULL);
+ SDL_RenderSetClipRect(m_renderer, NULL);
else
- SDL_SetClipRect(m_screen, &cliprect_stack.back());
+ SDL_RenderSetClipRect(m_renderer, &cliprect_stack.back());
}
/* EOF */
==============================================================================
Revision: ad5599b4822d
Author: Ingo Ruhnke <address@hidden>
Date: Sat Jul 26 23:54:13 2014 UTC
Log: Fixed crashing due to scancode/keycode mixup
https://code.google.com/p/pingus/source/detail?r=ad5599b4822d
Modified:
/src/editor/viewport.cpp
/src/pingus/global_event.cpp
=======================================
--- /src/editor/viewport.cpp Sat Jul 26 19:58:06 2014 UTC
+++ /src/editor/viewport.cpp Sat Jul 26 23:54:13 2014 UTC
@@ -112,7 +112,7 @@
void
Viewport::on_primary_button_press(int x_, int y_)
{
- const Uint8* keystate = SDL_GetKeyboardState(nullptr);
+ SDL_Keymod key_modifier = SDL_GetModState();
mouse_world_pos = screen2world(x_, y_);
mouse_screen_pos = Vector2i(x_, y_);
@@ -126,7 +126,7 @@
if (selection.find(obj) == selection.end())
{
// if the clicked on object isn't selected, select it and deselect
the rest
- if (keystate[SDLK_LSHIFT] || keystate[SDLK_RSHIFT])
+ if (key_modifier & KMOD_SHIFT)
{
selection.insert(obj);
selection_changed(selection);
@@ -140,7 +140,7 @@
}
else
{
- if (keystate[SDLK_LSHIFT] || keystate[SDLK_RSHIFT])
+ if (key_modifier & KMOD_SHIFT)
{
// if object is already selected and shift is pressed remove
// it from the selection
@@ -164,7 +164,7 @@
highlighted_area.left = highlighted_area.right = mouse_world_pos.x;
highlighted_area.top = highlighted_area.bottom = mouse_world_pos.y;
- if (!keystate[SDLK_LSHIFT] && !keystate[SDLK_RSHIFT])
+ if (!(key_modifier & KMOD_LSHIFT) && !(key_modifier & KMOD_RSHIFT))
{
clear_selection();
selection_changed(selection);
=======================================
--- /src/pingus/global_event.cpp Sat Jul 26 19:58:06 2014 UTC
+++ /src/pingus/global_event.cpp Sat Jul 26 23:54:13 2014 UTC
@@ -33,8 +33,6 @@
void
GlobalEvent::on_button_press(const SDL_KeyboardEvent& event)
{
- const Uint8* keystate = SDL_GetKeyboardState(nullptr);
-
switch (event.keysym.sym)
{
case SDLK_F10:
@@ -42,7 +40,7 @@
break;
case SDLK_RETURN:
- if (keystate[SDLK_LALT] || keystate[SDLK_RALT])
+ if (event.keysym.mod & KMOD_ALT)
{
config_manager.set_fullscreen(!config_manager.get_fullscreen());
}
@@ -51,7 +49,7 @@
case SDLK_TAB: // unlock mouse grab if Alt-Tab is pressed to allow the
user to change windows
if (config_manager.get_mouse_grab())
{
- if (keystate[SDLK_LALT] || keystate[SDLK_RALT])
+ if (event.keysym.mod & KMOD_ALT)
{
// FIXME: should suspend the grab till the user clicks the
// window again, not completely disable it
@@ -70,7 +68,7 @@
break;
case SDLK_o:
- if (keystate[SDLK_LCTRL] || keystate[SDLK_RCTRL])
+ if (event.keysym.mod & KMOD_CTRL)
{
if
(!dynamic_cast<OptionMenu*>(ScreenManager::instance()->get_current_screen().get()))
ScreenManager::instance()->push_screen(std::make_shared<OptionMenu>());
@@ -110,7 +108,7 @@
break;
case SDLK_m:
- if (keystate[SDLK_LCTRL] || keystate[SDLK_RCTRL])
+ if (event.keysym.mod & KMOD_CTRL)
{
log_info("Developer Mode: %1%", globals::developer_mode);
globals::developer_mode = !globals::developer_mode;
@@ -118,7 +116,7 @@
break;
case SDLK_g:
- if (keystate[SDLK_LCTRL] || keystate[SDLK_RCTRL])
+ if (event.keysym.mod & KMOD_CTRL)
{
config_manager.set_mouse_grab(!config_manager.get_mouse_grab());
}
==============================================================================
Revision: 724a09bc5a1d
Author: Ingo Ruhnke <address@hidden>
Date: Sat Jul 26 23:58:44 2014 UTC
Log: Enable BLEND render mode, fixed incorrect color on rect and line
drawing
https://code.google.com/p/pingus/source/detail?r=724a09bc5a1d
Modified:
/src/engine/display/sdl_framebuffer.cpp
=======================================
--- /src/engine/display/sdl_framebuffer.cpp Sat Jul 26 21:47:15 2014 UTC
+++ /src/engine/display/sdl_framebuffer.cpp Sat Jul 26 23:58:44 2014 UTC
@@ -172,7 +172,10 @@
dstrect.w = surface.get_width();
dstrect.h = surface.get_height();
+ // FIXME: push render state
+ SDL_SetRenderDrawBlendMode(m_renderer, SDL_BLENDMODE_BLEND);
SDL_RenderCopy(m_renderer, texture, nullptr, &dstrect);
+ // FIXME: pop render state
}
void
@@ -193,17 +196,20 @@
sdlsrcrect.w = static_cast<Uint16>(srcrect.get_width());
sdlsrcrect.h = static_cast<Uint16>(srcrect.get_height());
+ // FIXME: push render state
+ SDL_SetRenderDrawBlendMode(m_renderer, SDL_BLENDMODE_BLEND);
SDL_RenderCopy(m_renderer, texture, &sdlsrcrect, &dstrect);
+ // FIXME: pop render state
}
void
SDLFramebuffer::draw_line(const Vector2i& pos1, const Vector2i& pos2,
const Color& color)
{
- SDL_SetRenderDrawColor(m_renderer,
- color.r, color.b, color.g, color.a);
- SDL_RenderDrawLine(m_renderer,
- pos1.x, pos1.y,
- pos2.x, pos2.y);
+ // FIXME: push render state
+ SDL_SetRenderDrawBlendMode(m_renderer, SDL_BLENDMODE_BLEND);
+ SDL_SetRenderDrawColor(m_renderer, color.r, color.g, color.b, color.a);
+ SDL_RenderDrawLine(m_renderer, pos1.x, pos1.y, pos2.x, pos2.y);
+ // FIXME: pop render state
}
void
@@ -218,8 +224,11 @@
sdl_rect.w = rect.get_width();
sdl_rect.h = rect.get_height();
- SDL_SetRenderDrawColor(m_renderer, color.r, color.b, color.g, color.a);
+ // FIXME: push render state
+ SDL_SetRenderDrawBlendMode(m_renderer, SDL_BLENDMODE_BLEND);
+ SDL_SetRenderDrawColor(m_renderer, color.r, color.g, color.b, color.a);
SDL_RenderDrawRect(m_renderer, &sdl_rect);
+ // FIXME: pop render state
}
void
@@ -234,7 +243,8 @@
sdl_rect.w = rect.get_width();
sdl_rect.h = rect.get_height();
- SDL_SetRenderDrawColor(m_renderer, color.r, color.b, color.g, color.a);
+ SDL_SetRenderDrawBlendMode(m_renderer, SDL_BLENDMODE_BLEND);
+ SDL_SetRenderDrawColor(m_renderer, color.r, color.g, color.b, color.a);
SDL_RenderFillRect(m_renderer, &sdl_rect);
}
==============================================================================
Revision: ca13c9472f31
Author: Ingo Ruhnke <address@hidden>
Date: Sun Jul 27 00:17:46 2014 UTC
Log: Fixed another scancode/keycode issue
https://code.google.com/p/pingus/source/detail?r=ca13c9472f31
Modified:
/src/pingus/components/playfield.cpp
=======================================
--- /src/pingus/components/playfield.cpp Sat Jul 26 19:58:06 2014 UTC
+++ /src/pingus/components/playfield.cpp Sun Jul 27 00:17:46 2014 UTC
@@ -216,9 +216,8 @@
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])
+ const Uint8* keystate = SDL_GetKeyboardState(nullptr);
+ if (keystate[SDL_SCANCODE_DELETE])
{
CollisionMask mask("other/bash_radius_gfx");
Vector2i p = state.screen2world(mouse_pos);
@@ -226,7 +225,7 @@
p.x - mask.get_width()/2,
p.y - mask.get_height()/2);
}
- else if (keystate[SDLK_INSERT])
+ else if (keystate[SDL_SCANCODE_INSERT])
{
CollisionMask mask("other/bash_radius_gfx");
Vector2i p = state.screen2world(mouse_pos);
@@ -235,7 +234,7 @@
p.y - mask.get_height()/2,
Groundtype::GP_GROUND);
}
- else if (keystate[SDLK_HOME])
+ else if (keystate[SDL_SCANCODE_HOME])
{
CollisionMask mask("other/bash_radius_gfx");
Vector2i p = state.screen2world(mouse_pos);
@@ -244,7 +243,6 @@
p.y - mask.get_height()/2,
Groundtype::GP_BRIDGE);
}
-#endif
}
}
==============================================================================
Revision: 00c92cc70fe3
Author: Ingo Ruhnke <address@hidden>
Date: Sun Jul 27 00:18:02 2014 UTC
Log: Fixed window title and icon
https://code.google.com/p/pingus/source/detail?r=00c92cc70fe3
Modified:
/src/engine/display/opengl/opengl_framebuffer.cpp
/src/engine/display/sdl_framebuffer.cpp
/src/engine/system/sdl_system.cpp
=======================================
--- /src/engine/display/opengl/opengl_framebuffer.cpp Sat Jul 26 19:58:06
2014 UTC
+++ /src/engine/display/opengl/opengl_framebuffer.cpp Sun Jul 27 00:18:02
2014 UTC
@@ -17,6 +17,7 @@
#include "engine/display/opengl/opengl_framebuffer.hpp"
#include <SDL.h>
+#include <SDL_image.h>
#include <sstream>
#include <stdexcept>
@@ -53,7 +54,7 @@
flags |= SDL_WINDOW_RESIZABLE;
}
- m_window = SDL_CreateWindow("Pingus",
+ m_window = SDL_CreateWindow("Pingus " VERSION,
SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
size.width, size.height,
flags);
@@ -63,6 +64,7 @@
msg << "Couldn't set video mode (" << size.width << "x" << size.height
<< "): " << SDL_GetError();
throw std::runtime_error(msg.str());
}
+ SDL_SetWindowIcon(m_window, IMG_Load(Pathname("images/icons/pingus.png",
Pathname::DATA_PATH).get_sys_path().c_str()));
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
=======================================
--- /src/engine/display/sdl_framebuffer.cpp Sat Jul 26 23:58:44 2014 UTC
+++ /src/engine/display/sdl_framebuffer.cpp Sun Jul 27 00:18:02 2014 UTC
@@ -16,6 +16,8 @@
#include "engine/display/sdl_framebuffer.hpp"
+#include <SDL_image.h>
+
#include "engine/display/sdl_framebuffer_surface_impl.hpp"
#include "util/log.hpp"
@@ -282,7 +284,7 @@
flags |= SDL_WINDOW_RESIZABLE;
}
- m_window = SDL_CreateWindow("Pingus",
+ m_window = SDL_CreateWindow("Pingus " VERSION,
SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
size.width, size.height,
flags);
@@ -292,6 +294,7 @@
msg << "Couldn't set video mode (" << size.width << "x" << size.height
<< "): " << SDL_GetError();
throw std::runtime_error(msg.str());
}
+ SDL_SetWindowIcon(m_window, IMG_Load(Pathname("images/icons/pingus.png",
Pathname::DATA_PATH).get_sys_path().c_str()));
m_renderer = SDL_CreateRenderer(m_window, -1, SDL_RENDERER_ACCELERATED);
m_screen = SDL_CreateRGBSurface(0, size.width, size.height, 32,
=======================================
--- /src/engine/system/sdl_system.cpp Sat Jul 26 19:58:06 2014 UTC
+++ /src/engine/system/sdl_system.cpp Sun Jul 27 00:18:02 2014 UTC
@@ -43,10 +43,6 @@
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);
}
==============================================================================
Revision: d4df127a2cfb
Author: Ingo Ruhnke <address@hidden>
Date: Sun Jul 27 00:20:22 2014 UTC
Log: Copy all surface flags in Blitter::create_surface_from_format()
https://code.google.com/p/pingus/source/detail?r=d4df127a2cfb
Modified:
/src/engine/display/blitter.cpp
=======================================
--- /src/engine/display/blitter.cpp Sat Jul 26 21:37:49 2014 UTC
+++ /src/engine/display/blitter.cpp Sun Jul 27 00:20:22 2014 UTC
@@ -218,17 +218,24 @@
surface->format->Bmask,
surface->format->Amask);
-#ifdef OLD_SDL1
- if (surface->flags & SDL_SRCALPHA)
- SDL_SetSurfaceAlphaMod(new_surface, SDL_SRCALPHA,
surface->format->alpha);
+ Uint8 alpha;
+ if (SDL_GetSurfaceAlphaMod(surface, &alpha) == 0)
+ SDL_SetSurfaceAlphaMod(new_surface, alpha);
+
+ SDL_BlendMode blend_mode;
+ if (SDL_GetSurfaceBlendMode(surface, &blend_mode) == 0)
+ SDL_SetSurfaceBlendMode(new_surface, blend_mode);
+
+ Uint8 r, g, b;
+ if (SDL_GetSurfaceColorMod(surface, &r, &g, &b) == 0)
+ SDL_SetSurfaceColorMod(new_surface, r, g, b);
if (surface->format->palette)
- SDL_SetPalette(new_surface, SDL_LOGPAL,
surface->format->palette->colors,
- 0, surface->format->palette->ncolors);
+ SDL_SetSurfacePalette(new_surface, surface->format->palette);
- if (surface->flags & SDL_SRCCOLORKEY)
- SDL_SetColorKey(new_surface, SDL_SRCCOLORKEY,
surface->format->colorkey);
-#endif
+ Uint32 colorkey;
+ if (SDL_GetColorKey(surface, &colorkey) == 0)
+ SDL_SetColorKey(new_surface, SDL_TRUE, colorkey);
return new_surface;
}
==============================================================================
Revision: 670e41e94395
Author: Ingo Ruhnke <address@hidden>
Date: Sun Jul 27 00:38:16 2014 UTC
Log: Fixed up some colorkey handling
https://code.google.com/p/pingus/source/detail?r=670e41e94395
Modified:
/src/engine/display/blitter.cpp
/src/engine/display/surface.cpp
/src/pingus/collision_mask.cpp
/src/pingus/ground_map.cpp
=======================================
--- /src/engine/display/blitter.cpp Sun Jul 27 00:20:22 2014 UTC
+++ /src/engine/display/blitter.cpp Sun Jul 27 00:38:16 2014 UTC
@@ -33,12 +33,12 @@
bpp = surface->format->BytesPerPixel;
if (bpp == 1) {
SDL_Palette* pal = SDL_AllocPalette(256);
-#ifdef OLD_SDL1
+
Uint32 ckey;
int useckey = 0;
- useckey = surface->flags & SDL_SRCCOLORKEY;
-#endif
+ useckey = SDL_GetColorKey(surface, &ckey) == 0;
+
new_surface = SDL_CreateRGBSurface(0, width, height, 8, 0, 0, 0, 0);
SDL_LockSurface(surface);
@@ -49,9 +49,6 @@
new_pitch = new_surface->pitch;
memcpy(pal->colors, 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;
@@ -65,11 +62,11 @@
SDL_UnlockSurface(new_surface);
SDL_SetSurfacePalette(new_surface, pal);
-#ifdef OLD_SDL1
- if (useckey) {
- SDL_SetColorKey(new_surface, SDL_SRCCOLORKEY | SDL_RLEACCEL, ckey);
+ if (useckey)
+ {
+ SDL_SetColorKey(new_surface, SDL_TRUE, ckey);
+ SDL_SetSurfaceRLE(new_surface, SDL_TRUE);
}
-#endif
} else {
int ix, iy;
float fx, fy, fz;
=======================================
--- /src/engine/display/surface.cpp Sat Jul 26 21:37:49 2014 UTC
+++ /src/engine/display/surface.cpp Sun Jul 27 00:38:16 2014 UTC
@@ -295,7 +295,6 @@
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;
@@ -307,8 +306,9 @@
if (impl->surface->format->palette)
{
- if (impl->surface->flags & SDL_SRCCOLORKEY &&
- pixel == impl->surface->format->colorkey)
+ Uint32 colorkey;
+ if (SDL_GetColorKey(impl->surface, &colorkey) == 0 &&
+ pixel == colorkey)
{
return Color(0,0,0,0);
}
@@ -341,9 +341,6 @@
Color color;
SDL_GetRGBA(pixel, get_surface()->format, &color.r, &color.g, &color.b,
&color.a);
return color;
-#else
- return Color();
-#endif
}
Surface
@@ -502,11 +499,8 @@
bool
Surface::has_colorkey() const
{
-#ifdef OLD_SDL1
- return impl->surface->flags & SDL_SRCCOLORKEY;
-#else
- return false;
-#endif
+ Uint32 colorkey;
+ return SDL_GetColorKey(impl->surface, &colorkey) == 0;
}
bool
@@ -518,7 +512,6 @@
void
Surface::print(std::ostream& out)
{
-#ifdef OLD_SDL1
out << boost::format("Pointer: 0x%p\n"
"Rmask: 0x%08x\n"
"Gmask: 0x%08x\n"
@@ -534,18 +527,28 @@
% impl->surface->format->Bmask
% impl->surface->format->Amask
% impl->surface->flags
- % ((impl->surface->flags & SDL_HWSURFACE) ? "HWSURFACE " : "")
- % ((impl->surface->flags & SDL_SWSURFACE) ? "SWSURFACE " : "")
- % ((impl->surface->flags & SDL_SRCCOLORKEY) ? "SRCCOLORKEY " : "")
- % ((impl->surface->flags & SDL_SRCALPHA) ? "SRCALPHA " : "")
% impl->surface->format->palette
% static_cast<int>(impl->surface->format->BitsPerPixel);
- if (impl->surface->flags & SDL_SRCCOLORKEY)
- out << "Colorkey: " <<
static_cast<int>(impl->surface->format->colorkey) << std::endl;
+ Uint32 colorkey;
+ if (SDL_GetColorKey(impl->surface, &colorkey) == 0)
+ {
+ out << "Colorkey: " << boost::format("0x%08x") % colorkey << std::endl;
+ }
+ else
+ {
+ out << "Colorkey: <none>" << std::endl;
+ }
- if (impl->surface->flags & SDL_SRCALPHA)
- out << "Alpha: " << static_cast<int>(impl->surface->format->alpha) <<
std::endl;
+ Uint8 alpha;
+ if (SDL_GetSurfaceAlphaMod(impl->surface, &alpha) == 0)
+ {
+ out << "Alpha: " << static_cast<int>(alpha) << std::endl;
+ }
+ else
+ {
+ out << "Alpha: <none>" << std::endl;
+ }
if (0)
{
@@ -560,7 +563,6 @@
out << std::endl;
SDL_UnlockSurface(impl->surface);
}
-#endif
}
/* EOF */
=======================================
--- /src/pingus/collision_mask.cpp Sat Jul 26 19:58:06 2014 UTC
+++ /src/pingus/collision_mask.cpp Sun Jul 27 00:38:16 2014 UTC
@@ -73,14 +73,14 @@
if (sdl_surface->format->palette)
{
-#ifdef OLD_SDL1
uint8_t* source = static_cast<uint8_t*>(sdl_surface->pixels);
- if (sdl_surface->flags & SDL_SRCCOLORKEY)
+ Uint32 colorkey;
+ if (SDL_GetColorKey(sdl_surface, &colorkey) == 0)
{ // surface with transparent areas
for(int y = 0; y < height; ++y)
for(int x = 0; x < width; ++x)
{
- if (source[y*pitch + x] == sdl_surface->format->colorkey)
+ if (source[y*pitch + x] == colorkey)
buffer[y*width + x] = 0;
else
buffer[y*width + x] = 1;
@@ -90,7 +90,6 @@
{ // completly opaque surface
memset(buffer.get(), 1, width*height);
}
-#endif
}
else if (sdl_surface->format->BitsPerPixel == 24)
{
=======================================
--- /src/pingus/ground_map.cpp Sat Jul 26 19:58:06 2014 UTC
+++ /src/pingus/ground_map.cpp Sun Jul 27 00:38:16 2014 UTC
@@ -201,7 +201,6 @@
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)
@@ -231,7 +230,7 @@
Uint8* target_buf = static_cast<Uint8*>(provider.get_data());
Uint8* source_buf = static_cast<Uint8*>(sprovider.get_data());
-
+ Uint32 colorkey;
if (sprovider.get_surface()->format->BitsPerPixel == 32)
{
for (int y = start_y; y < end_y; ++y)
@@ -252,10 +251,8 @@
}
}
}
- else if (sprovider.get_surface()->flags & SDL_SRCCOLORKEY)
+ else if (SDL_GetColorKey(sprovider.get_surface(), &colorkey) == 0)
{
- Uint32 colorkey = sprovider.get_surface()->format->colorkey;
-
for (int y = start_y; y < end_y; ++y)
{
Uint8* tptr = target_buf + tpitch*(y+y_pos) + 4*(x_pos + start_x);
@@ -294,7 +291,6 @@
sprovider.unlock();
provider.unlock();
-#endif
}
void
==============================================================================
Revision: efa6d5294172
Author: Ingo Ruhnke <address@hidden>
Date: Sun Jul 27 02:14:18 2014 UTC
Log: Some fixes to fullscreen mode, somewhat incomplete
https://code.google.com/p/pingus/source/detail?r=efa6d5294172
Modified:
/src/engine/display/sdl_framebuffer.cpp
=======================================
--- /src/engine/display/sdl_framebuffer.cpp Sun Jul 27 00:18:02 2014 UTC
+++ /src/engine/display/sdl_framebuffer.cpp Sun Jul 27 02:14:18 2014 UTC
@@ -273,39 +273,56 @@
void
SDLFramebuffer::set_video_mode(const Size& size, bool fullscreen, bool
resizable)
{
- Uint32 flags = 0;
-
- if (fullscreen)
+ if (m_window)
{
- flags |= SDL_WINDOW_FULLSCREEN;
+ if (!fullscreen)
+ {
+ SDL_SetWindowSize(m_window, size.width, size.height);
+ SDL_SetWindowFullscreen(m_window, 0);
+ }
+ else
+ {
+ SDL_SetWindowSize(m_window, size.width, size.height);
+ SDL_SetWindowDisplayMode(m_window, nullptr);
+ SDL_SetWindowFullscreen(m_window, SDL_WINDOW_FULLSCREEN);
+ }
}
- else if (resizable)
+ else
{
- flags |= SDL_WINDOW_RESIZABLE;
- }
+ Uint32 flags = 0;
+
+ if (fullscreen)
+ {
+ flags |= SDL_WINDOW_FULLSCREEN;
+ }
+ else if (resizable)
+ {
+ flags |= SDL_WINDOW_RESIZABLE;
+ }
+
+ m_window = SDL_CreateWindow("Pingus " VERSION,
+ 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 << "): " << SDL_GetError();
+ throw std::runtime_error(msg.str());
+ }
+ SDL_SetWindowIcon(m_window,
IMG_Load(Pathname("images/icons/pingus.png",
Pathname::DATA_PATH).get_sys_path().c_str()));
- m_window = SDL_CreateWindow("Pingus " VERSION,
- 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
<< "): " << 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);
}
- SDL_SetWindowIcon(m_window, IMG_Load(Pathname("images/icons/pingus.png",
Pathname::DATA_PATH).get_sys_path().c_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
==============================================================================
Revision: 47bc68215b24
Author: Ingo Ruhnke <address@hidden>
Date: Sun Jul 27 04:14:52 2014 UTC
Log: Added missing <sstream>
https://code.google.com/p/pingus/source/detail?r=47bc68215b24
Modified:
/src/engine/display/sdl_framebuffer.cpp
=======================================
--- /src/engine/display/sdl_framebuffer.cpp Sun Jul 27 02:14:18 2014 UTC
+++ /src/engine/display/sdl_framebuffer.cpp Sun Jul 27 04:14:52 2014 UTC
@@ -17,6 +17,7 @@
#include "engine/display/sdl_framebuffer.hpp"
#include <SDL_image.h>
+#include <sstream>
#include "engine/display/sdl_framebuffer_surface_impl.hpp"
#include "util/log.hpp"
==============================================================================
Revision: 04f0e083a599
Author: Ingo Ruhnke <address@hidden>
Date: Sun Jul 27 15:23:11 2014 UTC
Log: Removed some unused code
https://code.google.com/p/pingus/source/detail?r=04f0e083a599
Modified:
/src/engine/display/sdl_framebuffer.cpp
/src/engine/display/sdl_framebuffer.hpp
=======================================
--- /src/engine/display/sdl_framebuffer.cpp Sun Jul 27 04:14:52 2014 UTC
+++ /src/engine/display/sdl_framebuffer.cpp Sun Jul 27 15:23:11 2014 UTC
@@ -23,99 +23,6 @@
#include "util/log.hpp"
namespace {
-
-typedef void (*draw_pixel_func)(SDL_Surface* screen, int, int, const
Color&);
-
-inline void draw_pixel16(SDL_Surface* screen, int x, int y, const Color& c)
-{
- Uint32 color = SDL_MapRGBA(screen->format, c.r, c.g, c.b, c.a);
-
- if (c.a < 255) {
- Uint16 *p;
- unsigned long dp;
- uint8_t alpha;
-
- // Loses precision for speed
- alpha = static_cast<uint8_t>((255 - c.a) >> 3);
-
- p = &(static_cast<Uint16 *>(screen->pixels))[x + y * screen->w];
- color = (((color << 16) | color) & 0x07E0F81F);
- dp = *p;
- dp = ((dp << 16) | dp) & 0x07E0F81F;
- dp = ((((dp - color) * alpha) >> 5) + color) & 0x07E0F81F;
- *p = static_cast<Uint16>((dp >> 16) | dp);
- } else {
- static_cast<Uint16*>(screen->pixels)[x + y * screen->w] =
static_cast<Uint16>(color);
- }
-}
-
-inline void draw_pixel32(SDL_Surface* screen, int x, int y, const Color& c)
-{
- Uint32 color = SDL_MapRGBA(screen->format, c.r, c.g, c.b, c.a);
-
- if (c.a < 255) {
- Uint32 *p;
- unsigned long sp2;
- unsigned long dp1;
- unsigned long dp2;
- unsigned char alpha;
-
- alpha = static_cast<unsigned char>(255 - c.a);
-
- p = &(static_cast<Uint32*>(screen->pixels))[x + y * screen->w];
-
- sp2 = (color & 0xFF00FF00) >> 8;
- color &= 0x00FF00FF;
-
- dp1 = *p;
- dp2 = (dp1 & 0xFF00FF00) >> 8;
- dp1 &= 0x00FF00FF;
-
- dp1 = ((((dp1 - color) * alpha) >> 8) + color) & 0x00FF00FF;
- dp2 = ((((dp2 - sp2) * alpha) >> 8) + sp2) & 0x00FF00FF;
- *p = static_cast<Uint32>(dp1 | (dp2 << 8));
- } else {
- (static_cast<Uint32*>(screen->pixels))[x + y * screen->w] = color;
- }
-}
-
-draw_pixel_func get_draw_pixel(SDL_Surface* screen)
-{
- switch (screen->format->BitsPerPixel)
- {
- case 16:
- return draw_pixel16;
- case 32:
- return draw_pixel32;
- }
- return NULL;
-}
-
-void draw_vline(SDL_Surface* screen, int x, int y, int length, const
Color& color)
-{
- draw_pixel_func draw_pixel = get_draw_pixel(screen);
- if (!draw_pixel)
- return;
-
- SDL_LockSurface(screen);
- for (int i = 0; i < length; ++i) {
- draw_pixel(screen, x, y + i, color);
- }
- SDL_UnlockSurface(screen);
-}
-
-void draw_hline(SDL_Surface* screen, int x, int y, int length, const
Color& color)
-{
- draw_pixel_func draw_pixel = get_draw_pixel(screen);
- if (!draw_pixel)
- return;
-
- SDL_LockSurface(screen);
- for (int i = 0; i < length; ++i) {
- draw_pixel(screen, x + i, y, color);
- }
- SDL_UnlockSurface(screen);
-}
SDL_Rect Intersection(SDL_Rect* r1, SDL_Rect* r2)
{
@@ -128,14 +35,6 @@
rect.h = static_cast<Uint16>(Math::max(static_cast<int>(endy - rect.y),
0));
return rect;
}
-
-void clip(int& i, int min, int max)
-{
- if (i < min)
- i = min;
- else if (i > max)
- i = max;
-}
} // namespace
@@ -143,16 +42,12 @@
SDLFramebuffer::SDLFramebuffer() :
m_window(nullptr),
m_renderer(nullptr),
- m_screen(nullptr),
- m_texture(nullptr),
cliprect_stack()
{
}
SDLFramebuffer::~SDLFramebuffer()
{
- SDL_DestroyTexture(m_texture);
- SDL_FreeSurface(m_screen);
SDL_DestroyRenderer(m_renderer);
SDL_DestroyWindow(m_window);
}
@@ -314,15 +209,6 @@
SDL_SetWindowIcon(m_window,
IMG_Load(Pathname("images/icons/pingus.png",
Pathname::DATA_PATH).get_sys_path().c_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);
}
}
=======================================
--- /src/engine/display/sdl_framebuffer.hpp Sat Jul 26 19:58:06 2014 UTC
+++ /src/engine/display/sdl_framebuffer.hpp Sun Jul 27 15:23:11 2014 UTC
@@ -24,8 +24,6 @@
private:
SDL_Window* m_window;
SDL_Renderer* m_renderer;
- SDL_Surface* m_screen;
- SDL_Texture* m_texture;
std::vector<SDL_Rect> cliprect_stack;
public:
==============================================================================
Revision: 84a2b4fd67ea
Author: Ingo Ruhnke <address@hidden>
Date: Sun Jul 27 16:32:00 2014 UTC
Log: Fixed screenshoting for SDLFramebuffer, removed HAVE_OPENGL define
https://code.google.com/p/pingus/source/detail?r=84a2b4fd67ea
Modified:
/SConscript
/src/engine/display/delta/delta_framebuffer.cpp
/src/engine/display/delta/delta_framebuffer.hpp
/src/engine/display/display.cpp
/src/engine/display/framebuffer.hpp
/src/engine/display/null_framebuffer.hpp
/src/engine/display/opengl/opengl_framebuffer.cpp
/src/engine/display/opengl/opengl_framebuffer.hpp
/src/engine/display/screenshot.cpp
/src/engine/display/screenshot.hpp
/src/engine/display/sdl_framebuffer.cpp
/src/engine/display/sdl_framebuffer.hpp
/src/pingus/screens/option_menu.cpp
=======================================
--- /SConscript Sat Jul 26 18:07:52 2014 UTC
+++ /SConscript Sun Jul 27 16:32:00 2014 UTC
@@ -127,8 +127,7 @@
else:
self.reports += " * OpenGL support: enabled\n"
self.conf.env.Append(optional_sources =
['src/engine/display/opengl/opengl_framebuffer_surface_impl.cpp',
- 'src/engine/display/opengl/opengl_framebuffer.cpp'
],
- CPPDEFINES = [('HAVE_OPENGL', 1)])
+ 'src/engine/display/opengl/opengl_framebuffer.cpp'
])
if sys.platform == "darwin":
self.conf.env.Append(LINKFLAGS =
[ '-framework', 'OpenGL', '-framework', 'Cocoa' ])
else:
=======================================
--- /src/engine/display/delta/delta_framebuffer.cpp Fri Oct 14 02:03:23
2011 UTC
+++ /src/engine/display/delta/delta_framebuffer.cpp Sun Jul 27 16:32:00
2014 UTC
@@ -40,6 +40,12 @@
{
return framebuffer->create_surface(surface);
}
+
+Surface
+DeltaFramebuffer::make_screenshot() const
+{
+ return framebuffer->make_screenshot();
+}
void
DeltaFramebuffer::set_video_mode(const Size& size, bool fullscreen, bool
resizable)
=======================================
--- /src/engine/display/delta/delta_framebuffer.hpp Fri Oct 14 02:03:23
2011 UTC
+++ /src/engine/display/delta/delta_framebuffer.hpp Sun Jul 27 16:32:00
2014 UTC
@@ -34,6 +34,8 @@
FramebufferSurface create_surface(const Surface& surface);
+ Surface make_screenshot() const override;
+
void set_video_mode(const Size& size, bool fullscreen, bool resizable);
bool is_fullscreen() const;
bool is_resizable() const;
=======================================
--- /src/engine/display/display.cpp Sat Jul 26 19:58:06 2014 UTC
+++ /src/engine/display/display.cpp Sun Jul 27 16:32:00 2014 UTC
@@ -22,9 +22,7 @@
#include "engine/display/sdl_framebuffer.hpp"
#include "engine/screen/screen_manager.hpp"
#include "pingus/globals.hpp"
-#ifdef HAVE_OPENGL
-# include "engine/display/opengl/opengl_framebuffer.hpp"
-#endif
+#include "engine/display/opengl/opengl_framebuffer.hpp"
#include "engine/display/delta/delta_framebuffer.hpp"
#include "engine/display/null_framebuffer.hpp"
#include "util/log.hpp"
@@ -95,12 +93,8 @@
switch (framebuffer_type)
{
case OPENGL_FRAMEBUFFER:
-#ifdef HAVE_OPENGL
s_framebuffer = std::unique_ptr<Framebuffer>(new
OpenGLFramebuffer());
s_framebuffer->set_video_mode(size, fullscreen, resizable);
-#else
- raise_exception(std::runtime_error, "OpenGL support was not compiled
in");
-#endif
break;
case NULL_FRAMEBUFFER:
=======================================
--- /src/engine/display/framebuffer.hpp Fri Oct 14 02:03:23 2011 UTC
+++ /src/engine/display/framebuffer.hpp Sun Jul 27 16:32:00 2014 UTC
@@ -36,6 +36,8 @@
virtual FramebufferSurface create_surface(const Surface& surface) =0;
+ virtual Surface make_screenshot() const =0;
+
virtual void set_video_mode(const Size& size, bool fullscreen, bool
resizable) =0;
virtual bool is_fullscreen() const =0;
virtual bool is_resizable() const =0;
=======================================
--- /src/engine/display/null_framebuffer.hpp Fri Oct 14 02:03:23 2011 UTC
+++ /src/engine/display/null_framebuffer.hpp Sun Jul 27 16:32:00 2014 UTC
@@ -32,6 +32,8 @@
~NullFramebuffer();
FramebufferSurface create_surface(const Surface& surface);
+
+ Surface make_screenshot() const override { return Surface(); }
void set_video_mode(const Size& size, bool fullscreen, bool resizable);
bool is_fullscreen() const;
=======================================
--- /src/engine/display/opengl/opengl_framebuffer.cpp Sun Jul 27 00:18:02
2014 UTC
+++ /src/engine/display/opengl/opengl_framebuffer.cpp Sun Jul 27 16:32:00
2014 UTC
@@ -39,6 +39,22 @@
{
return FramebufferSurface(new
OpenGLFramebufferSurfaceImpl(surface.get_surface()));
}
+
+Surface
+OpenGLFramebuffer::make_screenshot() const
+{
+ Size size = get_size();
+
+ glPixelStorei(GL_PACK_ALIGNMENT, 1);
+ std::unique_ptr<uint8_t[]> buffer(new uint8_t[size.width * size.height *
4]);
+ glReadPixels(0, 0, size.width, size.height, GL_RGBA, GL_UNSIGNED_BYTE,
buffer.get());
+
+ Surface screenshot(size.width, size.height);
+#ifdef OLD_SDL1
+ // insert code
+#endif
+ return screenshot;
+}
void
OpenGLFramebuffer::set_video_mode(const Size& size, bool fullscreen, bool
resizable)
=======================================
--- /src/engine/display/opengl/opengl_framebuffer.hpp Sat Jul 26 19:58:06
2014 UTC
+++ /src/engine/display/opengl/opengl_framebuffer.hpp Sun Jul 27 16:32:00
2014 UTC
@@ -5,12 +5,12 @@
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-//
+//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
-//
+//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
@@ -31,11 +31,13 @@
FramebufferSurface create_surface(const Surface& surface);
+ Surface make_screenshot() const override;
+
void set_video_mode(const Size& size, bool fullscreen, bool resizable);
bool is_fullscreen() const;
bool is_resizable() const;
void flip();
-
+
void push_cliprect(const Rect&);
void pop_cliprect();
=======================================
--- /src/engine/display/screenshot.cpp Sat Jul 26 19:58:06 2014 UTC
+++ /src/engine/display/screenshot.cpp Sun Jul 27 16:32:00 2014 UTC
@@ -20,10 +20,11 @@
#include <assert.h>
#include <png.h>
-#ifdef HAVE_OPENGL
#include <SDL_opengl.h>
-#endif
+#include "engine/display/display.hpp"
+#include "engine/display/framebuffer.hpp"
+#include "engine/display/surface.hpp"
#include "pingus/gettext.h"
#include "util/log.hpp"
#include "util/system.hpp"
@@ -33,116 +34,23 @@
std::string
Screenshot::make_screenshot()
{
- std::string filename = get_filename();
-
- log_info("Screenshot: Saving screenshot to: %1%", filename);
-#ifdef OLD_SDL1
- save(SDL_GetVideoSurface(), filename);
-#endif
- log_info("Screenshot: Screenshot is done.");
-
- return filename;
-}
-
-void
-Screenshot::save(SDL_Surface* surface, const std::string& filename)
-{
- std::unique_ptr<uint8_t[]> buffer(new uint8_t[surface->w * surface->h *
3]);
-
-#ifdef HAVE_OPENGL
- if(surface->flags & SDL_WINDOW_OPENGL)
+ Surface screen = Display::get_framebuffer()->make_screenshot();
+ if (screen)
{
- glPixelStorei(GL_PACK_ALIGNMENT, 1);
- glReadPixels(0, 0, surface->w, surface->h, GL_RGB, GL_UNSIGNED_BYTE,
buffer.get());
- save_png(filename, buffer.get(), surface->w, surface->h, true);
+ std::string filename = get_filename();
+ log_info("Screenshot: Saving screenshot to: %1%", filename);
+ save_png(filename, screen.get_data(), screen.get_width(),
screen.get_height(), screen.get_pitch());
+ log_info("Screenshot: Screenshot is done.");
+ return filename;
}
else
-#endif
{
- SDL_LockSurface(surface);
-
- switch(surface->format->BitsPerPixel)
- {
- case 16: // 16bit
- {
- uint8_t* pixels = static_cast<uint8_t*>(surface->pixels);
- for (int y = 0; y < surface->h; ++y)
- for (int x = 0; x < surface->w; ++x)
- {
- int i = (y * surface->w + x);
- SDL_GetRGB(*(reinterpret_cast<uint16_t*>(pixels + y *
surface->pitch + x*2)),
- surface->format,
- buffer.get() + i*3 + 0, buffer.get() + i*3 + 1,
buffer.get() + i*3 + 2);
- }
- break;
- }
-
- case 24: // 24bit
- {
- uint8_t* pixels = static_cast<uint8_t*>(surface->pixels);
- for (int y = 0; y < surface->h; ++y)
- for (int x = 0; x < surface->w; ++x)
- {
- int i = (y * surface->w + x);
- SDL_GetRGB(*(reinterpret_cast<uint32_t*>(pixels + y *
surface->pitch + x*3)),
- surface->format,
- buffer.get() + i*3 + 0, buffer.get() + i*3 + 1,
buffer.get() + i*3 + 2);
- }
- break;
- }
-
- case 32: // 32bit
- {
- uint8_t* pixels = static_cast<uint8_t*>(surface->pixels);
- for (int y = 0; y < surface->h; ++y)
- for (int x = 0; x < surface->w; ++x)
- {
- int i = (y * surface->w + x);
- SDL_GetRGB(*(reinterpret_cast<uint32_t*>(pixels + y *
surface->pitch + x*4)),
- surface->format,
- buffer.get() + i*3 + 0, buffer.get() + i*3 + 1,
buffer.get() + i*3 + 2);
- }
- break;
- }
- default:
- log_info("BitsPerPixel: %1%", int(surface->format->BitsPerPixel));
- assert(!"Unknown color format");
- break;
- }
-
- save_png(filename, buffer.get(), surface->w, surface->h);
-
- SDL_UnlockSurface(surface);
+ return std::string();
}
}
void
-Screenshot::save_ppm(const std::string& filename, uint8_t* buffer, int
width, int height)
-{
- FILE* out = fopen(filename.c_str(), "wb");
-
- if (!out)
- {
- perror(filename.c_str());
- log_info("Screenshot: Couldn't write file: %1%", filename);
- return;
- }
-
- fprintf(out,
- "P6\n"
- "# CREATOR: Pingus %s\n"
- "%d %d\n"
- "255\n",
- VERSION,
- width,
- height);
-
- fwrite(buffer, sizeof(unsigned char), width * height * 3, out);
- fclose(out);
-}
-
-void
-Screenshot::save_png(const std::string& filename, uint8_t* buffer, int
width, int height, bool flipvertically)
+Screenshot::save_png(const std::string& filename, uint8_t* buffer, int
width, int height, int pitch)
{
FILE* fp;
png_structp png_ptr;
@@ -187,19 +95,19 @@
PNG_FILTER_TYPE_DEFAULT);
png_write_info(png_ptr, info_ptr);
-
- if (flipvertically){
- for (int i = height-1; i >= 0; --i)
+ {
+ std::unique_ptr<uint8_t[]> row{ new uint8_t[width * 3] };
+ for (int y = 0; y < height; ++y)
{
- png_write_row(png_ptr, buffer + i * width * 3);
- }
- } else {
- for (int i = 0; i < height; ++i)
- {
- png_write_row(png_ptr, buffer + i * width * 3);
+ for(int x = 0; x < width; ++x)
+ {
+ row[3*x + 0] = (buffer + y * pitch)[4*x + 3];
+ row[3*x + 1] = (buffer + y * pitch)[4*x + 2];
+ row[3*x + 2] = (buffer + y * pitch)[4*x + 1];
+ }
+ png_write_row(png_ptr, row.get());
}
}
-
png_write_end(png_ptr, info_ptr);
// clean up after the write, and free any memory allocated
=======================================
--- /src/engine/display/screenshot.hpp Sat Sep 3 19:54:44 2011 UTC
+++ /src/engine/display/screenshot.hpp Sun Jul 27 16:32:00 2014 UTC
@@ -30,11 +30,9 @@
public:
static std::string make_screenshot();
- static void save(SDL_Surface* surface, const std::string& filename);
- /** buffer must be RGB and width*height*3 large */
- static void save_ppm(const std::string& filename, uint8_t* buffer, int
width, int height);
- static void save_png(const std::string& filename, uint8_t* buffer, int
width, int height, bool flipvertically = false);
+ /** buffer must be RGBX and width*height*4 large */
+ static void save_png(const std::string& filename, uint8_t* buffer, int
width, int height, int pitch);
private:
Screenshot();
=======================================
--- /src/engine/display/sdl_framebuffer.cpp Sun Jul 27 15:23:11 2014 UTC
+++ /src/engine/display/sdl_framebuffer.cpp Sun Jul 27 16:32:00 2014 UTC
@@ -5,12 +5,12 @@
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-//
+//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
-//
+//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
@@ -57,6 +57,23 @@
{
return FramebufferSurface(new SDLFramebufferSurfaceImpl(m_renderer,
surface.get_surface()));
}
+
+Surface
+SDLFramebuffer::make_screenshot() const
+{
+ Size size = get_size();
+ Surface screenshot(size.width, size.height);
+ int ret = SDL_RenderReadPixels(m_renderer, nullptr,
+ SDL_PIXELFORMAT_RGBX8888,
+ screenshot.get_data(),
+ screenshot.get_pitch());
+ if (ret != 0)
+ {
+ log_error("%1%", SDL_GetError());
+ }
+
+ return screenshot;
+}
void
SDLFramebuffer::draw_surface(const FramebufferSurface& surface, const
Vector2i& pos)
@@ -86,7 +103,7 @@
dstrect.x = static_cast<Sint16>(pos.x);
dstrect.y = static_cast<Sint16>(pos.y);
dstrect.w = srcrect.get_width();
- dstrect.h = srcrect.get_height();
+ dstrect.h = srcrect.get_height();
SDL_Rect sdlsrcrect;
sdlsrcrect.x = static_cast<Sint16>(srcrect.left);
@@ -237,7 +254,7 @@
{
sdl_rect = Intersection(&cliprect_stack.back(), &sdl_rect);
}
-
+
cliprect_stack.push_back(sdl_rect);
SDL_RenderSetClipRect(m_renderer, &cliprect_stack.back());
}
=======================================
--- /src/engine/display/sdl_framebuffer.hpp Sun Jul 27 15:23:11 2014 UTC
+++ /src/engine/display/sdl_framebuffer.hpp Sun Jul 27 16:32:00 2014 UTC
@@ -32,6 +32,8 @@
FramebufferSurface create_surface(const Surface& surface);
+ Surface make_screenshot() const override;
+
void set_video_mode(const Size& size, bool fullscreen, bool resizable);
bool is_fullscreen() const;
bool is_resizable() const;
=======================================
--- /src/pingus/screens/option_menu.cpp Sun Jul 27 03:58:39 2014 UTC
+++ /src/pingus/screens/option_menu.cpp Sun Jul 27 16:32:00 2014 UTC
@@ -130,17 +130,13 @@
ChoiceBox* renderer_box = new ChoiceBox(Rect());
renderer_box->add_choice("sdl");
renderer_box->add_choice("delta");
-#ifdef HAVE_OPENGL
renderer_box->add_choice("opengl");
-#endif
switch(config_manager.get_renderer())
{
case SDL_FRAMEBUFFER: renderer_box->set_current_choice(0); break;
case DELTA_FRAMEBUFFER: renderer_box->set_current_choice(1); break;
-#ifdef HAVE_OPENGL
case OPENGL_FRAMEBUFFER: renderer_box->set_current_choice(2); break;
-#endif
default: assert(!"unknown renderer type");
}
==============================================================================
Revision: 6430553e4cee
Author: Ingo Ruhnke <address@hidden>
Date: Sun Jul 27 16:36:35 2014 UTC
Log: Use SDL_GetRendererOutputSize() instead of window size for
screenshots
https://code.google.com/p/pingus/source/detail?r=6430553e4cee
Modified:
/src/engine/display/sdl_framebuffer.cpp
=======================================
--- /src/engine/display/sdl_framebuffer.cpp Sun Jul 27 16:32:00 2014 UTC
+++ /src/engine/display/sdl_framebuffer.cpp Sun Jul 27 16:36:35 2014 UTC
@@ -61,18 +61,26 @@
Surface
SDLFramebuffer::make_screenshot() const
{
- Size size = get_size();
- Surface screenshot(size.width, size.height);
- int ret = SDL_RenderReadPixels(m_renderer, nullptr,
- SDL_PIXELFORMAT_RGBX8888,
- screenshot.get_data(),
- screenshot.get_pitch());
- if (ret != 0)
+ Size size;
+ if (SDL_GetRendererOutputSize(m_renderer, &size.width, &size.height) !=
0)
{
- log_error("%1%", SDL_GetError());
+ log_error("SDL_GetRenderOutputSize failed: %1%", SDL_GetError());
+ return Surface();
}
+ else
+ {
+ Surface screenshot(size.width, size.height);
+ int ret = SDL_RenderReadPixels(m_renderer, nullptr,
+ SDL_PIXELFORMAT_RGBX8888,
+ screenshot.get_data(),
+ screenshot.get_pitch());
+ if (ret != 0)
+ {
+ log_error("%1%", SDL_GetError());
+ }
- return screenshot;
+ return screenshot;
+ }
}
void
==============================================================================
Revision: 39ab90dc1037
Author: Ingo Ruhnke <address@hidden>
Date: Sun Jul 27 17:18:40 2014 UTC
Log: Swapped Screenshot subpixels around
https://code.google.com/p/pingus/source/detail?r=39ab90dc1037
Modified:
/src/engine/display/screenshot.cpp
/src/engine/display/sdl_framebuffer.cpp
=======================================
--- /src/engine/display/screenshot.cpp Sun Jul 27 16:32:00 2014 UTC
+++ /src/engine/display/screenshot.cpp Sun Jul 27 17:18:40 2014 UTC
@@ -101,9 +101,9 @@
{
for(int x = 0; x < width; ++x)
{
- row[3*x + 0] = (buffer + y * pitch)[4*x + 3];
- row[3*x + 1] = (buffer + y * pitch)[4*x + 2];
- row[3*x + 2] = (buffer + y * pitch)[4*x + 1];
+ row[3*x + 0] = (buffer + y * pitch)[4*x + 0];
+ row[3*x + 1] = (buffer + y * pitch)[4*x + 1];
+ row[3*x + 2] = (buffer + y * pitch)[4*x + 2];
}
png_write_row(png_ptr, row.get());
}
=======================================
--- /src/engine/display/sdl_framebuffer.cpp Sun Jul 27 16:36:35 2014 UTC
+++ /src/engine/display/sdl_framebuffer.cpp Sun Jul 27 17:18:40 2014 UTC
@@ -71,7 +71,7 @@
{
Surface screenshot(size.width, size.height);
int ret = SDL_RenderReadPixels(m_renderer, nullptr,
- SDL_PIXELFORMAT_RGBX8888,
+ SDL_PIXELFORMAT_ABGR8888,
screenshot.get_data(),
screenshot.get_pitch());
if (ret != 0)
==============================================================================
Revision: eac5e3ce0967
Author: Ingo Ruhnke <address@hidden>
Date: Sun Jul 27 18:10:17 2014 UTC
Log: Implemented mouse grab stuff for SDLFramebuffer
https://code.google.com/p/pingus/source/detail?r=eac5e3ce0967
Modified:
/src/engine/display/display.cpp
/src/engine/display/display.hpp
/src/engine/display/framebuffer.hpp
/src/engine/display/sdl_framebuffer.cpp
/src/engine/display/sdl_framebuffer.hpp
/src/pingus/components/playfield.cpp
=======================================
--- /src/engine/display/display.cpp Sun Jul 27 16:32:00 2014 UTC
+++ /src/engine/display/display.cpp Sun Jul 27 18:10:17 2014 UTC
@@ -82,6 +82,12 @@
{
return s_framebuffer->is_resizable();
}
+
+bool
+Display::has_grab()
+{
+ return s_framebuffer->has_grab();
+}
void
Display::create_window(FramebufferType framebuffer_type, const Size& size,
bool fullscreen, bool resizable)
=======================================
--- /src/engine/display/display.hpp Fri Oct 14 02:03:23 2011 UTC
+++ /src/engine/display/display.hpp Sun Jul 27 18:10:17 2014 UTC
@@ -46,6 +46,7 @@
static bool is_fullscreen();
static bool is_resizable();
+ static bool has_grab();
static Framebuffer* get_framebuffer();
=======================================
--- /src/engine/display/framebuffer.hpp Sun Jul 27 16:32:00 2014 UTC
+++ /src/engine/display/framebuffer.hpp Sun Jul 27 18:10:17 2014 UTC
@@ -41,6 +41,7 @@
virtual void set_video_mode(const Size& size, bool fullscreen, bool
resizable) =0;
virtual bool is_fullscreen() const =0;
virtual bool is_resizable() const =0;
+ virtual bool has_grab() const { return false; }
virtual void flip() =0;
virtual void push_cliprect(const Rect&) =0;
=======================================
--- /src/engine/display/sdl_framebuffer.cpp Sun Jul 27 17:18:40 2014 UTC
+++ /src/engine/display/sdl_framebuffer.cpp Sun Jul 27 18:10:17 2014 UTC
@@ -248,6 +248,12 @@
{
return SDL_GetWindowFlags(m_window) & SDL_WINDOW_RESIZABLE;
}
+
+bool
+SDLFramebuffer::has_grab() const
+{
+ return SDL_GetWindowGrab(m_window);
+}
void
SDLFramebuffer::push_cliprect(const Rect& rect)
=======================================
--- /src/engine/display/sdl_framebuffer.hpp Sun Jul 27 16:32:00 2014 UTC
+++ /src/engine/display/sdl_framebuffer.hpp Sun Jul 27 18:10:17 2014 UTC
@@ -30,28 +30,29 @@
SDLFramebuffer();
~SDLFramebuffer();
- FramebufferSurface create_surface(const Surface& surface);
+ FramebufferSurface create_surface(const Surface& surface) override;
Surface make_screenshot() const override;
- void set_video_mode(const Size& size, bool fullscreen, bool resizable);
- bool is_fullscreen() const;
- bool is_resizable() const;
- void flip();
+ void set_video_mode(const Size& size, bool fullscreen, bool resizable)
override;
+ bool is_fullscreen() const override;
+ bool is_resizable() const override;
+ bool has_grab() const override;
+ void flip() override;
void update_rects(const std::vector<Rect>& rects);
- void push_cliprect(const Rect&);
- void pop_cliprect();
+ void push_cliprect(const Rect&) override;
+ void pop_cliprect() override;
- void draw_surface(const FramebufferSurface& src, const Vector2i& pos);
- void draw_surface(const FramebufferSurface& src, const Rect& srcrect,
const Vector2i& pos);
+ void draw_surface(const FramebufferSurface& src, const Vector2i& pos)
override;
+ void draw_surface(const FramebufferSurface& src, const Rect& srcrect,
const Vector2i& pos) override;
- void draw_line(const Vector2i& pos1, const Vector2i& pos2, const Color&
color);
+ void draw_line(const Vector2i& pos1, const Vector2i& pos2, const Color&
color) override;
- void draw_rect(const Rect& rect, const Color& color);
- void fill_rect(const Rect& rect, const Color& color);
+ void draw_rect(const Rect& rect, const Color& color) override;
+ void fill_rect(const Rect& rect, const Color& color) override;
- Size get_size() const;
+ Size get_size() const override;
private:
SDLFramebuffer (const SDLFramebuffer&);
=======================================
--- /src/pingus/components/playfield.cpp Sun Jul 27 00:17:46 2014 UTC
+++ /src/pingus/components/playfield.cpp Sun Jul 27 18:10:17 2014 UTC
@@ -139,8 +139,7 @@
}
}
-#ifdef OLD_SDL1
- if (globals::auto_scrolling && (Display::is_fullscreen() ||
SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_ON))
+ if (globals::auto_scrolling && (Display::is_fullscreen() ||
Display::has_grab()))
{
scroll_speed = static_cast<int>(800 * delta);
@@ -162,7 +161,6 @@
state.set_pos(state.get_pos() + Vector2i(0, scroll_speed));
}
}
-#endif
}
void
==============================================================================
Revision: cc9ee03e5e4a
Author: Ingo Ruhnke <address@hidden>
Date: Sun Jul 27 19:17:47 2014 UTC
Log: Implemented SDL2 text/unicode handling
https://code.google.com/p/pingus/source/detail?r=cc9ee03e5e4a
Modified:
/src/editor/inputbox.cpp
/src/editor/inputbox.hpp
/src/engine/gui/component.hpp
/src/engine/gui/group_component.cpp
/src/engine/gui/group_component.hpp
/src/engine/gui/gui_manager.cpp
/src/engine/input/control.hpp
/src/engine/input/controller.cpp
/src/engine/input/controller.hpp
/src/engine/input/event.hpp
/src/engine/input/sdl_driver.cpp
/src/engine/screen/gui_screen.cpp
=======================================
--- /src/editor/inputbox.cpp Sat Jul 26 19:58:06 2014 UTC
+++ /src/editor/inputbox.cpp Sun Jul 27 19:17:47 2014 UTC
@@ -71,16 +71,13 @@
on_change(text);
on_enter(text);
}
- else
- {
-#ifdef OLD_SDL1
- if (ev.keysym.unicode)
- {
- text += UTF8::encode_utf8(ev.keysym.unicode);
- on_change(text);
- }
-#endif
- }
+}
+
+void
+Inputbox::on_text_input(const Input::TextInputEvent& ev)
+{
+ text += ev.text;
+ on_change(text);
}
} // namespace Editor
=======================================
--- /src/editor/inputbox.hpp Sat Jul 26 18:49:11 2014 UTC
+++ /src/editor/inputbox.hpp Sun Jul 27 19:17:47 2014 UTC
@@ -37,6 +37,7 @@
void set_text(const std::string& text);
std::string get_text() const { return text; }
void on_key_pressed(const Input::KeyboardEvent& ev);
+ void on_text_input(const Input::TextInputEvent& ev);
void update_layout() {}
=======================================
--- /src/engine/gui/component.hpp Wed Sep 7 11:00:46 2011 UTC
+++ /src/engine/gui/component.hpp Sun Jul 27 19:17:47 2014 UTC
@@ -86,6 +86,8 @@
/** Emitted whenever a keyboard character is pressed. Only certain
components should implement this */
virtual void on_key_pressed(const Input::KeyboardEvent& ev) {}
+
+ virtual void on_text_input(const Input::TextInputEvent& ev) {}
GroupComponent* get_parent() const;
void set_parent(GroupComponent* p);
=======================================
--- /src/engine/gui/group_component.cpp Wed Sep 7 11:00:46 2011 UTC
+++ /src/engine/gui/group_component.cpp Sun Jul 27 19:17:47 2014 UTC
@@ -186,6 +186,17 @@
else if (mouse_over_comp)
mouse_over_comp->on_key_pressed(ev);
}
+
+void
+GroupComponent::on_text_input(const Input::TextInputEvent& ev)
+{
+ if (grabbed_comp)
+ grabbed_comp->on_text_input(ev);
+ else if (focused_comp)
+ focused_comp->on_text_input(ev);
+ else if (mouse_over_comp)
+ mouse_over_comp->on_text_input(ev);
+}
void
GroupComponent::on_pointer_move(int x, int y)
=======================================
--- /src/engine/gui/group_component.hpp Tue Oct 11 15:42:27 2011 UTC
+++ /src/engine/gui/group_component.hpp Sun Jul 27 19:17:47 2014 UTC
@@ -62,6 +62,8 @@
void on_key_pressed(const Input::KeyboardEvent& ev);
+ void on_text_input(const Input::TextInputEvent& ev);
+
void on_pointer_enter();
void on_pointer_leave();
=======================================
--- /src/engine/gui/gui_manager.cpp Sun Jul 27 03:58:39 2014 UTC
+++ /src/engine/gui/gui_manager.cpp Sun Jul 27 19:17:47 2014 UTC
@@ -78,6 +78,10 @@
// AxisEvents can be ignored in the GUI, they are handled elsewhere
log_debug("GUIManager: AxisEvent: %1%", event.axis.dir);
break;
+
+ case Input::TEXT_INPUT_EVENT_TYPE:
+ on_text_input(event.text);
+ break;
case Input::KEYBOARD_EVENT_TYPE:
if (event.keyboard.state)
=======================================
--- /src/engine/input/control.hpp Wed Sep 7 11:00:46 2011 UTC
+++ /src/engine/input/control.hpp Sun Jul 27 19:17:47 2014 UTC
@@ -415,7 +415,7 @@
class Keyboard : public Control
{
protected:
- SDL_KeyboardEvent m_ev;
+ SDL_Event m_ev;
public:
Keyboard(Control* parent_) :
@@ -423,8 +423,8 @@
m_ev()
{}
- void send_char(const SDL_KeyboardEvent& ev) { m_ev = ev;
notify_parent(); }
- SDL_KeyboardEvent get_ev() { return m_ev; }
+ void send_event(const SDL_Event& ev) { m_ev = ev; notify_parent(); }
+ SDL_Event get_ev() { return m_ev; }
private:
Keyboard(const Keyboard&);
@@ -476,7 +476,21 @@
{}
virtual void notify_parent() {
- controller->add_keyboard_event(m_ev);
+ switch(m_ev.type)
+ {
+ case SDL_KEYUP:
+ case SDL_KEYDOWN:
+ controller->add_keyboard_event(m_ev.key);
+ break;
+
+ case SDL_TEXTINPUT:
+ controller->add_text_input_event(m_ev.text);
+ break;
+
+ default:
+ log_error("unexpected SDL_Event: %1%", m_ev.type);
+ break;
+ }
}
private:
=======================================
--- /src/engine/input/controller.cpp Sun Jul 27 03:58:39 2014 UTC
+++ /src/engine/input/controller.cpp Sun Jul 27 19:17:47 2014 UTC
@@ -256,6 +256,12 @@
{
events.push_back(makeKeyboardEvent(ev));
}
+
+void
+Controller::add_text_input_event(const SDL_TextInputEvent& ev)
+{
+ events.push_back(makeTextInputEvent(ev));
+}
void
Controller::clear_events()
=======================================
--- /src/engine/input/controller.hpp Tue Sep 20 22:44:32 2011 UTC
+++ /src/engine/input/controller.hpp Sun Jul 27 19:17:47 2014 UTC
@@ -68,6 +68,7 @@
void add_pointer_event(int id, float x, float y);
void add_scroller_event(int id, float xrel, float yrel);
void add_keyboard_event(const SDL_KeyboardEvent& ev);
+ void add_text_input_event(const SDL_TextInputEvent& ev);
void add_axis(int id, ControllerAxis* axis);
void add_button(int id, ControllerButton* button);
=======================================
--- /src/engine/input/event.hpp Sat Jul 26 19:58:06 2014 UTC
+++ /src/engine/input/event.hpp Sun Jul 27 19:17:47 2014 UTC
@@ -29,7 +29,8 @@
POINTER_EVENT_TYPE,
AXIS_EVENT_TYPE,
SCROLLER_EVENT_TYPE,
- KEYBOARD_EVENT_TYPE };
+ KEYBOARD_EVENT_TYPE,
+ TEXT_INPUT_EVENT_TYPE };
enum EventName {
// Buttons
@@ -101,16 +102,22 @@
SDL_Keysym keysym;
};
+struct TextInputEvent
+{
+ char text[sizeof(SDL_TextInputEvent::text)];
+};
+
struct Event
{
EventType type;
union {
- ButtonEvent button;
- PointerEvent pointer;
- AxisEvent axis;
- ScrollEvent scroll;
+ ButtonEvent button;
+ PointerEvent pointer;
+ AxisEvent axis;
+ ScrollEvent scroll;
KeyboardEvent keyboard;
+ TextInputEvent text;
};
};
@@ -172,6 +179,16 @@
return event;
}
+
+inline Event makeTextInputEvent(const SDL_TextInputEvent& ev)
+{
+ Event event;
+
+ event.type = TEXT_INPUT_EVENT_TYPE;
+ memcpy(event.text.text, ev.text, sizeof(SDL_TextInputEvent::text));
+
+ return event;
+}
} // namespace Input
=======================================
--- /src/engine/input/sdl_driver.cpp Sat Jul 26 21:37:49 2014 UTC
+++ /src/engine/input/sdl_driver.cpp Sun Jul 27 19:17:47 2014 UTC
@@ -240,6 +240,22 @@
}
break;
+ case SDL_MOUSEWHEEL:
+ log_error("mousewheel not implemented: %1% %2%",
event.wheel.which, event.wheel.x, event.wheel.y);
+ break;
+
+ case SDL_TEXTINPUT:
+ if (keyboard_binding)
+ {
+ keyboard_binding->send_event(event);
+ }
+ break;
+
+ case SDL_TEXTEDITING:
+ log_error("textediting not implemented: %1% %2% '%3%'",
+ event.edit.start, event.edit.length, event.edit.text);
+ break;
+
case SDL_MOUSEBUTTONDOWN:
case SDL_MOUSEBUTTONUP:
for(std::vector<MouseButtonBinding>::iterator i =
mouse_button_bindings.begin();
@@ -271,7 +287,7 @@
case SDL_KEYUP:
// keyboard events
if (keyboard_binding)
- keyboard_binding->send_char(event.key);
+ keyboard_binding->send_event(event);
// global event hacks
if (event.key.state == SDL_PRESSED)
=======================================
--- /src/engine/screen/gui_screen.cpp Sun Jul 27 03:58:39 2014 UTC
+++ /src/engine/screen/gui_screen.cpp Sun Jul 27 19:17:47 2014 UTC
@@ -87,6 +87,12 @@
}
break;
+ case Input::TEXT_INPUT_EVENT_TYPE:
+ {
+
+ }
+ break;
+
default:
log_error("unhandled event type: %1%", event.type);
break;
==============================================================================
Revision: 8f04a8edc92e
Author: Ingo Ruhnke <address@hidden>
Date: Sun Jul 27 19:22:52 2014 UTC
Log: Fixed another scancode/keycode mixup
https://code.google.com/p/pingus/source/detail?r=8f04a8edc92e
Modified:
/src/engine/input/sdl_driver.cpp
=======================================
--- /src/engine/input/sdl_driver.cpp Sun Jul 27 19:17:47 2014 UTC
+++ /src/engine/input/sdl_driver.cpp Sun Jul 27 19:22:52 2014 UTC
@@ -33,9 +33,9 @@
string2key(),
joystick_handles()
{
- for (int i = 0; i < SDL_NUM_SCANCODES; ++i)
+ for (int i = 0; i < SDL_NUM_SCANCODES; ++i)
{
- const char* key_name = SDL_GetKeyName(static_cast<SDL_Keycode>(i));
+ const char* key_name =
SDL_GetScancodeName(static_cast<SDL_Scancode>(i));
string2key[key_name] = static_cast<SDL_Keycode>(i);
// FIXME: Make the keynames somewhere user visible so that users can
use them
==============================================================================
Revision: faf08734aa8c
Author: Ingo Ruhnke <address@hidden>
Date: Sun Jul 27 19:32:36 2014 UTC
Log: Fixed keyboard->button mapping
https://code.google.com/p/pingus/source/detail?r=faf08734aa8c
Modified:
/data/controller/default.scm
/src/engine/input/sdl_driver.cpp
/src/engine/input/sdl_driver.hpp
/src/pingus/screens/game_session.cpp
=======================================
--- /data/controller/default.scm Sat Oct 22 23:50:29 2011 UTC
+++ /data/controller/default.scm Sun Jul 27 19:32:36 2014 UTC
@@ -7,10 +7,10 @@
(standard-scroller
(core:button-scroller
- (up (sdl:keyboard-button (key "up")))
- (down (sdl:keyboard-button (key "down")))
- (left (sdl:keyboard-button (key "left")))
- (right (sdl:keyboard-button (key "right")))))
+ (up (sdl:keyboard-button (key "Up")))
+ (down (sdl:keyboard-button (key "Down")))
+ (left (sdl:keyboard-button (key "Left")))
+ (right (sdl:keyboard-button (key "Right")))))
(primary-button
(sdl:mouse-button (button 1)))
@@ -20,26 +20,26 @@
(sdl:mouse-button (button 3)))
(pause-button
- (sdl:keyboard-button (key "p")))
+ (sdl:keyboard-button (key "P")))
(fast-forward-button
- (sdl:keyboard-button (key "f"))
- (sdl:keyboard-button (key "space")))
+ (sdl:keyboard-button (key "F"))
+ (sdl:keyboard-button (key "Space")))
(single-step-button
- (sdl:keyboard-button (key "s")))
+ (sdl:keyboard-button (key "S")))
(armageddon-button
- (sdl:keyboard-button (key "a")))
+ (sdl:keyboard-button (key "A")))
(escape-button
- (sdl:keyboard-button (key "escape")))
+ (sdl:keyboard-button (key "Escape")))
(action-up-button
(sdl:mouse-button (button 4)))
-
+
(action-down-button
- (sdl:keyboard-button (key "tab"))
+ (sdl:keyboard-button (key "Tab"))
(sdl:mouse-button (button 5)))
(action-1-button (sdl:keyboard-button (key "1")))
=======================================
--- /src/engine/input/sdl_driver.cpp Sun Jul 27 19:22:52 2014 UTC
+++ /src/engine/input/sdl_driver.cpp Sun Jul 27 19:32:36 2014 UTC
@@ -5,12 +5,12 @@
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-//
+//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
-//
+//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
@@ -30,14 +30,11 @@
joystick_button_bindings(),
joystick_axis_bindings(),
keyboard_binding(0),
- string2key(),
joystick_handles()
{
for (int i = 0; i < SDL_NUM_SCANCODES; ++i)
{
const char* key_name =
SDL_GetScancodeName(static_cast<SDL_Scancode>(i));
- string2key[key_name] = static_cast<SDL_Keycode>(i);
-
// FIXME: Make the keynames somewhere user visible so that users can
use them
log_debug("Key: '%1%'", key_name);
}
@@ -45,7 +42,7 @@
SDLDriver::~SDLDriver()
{
-
+
}
Keyboard*
@@ -64,12 +61,12 @@
reader.read_int("device", binding.device);
reader.read_int("button", binding.button);
-
+
if (open_joystick(binding.device))
{
binding.binding = new Button(parent);
joystick_button_bindings.push_back(binding);
-
+
return binding.binding;
}
else
@@ -89,23 +86,23 @@
}
else if (reader.get_name() == "sdl:keyboard-button")
{
- std::string key;
- if (reader.read_string("key", key))
+ std::string key_str;
+ if (reader.read_string("key", key_str))
{
- String2Key::iterator i = string2key.find(key);
- if (i != string2key.end())
+ SDL_Keycode key = SDL_GetKeyFromName(key_str.c_str());
+ if (key != SDLK_UNKNOWN)
{
KeyboardButtonBinding binding;
-
- binding.key = i->second;
+
+ binding.key = key;
binding.binding = new Button(parent);
keyboard_button_bindings.push_back(binding);
return binding.binding;
}
- else
+ else
{
- log_error("couldn't find keysym for key '%1%'", key);
+ log_error("couldn't find keycode for key '%1%'", key_str);
return 0;
}
}
@@ -130,12 +127,12 @@
reader.read_int("device", binding.device);
reader.read_int("axis", binding.axis);
-
+
if (open_joystick(binding.device))
{
binding.binding = new Axis(parent);
joystick_axis_bindings.push_back(binding);
-
+
return binding.binding;
}
else
@@ -185,7 +182,7 @@
}
}
-bool
+bool
SDLDriver::open_joystick(int device)
{
JoystickHandles::iterator i = joystick_handles.find(device);
@@ -228,7 +225,7 @@
for(std::vector<PointerBinding>::iterator i =
pointer_bindings.begin();
i != pointer_bindings.end(); ++i)
{
- i->binding->set_pos(Vector2f(static_cast<float>(event.motion.x),
+ i->binding->set_pos(Vector2f(static_cast<float>(event.motion.x),
static_cast<float>(event.motion.y)));
}
@@ -277,13 +274,13 @@
case SDL_WINDOWEVENT_RESIZED:
Display::resize(Size(event.window.data1, event.window.data2));
break;
-
+
default:
break;
}
break;
- case SDL_KEYDOWN:
+ case SDL_KEYDOWN:
case SDL_KEYUP:
// keyboard events
if (keyboard_binding)
@@ -293,7 +290,7 @@
if (event.key.state == SDL_PRESSED)
global_event.on_button_press(event.key);
else
- global_event.on_button_release(event.key);
+ global_event.on_button_release(event.key);
// game button events
for(std::vector<KeyboardButtonBinding>::iterator i =
keyboard_button_bindings.begin();
@@ -311,14 +308,14 @@
case SDL_JOYAXISMOTION:
for(std::vector<JoystickAxisBinding>::iterator i =
joystick_axis_bindings.begin();
- i != joystick_axis_bindings.end(); ++i)
+ i != joystick_axis_bindings.end(); ++i)
{
if (event.jaxis.which == i->device &&
event.jaxis.axis == i->axis)
i->binding->set_state(static_cast<float>(event.jaxis.value) /
32767.0f);
}
break;
-
+
case SDL_JOYBUTTONDOWN:
case SDL_JOYBUTTONUP:
for(std::vector<JoystickButtonBinding>::iterator i =
joystick_button_bindings.begin();
@@ -331,7 +328,7 @@
}
}
break;
-
+
default:
// FIXME: Do something with other events
break;
=======================================
--- /src/engine/input/sdl_driver.hpp Sat Jul 26 19:58:06 2014 UTC
+++ /src/engine/input/sdl_driver.hpp Sun Jul 27 19:32:36 2014 UTC
@@ -5,12 +5,12 @@
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-//
+//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
-//
+//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
@@ -74,12 +74,9 @@
std::vector<JoystickAxisBinding> joystick_axis_bindings;
Keyboard* keyboard_binding;
- typedef std::map<std::string, SDL_Keycode> String2Key;
- String2Key string2key;
-
typedef std::map<int, SDL_Joystick*> JoystickHandles;
JoystickHandles joystick_handles;
-
+
public:
SDLDriver();
~SDLDriver();
=======================================
--- /src/pingus/screens/game_session.cpp Sun Jul 27 03:58:39 2014 UTC
+++ /src/pingus/screens/game_session.cpp Sun Jul 27 19:32:36 2014 UTC
@@ -5,12 +5,12 @@
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-//
+//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
-//
+//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
@@ -60,7 +60,7 @@
log_debug("GameSession");
// -- Client stuff
-
+
// These object will get deleted by the gui_manager
button_panel = new ButtonPanel(get_server(), Vector2i(0, (size.height -
150)/2));
@@ -69,7 +69,7 @@
playfield = new Playfield(get_server(), this,
Rect(Vector2i(Math::max((Display::get_width() - world_width)/2, 0),
-
Math::max((Display::get_height() - world_height)/2, 0)),
+
Math::max((Display::get_height() - world_height)/2, 0)),
Size(Math::min(Display::get_width(),
world_width),
Math::min(Display::get_height(),
world_height))));
@@ -172,7 +172,7 @@
GameSession::draw_background (DrawingContext& gc)
{
Rect rect = playfield->get_rect();
-
+
if (rect != Rect(Vector2i(0,0), Size(Display::get_width(),
Display::get_height())))
{ // Draw a black border around the playfield when the playfield is
smaller then the screen
Color border_color(0, 0, 0);
@@ -245,9 +245,12 @@
case Input::KEYBOARD_EVENT_TYPE:
break;
+ case Input::TEXT_INPUT_EVENT_TYPE:
+ break;
+
default:
// unhandled event
- log_info("GameSession::process_events (): unhandled event: %1%",
event.type);
+ log_info("unhandled event: %1%", event.type);
break;
}
}
@@ -345,7 +348,7 @@
if (globals::developer_mode)
log_info("Starting Music: %1%", server->get_plf().get_music());
- if (server->get_plf().get_music() == "none" ||
+ if (server->get_plf().get_music() == "none" ||
server->get_plf().get_music().empty())
{
Sound::PingusSound::stop_music();
@@ -401,9 +404,9 @@
int world_width = server->get_world()->get_width();
int world_height = server->get_world()->get_height();
-
+
playfield->set_rect(Rect(Vector2i(Math::max((size.width -
world_width)/2, 0),
- Math::max((size.height -
world_height)/2, 0)),
+ Math::max((size.height -
world_height)/2, 0)),
Size(Math::min(size.width, world_width),
Math::min(size.height, world_height))));
==============================================================================
Revision: 5dbbef7d71ab
Author: Ingo Ruhnke <address@hidden>
Date: Mon Jul 28 01:18:22 2014 UTC
Log: Updated logmich
https://code.google.com/p/pingus/source/detail?r=5dbbef7d71ab
Modified:
/external/logmich/include/logmich/logger.hpp
=======================================
--- /external/logmich/include/logmich/logger.hpp Sun Jul 27 03:58:17 2014
UTC
+++ /external/logmich/include/logmich/logger.hpp Mon Jul 28 01:18:22 2014
UTC
@@ -85,9 +85,16 @@
template<typename ...Args>
void append_format(LogLevel level, const std::string& file, int line,
const std::string& fmt, Args&&... args)
{
- boost::format format(fmt);
- detail::unpack_fmt(format, args...);
- append(level, file, line, format.str());
+ try
+ {
+ boost::format format(fmt);
+ detail::unpack_fmt(format, args...);
+ append(level, file, line, format.str());
+ }
+ catch(const std::exception& err)
+ {
+ std::cerr << "[LOG ERROR] " << file << ":" << line << ": " <<
err.what() << ": \"" << fmt << "\"" << std::endl;
+ }
}
};
==============================================================================
Revision: 1ba48a022bcc
Author: Ingo Ruhnke <address@hidden>
Date: Mon Jul 28 01:21:27 2014 UTC
Log: Updated TODO
https://code.google.com/p/pingus/source/detail?r=1ba48a022bcc
Modified:
/TODO
=======================================
--- /TODO Fri Dec 23 13:24:30 2011 UTC
+++ /TODO Mon Jul 28 01:21:27 2014 UTC
@@ -38,6 +38,19 @@
important, add what you find to this TODO
+Roadmap for 0.8.0
+=================
+
+* finish/test SDL2 port
+
+ - OpenGL renderer is broken
+ - Delta renderer is broken
+ - some sound effects are broken
+ - fade-in/out is glitchy
+ - fullscreen doesn't work
+
+
+
Roadmap for 0.7.5
=================
==============================================================================
Revision: 6b9a23120481
Author: Ingo Ruhnke <address@hidden>
Date: Mon Jul 28 02:04:20 2014 UTC
Log: Added GL context creation, fixed alpha value issue that made
surfaces invisible in GL
https://code.google.com/p/pingus/source/detail?r=6b9a23120481
Modified:
/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/opengl/opengl_framebuffer.cpp Sun Jul 27 16:32:00
2014 UTC
+++ /src/engine/display/opengl/opengl_framebuffer.cpp Mon Jul 28 02:04:20
2014 UTC
@@ -5,12 +5,12 @@
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
-//
+//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
-//
+//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
@@ -22,15 +22,18 @@
#include <stdexcept>
#include "engine/display/opengl/opengl_framebuffer_surface_impl.hpp"
+#include "util/raise_exception.hpp"
OpenGLFramebuffer::OpenGLFramebuffer() :
m_window(),
- cliprect_stack()
+ m_glcontext(),
+ cliprect_stack()
{
}
OpenGLFramebuffer::~OpenGLFramebuffer()
{
+ SDL_GL_DeleteContext(m_glcontext);
SDL_DestroyWindow(m_window);
}
@@ -47,60 +50,94 @@
glPixelStorei(GL_PACK_ALIGNMENT, 1);
std::unique_ptr<uint8_t[]> buffer(new uint8_t[size.width * size.height *
4]);
- glReadPixels(0, 0, size.width, size.height, GL_RGBA, GL_UNSIGNED_BYTE,
buffer.get());
+ glReadPixels(0, 0, size.width, size.height, GL_RGB, GL_UNSIGNED_BYTE,
buffer.get());
Surface screenshot(size.width, size.height);
-#ifdef OLD_SDL1
- // insert code
-#endif
+ uint8_t* op = screenshot.get_data();
+ int pitch = screenshot.get_pitch();
+ for(int y = 0; y < size.height; ++y)
+ {
+ for(int x = 0; x < size.height; ++x)
+ {
+ op[y * pitch + 4*x + 0] = buffer[4 * size.width + 3*x + 0];
+ op[y * pitch + 4*x + 1] = buffer[4 * size.width + 3*x + 1];
+ op[y * pitch + 4*x + 2] = buffer[4 * size.width + 3*x + 2];
+ }
+ }
return screenshot;
}
void
OpenGLFramebuffer::set_video_mode(const Size& size, bool fullscreen, bool
resizable)
{
- int flags = SDL_WINDOW_OPENGL;
-
- if (fullscreen)
+ if (m_window)
{
- flags |= SDL_WINDOW_FULLSCREEN;
+ log_error("video mode switching not implemented");
}
- else if (resizable)
+ else
{
- flags |= SDL_WINDOW_RESIZABLE;
- }
+ int flags = SDL_WINDOW_OPENGL;
- m_window = SDL_CreateWindow("Pingus " VERSION,
- 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
<< "): " << SDL_GetError();
- throw std::runtime_error(msg.str());
- }
- SDL_SetWindowIcon(m_window, IMG_Load(Pathname("images/icons/pingus.png",
Pathname::DATA_PATH).get_sys_path().c_str()));
+ if (fullscreen)
+ {
+ flags |= SDL_WINDOW_FULLSCREEN;
+ }
+ else if (resizable)
+ {
+ flags |= SDL_WINDOW_RESIZABLE;
+ }
+
+ SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
+
+ SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
+ SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
+ SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
+ SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, 32);
+
+ SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
+
+ if (false) // anti-aliasing
+ {
+ SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); // boolean value,
either it's enabled or not
+ SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 2); // 0, 2, or 4 for
number of samples
+ }
+
+ m_window = SDL_CreateWindow("Pingus " VERSION,
+ SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
+ size.width, size.height,
+ flags);
+ if (!m_window)
+ {
+ raise_error("Couldn't set video mode (" << size.width << "x" <<
size.height << "): " << SDL_GetError());
+ }
+ SDL_SetWindowIcon(m_window,
IMG_Load(Pathname("images/icons/pingus.png",
Pathname::DATA_PATH).get_sys_path().c_str()));
+
+ m_glcontext = SDL_GL_CreateContext(m_window);
+ if (!m_glcontext)
+ {
+ raise_error("couldn't create GL context: " << SDL_GetError());
+ }
- glEnableClientState(GL_VERTEX_ARRAY);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- // setup opengl state and transform
- glDisable(GL_DEPTH_TEST);
- glDisable(GL_CULL_FACE);
- glEnable(GL_TEXTURE_2D);
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ // setup opengl state and transform
+ glDisable(GL_DEPTH_TEST);
+ glDisable(GL_CULL_FACE);
+ glEnable(GL_TEXTURE_2D);
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glViewport(0, 0, size.width, size.height);
+ glViewport(0, 0, size.width, size.height);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
- glOrtho(0, size.width, size.height, 0, -1, 1);
+ glOrtho(0, size.width, size.height, 0, -1, 1);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+ }
}
bool
@@ -120,7 +157,7 @@
{
SDL_GL_SwapWindow(m_window);
}
-
+
void
OpenGLFramebuffer::push_cliprect(const Rect& rect)
{
@@ -133,15 +170,15 @@
}
else
{
- cliprect_stack.push_back(Rect(Math::max(cliprect_stack.back().left,
rect.left),
- Math::max(cliprect_stack.back().top,
rect.top),
- Math::min(cliprect_stack.back().right,
rect.right),
+ cliprect_stack.push_back(Rect(Math::max(cliprect_stack.back().left,
rect.left),
+ Math::max(cliprect_stack.back().top,
rect.top),
+ Math::min(cliprect_stack.back().right,
rect.right),
Math::min(cliprect_stack.back().bottom,
rect.bottom)));
}
glScissor(cliprect_stack.back().left,
- get_size().height - cliprect_stack.back().bottom,
- cliprect_stack.back().get_width(),
+ get_size().height - cliprect_stack.back().bottom,
+ cliprect_stack.back().get_width(),
cliprect_stack.back().get_height());
}
@@ -157,7 +194,7 @@
else
{
const Rect& rect = cliprect_stack.back();
- glScissor(rect.left, rect.top,
+ glScissor(rect.left, rect.top,
rect.get_width(), rect.get_height());
}
}
@@ -172,9 +209,9 @@
OpenGLFramebuffer::draw_surface(const FramebufferSurface& src, const Rect&
srcrect, const Vector2i& pos)
{
const OpenGLFramebufferSurfaceImpl* texture =
static_cast<OpenGLFramebufferSurfaceImpl*>(src.get_impl());
-
+
glBindTexture(GL_TEXTURE_2D, texture->get_handle());
-
+
int vertices[] = {
pos.x, pos.y,
pos.x+srcrect.get_width(), pos.y,
@@ -182,18 +219,18 @@
pos.x, pos.y+srcrect.get_height(),
};
glVertexPointer(2, GL_INT, 0, vertices);
-
+
float uvs[] = {
- static_cast<float>(srcrect.left) /
static_cast<float>(texture->get_texture_size().width),
+ static_cast<float>(srcrect.left) /
static_cast<float>(texture->get_texture_size().width),
static_cast<float>(srcrect.top) /
static_cast<float>(texture->get_texture_size().height),
- static_cast<float>(srcrect.right) /
static_cast<float>(texture->get_texture_size().width),
+ static_cast<float>(srcrect.right) /
static_cast<float>(texture->get_texture_size().width),
static_cast<float>(srcrect.top) /
static_cast<float>(texture->get_texture_size().height),
- static_cast<float>(srcrect.right) /
static_cast<float>(texture->get_texture_size().width),
+ static_cast<float>(srcrect.right) /
static_cast<float>(texture->get_texture_size().width),
static_cast<float>(srcrect.bottom) /
static_cast<float>(texture->get_texture_size().height),
- static_cast<float>(srcrect.left) /
static_cast<float>(texture->get_texture_size().width),
+ static_cast<float>(srcrect.left) /
static_cast<float>(texture->get_texture_size().width),
static_cast<float>(srcrect.bottom) /
static_cast<float>(texture->get_texture_size().height)
};
=======================================
--- /src/engine/display/opengl/opengl_framebuffer.hpp Sun Jul 27 16:32:00
2014 UTC
+++ /src/engine/display/opengl/opengl_framebuffer.hpp Mon Jul 28 02:04:20
2014 UTC
@@ -23,6 +23,7 @@
{
private:
SDL_Window* m_window;
+ SDL_GLContext m_glcontext;
std::vector<Rect> cliprect_stack;
public:
=======================================
--- /src/engine/display/opengl/opengl_framebuffer_surface_impl.cpp Sat Jul
26 21:37:49 2014 UTC
+++ /src/engine/display/opengl/opengl_framebuffer_surface_impl.cpp Mon Jul
28 02:04:20 2014 UTC
@@ -50,7 +50,7 @@
m_texture_size.width,
m_texture_size.height, 32,
0x000000ff, 0x0000ff00,
0x00ff0000, 0xff000000);
#endif
- SDL_SetSurfaceAlphaMod(src, 0);
+ //SDL_SetSurfaceAlphaMod(src, 0);
SDL_BlitSurface(src, 0, convert, 0);
GLenum sdl_format;
==============================================================================
Revision: 7a70d0dc4c26
Author: Ingo Ruhnke <address@hidden>
Date: Mon Jul 28 02:04:49 2014 UTC
Log: Some incomplete work on fullscreen mode switching
https://code.google.com/p/pingus/source/detail?r=7a70d0dc4c26
Modified:
/src/engine/display/display.cpp
/src/engine/display/display.hpp
/src/engine/display/sdl_framebuffer.cpp
/src/pingus/config_manager.cpp
/src/pingus/screens/option_menu.cpp
=======================================
--- /src/engine/display/display.cpp Sun Jul 27 18:10:17 2014 UTC
+++ /src/engine/display/display.cpp Mon Jul 28 02:04:49 2014 UTC
@@ -153,96 +153,54 @@
Size
Display::find_closest_fullscreen_video_mode(const Size& size)
{
-#ifdef OLD_SDL1
- SDL_Rect** modes = SDL_ListModes(NULL, SDL_WINDOW_FULLSCREEN);
+ SDL_DisplayMode target;
+ SDL_DisplayMode closest;
+
+ target.w = size.width;
+ target.h = size.height;
+ target.format = 0; // don't care
+ target.refresh_rate = 0; // don't care
+ target.driverdata = nullptr;
- if (modes == static_cast<SDL_Rect**>(0))
- { // No resolutions at all available, bad
+ if (!SDL_GetClosestDisplayMode(0, &target, &closest))
+ {
+ log_error("couldn't find video mode matching %1%x%1%", size.width,
size.height);
return size;
}
- else if(modes == reinterpret_cast<SDL_Rect**>(-1))
- {
- return size;
- }
- else
+ else
{
- // FIXME: This might not work that well with different aspect ratios
- int distance = -1;
- Size best_fit = size;
-
- for(int i = 0; modes[i]; ++i)
- {
- int this_distance = abs(size.width - modes[i]->w) + abs(size.height
- modes[i]->h);
-
- if (distance == -1 || distance > this_distance)
- {
- distance = this_distance;
-
- best_fit.width = modes[i]->w;
- best_fit.height = modes[i]->h;
- }
- }
-
- return best_fit;
+ return {closest.w, closest.h};
}
-#else
- return Size(800, 600);
-#endif
}
-struct SortBySize
-{
- bool operator()(const Size& lhs, const Size& rhs)
- {
- return lhs.get_area() < rhs.get_area();
- }
-};
-
-std::vector<Size>
+std::vector<SDL_DisplayMode>
Display::get_fullscreen_video_modes()
{
-#ifdef OLD_SDL1
- std::vector<Size> video_modes;
- SDL_Rect** modes = SDL_ListModes(NULL, SDL_FULLSCREEN);
+ std::vector<SDL_DisplayMode> video_modes;
- if (modes == reinterpret_cast<SDL_Rect**>(0))
- { // No resolutions at all available, bad
-
- }
- else if(modes == reinterpret_cast<SDL_Rect**>(-1))
- { // FIXME: Under which OSs is this triggred, if ever?
- log_warn("falling back to hardcoded list of screen resolutions");
+ int num_displays = SDL_GetNumVideoDisplays();
+ log_info("number of displays: %1%", num_displays);
- // All resolutions should work, so we fall back to hardcoded defaults
- video_modes.push_back(Size( 640, 480)); // 4:3, VGA
- video_modes.push_back(Size( 800, 600)); // 4:3, PAL
- video_modes.push_back(Size(1024, 768)); // Nokia N770, N800
- video_modes.push_back(Size(1152, 864)); // 4:3, SVGA
- video_modes.push_back(Size(1280, 720)); // 16:9
- video_modes.push_back(Size(1280, 800)); // 16:10
- video_modes.push_back(Size(1280, 960)); // 4:3, XGA
- video_modes.push_back(Size(1280, 1024)); // 5:4
- video_modes.push_back(Size(1366, 768)); // ~16:9, Wide XGA
- video_modes.push_back(Size(1440, 900)); // 16:10
- video_modes.push_back(Size(1680, 1050)); // 16:10
- video_modes.push_back(Size(1600, 1200)); // 4:3, UXGA
- video_modes.push_back(Size(1920, 1080)); // 16:9, HD-TV, 1080p
- video_modes.push_back(Size(1920, 1200)); // 16:10
- }
- else
+ for(int display = 0; display < num_displays; ++display)
{
- for(int i = 0; modes[i]; ++i)
+ int num_modes = SDL_GetNumDisplayModes(display);
+
+ for (int i = 0; i < num_modes; ++i)
{
- video_modes.push_back(Size(modes[i]->w, modes[i]->h));
+ SDL_DisplayMode mode;
+ if (SDL_GetDisplayMode(display, i, &mode) != 0)
+ {
+ log_error("failed to get display mode: %1%", SDL_GetError());
+ }
+ else
+ {
+ log_debug("address@hidden %4%", mode.w, mode.h, mode.refresh_rate,
SDL_GetPixelFormatName(mode.format));
+ video_modes.push_back(mode);
+ }
}
}
-
- std::sort(video_modes.begin(), video_modes.end(), SortBySize());
return video_modes;
-#else
- return std::vector<Size>{{800, 600}};
-#endif
}
/* EOF */
=======================================
--- /src/engine/display/display.hpp Sun Jul 27 18:10:17 2014 UTC
+++ /src/engine/display/display.hpp Mon Jul 28 02:04:49 2014 UTC
@@ -19,6 +19,7 @@
#include <memory>
#include <vector>
+#include <SDL.h>
#include "math/size.hpp"
#include "pingus/options.hpp"
@@ -51,7 +52,7 @@
static Framebuffer* get_framebuffer();
static Size find_closest_fullscreen_video_mode(const Size& size);
- static std::vector<Size> get_fullscreen_video_modes();
+ static std::vector<SDL_DisplayMode> get_fullscreen_video_modes();
private:
Display ();
=======================================
--- /src/engine/display/sdl_framebuffer.cpp Sun Jul 27 18:10:17 2014 UTC
+++ /src/engine/display/sdl_framebuffer.cpp Mon Jul 28 02:04:49 2014 UTC
@@ -203,8 +203,16 @@
}
else
{
- SDL_SetWindowSize(m_window, size.width, size.height);
- SDL_SetWindowDisplayMode(m_window, nullptr);
+ SDL_DisplayMode mode;
+ mode.w = size.width;
+ mode.h = size.height;
+ mode.refresh_rate = 0;
+ mode.driverdata = nullptr;
+
+ if (SDL_SetWindowDisplayMode(m_window, &mode) != 0)
+ {
+ log_error("failed to set display mode: %1%", SDL_GetError());
+ }
SDL_SetWindowFullscreen(m_window, SDL_WINDOW_FULLSCREEN);
}
}
=======================================
--- /src/pingus/config_manager.cpp Sat Jul 26 19:58:06 2014 UTC
+++ /src/pingus/config_manager.cpp Mon Jul 28 02:04:49 2014 UTC
@@ -109,9 +109,7 @@
{
if (Display::is_fullscreen())
{
-#ifndef WIN32
Display::set_video_mode(size, Display::is_fullscreen(), false);
-#endif
}
on_fullscreen_resolution_change(size);
}
@@ -132,9 +130,7 @@
if (v != get_fullscreen())
{
-#ifndef WIN32
- Display::set_video_mode(Display::get_size(), Display::is_fullscreen(),
false);
-#endif
+ Display::set_video_mode(Display::get_size(), v, false);
on_fullscreen_change(v);
}
=======================================
--- /src/pingus/screens/option_menu.cpp Sun Jul 27 16:32:00 2014 UTC
+++ /src/pingus/screens/option_menu.cpp Mon Jul 28 02:04:49 2014 UTC
@@ -107,7 +107,7 @@
ChoiceBox* resolution_box = new ChoiceBox(Rect());
{
- std::vector<Size> resolutions = Display::get_fullscreen_video_modes();
+ std::vector<SDL_DisplayMode> resolutions =
Display::get_fullscreen_video_modes();
Size fullscreen = config_manager.get_fullscreen_resolution();
int choice = static_cast<int>(resolutions.size()) - 1;
@@ -115,10 +115,12 @@
{
// add resolution to the box
std::ostringstream ostr;
- ostr << it->width << "x" << it->height;
+ ostr << it->w << "x" << it->h << "@" << it->refresh_rate;
resolution_box->add_choice(ostr.str());
- if (fullscreen == *it)
+ // FIXME: ignoring refresh_rate
+ if (fullscreen.width == it->w &&
+ fullscreen.height == it->h)
{
choice = static_cast<int>(it - resolutions.begin());
}
@@ -457,12 +459,17 @@
OptionMenu::on_resolution_change(const std::string& str)
{
Size size_;
- if (sscanf(str.c_str(), "%dx%d", &size_.width, &size_.height) != 2)
+ int refresh_rate;
+ if (sscanf(str.c_str(), "address@hidden", &size_.width, &size_.height,
&refresh_rate) != 3)
{
log_error("failed to parse: %1%", str);
}
else
{
+#ifdef OLD_SDL1
+ // FIXME: ignoring refresh rate here
+#endif
+
config_manager.set_fullscreen_resolution(size_);
}
}
==============================================================================
Revision: 270ad4e4cf39
Author: Ingo Ruhnke <address@hidden>
Date: Thu Sep 11 21:54:14 2014 UTC
Log: Stuff
https://code.google.com/p/pingus/source/detail?r=270ad4e4cf39
Modified:
/TODO
/src/engine/display/display.cpp
/src/engine/display/opengl/opengl_framebuffer.cpp
/src/engine/screen/screen_manager.cpp
=======================================
--- /TODO Mon Jul 28 01:21:27 2014 UTC
+++ /TODO Thu Sep 11 21:54:14 2014 UTC
@@ -44,10 +44,16 @@
* finish/test SDL2 port
- OpenGL renderer is broken
+ -> resize doesn't work
- Delta renderer is broken
- - some sound effects are broken
- - fade-in/out is glitchy
+ -> doesn't work correctly at all, can't use SDLFramebuffer any
+ more due to Renderer
+ -> see SDL_GetWindowSurface()
+ SDL_UpdateWindowSurfaceRects()
+ - some sound effects are broken -> convert to other format bit-depth,
etc.
+ - fade-in/out is glitchy -> rewrite with SDL_SetRenderTarget()
- fullscreen doesn't work
+ - add GameController support
=======================================
--- /src/engine/display/display.cpp Mon Jul 28 02:04:49 2014 UTC
+++ /src/engine/display/display.cpp Thu Sep 11 21:54:14 2014 UTC
@@ -62,9 +62,6 @@
if (size.width < 640) size.width = 640;
if (size.height < 480) size.height = 480;
- // FIXME: Calling this causes horrible flicker, since the screen
- // goes black on a size change. Seems to be an SDL issue.
- // This call also shouldn't be part of ScreenManager, but
Framebuffer/Display internal
Display::set_video_mode(size, is_fullscreen(), true);
if (ScreenManager::instance())
=======================================
--- /src/engine/display/opengl/opengl_framebuffer.cpp Mon Jul 28 02:04:20
2014 UTC
+++ /src/engine/display/opengl/opengl_framebuffer.cpp Thu Sep 11 21:54:14
2014 UTC
@@ -72,7 +72,17 @@
{
if (m_window)
{
- log_error("video mode switching not implemented");
+ SDL_SetWindowSize(m_window, size.width, size.height);
+
+ log_error("video mode switching not implemented: %1%x%2%", size.width,
size.height);
+ glViewport(0, 0, size.width, size.height);
+
+ glMatrixMode(GL_PROJECTION);
+ glOrtho(0, size.width, size.height, 0, -1, 1);
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+ glClearColor(1.0, 1.0, 0.0, 1.0);
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
else
{
=======================================
--- /src/engine/screen/screen_manager.cpp Sun Jul 27 03:58:39 2014 UTC
+++ /src/engine/screen/screen_manager.cpp Thu Sep 11 21:54:14 2014 UTC
@@ -378,6 +378,7 @@
display_gc->clear();
progress = static_cast<float>(SDL_GetTicks() - last_ticks)/1000.0f *
2.0f;
+ SDL_Delay(1000);
}
input_manager.refresh();
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] [pingus] 25 new revisions pushed by address@hidden on 2014-09-11 21:58 GMT,
pingus <=