blob: 8066f8a8686954d24f65a6dd76091bc9d2e9b62c (
plain)
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
|
#ifndef __JIN_RENDER_WINDOW
#define __JIN_RENDER_WINDOW
#include <SDL2/SDL.h>
#include "../utils/utils.h"
namespace jin
{
namespace render
{
class Window
{
public:
struct Setting
{
int width, height; // ڴС
bool vsync; // ֱͬ
const char* title; //
};
onlyonce void init(const Setting& setting);
SDL_Window* getWnd();
SDL_GLContext getCtx();
static inline Window* get()
{
return (g_wnd ? g_wnd : (g_wnd = new Window()));
}
inline int getW()
{
return width;
}
inline int getH()
{
return height;
}
inline void swapBuffers();
private:
Window();
~Window();
static Window* g_wnd;
SDL_Window* wnd;
SDL_GLContext ctx;
int width, height;
inline void _init(const Setting& setting);
};
}
}
#endif
|