diff --git a/platform/frt_sdl/doc/ReleaseNotes.md b/platform/frt_sdl/doc/ReleaseNotes.md index 8c9a8c9fb..a4d4cb0ef 100644 --- a/platform/frt_sdl/doc/ReleaseNotes.md +++ b/platform/frt_sdl/doc/ReleaseNotes.md @@ -1,6 +1,14 @@ Release Notes ============= +# FRT 2.0.1 + +- Fixes for Godot 3.5 +- Better SDL2 error messages +- Use Soft Fullscreen +- VSync +- Icon + ## FRT 2.0.0 A rewrite of FRT that uses SDL2 instead of custom modules. diff --git a/platform/frt_sdl/frt.h b/platform/frt_sdl/frt.h index 4ce515148..8a2ae9a01 100644 --- a/platform/frt_sdl/frt.h +++ b/platform/frt_sdl/frt.h @@ -5,7 +5,7 @@ SPDX-License-Identifier: MIT */ -#define FRT_VERSION "2.0.0" +#define FRT_VERSION "2.0.1" #if __cplusplus >= 201103L #define FRT_OVERRIDE override diff --git a/platform/frt_sdl/frt_godot3.cc b/platform/frt_sdl/frt_godot3.cc index 6171febe1..213c2f769 100644 --- a/platform/frt_sdl/frt_godot3.cc +++ b/platform/frt_sdl/frt_godot3.cc @@ -301,6 +301,14 @@ public: // OS void _set_use_vsync(bool enable) FRT_OVERRIDE { os_.set_use_vsync(enable); } + void set_icon(const Ref &icon) FRT_OVERRIDE { + if (icon.is_null()) + return; + Ref i = icon->duplicate(); + i->convert(Image::FORMAT_RGBA8); + PoolVector::Read r = i->get_data().read(); + os_.set_icon(i->get_width(), i->get_height(), r.ptr()); + } public: // EventHandler void handle_resize_event(ivec2 size) FRT_OVERRIDE { video_mode_.width = size.x; @@ -376,6 +384,9 @@ public: // EventHandler void handle_quit_event() FRT_OVERRIDE { quit_ = true; } + void handle_flush_events() FRT_OVERRIDE { + input_->flush_buffered_events(); + } }; } // namespace frt diff --git a/platform/frt_sdl/scripts/rolling.sh b/platform/frt_sdl/scripts/rolling.sh index 26a15ecde..c86aa9462 100755 --- a/platform/frt_sdl/scripts/rolling.sh +++ b/platform/frt_sdl/scripts/rolling.sh @@ -12,7 +12,7 @@ if [ $# -ge 2 -a "$1" = '-t' ] ; then tag=$2 shift 2 else - tag=343 + tag=350 fi build_216_98() { diff --git a/platform/frt_sdl/sdl2_adapter.h b/platform/frt_sdl/sdl2_adapter.h index 9be0cde49..9d45bfb99 100644 --- a/platform/frt_sdl/sdl2_adapter.h +++ b/platform/frt_sdl/sdl2_adapter.h @@ -143,6 +143,7 @@ struct EventHandler { virtual void handle_js_axis_event(int id, int axis, float value) = 0; virtual void handle_js_hat_event(int id, int mask) = 0; virtual void handle_quit_event() = 0; + virtual void handle_flush_events() = 0; }; EventHandler::~EventHandler() { @@ -339,7 +340,7 @@ public: void init(GraphicsAPI api, int width, int height, bool resizable, bool borderless, bool always_on_top) { setenv("SDL_VIDEO_RPI_OPTIONS", "gravity=center,scale=letterbox,background=1", 0); if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK) < 0) - fatal("SDL_Init failed."); + fatal("SDL_Init failed: %s.", SDL_GetError()); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, api == API_OpenGL_ES2 ? 2 : 3); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0); @@ -352,7 +353,7 @@ public: if (always_on_top) flags |= SDL_WINDOW_ALWAYS_ON_TOP; if (!(window_ = SDL_CreateWindow("frt2", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, flags))) - fatal("SDL_CreateWindow failed."); + fatal("SDL_CreateWindow failed: %s.", SDL_GetError()); context_ = SDL_GL_CreateContext(window_); SDL_GL_MakeCurrent(window_, context_); } @@ -409,6 +410,7 @@ public: break; } } + handler_->handle_flush_events(); } const InputModifierState *get_modifier_state() const { return &st_; @@ -416,6 +418,16 @@ public: void set_title(const char *title) { SDL_SetWindowTitle(window_, title); } + void set_icon(int width, int height, const unsigned char *data) { + SDL_Surface *icon = SDL_CreateRGBSurfaceWithFormat(0, width, height, 32, SDL_PIXELFORMAT_ABGR8888); + if (!icon) + return; + SDL_LockSurface(icon); + memcpy(icon->pixels, data, width * height * 4); + SDL_UnlockSurface(icon); + SDL_SetWindowIcon(window_, icon); + SDL_FreeSurface(icon); + } void set_pos(ivec2 pos) { SDL_SetWindowPosition(window_, pos.x, pos.y); }