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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
#include <windows.h>
#include <vector>
#include "GUI/EditorWindows.h"
#include "Runtime/Lua/LuaBind/LuaBind.h"
#include "EditorManager.h"
#include "Runtime/Graphics/OpenGL.h"
#include "Editor/Scripting/EditorScripting.h"
#include "Editor/Win/Win.h"
#include "Runtime/Threading/Thread.h"
#include "Runtime/GUI/Font.h"
using namespace LuaBind;
void ErrorHandle(cc8* msg)
{
log_error("[Lua] %s", msg);
}
void TestFont()
{
//TextGeneratingSettings setting;
//setting.margin = 5;
//setting.padding = 5;
//setting.atlasSize = Internal::Vector2(512, 512);
//Font::Instance()->Setup(setting);
//auto content = L"abcdf与电子计算机的区别 与电子计算机的最大区别在于: 只是简单的计算工具,有些机型具备函数计算功能,有些机型具备一定的贮存功能,但一般只能存储几组数据。计算机则具备复杂存贮功能、控制功能,更加";
// Font::Instance()->RenderCharacters((character::Codepoint*)content, wcslen(content), 14);
}
int BeforeMainLoop(lua_State* L)
{
TestFont();
return 0;
}
void InitLuaState(LuaBind::VM& vm)
{
vm.Setup();
vm.OpenLibs();
LuaBind::onRegisterNativeClass = LuaHelper::OnRegisterNativeClass;
LuaBind::onErrorOccured = ErrorHandle;
if (!SetupGameLabEditorScripting(vm.GetMainThread()))
{
log_error("Can't setup scripting.");
}
// https://stackoverflow.com/questions/21495901/loadlibrarya-and-relative-path/21495971
// ll_load装载dll,路径需要设置搜索路径
std::string workingDir = Win::GetCurrentWorkingDirectory();
Win::SetDllSearchDirectory(workingDir);
LuaBind::State state = vm.GetMainState();
state.PushGlobalNamespace();
state.RegisterMethod("BeforeMainLoop", BeforeMainLoop);
state.DoFile("./boot.lua");
}
#ifdef GAMELAB_DEBUG
int main()
#else
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw)
#endif
{
log_info("log_info_c test, %s %d", "hello", 3);
WindowUtil::RegisterClasses();
LuaBind::VM vm;
InitLuaState(vm);
return 0;
}
|