World of Might and Magic  0.2.0
Open reimplementation of Might and Magic 6 7 8 game engine
Sdl2Window.h
См. документацию.
1 #pragma once
2 
3 #include "SDL.h"
4 
5 #include "Platform/OSWindow.h"
6 
7 class Sdl2Window : public OSWindow {
8  public:
10  : OSWindow() {
11  this->sdlWindow = sdlWindow;
12  this->sdlWindowSurface = sdlWindowSurface;
13  }
14 
15  void SetFullscreenMode() override;
16  void SetWindowedMode(int new_window_width, int new_window_height) override;
17  void SetCursor(const char *cursor_name) override;
18 
19  int GetX() const override;
20  int GetY() const override;
21  unsigned int GetWidth() const override;
22  unsigned int GetHeight() const override;
23 
24  Point TransformCursorPos(Point &pt) const override; // screen to client
25 
26  bool OnOSMenu(int item_id) override;
27 
28  void Show() override;
29  bool Focused() override;
30  void Activate() override;
31 
32  void PeekSingleMessage() override;
33  void PeekMessageLoop() override;
34 
35  void *GetWinApiHandle() override;
36 
37  // window-renderer integration, probably should be a separate class
38  void OpenGlCreate() override;
39  void OpenGlSwapBuffers() override;
40 
41  private:
42  SDL_Window *sdlWindow = nullptr;
45 
46  void MessageProc(const SDL_Event &e);
47  int SdlkToChar(SDL_Keycode key, bool uppercase) const;
48  int SdlkToVk(SDL_Keycode key) const;
49 };
Sdl2Window::sdlWindow
SDL_Window * sdlWindow
Definition: Sdl2Window.h:42
SDL.h
OSWindow.h
Sdl2Window::GetWinApiHandle
void * GetWinApiHandle() override
Definition: Sdl2Window.cpp:113
Sdl2Window::OpenGlCreate
void OpenGlCreate() override
Definition: Sdl2Window.cpp:242
Sdl2Window
Definition: Sdl2Window.h:7
SDL_Surface
A collection of pixels used in software blitting.
Definition: SDL_surface.h:70
Sdl2Window::Activate
void Activate() override
Definition: Sdl2Window.cpp:185
Sdl2Window::Focused
bool Focused() override
Definition: Sdl2Window.cpp:180
SDL_GLContext
void * SDL_GLContext
An opaque handle to an OpenGL context.
Definition: SDL_video.h:192
Sdl2Window::sdlOpenGlContext
SDL_GLContext sdlOpenGlContext
Definition: Sdl2Window.h:44
Sdl2Window::SetFullscreenMode
void SetFullscreenMode() override
Definition: Sdl2Window.cpp:126
Sdl2Window::SdlkToChar
int SdlkToChar(SDL_Keycode key, bool uppercase) const
Definition: Sdl2Window.cpp:192
Sdl2Window::TransformCursorPos
Point TransformCursorPos(Point &pt) const override
Definition: Sdl2Window.cpp:162
SDL_Keycode
Sint32 SDL_Keycode
The SDL virtual key representation.
Definition: SDL_keycode.h:45
OSWindow
Definition: OSWindow.h:12
Sdl2Window::SetCursor
void SetCursor(const char *cursor_name) override
Definition: Sdl2Window.cpp:132
Sdl2Window::sdlWindowSurface
SDL_Surface * sdlWindowSurface
Definition: Sdl2Window.h:43
Sdl2Window::OnOSMenu
bool OnOSMenu(int item_id) override
Definition: Sdl2Window.cpp:169
Sdl2Window::MessageProc
void MessageProc(const SDL_Event &e)
Definition: Sdl2Window.cpp:5
Sdl2Window::GetY
int GetY() const override
Definition: Sdl2Window.cpp:142
Sdl2Window::PeekSingleMessage
void PeekSingleMessage() override
Definition: Sdl2Window.cpp:106
Sdl2Window::GetWidth
unsigned int GetWidth() const override
Definition: Sdl2Window.cpp:149
Sdl2Window::SetWindowedMode
void SetWindowedMode(int new_window_width, int new_window_height) override
Definition: Sdl2Window.cpp:129
SDL_Window
struct SDL_Window SDL_Window
The type used to identify a window.
Definition: SDL_video.h:90
Sdl2Window::OpenGlSwapBuffers
void OpenGlSwapBuffers() override
Definition: Sdl2Window.cpp:266
Sdl2Window::Show
void Show() override
Definition: Sdl2Window.cpp:173
SDL_Event
General event structure.
Definition: SDL_events.h:558
Sdl2Window::SdlkToVk
int SdlkToVk(SDL_Keycode key) const
Definition: Sdl2Window.cpp:206
Point
Definition: Point.h:3
Sdl2Window::Sdl2Window
Sdl2Window(SDL_Window *sdlWindow, SDL_Surface *sdlWindowSurface)
Definition: Sdl2Window.h:9
Sdl2Window::GetHeight
unsigned int GetHeight() const override
Definition: Sdl2Window.cpp:155
Sdl2Window::GetX
int GetX() const override
Definition: Sdl2Window.cpp:135
Sdl2Window::PeekMessageLoop
void PeekMessageLoop() override
Definition: Sdl2Window.cpp:99