diff options
Diffstat (limited to 'Data/Scripts')
-rw-r--r-- | Data/Scripts/Editor/AssetBrowser.lua | 60 | ||||
-rw-r--r-- | Data/Scripts/EditorApplication.lua | 61 |
2 files changed, 60 insertions, 61 deletions
diff --git a/Data/Scripts/Editor/AssetBrowser.lua b/Data/Scripts/Editor/AssetBrowser.lua index e6e4a4a..b936702 100644 --- a/Data/Scripts/Editor/AssetBrowser.lua +++ b/Data/Scripts/Editor/AssetBrowser.lua @@ -8,17 +8,63 @@ AssetBrowser.Ctor = function(self) self.base.Ctor(self, "AssetBrowser")
end
+local shader = nil
+
+local glsl = [[
+
+#version 330 core
+
+VSH_BEGIN
+
+layout (location = 0) in vec2 vPos;
+layout (location = 1) in vec2 vUV;
+
+uniform mat4 mvp;
+
+void main()
+{
+ vec4 clip = mvp * vec4(vPos, -1, 1.0);
+ gl_Position = clip;
+}
+
+VSH_END
+
+FSH_BEGIN
+
+out vec4 FragColor;
+
+void main()
+{
+ FragColor = vec4(1,1,1,1);
+}
+FSH_END
+
+]]
+
AssetBrowser.OnGUI = function(self)
+
+ if shader == nil then
+ shader = GameLab.Engine.Rendering.Shader.New(glsl)
+ end
+
+ local ortho = Matrix44.New()
+ ortho:SetOrtho(-200, 200, -200, 200, 0.1, 10)
+
Debug.Log("AssetBrowser.OnGUI()")
GL.ClearColor({0,0,0,1})
GL.Clear(GL.EBufferType.ColorBuffer)
- GL.Color({1,1,0,1})
- GL.LoadPixelMatrix(-250, 250, -300, 300)
- GL.Begin(GL.EPrimitiveType.Triangles)
- GL.Vertex({0,0,-1})
- GL.Vertex({0,300,-1})
- GL.Vertex({250,0,-1})
- GL.End()
+ -- GL.Color({1,1,0,1})
+ -- GL.LoadPixelMatrix(-250, 250, -300, 300)
+ -- GL.Begin(GL.EPrimitiveType.Triangles)
+ -- GL.Vertex({0,0,-1})
+ -- GL.Vertex({0,300,-1})
+ -- GL.Vertex({250,0,-1})
+ -- GL.End()
+
+ shader:Use()
+ shader:SetMatrix44("mvp", ortho)
+ GameLab.Engine.Rendering.DrawUIQuad({0, 0, 100, 100})
+
end
AssetBrowser.OnFocus = function(self)
diff --git a/Data/Scripts/EditorApplication.lua b/Data/Scripts/EditorApplication.lua index a233d88..75749df 100644 --- a/Data/Scripts/EditorApplication.lua +++ b/Data/Scripts/EditorApplication.lua @@ -3,6 +3,8 @@ 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 @@ -23,7 +25,7 @@ app:SetMainWindow(mainWindow) local guiWindow = GUI.GUIWindow.New() guiWindow:SetContainerWindow(mainWindow) -guiWindow:SetPosition({0,0, 500, 400}) +guiWindow:SetPosition({0,0, 400, 400}) collectgarbage() @@ -40,7 +42,7 @@ Debug.Log(inspect(v)) Debug.Log(EditorWindowManager.name) -local c = Rendering.Color.New(1,1,1,1) +local c = Engine.Rendering.Color.New(1,1,1,1) Debug.Log(inspect(c)) Debug.Log(inspect(GL.EBufferType)) @@ -64,13 +66,13 @@ GameLab.IO.ReadFilesAsync(files, function() Debug.Log("finished") end) -local imgData = Resource.LoadImageData("./Resources/Images/brickwall.jpg") +local imgData = Engine.Resource.LoadImageData("./Resources/Images/brickwall.jpg") Debug.Log(tostring(imgData:GetWidth())) Debug.Log(tostring(imgData:GetHeight())) -local tex = Resource.LoadTexture("./Resources/Images/brickwall.jpg") +local tex = Engine.Resource.LoadTexture("./Resources/Images/brickwall.jpg") -local request = Resource.LoadImageDataAsync("./Resources/Images/brickwall.jpg") +local request = Engine.Resource.LoadImageDataAsync("./Resources/Images/brickwall.jpg") local vsh = [[ #version 330 core @@ -109,55 +111,6 @@ local fsh = [[ } ]] -local glsl = [[ - -#version 330 core -uniform vec2 screenSize; - -VSH_BEGIN - -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); -} - -VSH_END - - -FSH_BEGIN - -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); -} - -FSH_END - -]] - -local shader = Rendering.Shader.New(glsl) - while true do app:OnStep() |