FCT
载入中...
搜索中...
未找到
runtime.h
浏览该文件的文档.
1#ifndef FCT_RUNTIME_H
2#define FCT_RUNTIME_H
3#include "../ThirdParty.h"
4#include "../UI/Window.h"
11#ifdef FCT_USE_FREEIMAGE
13#endif
14namespace FCT
15{
17#ifdef FCT_USE_VULKAN
19#endif
20#ifdef FCT_USE_GLFW
22#endif
24 };
25 /*
26 *todo:
27 * 此处 runtime 是给用户包装用 的,允许有多个,
28 * 应当在内部统一隐藏一个单例 内部Runtime 负责真正的Runtiem
29 * 对于一些只能调用一次的Init的Init,term
30 */
31 class Runtime {
32 public:
34 init();
35#ifdef FCT_USE_VULKAN
36 g_common->vkContextCommon = FCT_NEW(VK_ContextCommon,this);
37 g_common->vkContextCommon->init();
38#endif
39#ifdef FCT_USE_GLFW
40 g_common->glfwUICommon = FCT_NEW(GLFW_UICommon);
41#endif
42#ifdef FCT_USE_FREEIMAGE
43 //todo:从FCTv2 直接迁移过来 的,应当改为common的模式
45#endif
46 g_common->freetypeFontCommon = FCT_NEW(Freetype_FontCommon);
47 g_common->freetypeFontCommon->init();
48 }
50#ifdef FCT_USE_VULKAN
51 g_common->vkContextCommon->term();
52#endif
53 g_common->freetypeFontCommon->tern();
54 FCT_DELETE(g_common->freetypeFontCommon);
55#ifdef FCT_USE_GLFW
56 FCT_DELETE(g_common->glfwUICommon);
57#endif
58 term();
59 }
60 void init();
61 void term();
62 int getDeviceWidth();
63 int getDeviceHeight();
65 Window* createWindow(int w,int h,const char* title = "") {
66 Window* window = createWindow();
67 window->size(w,h);
68 window->title(title);
69 window->create();
70 return window;
71 }
72 Window* createWindow(int x,int y,int w,int h,const char* title = "") {
73 Window* window = createWindow();
74 window->pos(x,y);
75 window->size(w,h);
76 window->title(title);
77 window->create();
78 return window;
79 }
84 {
85 return g_common->freetypeFontCommon->create();
86 }
87 void postUiTask(UITaskFunction task,void* param = nullptr,bool waited = true)
88 {
89
90#ifdef FCT_USE_GLFW
91 g_common->glfwUICommon->postUiTask(task,param, waited);
92#endif
93 }
94 private:
96 Runtime(const Runtime&) = delete;
97 Runtime& operator=(const Runtime&) = delete;
98 };
99}
100#endif
#define FCT_NEW(type,...)
#define FCT_DELETE(args)
ModelLoader * createModelLoader()
Window * createWindow(int x, int y, int w, int h, const char *title="")
ImageLoader * createImageLoader()
Runtime(const Runtime &)=delete
Freetype_Font * createFont()
Window * createWindow(int w, int h, const char *title="")
RuntimeCommon * g_common
Runtime & operator=(const Runtime &)=delete
void postUiTask(UITaskFunction task, void *param=nullptr, bool waited=true)
void size(int w, int h)
void pos(int x, int y)
void title(const std::string &title)
void create(WindowCreateFlags flags=WindowCreateFlag::defaultConfig)
std::function< void(void *)> UITaskFunction
Freetype_FontCommon * freetypeFontCommon
VK_ContextCommon * vkContextCommon
GLFW_UICommon * glfwUICommon