aboutsummaryrefslogtreecommitdiff
path: root/libjin/Graphics
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2018-07-28 21:37:51 +0800
committerchai <chaifix@163.com>2018-07-28 21:37:51 +0800
commitfb1ca399126712a03fd41fe555a6228618da1665 (patch)
treeca2484c6632bf1fb3b86441006fb3f81812c801e /libjin/Graphics
parent714b68bf2e6e3caf7119b40210cad291a9a349f2 (diff)
*update
Diffstat (limited to 'libjin/Graphics')
-rw-r--r--libjin/Graphics/Canvas.cpp2
-rw-r--r--libjin/Graphics/Window.cpp13
-rw-r--r--libjin/Graphics/Window.h12
3 files changed, 16 insertions, 11 deletions
diff --git a/libjin/Graphics/Canvas.cpp b/libjin/Graphics/Canvas.cpp
index dddc889..f5bd09f 100644
--- a/libjin/Graphics/Canvas.cpp
+++ b/libjin/Graphics/Canvas.cpp
@@ -109,7 +109,7 @@ namespace graphics
cur = 0;
glBindFramebuffer(GL_FRAMEBUFFER, 0);
- WindowSystem* wnd = WindowSystem::get();
+ Window* wnd = Window::get();
int ww = wnd->getW(),
wh = wnd->getH();
diff --git a/libjin/Graphics/Window.cpp b/libjin/Graphics/Window.cpp
index 8a7e8a2..cdff426 100644
--- a/libjin/Graphics/Window.cpp
+++ b/libjin/Graphics/Window.cpp
@@ -14,7 +14,7 @@ namespace jin
namespace graphics
{
- bool WindowSystem::initSystem(const SettingBase* s)
+ bool Window::initSystem(const SettingBase* s)
{
Loghelper::log(Loglevel::LV_INFO, "Init window system");
@@ -22,7 +22,6 @@ namespace graphics
return false;
const Setting* setting = (Setting*)s;
-
width = setting->width;
height = setting->height;
fps = setting->fps;
@@ -53,8 +52,12 @@ namespace graphics
int wx = SDL_WINDOWPOS_UNDEFINED,
wy = SDL_WINDOWPOS_UNDEFINED;
+
+ int flag = SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL;
+ if (setting->fullscreen) flag |= SDL_WINDOW_FULLSCREEN;
+ if (setting->resizable) flag |= SDL_WINDOW_RESIZABLE;
- wnd = SDL_CreateWindow(title, wx, wy, width, height, SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL);
+ wnd = SDL_CreateWindow(title, wx, wy, width, height, flag);
if (wnd == NULL)
return false;
ctx = SDL_GL_CreateContext(wnd);
@@ -74,13 +77,13 @@ namespace graphics
return true;
}
- void WindowSystem::quitSystem()
+ void Window::quitSystem()
{
SDL_DestroyWindow(wnd);
SDL_Quit();
}
- inline void WindowSystem::swapBuffers()
+ inline void Window::swapBuffers()
{
if (wnd)
SDL_GL_SwapWindow(wnd);
diff --git a/libjin/Graphics/Window.h b/libjin/Graphics/Window.h
index 66c34a5..e09e9f9 100644
--- a/libjin/Graphics/Window.h
+++ b/libjin/Graphics/Window.h
@@ -12,7 +12,7 @@ namespace jin
namespace graphics
{
- class WindowSystem : public Subsystem<WindowSystem>
+ class Window : public Subsystem<Window>
{
public:
@@ -20,22 +20,24 @@ namespace graphics
{
public:
const char* title; //
+ bool fullscreen; // ȫ
int width, height; // ڴС
bool vsync; // ֱͬ
int fps; // FPS
+ bool resizable; // resize
};
inline int getW(){ return width; }
inline int getH(){ return height; }
- inline int getFPS() { return fps; }
+ inline int getFPS(){ return fps; }
inline void swapBuffers();
private:
- WindowSystem() {};
- virtual ~WindowSystem() {};
+ Window() {};
+ virtual ~Window() {};
- SINGLETON(WindowSystem);
+ SINGLETON(Window);
SDL_Window* wnd;