summaryrefslogtreecommitdiff
path: root/Data
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2021-11-19 15:33:48 +0800
committerchai <chaifix@163.com>2021-11-19 15:33:48 +0800
commit1cd31d14c95f9d52e30fbc611df5da4b46f048d9 (patch)
tree86dbda850f9b8ed26b152c6521adc0a777d6563a /Data
parent2ab7fad7b308debba0aacbf76831569f360d19a0 (diff)
*misc
Diffstat (limited to 'Data')
-rw-r--r--Data/BuiltIn/Libraries/GameLab/Engine/GUI/IMGUI.lua39
-rw-r--r--Data/BuiltIn/Libraries/GameLab/Engine/Math/Rect.lua8
-rw-r--r--Data/Libraries/GameLab/Editor/Window/GUIWindow.lua37
-rw-r--r--Data/Libraries/GameLab/Editor/Window/SplitWindow.lua6
-rw-r--r--Data/Resources/Shaders/Editor-Text.glsl5
-rw-r--r--Data/Scripts/EditorApplication.lua4
-rw-r--r--Data/boot.lua2
7 files changed, 65 insertions, 36 deletions
diff --git a/Data/BuiltIn/Libraries/GameLab/Engine/GUI/IMGUI.lua b/Data/BuiltIn/Libraries/GameLab/Engine/GUI/IMGUI.lua
index c2677bc..a16c2ed 100644
--- a/Data/BuiltIn/Libraries/GameLab/Engine/GUI/IMGUI.lua
+++ b/Data/BuiltIn/Libraries/GameLab/Engine/GUI/IMGUI.lua
@@ -12,6 +12,8 @@ local shaders = Res.shaders
local GL = GameLab.Engine.GL
local Matrix44 = find "GameLab.Engine.Math.Matrix44"
local Rendering = GameLab.Engine.Rendering
+local EEventType = GameLab.Events.EEventType
+local Resource = GameLab.Engine.Resource
GUI.BeginOnGUI = function()
GUIState.ResetControlID()
@@ -45,18 +47,33 @@ GUI.Label = function()
end
local shader
+local tex
+
GUI.Box = function(position, color, size)
- --Rendering.UseShader(Res.shaders["EditorShape"])
- local ortho = Matrix44()
- ortho:SetOrtho(0, size.x, size.y, 0, 0.1, 10)
- if shader == nil then
- shader = Rendering.Shader.CreateFromFile("./Resources/Shaders/Editor-Text.glsl")
- end
-
- Rendering.UseShader(shader)
- Rendering.SetMatrix44("gamelab_mat_mvp", ortho)
- Rendering.SetVector2("gamelab_ui_position", {0, 0})
- EditorGUI.Text(_G["default_font"], "你好世界!\nMaterials\nHello,World!\nProject Window Properties", 12)
+ if Event.current.type == EEventType.Repaint then
+ -- GL.ClearColor({0.13, 0.13, 0.13, 1})
+ -- GL.Clear(GL.EBufferType.ColorBuffer)
+ --Rendering.UseShader(Res.shaders["EditorShape"])
+ local ortho = Matrix44()
+ ortho:SetOrtho(0, size.x, size.y, 0, 0.1, 10)
+ if shader == nil then
+ shader = Rendering.Shader.CreateFromFile("./Resources/Shaders/Editor-Text.glsl")
+ --shader = Rendering.Shader.CreateFromFile("./Resources/Shaders/Editor-UI.glsl")
+ end
+ if tex == nil then
+ tex = Resource.LoadTexture("./Resources/Images/tile.png")
+ --tex = Engine.Resource.LoadTexture("./Resources/Images/brickwall_small.jpg")
+ end
+
+ Rendering.UseShader(shader)
+ Rendering.SetMatrix44("gamelab_mat_mvp", ortho)
+ Rendering.SetVector2("gamelab_ui_position", {0, 0})
+ --Rendering.SetTexture("gamelab_main_tex", tex)
+ --Rendering.DrawUIQuad({0, 0, 200, 200})
+ --Rendering.DrawUI9Slicing(1, {25, 25}, {25, 25}, {80, 80}, {400, 30} )
+ EditorGUI.Text(_G["default_font"], "你好世界!\nMaterials\nHello,World!\nProject Window Properties", 12)
+ --EditorGUI.Text(_G["default_font"], "hello", 12)
+ end
end
GUI.HorizontalSlider = function()
diff --git a/Data/BuiltIn/Libraries/GameLab/Engine/Math/Rect.lua b/Data/BuiltIn/Libraries/GameLab/Engine/Math/Rect.lua
index afadee8..2a1733a 100644
--- a/Data/BuiltIn/Libraries/GameLab/Engine/Math/Rect.lua
+++ b/Data/BuiltIn/Libraries/GameLab/Engine/Math/Rect.lua
@@ -10,10 +10,10 @@ end
Rect.Set = function(self, rect)
if rect.Is and rect:Is(Rect) then
- self.x = rect.x or rect.x
- self.y = rect.y or rect.y
- self.width = rect.z or rect.width
- self.height = rect.w or rect.height
+ self.x = rect.x
+ self.y = rect.y
+ self.width = rect.width
+ self.height = rect.height
else
self.x = rect.x or rect[1]
self.y = rect.y or rect[2]
diff --git a/Data/Libraries/GameLab/Editor/Window/GUIWindow.lua b/Data/Libraries/GameLab/Editor/Window/GUIWindow.lua
index e2ceee5..c430cfd 100644
--- a/Data/Libraries/GameLab/Editor/Window/GUIWindow.lua
+++ b/Data/Libraries/GameLab/Editor/Window/GUIWindow.lua
@@ -9,10 +9,11 @@ local Utils = require "GameLab.Utils"
local Events = require "GameLab.Events"
local GUI = require "GameLab.Engine.GUI"
-local Rect = Math.Rect
-local Event = Events.Event
-local Vector2 = Math.Vector2
-local Color = Rendering.Color
+local Rect = Math.Rect
+local Event = Events.Event
+local EEventType = Events.EEventType
+local Vector2 = Math.Vector2
+local Color = Rendering.Color
local clone = Utils.Clone
@@ -99,20 +100,22 @@ end
-- 最主要的回调函数,同时处理窗口管理、事件、布局、渲染
GUIWindow.OnGUI = function(self)
Debug.Log("OnGUI")
- self:ClearBackground()
local event = Event.current
- local sp = self.splitWindow
- if sp ~= nil and event ~= nil then
- local e = clone(event)
- e.mousePosition:Add(self.position.xy) -- 坐标转换到全局containerWindow的坐标
- sp:DoSplit(e)
+ if event.type ~= EEventType.Repaint then
+ local sp = self.splitWindow
+ if sp ~= nil and event ~= nil then
+ local e = clone(event)
+ e.mousePosition:Add(self.position.xy) -- 坐标转换到全局containerWindow的坐标
+ sp:DoSplit(e)
+ end
end
+ self:ClearBackground()
GUI.Box(Rect(), Color(), self.position.size)
-end
+end
GUIWindow.GetContainerWindow = function(self)
return self.m_ContainerWindow
@@ -120,11 +123,17 @@ end
GUIWindow.OnFocus = function(self)
Debug.Log("GUIWindow.OnFocus")
-end
+end
GUIWindow.ClearBackground = function(self)
- GL.ClearColor(self.m_ClearColor)
- GL.Clear(GL.EBufferType.ColorBuffer)
+ if Event.current.type == EEventType.Repaint then
+ GL.ClearColor(self.m_ClearColor)
+ GL.Clear(GL.EBufferType.ColorBuffer)
+ end
end
+GUIWindow.DoRepaint = function(self)
+ self.m_Native:DoPaint()
+end
+
return GUIWindow \ No newline at end of file
diff --git a/Data/Libraries/GameLab/Editor/Window/SplitWindow.lua b/Data/Libraries/GameLab/Editor/Window/SplitWindow.lua
index fea443d..cd8d3a3 100644
--- a/Data/Libraries/GameLab/Editor/Window/SplitWindow.lua
+++ b/Data/Libraries/GameLab/Editor/Window/SplitWindow.lua
@@ -179,4 +179,10 @@ SplitWindow.AddSubWindow = function(self, subWindow)
subWindow.m_Parent = self
end
+SplitWindow.DoRepaint = function(self)
+ for _, wnd in ipairs(self.m_SubWindows) do
+ wnd:DoRepaint()
+ end
+end
+
return SplitWindow \ No newline at end of file
diff --git a/Data/Resources/Shaders/Editor-Text.glsl b/Data/Resources/Shaders/Editor-Text.glsl
index d1003c3..3c1ad4f 100644
--- a/Data/Resources/Shaders/Editor-Text.glsl
+++ b/Data/Resources/Shaders/Editor-Text.glsl
@@ -5,7 +5,7 @@ Cull Off
Blend SrcAlpha OneMinusSrcAlpha
DepthTest Off
CMD_END
-
+
uniform mat4 gamelab_mat_mvp;
uniform sampler2D gamelab_main_tex;
uniform vec2 gamelab_ui_position;
@@ -36,11 +36,8 @@ out vec4 FragColor;
void main()
{
- //vec2 uv = vec2(uv.x, 1 - uv.y);
vec4 sampled = vec4(0.8,0.8,0.8,texture(gamelab_main_tex, uv).r);
sampled *= color;
- // if(sampled.a == 0)
- // sampled = vec4(1,0,0,1);
FragColor = sampled;
}
FSH_END
diff --git a/Data/Scripts/EditorApplication.lua b/Data/Scripts/EditorApplication.lua
index 92df9ad..1a31cdd 100644
--- a/Data/Scripts/EditorApplication.lua
+++ b/Data/Scripts/EditorApplication.lua
@@ -45,8 +45,8 @@ local v = GameLab.Engine.Math.Vector4(1,2,3,4)
local c = Engine.Rendering.Color(1,1,1,1)
-GL.ClearColor({1,1,1,1})
-GL.Clear(GL.EBufferType.ColorBuffer)
+-- GL.ClearColor({1,1,1,1})
+-- GL.Clear(GL.EBufferType.ColorBuffer)
local files = {
"README.txt",
diff --git a/Data/boot.lua b/Data/boot.lua
index ff8e93f..94dabd1 100644
--- a/Data/boot.lua
+++ b/Data/boot.lua
@@ -37,7 +37,7 @@ require "GameLab.Editor"
require "GameLab.Editor.Window"
-- debugging
---require("LuaPanda").start("127.0.0.1",8818)
+require("LuaPanda").start("127.0.0.1",8818)
-- launch editor
dofile("./Scripts/EditorApplication.lua")