This commit is contained in:
Relintai 2022-10-08 19:36:12 +02:00
parent e35409a37f
commit 2f68443761
5 changed files with 35 additions and 4 deletions

View File

@ -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.

View File

@ -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

View File

@ -301,6 +301,14 @@ public: // OS
void _set_use_vsync(bool enable) FRT_OVERRIDE {
os_.set_use_vsync(enable);
}
void set_icon(const Ref<Image> &icon) FRT_OVERRIDE {
if (icon.is_null())
return;
Ref<Image> i = icon->duplicate();
i->convert(Image::FORMAT_RGBA8);
PoolVector<uint8_t>::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

View File

@ -12,7 +12,7 @@ if [ $# -ge 2 -a "$1" = '-t' ] ; then
tag=$2
shift 2
else
tag=343
tag=350
fi
build_216_98() {

View File

@ -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);
}