summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2021-10-26 19:33:40 +0800
committerchai <chaifix@163.com>2021-10-26 19:33:40 +0800
commit051abd04e4527095ef15412939450fbe504daebe (patch)
tree30a966d104ee866bc135cce58b4a5fa561c8c4e7
parentb1228baf73f6dc3336e24afbf36087e15730732a (diff)
+texture & imagedata
-rw-r--r--Data/Configs/Settings.json3
-rw-r--r--Data/DefaultContent/Libraries/GameLab/Engine/Math/Vector2.lua5
-rw-r--r--Data/DefaultContent/Libraries/GameLab/Engine/Math/Vector3.lua6
-rw-r--r--Data/DefaultContent/Libraries/GameLab/Engine/Rendering/Image.lua20
-rw-r--r--Data/DefaultContent/Resources/Images/white.pngbin0 -> 219 bytes
-rw-r--r--Data/Libraries/GameLab/Editor/init.lua6
-rw-r--r--Data/Libraries/lua-csv/.gitignore (renamed from Data/DefaultContent/Libraries/lua-csv/.gitignore)0
-rw-r--r--Data/Libraries/lua-csv/AUTHORS (renamed from Data/DefaultContent/Libraries/lua-csv/AUTHORS)0
-rw-r--r--Data/Libraries/lua-csv/LICENSE (renamed from Data/DefaultContent/Libraries/lua-csv/LICENSE)0
-rw-r--r--Data/Libraries/lua-csv/README.md (renamed from Data/DefaultContent/Libraries/lua-csv/README.md)0
-rw-r--r--Data/Libraries/lua-csv/lua/config.ld (renamed from Data/DefaultContent/Libraries/lua-csv/lua/config.ld)0
-rw-r--r--Data/Libraries/lua-csv/lua/csv.lua (renamed from Data/DefaultContent/Libraries/lua-csv/lua/csv.lua)0
-rw-r--r--Data/Libraries/lua-csv/lua/test.lua (renamed from Data/DefaultContent/Libraries/lua-csv/lua/test.lua)0
-rw-r--r--Data/Libraries/lua-csv/makefile (renamed from Data/DefaultContent/Libraries/lua-csv/makefile)0
-rw-r--r--Data/Libraries/lua-csv/rockspecs/csv-1-1.rockspec (renamed from Data/DefaultContent/Libraries/lua-csv/rockspecs/csv-1-1.rockspec)0
-rw-r--r--Data/Libraries/lua-csv/rockspecs/csv-scm-1.rockspec (renamed from Data/DefaultContent/Libraries/lua-csv/rockspecs/csv-scm-1.rockspec)0
-rw-r--r--Data/Libraries/lua-csv/test-data/BOM.csv (renamed from Data/DefaultContent/Libraries/lua-csv/test-data/BOM.csv)0
-rw-r--r--Data/Libraries/lua-csv/test-data/bars.txt (renamed from Data/DefaultContent/Libraries/lua-csv/test-data/bars.txt)0
-rw-r--r--Data/Libraries/lua-csv/test-data/blank-line.csv (renamed from Data/DefaultContent/Libraries/lua-csv/test-data/blank-line.csv)0
-rw-r--r--Data/Libraries/lua-csv/test-data/embedded-newlines.csv (renamed from Data/DefaultContent/Libraries/lua-csv/test-data/embedded-newlines.csv)0
-rw-r--r--Data/Libraries/lua-csv/test-data/embedded-quotes.csv (renamed from Data/DefaultContent/Libraries/lua-csv/test-data/embedded-quotes.csv)0
-rw-r--r--Data/Libraries/lua-csv/test-data/header.csv (renamed from Data/DefaultContent/Libraries/lua-csv/test-data/header.csv)0
-rw-r--r--Data/Resources/Gizmos/Gizmos.xlsxbin6184 -> 0 bytes
-rw-r--r--Data/Resources/Icons/buttons/add.pngbin0 -> 314 bytes
-rw-r--r--Data/Resources/Icons/buttons/alpha.pngbin0 -> 2898 bytes
-rw-r--r--Data/Resources/Icons/buttons/checker.pngbin0 -> 2837 bytes
-rw-r--r--Data/Resources/Icons/buttons/cog.pngbin0 -> 3217 bytes
-rw-r--r--Data/Resources/Icons/buttons/del.pngbin0 -> 129 bytes
-rw-r--r--Data/Resources/Icons/buttons/del2.pngbin0 -> 2903 bytes
-rw-r--r--Data/Resources/Icons/buttons/del3.pngbin0 -> 3076 bytes
-rw-r--r--Data/Resources/Icons/buttons/delete.pngbin0 -> 2927 bytes
-rw-r--r--Data/Resources/Icons/buttons/disable.pngbin0 -> 2983 bytes
-rw-r--r--Data/Resources/Icons/buttons/down.pngbin0 -> 2998 bytes
-rw-r--r--Data/Resources/Icons/buttons/forward.pngbin0 -> 2926 bytes
-rw-r--r--Data/Resources/Icons/buttons/invisible.pngbin0 -> 3321 bytes
-rw-r--r--Data/Resources/Icons/buttons/lock.pngbin0 -> 2952 bytes
-rw-r--r--Data/Resources/Icons/buttons/open.pngbin0 -> 2978 bytes
-rw-r--r--Data/Resources/Icons/buttons/pause.pngbin0 -> 2941 bytes
-rw-r--r--Data/Resources/Icons/buttons/pen.pngbin0 -> 3126 bytes
-rw-r--r--Data/Resources/Icons/buttons/play.pngbin0 -> 3026 bytes
-rw-r--r--Data/Resources/Icons/buttons/play2.pngbin0 -> 3018 bytes
-rw-r--r--Data/Resources/Icons/buttons/pop_disabled.pngbin0 -> 2942 bytes
-rw-r--r--Data/Resources/Icons/buttons/pop_hover.pngbin0 -> 2893 bytes
-rw-r--r--Data/Resources/Icons/buttons/pop_normal.pngbin0 -> 2895 bytes
-rw-r--r--Data/Resources/Icons/buttons/pop_selected.pngbin0 -> 2901 bytes
-rw-r--r--Data/Resources/Icons/buttons/prefab_apply.pngbin0 -> 3053 bytes
-rw-r--r--Data/Resources/Icons/buttons/prefab_revert.pngbin0 -> 3070 bytes
-rw-r--r--Data/Resources/Icons/buttons/rgb.pngbin0 -> 2954 bytes
-rw-r--r--Data/Resources/Icons/buttons/search.pngbin0 -> 2947 bytes
-rw-r--r--Data/Resources/Icons/buttons/smalladd.pngbin0 -> 2947 bytes
-rw-r--r--Data/Resources/Icons/buttons/smalldel.pngbin0 -> 2967 bytes
-rw-r--r--Data/Resources/Icons/buttons/smalldisable.pngbin0 -> 3173 bytes
-rw-r--r--Data/Resources/Icons/buttons/smalldisableempty.pngbin0 -> 2970 bytes
-rw-r--r--Data/Resources/Icons/buttons/smalllock.pngbin0 -> 3012 bytes
-rw-r--r--Data/Resources/Icons/buttons/star.pngbin0 -> 3246 bytes
-rw-r--r--Data/Resources/Icons/buttons/stopplay.pngbin0 -> 2918 bytes
-rw-r--r--Data/Resources/Icons/buttons/up.pngbin0 -> 2990 bytes
-rw-r--r--Data/Resources/Images/UI.csv2
-rw-r--r--Data/Resources/Images/UI.xlsxbin6625 -> 0 bytes
-rw-r--r--Data/Resources/Images/brickwall.jpgbin0 -> 198744 bytes
-rw-r--r--Data/Resources/Metatable/Excel/Extract_All.cmd3
-rw-r--r--Data/Resources/Metatable/Excel/Extract_Shaders.cmd1
-rw-r--r--Data/Resources/Metatable/Excel/Icons.xlsxbin9170 -> 12385 bytes
-rw-r--r--Data/Resources/Metatable/Excel/Shaders.xlsxbin0 -> 8891 bytes
-rw-r--r--Data/Resources/Metatable/Icons.csv15
-rw-r--r--Data/Resources/Metatable/Shaders.csv2
-rw-r--r--Data/Scripts/EditorApplication.lua6
-rw-r--r--Data/Scripts/EditorGUI/EditorImages.lua25
-rw-r--r--Data/boot.lua8
-rw-r--r--Projects/VisualStudio/Editor/Editor.vcxproj2
-rw-r--r--Projects/VisualStudio/Editor/Editor.vcxproj.filters6
-rw-r--r--Runtime/Debug/Log.cpp8
-rw-r--r--Runtime/FileSystem/FileJobs.h3
-rw-r--r--Runtime/Graphics/Device.h12
-rw-r--r--Runtime/Graphics/ImageData.h49
-rw-r--r--Runtime/Graphics/RenderTexture.h4
-rw-r--r--Runtime/Graphics/Texture.cpp69
-rw-r--r--Runtime/Graphics/Texture.h103
-rw-r--r--Runtime/Lua/LuaHelper.cpp5
-rw-r--r--Runtime/Lua/LuaHelper.h7
-rw-r--r--Runtime/Scripting/Rendering/ImageData.bind.cpp38
-rw-r--r--Runtime/Scripting/Rendering/Rendering.bind.cpp32
-rw-r--r--Runtime/Scripting/Rendering/Texture.bind.cpp143
83 files changed, 507 insertions, 76 deletions
diff --git a/Data/Configs/Settings.json b/Data/Configs/Settings.json
index e69de29..cb92a2e 100644
--- a/Data/Configs/Settings.json
+++ b/Data/Configs/Settings.json
@@ -0,0 +1,3 @@
+{
+
+} \ No newline at end of file
diff --git a/Data/DefaultContent/Libraries/GameLab/Engine/Math/Vector2.lua b/Data/DefaultContent/Libraries/GameLab/Engine/Math/Vector2.lua
index 5697797..822537f 100644
--- a/Data/DefaultContent/Libraries/GameLab/Engine/Math/Vector2.lua
+++ b/Data/DefaultContent/Libraries/GameLab/Engine/Math/Vector2.lua
@@ -1,5 +1,8 @@
local Vector2 = GameLab.Class("GameLab.Engine.Math.Vector2")
-
+Vector2.Ctor = function(self, x, y)
+ self.x = x or 0
+ self.y = y or 0
+end
return Vector2 \ No newline at end of file
diff --git a/Data/DefaultContent/Libraries/GameLab/Engine/Math/Vector3.lua b/Data/DefaultContent/Libraries/GameLab/Engine/Math/Vector3.lua
index caa28a4..e383bf0 100644
--- a/Data/DefaultContent/Libraries/GameLab/Engine/Math/Vector3.lua
+++ b/Data/DefaultContent/Libraries/GameLab/Engine/Math/Vector3.lua
@@ -1,5 +1,9 @@
local Vector3 = GameLab.Class("GameLab.Engine.Math.Vector3")
-
+Vector3.Ctor = function(self, x, y, z)
+ self.x = x or 0
+ self.y = y or 0
+ self.z = z or 0
+end
return Vector3 \ No newline at end of file
diff --git a/Data/DefaultContent/Libraries/GameLab/Engine/Rendering/Image.lua b/Data/DefaultContent/Libraries/GameLab/Engine/Rendering/Image.lua
new file mode 100644
index 0000000..b209425
--- /dev/null
+++ b/Data/DefaultContent/Libraries/GameLab/Engine/Rendering/Image.lua
@@ -0,0 +1,20 @@
+-- Image在texture基础上增加了一些元数据
+local Image = GameLab.Class("GameLab.Engine.Rendering.Image")
+
+Image.Ctor = function(self, texture)
+ self.texture = texture -- "atlas"
+ self.rect = {0, 0, 1, 1} -- 这个image在texture中的位置
+ self.isSlicing = false
+ self.slicing = {0, 0, 0, 0}
+end
+
+Image.GetWidth = function(self)
+end
+
+Image.GetHeight = function(self)
+end
+
+Image.GetSize = function(self)
+end
+
+return Image \ No newline at end of file
diff --git a/Data/DefaultContent/Resources/Images/white.png b/Data/DefaultContent/Resources/Images/white.png
new file mode 100644
index 0000000..ce5b789
--- /dev/null
+++ b/Data/DefaultContent/Resources/Images/white.png
Binary files differ
diff --git a/Data/Libraries/GameLab/Editor/init.lua b/Data/Libraries/GameLab/Editor/init.lua
index 99a8091..97b4b2e 100644
--- a/Data/Libraries/GameLab/Editor/init.lua
+++ b/Data/Libraries/GameLab/Editor/init.lua
@@ -1,2 +1,8 @@
+local m = GameLab.Editor or {}
+GameLab.Editor = m
+local import = GameLab.import(...)
+m.AssetManager = import("AssetManager")
+
+return m \ No newline at end of file
diff --git a/Data/DefaultContent/Libraries/lua-csv/.gitignore b/Data/Libraries/lua-csv/.gitignore
index 131f9b6..131f9b6 100644
--- a/Data/DefaultContent/Libraries/lua-csv/.gitignore
+++ b/Data/Libraries/lua-csv/.gitignore
diff --git a/Data/DefaultContent/Libraries/lua-csv/AUTHORS b/Data/Libraries/lua-csv/AUTHORS
index 84961bd..84961bd 100644
--- a/Data/DefaultContent/Libraries/lua-csv/AUTHORS
+++ b/Data/Libraries/lua-csv/AUTHORS
diff --git a/Data/DefaultContent/Libraries/lua-csv/LICENSE b/Data/Libraries/lua-csv/LICENSE
index d8472a0..d8472a0 100644
--- a/Data/DefaultContent/Libraries/lua-csv/LICENSE
+++ b/Data/Libraries/lua-csv/LICENSE
diff --git a/Data/DefaultContent/Libraries/lua-csv/README.md b/Data/Libraries/lua-csv/README.md
index d10314a..d10314a 100644
--- a/Data/DefaultContent/Libraries/lua-csv/README.md
+++ b/Data/Libraries/lua-csv/README.md
diff --git a/Data/DefaultContent/Libraries/lua-csv/lua/config.ld b/Data/Libraries/lua-csv/lua/config.ld
index af51949..af51949 100644
--- a/Data/DefaultContent/Libraries/lua-csv/lua/config.ld
+++ b/Data/Libraries/lua-csv/lua/config.ld
diff --git a/Data/DefaultContent/Libraries/lua-csv/lua/csv.lua b/Data/Libraries/lua-csv/lua/csv.lua
index 64196c0..64196c0 100644
--- a/Data/DefaultContent/Libraries/lua-csv/lua/csv.lua
+++ b/Data/Libraries/lua-csv/lua/csv.lua
diff --git a/Data/DefaultContent/Libraries/lua-csv/lua/test.lua b/Data/Libraries/lua-csv/lua/test.lua
index f418cf6..f418cf6 100644
--- a/Data/DefaultContent/Libraries/lua-csv/lua/test.lua
+++ b/Data/Libraries/lua-csv/lua/test.lua
diff --git a/Data/DefaultContent/Libraries/lua-csv/makefile b/Data/Libraries/lua-csv/makefile
index dfa7596..dfa7596 100644
--- a/Data/DefaultContent/Libraries/lua-csv/makefile
+++ b/Data/Libraries/lua-csv/makefile
diff --git a/Data/DefaultContent/Libraries/lua-csv/rockspecs/csv-1-1.rockspec b/Data/Libraries/lua-csv/rockspecs/csv-1-1.rockspec
index 6f280aa..6f280aa 100644
--- a/Data/DefaultContent/Libraries/lua-csv/rockspecs/csv-1-1.rockspec
+++ b/Data/Libraries/lua-csv/rockspecs/csv-1-1.rockspec
diff --git a/Data/DefaultContent/Libraries/lua-csv/rockspecs/csv-scm-1.rockspec b/Data/Libraries/lua-csv/rockspecs/csv-scm-1.rockspec
index 29629da..29629da 100644
--- a/Data/DefaultContent/Libraries/lua-csv/rockspecs/csv-scm-1.rockspec
+++ b/Data/Libraries/lua-csv/rockspecs/csv-scm-1.rockspec
diff --git a/Data/DefaultContent/Libraries/lua-csv/test-data/BOM.csv b/Data/Libraries/lua-csv/test-data/BOM.csv
index 9787c0d..9787c0d 100644
--- a/Data/DefaultContent/Libraries/lua-csv/test-data/BOM.csv
+++ b/Data/Libraries/lua-csv/test-data/BOM.csv
diff --git a/Data/DefaultContent/Libraries/lua-csv/test-data/bars.txt b/Data/Libraries/lua-csv/test-data/bars.txt
index 9decabc..9decabc 100644
--- a/Data/DefaultContent/Libraries/lua-csv/test-data/bars.txt
+++ b/Data/Libraries/lua-csv/test-data/bars.txt
diff --git a/Data/DefaultContent/Libraries/lua-csv/test-data/blank-line.csv b/Data/Libraries/lua-csv/test-data/blank-line.csv
index 63fc515..63fc515 100644
--- a/Data/DefaultContent/Libraries/lua-csv/test-data/blank-line.csv
+++ b/Data/Libraries/lua-csv/test-data/blank-line.csv
diff --git a/Data/DefaultContent/Libraries/lua-csv/test-data/embedded-newlines.csv b/Data/Libraries/lua-csv/test-data/embedded-newlines.csv
index 67987d1..67987d1 100644
--- a/Data/DefaultContent/Libraries/lua-csv/test-data/embedded-newlines.csv
+++ b/Data/Libraries/lua-csv/test-data/embedded-newlines.csv
diff --git a/Data/DefaultContent/Libraries/lua-csv/test-data/embedded-quotes.csv b/Data/Libraries/lua-csv/test-data/embedded-quotes.csv
index e0c5c73..e0c5c73 100644
--- a/Data/DefaultContent/Libraries/lua-csv/test-data/embedded-quotes.csv
+++ b/Data/Libraries/lua-csv/test-data/embedded-quotes.csv
diff --git a/Data/DefaultContent/Libraries/lua-csv/test-data/header.csv b/Data/Libraries/lua-csv/test-data/header.csv
index 89f702e..89f702e 100644
--- a/Data/DefaultContent/Libraries/lua-csv/test-data/header.csv
+++ b/Data/Libraries/lua-csv/test-data/header.csv
diff --git a/Data/Resources/Gizmos/Gizmos.xlsx b/Data/Resources/Gizmos/Gizmos.xlsx
deleted file mode 100644
index cb921d4..0000000
--- a/Data/Resources/Gizmos/Gizmos.xlsx
+++ /dev/null
Binary files differ
diff --git a/Data/Resources/Icons/buttons/add.png b/Data/Resources/Icons/buttons/add.png
new file mode 100644
index 0000000..332a030
--- /dev/null
+++ b/Data/Resources/Icons/buttons/add.png
Binary files differ
diff --git a/Data/Resources/Icons/buttons/alpha.png b/Data/Resources/Icons/buttons/alpha.png
new file mode 100644
index 0000000..207c18b
--- /dev/null
+++ b/Data/Resources/Icons/buttons/alpha.png
Binary files differ
diff --git a/Data/Resources/Icons/buttons/checker.png b/Data/Resources/Icons/buttons/checker.png
new file mode 100644
index 0000000..f6c3f0f
--- /dev/null
+++ b/Data/Resources/Icons/buttons/checker.png
Binary files differ
diff --git a/Data/Resources/Icons/buttons/cog.png b/Data/Resources/Icons/buttons/cog.png
new file mode 100644
index 0000000..5cf1e16
--- /dev/null
+++ b/Data/Resources/Icons/buttons/cog.png
Binary files differ
diff --git a/Data/Resources/Icons/buttons/del.png b/Data/Resources/Icons/buttons/del.png
new file mode 100644
index 0000000..34a9b5a
--- /dev/null
+++ b/Data/Resources/Icons/buttons/del.png
Binary files differ
diff --git a/Data/Resources/Icons/buttons/del2.png b/Data/Resources/Icons/buttons/del2.png
new file mode 100644
index 0000000..22cb0d3
--- /dev/null
+++ b/Data/Resources/Icons/buttons/del2.png
Binary files differ
diff --git a/Data/Resources/Icons/buttons/del3.png b/Data/Resources/Icons/buttons/del3.png
new file mode 100644
index 0000000..16d30d1
--- /dev/null
+++ b/Data/Resources/Icons/buttons/del3.png
Binary files differ
diff --git a/Data/Resources/Icons/buttons/delete.png b/Data/Resources/Icons/buttons/delete.png
new file mode 100644
index 0000000..31da2d8
--- /dev/null
+++ b/Data/Resources/Icons/buttons/delete.png
Binary files differ
diff --git a/Data/Resources/Icons/buttons/disable.png b/Data/Resources/Icons/buttons/disable.png
new file mode 100644
index 0000000..cfdc3da
--- /dev/null
+++ b/Data/Resources/Icons/buttons/disable.png
Binary files differ
diff --git a/Data/Resources/Icons/buttons/down.png b/Data/Resources/Icons/buttons/down.png
new file mode 100644
index 0000000..3fe5bf0
--- /dev/null
+++ b/Data/Resources/Icons/buttons/down.png
Binary files differ
diff --git a/Data/Resources/Icons/buttons/forward.png b/Data/Resources/Icons/buttons/forward.png
new file mode 100644
index 0000000..ee986ea
--- /dev/null
+++ b/Data/Resources/Icons/buttons/forward.png
Binary files differ
diff --git a/Data/Resources/Icons/buttons/invisible.png b/Data/Resources/Icons/buttons/invisible.png
new file mode 100644
index 0000000..a5a1f55
--- /dev/null
+++ b/Data/Resources/Icons/buttons/invisible.png
Binary files differ
diff --git a/Data/Resources/Icons/buttons/lock.png b/Data/Resources/Icons/buttons/lock.png
new file mode 100644
index 0000000..e5ae209
--- /dev/null
+++ b/Data/Resources/Icons/buttons/lock.png
Binary files differ
diff --git a/Data/Resources/Icons/buttons/open.png b/Data/Resources/Icons/buttons/open.png
new file mode 100644
index 0000000..178b46b
--- /dev/null
+++ b/Data/Resources/Icons/buttons/open.png
Binary files differ
diff --git a/Data/Resources/Icons/buttons/pause.png b/Data/Resources/Icons/buttons/pause.png
new file mode 100644
index 0000000..380f5a1
--- /dev/null
+++ b/Data/Resources/Icons/buttons/pause.png
Binary files differ
diff --git a/Data/Resources/Icons/buttons/pen.png b/Data/Resources/Icons/buttons/pen.png
new file mode 100644
index 0000000..3707dd5
--- /dev/null
+++ b/Data/Resources/Icons/buttons/pen.png
Binary files differ
diff --git a/Data/Resources/Icons/buttons/play.png b/Data/Resources/Icons/buttons/play.png
new file mode 100644
index 0000000..bcf2bae
--- /dev/null
+++ b/Data/Resources/Icons/buttons/play.png
Binary files differ
diff --git a/Data/Resources/Icons/buttons/play2.png b/Data/Resources/Icons/buttons/play2.png
new file mode 100644
index 0000000..fadfed2
--- /dev/null
+++ b/Data/Resources/Icons/buttons/play2.png
Binary files differ
diff --git a/Data/Resources/Icons/buttons/pop_disabled.png b/Data/Resources/Icons/buttons/pop_disabled.png
new file mode 100644
index 0000000..72b38d5
--- /dev/null
+++ b/Data/Resources/Icons/buttons/pop_disabled.png
Binary files differ
diff --git a/Data/Resources/Icons/buttons/pop_hover.png b/Data/Resources/Icons/buttons/pop_hover.png
new file mode 100644
index 0000000..b9518e8
--- /dev/null
+++ b/Data/Resources/Icons/buttons/pop_hover.png
Binary files differ
diff --git a/Data/Resources/Icons/buttons/pop_normal.png b/Data/Resources/Icons/buttons/pop_normal.png
new file mode 100644
index 0000000..63ef8d0
--- /dev/null
+++ b/Data/Resources/Icons/buttons/pop_normal.png
Binary files differ
diff --git a/Data/Resources/Icons/buttons/pop_selected.png b/Data/Resources/Icons/buttons/pop_selected.png
new file mode 100644
index 0000000..a26b9b3
--- /dev/null
+++ b/Data/Resources/Icons/buttons/pop_selected.png
Binary files differ
diff --git a/Data/Resources/Icons/buttons/prefab_apply.png b/Data/Resources/Icons/buttons/prefab_apply.png
new file mode 100644
index 0000000..0b35e92
--- /dev/null
+++ b/Data/Resources/Icons/buttons/prefab_apply.png
Binary files differ
diff --git a/Data/Resources/Icons/buttons/prefab_revert.png b/Data/Resources/Icons/buttons/prefab_revert.png
new file mode 100644
index 0000000..bc47649
--- /dev/null
+++ b/Data/Resources/Icons/buttons/prefab_revert.png
Binary files differ
diff --git a/Data/Resources/Icons/buttons/rgb.png b/Data/Resources/Icons/buttons/rgb.png
new file mode 100644
index 0000000..710a6cf
--- /dev/null
+++ b/Data/Resources/Icons/buttons/rgb.png
Binary files differ
diff --git a/Data/Resources/Icons/buttons/search.png b/Data/Resources/Icons/buttons/search.png
new file mode 100644
index 0000000..843fc7a
--- /dev/null
+++ b/Data/Resources/Icons/buttons/search.png
Binary files differ
diff --git a/Data/Resources/Icons/buttons/smalladd.png b/Data/Resources/Icons/buttons/smalladd.png
new file mode 100644
index 0000000..bb3b03a
--- /dev/null
+++ b/Data/Resources/Icons/buttons/smalladd.png
Binary files differ
diff --git a/Data/Resources/Icons/buttons/smalldel.png b/Data/Resources/Icons/buttons/smalldel.png
new file mode 100644
index 0000000..aafffd4
--- /dev/null
+++ b/Data/Resources/Icons/buttons/smalldel.png
Binary files differ
diff --git a/Data/Resources/Icons/buttons/smalldisable.png b/Data/Resources/Icons/buttons/smalldisable.png
new file mode 100644
index 0000000..b1d5999
--- /dev/null
+++ b/Data/Resources/Icons/buttons/smalldisable.png
Binary files differ
diff --git a/Data/Resources/Icons/buttons/smalldisableempty.png b/Data/Resources/Icons/buttons/smalldisableempty.png
new file mode 100644
index 0000000..ce5068f
--- /dev/null
+++ b/Data/Resources/Icons/buttons/smalldisableempty.png
Binary files differ
diff --git a/Data/Resources/Icons/buttons/smalllock.png b/Data/Resources/Icons/buttons/smalllock.png
new file mode 100644
index 0000000..9716287
--- /dev/null
+++ b/Data/Resources/Icons/buttons/smalllock.png
Binary files differ
diff --git a/Data/Resources/Icons/buttons/star.png b/Data/Resources/Icons/buttons/star.png
new file mode 100644
index 0000000..c8b11f5
--- /dev/null
+++ b/Data/Resources/Icons/buttons/star.png
Binary files differ
diff --git a/Data/Resources/Icons/buttons/stopplay.png b/Data/Resources/Icons/buttons/stopplay.png
new file mode 100644
index 0000000..bfe1897
--- /dev/null
+++ b/Data/Resources/Icons/buttons/stopplay.png
Binary files differ
diff --git a/Data/Resources/Icons/buttons/up.png b/Data/Resources/Icons/buttons/up.png
new file mode 100644
index 0000000..75713f0
--- /dev/null
+++ b/Data/Resources/Icons/buttons/up.png
Binary files differ
diff --git a/Data/Resources/Images/UI.csv b/Data/Resources/Images/UI.csv
deleted file mode 100644
index e9c9eea..0000000
--- a/Data/Resources/Images/UI.csv
+++ /dev/null
@@ -1,2 +0,0 @@
-filePath type slice left right top bottom
-asdasd
diff --git a/Data/Resources/Images/UI.xlsx b/Data/Resources/Images/UI.xlsx
deleted file mode 100644
index 15e2235..0000000
--- a/Data/Resources/Images/UI.xlsx
+++ /dev/null
Binary files differ
diff --git a/Data/Resources/Images/brickwall.jpg b/Data/Resources/Images/brickwall.jpg
new file mode 100644
index 0000000..39478d3
--- /dev/null
+++ b/Data/Resources/Images/brickwall.jpg
Binary files differ
diff --git a/Data/Resources/Metatable/Excel/Extract_All.cmd b/Data/Resources/Metatable/Excel/Extract_All.cmd
index f6dd7d2..8cd629f 100644
--- a/Data/Resources/Metatable/Excel/Extract_All.cmd
+++ b/Data/Resources/Metatable/Excel/Extract_All.cmd
@@ -1,2 +1,3 @@
./Extract_Gizmos.cmd
-./Extract_Icons.cmd \ No newline at end of file
+./Extract_Icons.cmd
+./Extract_Shaders.cmd \ No newline at end of file
diff --git a/Data/Resources/Metatable/Excel/Extract_Shaders.cmd b/Data/Resources/Metatable/Excel/Extract_Shaders.cmd
new file mode 100644
index 0000000..312000b
--- /dev/null
+++ b/Data/Resources/Metatable/Excel/Extract_Shaders.cmd
@@ -0,0 +1 @@
+"../../../../Tools/XlsxToCsv/xlsxToCsv.exe" Shaders.xlsx ../Shaders.csv \ No newline at end of file
diff --git a/Data/Resources/Metatable/Excel/Icons.xlsx b/Data/Resources/Metatable/Excel/Icons.xlsx
index 501ae81..bc359e5 100644
--- a/Data/Resources/Metatable/Excel/Icons.xlsx
+++ b/Data/Resources/Metatable/Excel/Icons.xlsx
Binary files differ
diff --git a/Data/Resources/Metatable/Excel/Shaders.xlsx b/Data/Resources/Metatable/Excel/Shaders.xlsx
new file mode 100644
index 0000000..3dcafa2
--- /dev/null
+++ b/Data/Resources/Metatable/Excel/Shaders.xlsx
Binary files differ
diff --git a/Data/Resources/Metatable/Icons.csv b/Data/Resources/Metatable/Icons.csv
index 04cb8d7..0b7221a 100644
--- a/Data/Resources/Metatable/Icons.csv
+++ b/Data/Resources/Metatable/Icons.csv
@@ -1,8 +1,7 @@
-Path,Type,Left,Right,Top,Bottom,
-UI.png,1,12,12,13,13,
-UI.png,1,12,12,13,13,
-UI.png,1,12,12,13,13,
-UI.png,1,12,12,13,13,
-UI.png,1,12,12,13,13,
-UI.png,1,12,12,13,13,
-UI.png,1,12,12,13,13,
+Name,Category,Path,Filter,Wrap,Slicing,Left,Right,Top,Bottom,
+btn_add,Button,buttons/add.png,,,,,,,,
+btn_alpha,Button,buttons/alpha.png,,,,,,,,
+btn_checker,Button,buttons/checker.png,,,,,,,,
+,,,,,,,,,,
+,,,,,,,,,,
+,,,,,,,,,,
diff --git a/Data/Resources/Metatable/Shaders.csv b/Data/Resources/Metatable/Shaders.csv
new file mode 100644
index 0000000..c0d2337
--- /dev/null
+++ b/Data/Resources/Metatable/Shaders.csv
@@ -0,0 +1,2 @@
+name,path,
+UI,UI.glsl,
diff --git a/Data/Scripts/EditorApplication.lua b/Data/Scripts/EditorApplication.lua
index d9f8b1f..8b54e41 100644
--- a/Data/Scripts/EditorApplication.lua
+++ b/Data/Scripts/EditorApplication.lua
@@ -63,6 +63,12 @@ GameLab.IO.ReadFilesAsync(files, function()
Debug.Log("finished")
end)
+local imgData = Rendering.LoadImage("./Resources/Images/brickwall.jpg")
+Debug.Log(tostring(imgData:GetWidth()))
+Debug.Log(tostring(imgData:GetHeight()))
+
+local tex = Rendering.Texture.New(imgData, false)
+
while true do
app:OnStep()
diff --git a/Data/Scripts/EditorGUI/EditorImages.lua b/Data/Scripts/EditorGUI/EditorImages.lua
index e98d064..3945edc 100644
--- a/Data/Scripts/EditorGUI/EditorImages.lua
+++ b/Data/Scripts/EditorGUI/EditorImages.lua
@@ -1,2 +1,25 @@
--- 编辑器图片资源
+-- 编辑器图片资源管理
+local EditorImages = {}
+EditorImages.icons = {} --[name] = image,
+EditorImages.gizmos = {}
+
+EditorImages.isImagesReady = false
+
+EditorImages.GetIcon = function(name)
+
+end
+
+EditorImages.GetGizmos = function(name)
+
+end
+
+local icons_metatable = "./Resources/Metatable/Icons.csv"
+local gizmos_metatable = "./Resources/Metatable/Gizmos.csv"
+
+-- 读取所有的编辑器图片资源
+EditorImages.LoadAllImages = function()
+
+end
+
+return EditorImages \ No newline at end of file
diff --git a/Data/boot.lua b/Data/boot.lua
index 6f49da7..7e7cfdc 100644
--- a/Data/boot.lua
+++ b/Data/boot.lua
@@ -13,7 +13,8 @@ local editorCLibs = "./Libraries/?.dll" .. "./Plugins/?.dll"
package.cpath=package.cpath .. ";" .. engineCLibs .. ";" .. editorCLibs
-- debugging
-require("LuaPanda").start("127.0.0.1",8818)
+-- 在这里会报一个异常, 不知道为什么
+--require("LuaPanda").start("127.0.0.1",8818)
-- redirect
if GAMELAB_DEBUG then
@@ -29,5 +30,8 @@ require "GameLab.Engine.GL"
require "GameLab.Editor"
require "GameLab.Editor.GUI"
+-- debugging
+require("LuaPanda").start("127.0.0.1",8818)
+
-- launch editor
-dofile("./Scripts/EditorApplication.lua") \ No newline at end of file
+dofile("./Scripts/EditorApplication.lua")
diff --git a/Projects/VisualStudio/Editor/Editor.vcxproj b/Projects/VisualStudio/Editor/Editor.vcxproj
index 39a9cf0..ad75401 100644
--- a/Projects/VisualStudio/Editor/Editor.vcxproj
+++ b/Projects/VisualStudio/Editor/Editor.vcxproj
@@ -209,8 +209,10 @@
<ClCompile Include="..\..\..\Runtime\Scripting\IO\IO.bind.cpp" />
<ClCompile Include="..\..\..\Runtime\Scripting\Path\Path.bind.cpp" />
<ClCompile Include="..\..\..\Runtime\Scripting\Rendering\GPUDataBuffer.bind.cpp" />
+ <ClCompile Include="..\..\..\Runtime\Scripting\Rendering\ImageData.bind.cpp" />
<ClCompile Include="..\..\..\Runtime\Scripting\Rendering\Rendering.bind.cpp" />
<ClCompile Include="..\..\..\Runtime\Scripting\Rendering\Shader.bind.cpp" />
+ <ClCompile Include="..\..\..\Runtime\Scripting\Rendering\Texture.bind.cpp" />
<ClCompile Include="..\..\..\Runtime\Threading\Job.cpp" />
<ClCompile Include="..\..\..\Runtime\Threading\JobSystem.cpp" />
<ClCompile Include="..\..\..\Runtime\Threading\Mutex.cpp" />
diff --git a/Projects/VisualStudio/Editor/Editor.vcxproj.filters b/Projects/VisualStudio/Editor/Editor.vcxproj.filters
index 29505ea..4170c69 100644
--- a/Projects/VisualStudio/Editor/Editor.vcxproj.filters
+++ b/Projects/VisualStudio/Editor/Editor.vcxproj.filters
@@ -336,6 +336,12 @@
<ClCompile Include="..\..\..\Runtime\Scripting\Common\DataBuffer.bind.cpp">
<Filter>Runtime\Scripting\Common</Filter>
</ClCompile>
+ <ClCompile Include="..\..\..\Runtime\Scripting\Rendering\Texture.bind.cpp">
+ <Filter>Runtime\Scripting\Rendering</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\Runtime\Scripting\Rendering\ImageData.bind.cpp">
+ <Filter>Runtime\Scripting\Rendering</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\Editor\GUI\Dock.h">
diff --git a/Runtime/Debug/Log.cpp b/Runtime/Debug/Log.cpp
index 4d28502..c92bdc8 100644
--- a/Runtime/Debug/Log.cpp
+++ b/Runtime/Debug/Log.cpp
@@ -63,9 +63,9 @@ void log_warning(std::string log)
s_ConsoleHandle = GetStdHandle(STD_OUTPUT_HANDLE);
}
SetConsoleTextAttribute(s_ConsoleHandle, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY);
- cout << currentDateTime() << " [Info] " << log << endl;
+ cout << currentDateTime() << " [Warning] " << log << endl;
#else
- cout << "\x1B[93m" << currentDateTime() << " [Info] " << log << "\x1B[0m" << endl;
+ cout << "\x1B[93m" << currentDateTime() << " [Warning] " << log << "\x1B[0m" << endl;
#endif
}
}
@@ -78,9 +78,9 @@ void log_error(std::string log)
s_ConsoleHandle = GetStdHandle(STD_OUTPUT_HANDLE);
}
SetConsoleTextAttribute(s_ConsoleHandle, FOREGROUND_RED | FOREGROUND_INTENSITY);
- cout << currentDateTime() << " [Info] " << log << endl;
+ cout << currentDateTime() << " [Error] " << log << endl;
#else
- cout << "\x1B[91m" << currentDateTime() << " [Info] " << log << "\x1B[0m" << endl;
+ cout << "\x1B[91m" << currentDateTime() << " [Error] " << log << "\x1B[0m" << endl;
#endif
}
}
diff --git a/Runtime/FileSystem/FileJobs.h b/Runtime/FileSystem/FileJobs.h
index 50e681d..1fe49f1 100644
--- a/Runtime/FileSystem/FileJobs.h
+++ b/Runtime/FileSystem/FileJobs.h
@@ -18,7 +18,8 @@ public:
void Process() override;
bool IsFinished() override;
+ int cur = 0; //ǰļ
std::vector<std::string> files; // ļ·
LuaBind::StrongRef callback; // ɺĻص
-};
+}; \ No newline at end of file
diff --git a/Runtime/Graphics/Device.h b/Runtime/Graphics/Device.h
index e445efa..c7a059e 100644
--- a/Runtime/Graphics/Device.h
+++ b/Runtime/Graphics/Device.h
@@ -12,8 +12,8 @@
struct DeviceSetting
{
- TextureFilter texFilter;
- TextureWrap texWrap;
+ ETextureFilterMode texFilter;
+ ETextureWrapMode texWrap;
};
class Device : public NonCopyable
@@ -46,8 +46,8 @@ public:
GET_SET(Color, ClearColor, m_ClearColor);
- GET_SET(TextureFilter, TextureFilter, m_TexFilter);
- GET_SET(TextureWrap, TextureWrap, m_TexWrap);
+ GET_SET(ETextureFilterMode, TextureFilter, m_TexFilter);
+ GET_SET(ETextureWrapMode, TextureWrap, m_TexWrap);
inline bool IsInsideFrame();
@@ -55,8 +55,8 @@ private:
uint m_EnableFlag;
// Global texture setting
- TextureFilter m_TexFilter;
- TextureWrap m_TexWrap;
+ ETextureFilterMode m_TexFilter;
+ ETextureWrapMode m_TexWrap;
Color m_ClearColor;
diff --git a/Runtime/Graphics/ImageData.h b/Runtime/Graphics/ImageData.h
index af44f11..4663e0e 100644
--- a/Runtime/Graphics/ImageData.h
+++ b/Runtime/Graphics/ImageData.h
@@ -3,27 +3,54 @@
#include <vector>
#include "Runtime/Threading/Job.h"
+#include "Runtime/Lua/LuaHelper.h"
// ͼƬ
-class ImageData
+class ImageData : public LuaBind::NativeClass<ImageData>
{
public:
- enum ImageFormat
+ enum EPixelFormat
{
- ImageFormat_Rgba_Int,
- ImageFormat_Rgba_Float,
+ RGBA,
+ RGB,
+ R,
+ RG,
+ BGR,
+ BGRA
};
-private:
- void* m_Data;
+ enum EPixelElementType
+ {
+ UNSIGNED_BYTE,
+ UNSIGNED_INT,
+ BYTE,
+ INT,
+ FLOAT,
+ };
+ ImageData(LuaBind::VM* vm)
+ : LuaBind::NativeClass<ImageData>(vm)
+ {
+ }
+
+ void* pixels; // ݣʽͲο http://docs.gl/gl3/glTexImage2D pixel dataformattype
+ EPixelFormat format;
+ EPixelElementType type;
+ int width, height;
+
+private:
+ LUA_BIND_DECL_CLASS(ImageData);
+
+ LUA_BIND_DECL_METHOD(_GetWidth);
+ LUA_BIND_DECL_METHOD(_GetHeight);
+ LUA_BIND_DECL_METHOD(_GetSize);
};
-enum ImageDataAsyncError
+enum EImageDataAsyncError
{
- ImageDataAsyncError_NoFile = 1,
- ImageDataAsyncError_ParseFailed = 2,
- ImageDataAsyncError_InvalidFormat = 3,
+ NoFile = 1,
+ ParseFailed = 2,
+ InvalidFormat = 3,
};
struct ImageDataRequest
@@ -42,6 +69,8 @@ namespace ImageDataUtil
ImageDataRequest* LoadAsync(std::vector<const char*> paths);
}
+// ڹֻ߳ߵȡ->꣬ύGPU߳
+
class ReadImageFilesJob : public Job
{
diff --git a/Runtime/Graphics/RenderTexture.h b/Runtime/Graphics/RenderTexture.h
index 74c5602..a501f50 100644
--- a/Runtime/Graphics/RenderTexture.h
+++ b/Runtime/Graphics/RenderTexture.h
@@ -7,10 +7,10 @@
class RenderTexture : public Texture
{
public:
- RenderTexture(TextureFormat format);
+ RenderTexture(ETextureFormat format);
};
-RenderTexture* CreateRenderTexture(int width, int height, TextureFormat format);
+RenderTexture* CreateRenderTexture(int width, int height, ETextureFormat format);
#endif \ No newline at end of file
diff --git a/Runtime/Graphics/Texture.cpp b/Runtime/Graphics/Texture.cpp
index e69de29..ce09927 100644
--- a/Runtime/Graphics/Texture.cpp
+++ b/Runtime/Graphics/Texture.cpp
@@ -0,0 +1,69 @@
+#include "ImageData.h"
+#include "Texture.h"
+
+using namespace LuaBind;
+
+Texture::Texture(LuaBind::VM* vm, TextureSetting setting, ImageData* imgData)
+ : NativeClass<Texture>(vm)
+{
+ m_Width = imgData->width;
+ m_Height = imgData->height;
+ m_Type = setting.type;
+ m_Format = setting.format;
+ m_WrapMode = setting.wrapMode;
+ m_FilterMode = setting.filterMode;
+ m_KeepPixelData = setting.keepImageData;
+
+ glGenTextures(1, &m_GPUID);
+ glBindTexture(GL_TEXTURE_2D, m_GPUID);
+
+ switch (m_WrapMode) {
+ case ETextureWrapMode::Clamp:
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
+ break;
+ case ETextureWrapMode::Repeat:
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
+ break;
+ case ETextureWrapMode::Mirror:
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT);
+ break;
+ default:
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
+ break;
+ }
+
+ switch (m_FilterMode) {
+ case ETextureFilterMode::Linear:
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ break;
+ case ETextureFilterMode::Nearest:
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ break;
+ default:
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ break;
+ }
+
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, imgData->width, imgData->height, 0, GL_RGB, GL_UNSIGNED_BYTE, imgData->pixels);
+
+ // keep image data ?
+ if (m_KeepPixelData)
+ {
+ LuaBind::State state = vm->GetCurThread();
+ imgData->PushUserdata(state);
+ SetMemberRef(state, m_ImageData, -1);
+ state.Pop(1);
+ }
+}
+
+Texture::~Texture()
+{
+ glDeleteTextures(1, &m_GPUID);
+} \ No newline at end of file
diff --git a/Runtime/Graphics/Texture.h b/Runtime/Graphics/Texture.h
index d09429c..30cf303 100644
--- a/Runtime/Graphics/Texture.h
+++ b/Runtime/Graphics/Texture.h
@@ -1,61 +1,96 @@
-#ifndef TEXTURE_H
-#define TEXTURE_H
+#pragma once
+#include <exception>
#include "Runtime/Lua/LuaHelper.h"
-#include "Runtime/Lua/LuaBind/LuaBind.h"
#include "../Utilities/UtilMacros.h"
#include "OpenGL.h"
-#include "ImageData.h"
-enum TextureFormat
+class ImageData;
+
+enum ETextureType
+{
+ TEX_2D,
+ TEX_CUBE,
+};
+
+enum ETextureFormat
+{
+ RGBA32,
+ RGB24,
+ RGB16,
+ R8,
+ A8,
+};
+
+enum ETextureWrapMode
+{
+ Clamp,
+ Repeat,
+ Mirror,
+};
+
+enum ETextureFilterMode
{
- TextureFormat_DepthComponent,
- TextureFormat_Red,
- TextureFormat_Green,
- TextureFormat_Blue,
- TextureFormat_Alpha,
- TextureFormat_Rgb,
- TextureFormat_Rgba,
+ Nearest,
+ Linear,
};
-enum TextureWrap
+struct TextureSetting
{
- TextureWrap_Clamp,
- TextureWrap_Repeat,
+ bool keepImageData; // Ƿ񱣴ͼƬ
+ int type; // ͼƬ
+ int format; // ڲʽ
+ int wrapMode; // Χ
+ int filterMode; // ˲
};
-enum TextureFilter
+class TextureException : public std::exception
{
- TextureFilter_Nearest,
- TextureFilter_Bilinear,
- TextureFilter_Trilinear,
+public:
+ TextureException(const char* what)
+ : std::exception(what)
+ {}
};
-class Texture
+class Texture : public LuaBind::NativeClass<Texture>
{
public:
- Texture();
- Texture(ImageData* imgData, TextureFormat format);
- Texture(ImageData* imgData, TextureFormat format, TextureWrap wrap, TextureFilter filter);
+ Texture(LuaBind::VM* vm, TextureSetting setting, ImageData* imgData)/*throw TextureException*/;
~Texture();
GET(int, Width, m_Width);
GET(int, Height, m_Height);
- GET(TextureFilter, Filter, m_Filter);
- GET(TextureWrap, Wrap, m_Wrap);
-
- GET(GLint, Handle, m_Handle);
+ GET(GLuint, GpuID, m_GPUID);
protected:
- GLint m_Handle;
+ GLuint m_GPUID;
+
int m_Width, m_Height;
- TextureFilter m_Filter;
- TextureWrap m_Wrap;
-};
+ int m_Type;
+ int m_Format;
+ int m_FilterMode;
+ int m_WrapMode;
+
+ bool m_KeepPixelData; // Ƿ񱣴ͼݣĬϵ󲻱
+
+ LuaBind::MemberRef m_ImageData; //ͼƬ
+
+ LUA_BIND_DECL_CLASS(Texture);
+
+ LUA_BIND_DECL_METHOD(_New);
+
+ LUA_BIND_DECL_METHOD(_GetWidth);
+ LUA_BIND_DECL_METHOD(_GetHeight);
+ LUA_BIND_DECL_METHOD(_GetSize);
+
+ LUA_BIND_DECL_METHOD(_GetType);
+ LUA_BIND_DECL_METHOD(_GetFormat);
+ LUA_BIND_DECL_METHOD(_GetWrapMode);
+ LUA_BIND_DECL_METHOD(_GetFilterMode);
-Texture* CreateTexture(ImageData* imgData, TextureFormat format);
-Texture* CreateTexture(ImageData* imgData, TextureFormat format, TextureWrap wrap, TextureFilter filter);
+ LUA_BIND_DECL_METHOD(_IsKeepImageData);
+ LUA_BIND_DECL_METHOD(_GetImageData);
-#endif \ No newline at end of file
+}; \ No newline at end of file
diff --git a/Runtime/Lua/LuaHelper.cpp b/Runtime/Lua/LuaHelper.cpp
index 2044ba2..9381b6c 100644
--- a/Runtime/Lua/LuaHelper.cpp
+++ b/Runtime/Lua/LuaHelper.cpp
@@ -59,4 +59,9 @@ bool LuaHelper::IsType(LuaBind::State& state, const char* typeName, int idx)
bool bIsType = tname == typeName;
state.SetTop(top);
return bIsType;
+}
+
+bool LuaHelper::InstantiateClass(LuaBind::State& state, const char* classFullName)
+{
+ return false;
} \ No newline at end of file
diff --git a/Runtime/Lua/LuaHelper.h b/Runtime/Lua/LuaHelper.h
index 56dae54..c3cd70e 100644
--- a/Runtime/Lua/LuaHelper.h
+++ b/Runtime/Lua/LuaHelper.h
@@ -5,13 +5,14 @@
// lua 5.1 doc: https://www.lua.org/manual/5.1/
+// GameLabһЩչ
class LuaHelper
{
public:
static int Call(const char* func, const char* params, ...);
-
static bool IsType(LuaBind::State& state, const char* typeName, int idx);
-
static void OnRegisterNativeClass(LuaBind::State& state, int cls, std::string clsName, std::string pkgName);
-
+ // luaʵջʧܷfalseҲѹջ
+ static bool InstantiateClass(LuaBind::State& state, const char* classFullName);
+
}; \ No newline at end of file
diff --git a/Runtime/Scripting/Rendering/ImageData.bind.cpp b/Runtime/Scripting/Rendering/ImageData.bind.cpp
new file mode 100644
index 0000000..88412e5
--- /dev/null
+++ b/Runtime/Scripting/Rendering/ImageData.bind.cpp
@@ -0,0 +1,38 @@
+#include "Runtime/Graphics/ImageData.h"
+
+using namespace LuaBind;
+
+LUA_BIND_REGISTRY(ImageData)
+{
+ LUA_BIND_REGISTER_METHODS(state,
+ { "GetWidth", _GetWidth },
+ { "GetHeight", _GetHeight },
+ { "GetSize", _GetSize }
+ );
+}
+
+LUA_BIND_POSTPROCESS(ImageData)
+{
+}
+
+LUA_BIND_IMPL_METHOD(ImageData, _GetWidth)
+{
+ LUA_BIND_PREPARE(L, ImageData);
+ state.Push(self->width);
+ return 1;
+}
+
+LUA_BIND_IMPL_METHOD(ImageData, _GetHeight)
+{
+ LUA_BIND_PREPARE(L, ImageData);
+ state.Push(self->height);
+ return 1;
+}
+
+LUA_BIND_IMPL_METHOD(ImageData, _GetSize)
+{
+ LUA_BIND_PREPARE(L, ImageData);
+ state.Push(self->width);
+ state.Push(self->height);
+ return 2;
+}
diff --git a/Runtime/Scripting/Rendering/Rendering.bind.cpp b/Runtime/Scripting/Rendering/Rendering.bind.cpp
index 29fa421..40b3ac5 100644
--- a/Runtime/Scripting/Rendering/Rendering.bind.cpp
+++ b/Runtime/Scripting/Rendering/Rendering.bind.cpp
@@ -1,4 +1,32 @@
#include "Runtime/Graphics/Shader.h"
+#include "Runtime/Graphics/Texture.h"
+#include "Runtime/Graphics/ImageData.h"
+
+#define STB_IMAGE_IMPLEMENTATION
+#include "ThirdParty/stb/stb_image.h"
+
+// imgData = Rendering.LoadImage(path)
+int LoadImage(lua_State* L)
+{
+ LUA_BIND_STATE(L);
+
+ const char* path = state.GetValue<const char*>(1, "");
+
+ stbi_set_flip_vertically_on_load(true);
+ ImageData* data = new ImageData(state.GetVM());
+ int channels;
+ data->pixels = stbi_load(path, &data->width, &data->height, &channels, 0);
+ data->format = ImageData::EPixelFormat::RGB;
+ data->type = ImageData::EPixelElementType::UNSIGNED_BYTE;
+
+ data->PushUserdata(state);
+ return 1;
+}
+
+static luaL_Reg funcs[] = {
+ {"LoadImage", LoadImage},
+ {0, 0}
+};
int luaopen_GameLab_Engine_Rendering(lua_State* L)
{
@@ -11,7 +39,11 @@ int luaopen_GameLab_Engine_Rendering(lua_State* L)
state.PushNamespace("Engine");
state.PushNamespace("Rendering");
+ state.RegisterMethods(funcs);
+
state.RegisterNativeClass<Shader>();
+ state.RegisterNativeClass<ImageData>();
+ state.RegisterNativeClass<Texture>();
return 1;
} \ No newline at end of file
diff --git a/Runtime/Scripting/Rendering/Texture.bind.cpp b/Runtime/Scripting/Rendering/Texture.bind.cpp
new file mode 100644
index 0000000..061a303
--- /dev/null
+++ b/Runtime/Scripting/Rendering/Texture.bind.cpp
@@ -0,0 +1,143 @@
+#include "Runtime/Graphics/Texture.h"
+
+using namespace LuaBind;
+
+LUA_BIND_REGISTRY(Texture)
+{
+ LUA_BIND_REGISTER_METHODS(state,
+ { "New", _New },
+ { "GetWidth", _GetWidth },
+ { "GetHeight", _GetHeight },
+ { "GetSize", _GetSize },
+ { "GetType", _GetType },
+ { "GetFormat", _GetFormat },
+ { "GetWrapMode", _GetWrapMode },
+ { "GetImageData", _GetImageData },
+ { "IsKeepImageData", _IsKeepImageData },
+ { "GetFilterMode", _GetFilterMode }
+ );
+}
+
+LUA_BIND_POSTPROCESS(Texture)
+{
+ LUA_BIND_REGISTER_ENUM(state, "ETextureType",
+ { "TEX_2D", ETextureType::TEX_2D },
+ { "TEX_CUBE", ETextureType::TEX_CUBE }
+ );
+ LUA_BIND_REGISTER_ENUM(state, "ETextureFormat",
+ { "RGBA32", ETextureFormat::RGBA32 },
+ { "RGB24", ETextureFormat::RGB24 },
+ { "RGB16", ETextureFormat::RGB16 },
+ { "R8", ETextureFormat::R8 },
+ { "A8", ETextureFormat::A8 }
+ );
+ LUA_BIND_REGISTER_ENUM(state, "ETextureWrapMode",
+ { "Clamp", ETextureWrapMode::Clamp },
+ { "Repeat", ETextureWrapMode::Repeat },
+ { "Mirror", ETextureWrapMode::Mirror }
+ );
+ LUA_BIND_REGISTER_ENUM(state, "ETextureFilterMode",
+ { "Nearest", ETextureFilterMode::Nearest },
+ { "Linear", ETextureFilterMode::Linear }
+ );
+}
+
+// Texture.New(imgData, keepImgData, type, format, wrapMode, filterMode)
+LUA_BIND_IMPL_METHOD(Texture, _New)
+{
+ LUA_BIND_STATE(L);
+ LUA_BIND_CHECK(L, "U");
+
+ ImageData* imgData = state.GetUserdata<ImageData>(1);
+
+ TextureSetting setting;
+ setting.keepImageData = state.GetValue(2, false);
+ setting.type = state.GetValue<int>(3, (int)ETextureType::TEX_2D);
+ setting.format = state.GetValue(4, (int)ETextureFormat::RGBA32);
+ setting.wrapMode = state.GetValue(5, (int)ETextureWrapMode::Clamp);
+ setting.filterMode = state.GetValue(6, (int)ETextureFilterMode::Linear);
+
+ try
+ {
+ Texture* tex = new Texture(state.GetVM(), setting, imgData);
+ tex->PushUserdata(state);
+ return 1;
+ }
+ catch (TextureException e)
+ {
+ luaL_error(L, "Failed to create texture.");
+ return 0;
+ }
+ return 0;
+}
+
+LUA_BIND_IMPL_METHOD(Texture, _GetWidth)
+{
+ LUA_BIND_PREPARE(L, Texture);
+ state.Push(self->m_Width);
+ return 1;
+}
+
+LUA_BIND_IMPL_METHOD(Texture, _GetHeight)
+{
+ LUA_BIND_PREPARE(L, Texture);
+ state.Push(self->m_Height);
+ return 1;
+}
+
+LUA_BIND_IMPL_METHOD(Texture, _GetSize)
+{
+ LUA_BIND_PREPARE(L, Texture);
+ state.Push(self->m_Width);
+ state.Push(self->m_Height);
+ return 2;
+}
+
+LUA_BIND_IMPL_METHOD(Texture, _GetType)
+{
+ LUA_BIND_PREPARE(L, Texture);
+ state.Push(self->m_Type);
+ return 1;
+}
+
+LUA_BIND_IMPL_METHOD(Texture, _GetFormat)
+{
+ LUA_BIND_PREPARE(L, Texture);
+ state.Push(self->m_Format);
+ return 1;
+}
+
+LUA_BIND_IMPL_METHOD(Texture, _GetWrapMode)
+{
+ LUA_BIND_PREPARE(L, Texture);
+ state.Push(self->m_WrapMode);
+ return 1;
+}
+
+LUA_BIND_IMPL_METHOD(Texture, _GetFilterMode)
+{
+ LUA_BIND_PREPARE(L, Texture);
+ state.Push(self->m_FilterMode);
+ return 1;
+}
+
+LUA_BIND_IMPL_METHOD(Texture, _IsKeepImageData)
+{
+ LUA_BIND_PREPARE(L, Texture);
+ state.Push(self->m_KeepPixelData);
+ return 1;
+}
+
+LUA_BIND_IMPL_METHOD(Texture, _GetImageData)
+{
+ LUA_BIND_PREPARE(L, Texture);
+ if (self->m_KeepPixelData)
+ {
+ self->PushMemberRef(state, self->m_ImageData);
+ }
+ else
+ {
+ state.PushNil();
+ }
+ return 1;
+}