aboutsummaryrefslogtreecommitdiff
path: root/src/libjin/render/window.h
blob: f29c82d16264fc3a21b6532eb758a5bee150dcc9 (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
#ifndef __JIN_RENDER_WINDOW
#define __JIN_RENDER_WINDOW
#include "SDL2/SDL.h"
namespace jin
{
namespace render
{
    class Window
    {
    public: 
        
        void init(int w, int h, const char* t);
        
        SDL_Window* getWnd();
        
        SDL_GLContext getCtx(); 
        
        static inline Window* get()
        {
            return (g_wnd ? g_wnd : (g_wnd = new Window()));
        }

        inline int Window::getW()
        {
            return w;
        }

        inline int Window::getH()
        {
            return h;
        }

        inline void Window::swapBuffers()
        {
            if (wnd)
                SDL_GL_SwapWindow(wnd);
        }
    private: 

        Window(); 
        ~Window(); 
        
        static Window* g_wnd; 
        
        SDL_Window* wnd; 
        
        SDL_GLContext ctx;
        
        int w, h;
    };
}
}
#endif