-
Notifications
You must be signed in to change notification settings - Fork 0
/
window.h
81 lines (62 loc) · 2.11 KB
/
window.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
//
// window.h
// cookrpg
//
// Created by Wayne Moorefield on 3/16/14.
// Copyright (c) 2014 East Wake Academy Tech Club. All rights reserved.
//
#ifndef __cookrpg__window__
#define __cookrpg__window__
#include <memory>
#include <map>
#include <string>
#include <SDL2/SDL.h>
#include "textureinterface.h"
#include "surface.h"
class Window
{
public:
virtual ~Window();
static std::shared_ptr<Window> create();
bool init();
bool uninit();
std::shared_ptr<TextureInterface> createTexture(std::shared_ptr<Surface> surface);
std::shared_ptr<TextureInterface> createTexture(const std::string& name,
int width, int height,
int pixelFormat);
int getPixelFormat() const;
int getWidth() const { return mWidth; }
int getHeight() const { return mHeight; }
void pruneTextures();
void render(std::shared_ptr<TextureInterface> texture,
const SDL_Rect *src,
const SDL_Rect *dst);
void render(std::shared_ptr<TextureInterface> texture,
const SDL_Rect *src,
const SDL_Rect *dst,
SDL_RendererFlip flipFlags);
void render(std::shared_ptr<TextureInterface> dstTexture,
std::shared_ptr<TextureInterface> srcTexture,
const SDL_Rect* src,
const SDL_Rect* dst);
void render(std::shared_ptr<TextureInterface> dstTexture,
std::shared_ptr<TextureInterface> srcTexture,
const SDL_Rect* src,
const SDL_Rect* dst,
SDL_RendererFlip flipFlags);
void clear();
void clear(std::shared_ptr<TextureInterface> texture);
void flip();
protected:
Window();
private:
SDL_Window* mWindow;
SDL_Renderer* mRenderer;
SDL_Surface* mPrimarySurface;
typedef std::map<std::string, std::shared_ptr<TextureInterface>> TextureMap;
TextureMap mTextures;
bool mInitialized;
int mWidth;
int mHeight;
};
#endif /* defined(__cookrpg__window__) */