aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2018-07-28 13:48:26 +0800
committerchai <chaifix@163.com>2018-07-28 13:48:26 +0800
commit3fa76830d3bde5cb3c76da0cc58dd613965b98e5 (patch)
tree6940d7db722a9f010682e3f69ba10ddb19ac4f5d
parent97c96e1d127a7a0c21d6bcf8af97b90649971d1f (diff)
*update
-rw-r--r--libjin/Core/Game.cpp8
-rw-r--r--libjin/Graphics/Window.cpp1
-rw-r--r--libjin/Graphics/Window.h17
-rw-r--r--test/01HelloWorld/main.cpp1
4 files changed, 15 insertions, 12 deletions
diff --git a/libjin/Core/Game.cpp b/libjin/Core/Game.cpp
index f2223b2..707a983 100644
--- a/libjin/Core/Game.cpp
+++ b/libjin/Core/Game.cpp
@@ -1,25 +1,31 @@
#include "game.h"
#include "../Time/Timer.h"
#include "../input/Event.h"
+#include "../Graphics/Window.h"
namespace jin
{
namespace core
{
+ using namespace jin::graphics;
using namespace jin::input;
Game::Game() :_running(true) {};
void Game::run()
{
+ WindowSystem* wnd = WindowSystem::get();
_running = true;
Event e;
+ int fps = 60;
+ if (wnd != nullptr)
+ fps = wnd->getFPS();
while (_running)
{
while (jin::input::pollEvent(&e))
{
- if (_instance != nullptr && _onEvent)
+ if (_onEvent != nullptr)
_onEvent(&e);
}
if (!_running)
diff --git a/libjin/Graphics/Window.cpp b/libjin/Graphics/Window.cpp
index 28e5b84..8a7e8a2 100644
--- a/libjin/Graphics/Window.cpp
+++ b/libjin/Graphics/Window.cpp
@@ -25,6 +25,7 @@ namespace graphics
width = setting->width;
height = setting->height;
+ fps = setting->fps;
bool vsync = setting->vsync;
const char* title = setting->title;
diff --git a/libjin/Graphics/Window.h b/libjin/Graphics/Window.h
index 6213cee..66c34a5 100644
--- a/libjin/Graphics/Window.h
+++ b/libjin/Graphics/Window.h
@@ -19,21 +19,15 @@ namespace graphics
struct Setting : SettingBase
{
public:
+ const char* title; //
int width, height; // ڴС
bool vsync; // ֱͬ
- const char* title; //
+ int fps; // FPS
};
- inline int getW()
- {
- return width;
- }
-
- inline int getH()
- {
- return height;
- }
-
+ inline int getW(){ return width; }
+ inline int getH(){ return height; }
+ inline int getFPS() { return fps; }
inline void swapBuffers();
private:
@@ -46,6 +40,7 @@ namespace graphics
SDL_Window* wnd;
int width, height;
+ int fps;
onlyonce bool initSystem(const SettingBase* setting) override;
onlyonce void quitSystem() override;
diff --git a/test/01HelloWorld/main.cpp b/test/01HelloWorld/main.cpp
index 09a12d3..77d5096 100644
--- a/test/01HelloWorld/main.cpp
+++ b/test/01HelloWorld/main.cpp
@@ -36,6 +36,7 @@ int main(int argc, char* argv[])
wndSetting.width = 600;
wndSetting.height = 512;
wndSetting.title = "test";
+ wndSetting.fps = 60;
wndSetting.vsync = false;
wnd->init(&wndSetting);