GlPortal Class Reference  0.1.1
Source code documentation of the free and open 3D action puzzle game.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Window.hpp
Go to the documentation of this file.
1 #ifndef RADIX_WINDOW_HPP
2 #define RADIX_WINDOW_HPP
3 
4 #include <memory>
5 #include <string>
6 #include <vector>
7 
8 #include <SDL2/SDL_video.h>
9 
10 #include <Gwen/Controls/Canvas.h>
11 #include <Gwen/Skins/TexturedBase.h>
12 
14 #include <radix/Viewport.hpp>
15 #include <radix/env/Config.hpp>
16 
17 namespace radix {
18 
19 class GlGwenRenderer;
20 class GWENInput;
21 
22 class Window : public Viewport, public InputSource {
23 public:
24  Window();
25  ~Window();
26  void create(const char*);
27  void setFullscreen();
29  void swapBuffers();
30  void getSize(int *width, int *height) const;
31  void close();
32 
33  void lockMouse();
34  void unlockMouse();
35 
36  std::unique_ptr<radix::GlGwenRenderer> gwenRenderer;
37  std::unique_ptr<Gwen::Skin::TexturedBase> gwenSkin;
38  std::unique_ptr<Gwen::Controls::Canvas> gwenCanvas;
39  std::unique_ptr<radix::GWENInput> gwenInput;
41 
42  void processEvents();
43 
46  bool isKeyDown(KeyboardKey key);
47  std::string getCharBuffer();
48  void addToBuffer(const std::string &character);
49  void clearBuffer();
50  void truncateCharBuffer();
51  void clear();
52  void printScreenToFile(std::string fileName);
53  SDL_Surface* flipVertical(SDL_Surface* sfc);
54 private:
55  void processMouseButtonEvents(SDL_Event &event);
56  void processWindowEvents(SDL_Event &event);
57  void initEpoxy();
58  unsigned int width;
59  unsigned int height;
60  SDL_Window *window;
61  SDL_GLContext context;
62 
63  std::vector<bool> keystates;
64  std::string charbuffer;
65 
66  static const char* DEFAULT_TITLE;
67  static const unsigned int DEFAULT_WIDTH, DEFAULT_HEIGHT;
68 };
69 
70 } /* namespace radix */
71 
72 #endif /* RADIX_WINDOW_HPP */
void processWindowEvents(SDL_Event &event)
Definition: Window.cpp:292
radix::Config config
Definition: Window.hpp:40
Definition: Viewport.hpp:6
void printScreenToFile(std::string fileName)
Definition: Window.cpp:441
void keyPressed(KeyboardKey key, KeyboardModifier mod)
Definition: Window.cpp:399
Definition: GameController.hpp:7
SDL_GLContext context
Definition: Window.hpp:61
bool isKeyDown(KeyboardKey key)
Definition: Window.cpp:415
void setFullscreen()
Definition: Window.cpp:160
std::unique_ptr< Gwen::Controls::Canvas > gwenCanvas
Definition: Window.hpp:38
std::vector< bool > keystates
Definition: Window.hpp:63
Definition: Window.hpp:22
void keyReleased(KeyboardKey key, KeyboardModifier mod)
Definition: Window.cpp:407
Definition: InputSource.hpp:16
void lockMouse()
Definition: Window.cpp:187
Configuration class.
Definition: Config.hpp:19
void close()
Definition: Window.cpp:172
void clearBuffer()
Definition: Window.cpp:427
static const unsigned int DEFAULT_HEIGHT
Definition: Window.hpp:67
static const unsigned int DEFAULT_WIDTH
Definition: Window.hpp:67
std::unique_ptr< radix::GlGwenRenderer > gwenRenderer
Definition: Window.hpp:36
std::string getCharBuffer()
Definition: Window.cpp:423
Window()
Definition: Window.cpp:26
static const char * DEFAULT_TITLE
Definition: Window.hpp:66
unsigned int height
Definition: Window.hpp:59
void clear()
Definition: Window.cpp:437
int KeyboardKey
Definition: InputSource.hpp:24
SDL_Window * window
Definition: Window.hpp:60
void getSize(int *width, int *height) const
Definition: Window.cpp:168
void setConfig(radix::Config &config)
Definition: Window.cpp:36
int KeyboardModifier
Definition: InputSource.hpp:25
SDL_Surface * flipVertical(SDL_Surface *sfc)
Definition: Window.cpp:457
void addToBuffer(const std::string &character)
Definition: Window.cpp:419
void initEpoxy()
Definition: Window.cpp:40
void swapBuffers()
Definition: Window.cpp:164
void truncateCharBuffer()
Definition: Window.cpp:431
std::unique_ptr< Gwen::Skin::TexturedBase > gwenSkin
Definition: Window.hpp:37
void unlockMouse()
Definition: Window.cpp:191
std::string charbuffer
Definition: Window.hpp:64
void processMouseButtonEvents(SDL_Event &event)
Definition: Window.cpp:251
void processEvents()
Definition: Window.cpp:197
void create(const char *)
Definition: Window.cpp:54
std::unique_ptr< radix::GWENInput > gwenInput
Definition: Window.hpp:39
unsigned int width
Definition: Window.hpp:58