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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
local json = require "LiteJson.json"
local inspect = require "inspect"
local AssetBrowser = require "./Scripts/Editor/AssetBrowser"
local EditorWindowManager = require "./Scripts/EditorGUI/EditorWindowManager"
local Editor = GameLab.Editor
local Engine = GameLab.Engine
local Resource = GameLab.Engine.Resource
local Rendering = GameLab.Engine.Rendering
local Debug = GameLab.Debug
local GUI = GameLab.Editor.GUI
local GL = GameLab.Engine.GL
local app = GameLab.Editor.EditorApplication.New()
if app == nil then
Debug.LogError("app is nil")
end
local mainWindow = GUI.ContainerWindow.New({400, 400, 800, 500}, GUI.EShowMode.MainWindow, {100, 100}, {700, 700})
mainWindow:SetTitle("GameLab")
mainWindow:SetIcon("./Data/Icon/GameLab.ico")
app:SetMainWindow(mainWindow)
local guiWindow = GUI.GUIWindow.New()
guiWindow:SetContainerWindow(mainWindow)
guiWindow:SetPosition({0,0, 400, 400})
collectgarbage()
Debug.Log(GameLab.Path.GetRootDirectory())
Debug.Log(inspect{foo=1,2,3,4})
local wnd = AssetBrowser.New()
Debug.Log(inspect(mainWindow._type))
guiWindow:SetInstance(wnd)
local v = GameLab.Engine.Math.Vector4.New(1,2,3,4)
Debug.Log(inspect(v))
Debug.Log(EditorWindowManager.name)
local c = Engine.Rendering.Color.New(1,1,1,1)
Debug.Log(inspect(c))
Debug.Log(inspect(GL.EBufferType))
GL.ClearColor({1,1,1,1})
GL.Clear(GL.EBufferType.ColorBuffer)
local files = {
"README.txt",
"README.txt",
"README.txt",
"README.txt",
"README.txt",
"README.txt",
"README.txt",
"README.txt",
"README.txt",
}
GameLab.IO.ReadFilesAsync(files, function()
Debug.Log("finished")
end)
local imgData = Engine.Resource.LoadImageData("./Resources/Images/brickwall.jpg")
Debug.Log(tostring(imgData:GetWidth()))
Debug.Log(tostring(imgData:GetHeight()))
local tex = Engine.Resource.LoadTexture("./Resources/Images/brickwall.jpg")
local request = Engine.Resource.LoadImageDataAsync("./Resources/Images/brickwall.jpg")
local vsh = [[
#version 330 core
layout (location = 0) in vec3 aPos;
layout (location = 1) in vec3 aColor;
layout (location = 2) in vec2 aTexCoord;
out vec3 ourColor;
out vec2 TexCoord;
void main()
{
gl_Position = vec4(aPos, 1.0);
ourColor = aColor;
TexCoord = vec2(aTexCoord.x, aTexCoord.y);
}
]]
local fsh = [[
#version 330 core
out vec4 FragColor;
in vec3 ourColor;
in vec2 TexCoord;
uniform float mixValue;
// texture samplers
uniform sampler2D texture1;
uniform sampler2D texture2;
void main()
{
// linearly interpolate between both textures
FragColor = mix(texture(texture1, TexCoord), texture(texture2, TexCoord), mixValue);
}
]]
BeforeMainLoop()
local font = Engine.GUI.Font.New("./Resources/Font/deng.ttf", {256, 256}, 5, 5)
_G["default_font"] = font
font:GetCharacters([[
UTF-8是Unicode的一种实现,是一种变长字节编码方式。对于某一个字符的UTF-8编码,如果只有一个字节则其最高二进制位为0;如果是多字节,其第一个字节从最高位开始,连续的二进制位值为1的个数决定了其编码的位数,其余各字节均以10开头。UTF-8最多可用到6个字节。
]], 12)
while true do
app:OnStep()
app:PullMessage()
end
|