mirror of
https://github.com/ondra-novak/gates_of_skeldal.git
synced 2025-07-05 14:10:27 -04:00
trying to debug, additional rewrites
This commit is contained in:
parent
378b5586ab
commit
42f780a729
87 changed files with 1771 additions and 529 deletions
55
platform/sdl/sdl_context.h
Normal file
55
platform/sdl/sdl_context.h
Normal file
|
@ -0,0 +1,55 @@
|
|||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <SDL2/SDL.h>
|
||||
#include <mouse.h>
|
||||
|
||||
class SDLContext {
|
||||
public:
|
||||
|
||||
SDLContext();
|
||||
|
||||
enum DisplayMode {
|
||||
native_window,
|
||||
double_window,
|
||||
fullscreen
|
||||
};
|
||||
|
||||
|
||||
void init_screen(DisplayMode mode, const char *title);
|
||||
|
||||
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);
|
||||
|
||||
protected:
|
||||
|
||||
struct SDL_Deleter {
|
||||
void operator()(SDL_Window *);
|
||||
void operator()(SDL_Renderer *);
|
||||
void operator()(SDL_Surface *);
|
||||
void operator()(SDL_Texture *);
|
||||
};
|
||||
|
||||
MS_EVENT ms_event;
|
||||
|
||||
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;
|
||||
|
||||
bool _quit_requested = false;
|
||||
bool _fullscreen_mode = false;
|
||||
void charge_timer();
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue