LPCGame
A Simple 2d Game Engine
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
window.h
1 #ifndef WINDOW_H
2 #define WINDOW_H
3 
4 #include <string>
5 #include <stdexcept>
6 #include <memory>
7 #include <SDL.h>
8 #include "image.h"
9 #include "animatedimage.h"
10 #include "rect.h"
11 #include "text.h"
12 #include "color.h"
13 #include "timer.h"
14 
16 
20 class Window {
21 public:
26  static void Init(std::string title = "Window");
28  static void Quit();
42  static void DrawTexture(SDL_Texture *tex, const Rectf &dstRect, Recti *clip = NULL, float angle = 0.0,
43  Vector2f pivot = Vector2f(0, 0), SDL_RendererFlip flip = SDL_FLIP_NONE);
54  static void Draw(Image *image, const Rectf &dstRect, Recti *clip = NULL,
55  float angle = 0.0, Vector2f pivot = Vector2f(0, 0), int flip = SDL_FLIP_NONE);
61  //static void Draw(Image *image, const Rectf &dstRect);
69  //static void Draw(Image *image, const Rectf &dstRect, Recti *clip);
75  //static void Draw(AnimatedImage* img, const Rectf &dstRect);
86  static void Draw(AnimatedImage* img, const Rectf &dstRect, float angle = 0.0,
87  Vector2f pivot = Vector2f(0, 0), int flip = SDL_FLIP_NONE);
93  //static void Draw(Text *text, const Rectf &dstRect);
103  static void Draw(Text *text, const Rectf &dstRect, float angle = 0.0, Vector2f pivot = Vector2f(0, 0),
104  int flip = SDL_FLIP_NONE);
111  static SDL_Texture* LoadTexture(std::string file);
120  static SDL_Texture* RenderText(std::string message, std::string fontFile, Color color, int fontSize);
126  static SDL_Texture* SurfaceToTexture(SDL_Surface *surf);
128  static void Clear();
130  static void Present();
135  static void HandleEvents(SDL_Event &e);
137  static Recti Box();
142  static void ShowAvgFps(bool log);
143 
144 private:
145  static std::unique_ptr<SDL_Window, void (*)(SDL_Window*)> mWindow;
146  static std::unique_ptr<SDL_Renderer, void (*)(SDL_Renderer*)> mRenderer;
148  static Timer mTimer;
149  static int mFrame;
150  static Recti mBox;
151  static int SCREEN_WIDTH;
152  static int SCREEN_HEIGHT;
153 };
154 
155 #endif