mirror of
https://github.com/ondra-novak/gates_of_skeldal.git
synced 2025-07-10 00:20:27 -04:00
revision of events
This commit is contained in:
parent
858c4384e8
commit
669f72908e
33 changed files with 661 additions and 382 deletions
|
@ -3,6 +3,8 @@
|
|||
#include <memory>
|
||||
#include <optional>
|
||||
#include <SDL2/SDL.h>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
#include <mouse.h>
|
||||
|
||||
class SDLContext {
|
||||
|
@ -22,14 +24,15 @@ public:
|
|||
void close_screen();
|
||||
|
||||
|
||||
uint16_t *get_surface_addr();
|
||||
int32_t get_surface_pitch();
|
||||
|
||||
|
||||
void pool_events();
|
||||
|
||||
void present_rect(uint16_t *pixels, unsigned int pitch, unsigned int x, unsigned int y, unsigned int xs,unsigned ys);
|
||||
|
||||
MS_EVENT getMsEvent() {
|
||||
std::lock_guard _(_mx);
|
||||
MS_EVENT out = ms_event;
|
||||
ms_event.event = 0;
|
||||
return out;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
struct SDL_Deleter {
|
||||
|
@ -43,13 +46,26 @@ protected:
|
|||
|
||||
std::unique_ptr<SDL_Window, SDL_Deleter> _window;
|
||||
std::unique_ptr<SDL_Renderer, SDL_Deleter> _renderer;
|
||||
std::unique_ptr<SDL_Surface, SDL_Deleter> _surface;
|
||||
std::unique_ptr<SDL_Texture, SDL_Deleter> _texture;
|
||||
|
||||
std::optional<SDL_TimerID> _active_timer;
|
||||
Uint32 _timer_event = 0;
|
||||
std::jthread _render_thread;
|
||||
|
||||
bool _quit_requested = false;
|
||||
bool _fullscreen_mode = false;
|
||||
bool _present = false;
|
||||
void charge_timer();
|
||||
|
||||
void event_loop(std::stop_token stp);
|
||||
std::mutex _mx;
|
||||
|
||||
struct UpdateMsg {
|
||||
SDL_Rect rc;
|
||||
std::vector<short> data;
|
||||
};
|
||||
|
||||
std::vector<UpdateMsg> _display_update_queue;
|
||||
Uint32 _update_request_event;
|
||||
|
||||
void update_screen();
|
||||
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue