新しいシェーダー関数

守矢諏訪子 <suwako@076.moe>、2026-06-27 02:44
コミット 8ac2f6391e7cc49247d231fb805081a346008d52 ・親 fb7bf68 ・ファイルを見る

25個のファイル、+577 -152

@@ -43,4 +43,7 @@
4343 #include <gui/about.hh>
4444 #include <gui/consolelog.hh>
4545 #include <gui/manual.hh>
46- #include <gui/settings.hh>
46+#include <gui/settings.hh>
47+#include <gui/newshader.hh>
48+//#include <gui/openshader.hh>
49+//#include <gui/saveasshader.hh>
@@ -42,6 +42,6 @@
4242 namespace gui {
4343 class About {
4444 public:
45- void Draw(GlfwInfo &glfw);
45+ void Draw(Info &info);
4646 }; // class About
4747 } // namespace gui
@@ -38,7 +38,7 @@
3838
3939 #include <util/types.hh>
4040
41-struct GlfwInfo;
41+struct Info;
4242 namespace db {
4343 class Locale;
4444 } // namespace db
@@ -59,7 +59,7 @@
5959 class ConsoleLog {
6060 public:
6161 void Add(LogEntry entry);
62- void Draw(GlfwInfo &info, cstr title = "コンソール");
62+ void Draw(Info &info, cstr title = "コンソール");
6363 void Clear();
6464
6565 private:
@@ -53,9 +53,13 @@
5353 Editor(string title, string renderName, string code, Languages lang, ImFont *cjkFont, ImFont *monoFont);
5454 ~Editor();
5555
56- TextEditor Get() const { return m_Editor; }
56+ TextEditor &Get() { return m_Editor; }
57+ const TextEditor &Get() const { return m_Editor; }
5758 void Render();
58- void SetCode(string code);
59+ void SetCode(const string &code) {
60+ m_Code = code;
61+ m_Editor.SetText(code);
62+ }
5963 void RenderStatusBar(TextEditor editor);
6064
6165 void SetTitle(const string &title) { m_Title = title; }
@@ -42,7 +42,7 @@
4242 namespace gui {
4343 class Manual {
4444 public:
45- void Draw(GlfwInfo &glfw);
45+ void Draw(Info &info);
4646
4747 private:
4848 void renderMarkdown(cstr text);
@@ -0,0 +1,58 @@
1+/*
2+# 076 License
3+
4+Copyright (c) テクニカル諏訪子
5+
6+Permission is hereby granted to any person obtaining a copy of the software
7+Shader Playground (the "Software") to use, modify, merge, copy, publish, distribute,
8+sublicense, and/or sell copies of the Software, subject to the following conditions:
9+
10+ 1. **Origin Attribution**:
11+ - You must not misrepresent the origin of the Software; you must not claim
12+ you created the original Software.
13+ - If the Software is used in a product, you must either:
14+ a. Provide clear attribution in the product's documentation, user interface,
15+ or other visible areas, **OR**
16+ b. Pay the original developers a fee they specify in writing.
17+ 2. **Usage Restriction**:
18+ - The Software, or any derivative works, dependencies, or libraries
19+ incorporating it, must not be used for censorship or to suppress freedom of
20+ speech, expression, or creativity. Prohibited uses include, but are not
21+ limited to:
22+ - Censorship of so-called "hate speech", visuals, non-mainstream opinions,
23+ ideas, or objective reality.
24+ - Tools or systems designed to restrict access to information or
25+ artistic works.
26+ 3. **Notice Preservation**:
27+ - This license and the above copyright notice must remain intact in all copies
28+ of the source code.
29+
30+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
31+INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
32+PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
33+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
34+CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
35+OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
36+*/
37+#pragma once
38+
39+#include <util/types.hh>
40+#include <util/structs.hh>
41+
42+namespace gui {
43+ class NewShader {
44+ public:
45+ NewShader(Info *info);
46+ ~NewShader();
47+
48+ db::ShaderData Make();
49+
50+ private:
51+ string getDefaultVert();
52+ string getDefaultFrag();
53+ string getDefaultLua();
54+
55+ private:
56+ Info *m_Info;
57+ }; // class NewShader
58+} // namespace gui
@@ -0,0 +1,43 @@
1+/*
2+# 076 License
3+
4+Copyright (c) テクニカル諏訪子
5+
6+Permission is hereby granted to any person obtaining a copy of the software
7+Shader Playground (the "Software") to use, modify, merge, copy, publish, distribute,
8+sublicense, and/or sell copies of the Software, subject to the following conditions:
9+
10+ 1. **Origin Attribution**:
11+ - You must not misrepresent the origin of the Software; you must not claim
12+ you created the original Software.
13+ - If the Software is used in a product, you must either:
14+ a. Provide clear attribution in the product's documentation, user interface,
15+ or other visible areas, **OR**
16+ b. Pay the original developers a fee they specify in writing.
17+ 2. **Usage Restriction**:
18+ - The Software, or any derivative works, dependencies, or libraries
19+ incorporating it, must not be used for censorship or to suppress freedom of
20+ speech, expression, or creativity. Prohibited uses include, but are not
21+ limited to:
22+ - Censorship of so-called "hate speech", visuals, non-mainstream opinions,
23+ ideas, or objective reality.
24+ - Tools or systems designed to restrict access to information or
25+ artistic works.
26+ 3. **Notice Preservation**:
27+ - This license and the above copyright notice must remain intact in all copies
28+ of the source code.
29+
30+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
31+INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
32+PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
33+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
34+CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
35+OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
36+*/
37+#pragma once
38+
39+#include <util/types.hh>
40+#include <util/structs.hh>
41+
42+namespace gui {
43+} // namespace gui
@@ -0,0 +1,43 @@
1+/*
2+# 076 License
3+
4+Copyright (c) テクニカル諏訪子
5+
6+Permission is hereby granted to any person obtaining a copy of the software
7+Shader Playground (the "Software") to use, modify, merge, copy, publish, distribute,
8+sublicense, and/or sell copies of the Software, subject to the following conditions:
9+
10+ 1. **Origin Attribution**:
11+ - You must not misrepresent the origin of the Software; you must not claim
12+ you created the original Software.
13+ - If the Software is used in a product, you must either:
14+ a. Provide clear attribution in the product's documentation, user interface,
15+ or other visible areas, **OR**
16+ b. Pay the original developers a fee they specify in writing.
17+ 2. **Usage Restriction**:
18+ - The Software, or any derivative works, dependencies, or libraries
19+ incorporating it, must not be used for censorship or to suppress freedom of
20+ speech, expression, or creativity. Prohibited uses include, but are not
21+ limited to:
22+ - Censorship of so-called "hate speech", visuals, non-mainstream opinions,
23+ ideas, or objective reality.
24+ - Tools or systems designed to restrict access to information or
25+ artistic works.
26+ 3. **Notice Preservation**:
27+ - This license and the above copyright notice must remain intact in all copies
28+ of the source code.
29+
30+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
31+INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
32+PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
33+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
34+CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
35+OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
36+*/
37+#pragma once
38+
39+#include <util/types.hh>
40+#include <util/structs.hh>
41+
42+namespace gui {
43+} // namespace gui
@@ -42,6 +42,6 @@
4242 namespace gui {
4343 class Settings {
4444 public:
45- void Draw(GlfwInfo &glfw);
45+ void Draw(Info &info);
4646 }; // class Settings
4747 } // namespace gui
@@ -40,5 +40,5 @@
4040 #include <util/structs.hh>
4141
4242 namespace gui {
43- void showTitleBar(GlfwInfo &glfw);
43+ void showTitleBar(Info &info);
4444 } // namespace gui
@@ -44,7 +44,7 @@
4444 public:
4545 void Init();
4646 void Resize(i32 width, i32 height);
47- void Draw(GlfwInfo &glfw);
47+ void Draw(Info &info);
4848
4949 u32 GetFBO() const { return m_FBO; }
5050 u32 GetTexture() const { return m_Texture; }
@@ -65,7 +65,7 @@
6565
6666 class LuaEngine {
6767 public:
68- LuaEngine(const string &code, Program *prog, GlfwInfo *glfwInfo);
68+ LuaEngine(const string &code, Program *prog, Info *info);
6969 ~LuaEngine();
7070
7171 public:
@@ -96,7 +96,7 @@
9696 sol::state m_Lua;
9797 string m_Code;
9898 Program *m_Program = nullptr;
99- GlfwInfo *m_GlfwInfo = {};
99+ Info *m_Info = {};
100100 string m_ApiVersion = "1.0.0";
101101 f32 m_LastTime = 0.f;
102102 };
@@ -40,6 +40,8 @@
4040 #include <version.hh>
4141 #include <functional>
4242 #include <string>
43+#include <cstdint>
44+#include <database/shaderdata.hh>
4345
4446 namespace gui {
4547 class ConsoleLog;
@@ -47,9 +49,10 @@
4749
4850 namespace db {
4951 class Locale;
52+ struct CodeData;
5053 } // namespace db
5154
52-struct GlfwInfo {
55+struct Info {
5356 glfwpp::Instance *instance;
5457 glfwpp::Window *window;
5558
@@ -58,12 +61,20 @@
5861 bool isManual = false;
5962 bool isSettings = false;
6063 bool isLangChange = false;
64+ bool isNewShader = false;
6165
6266 std::string version = version::full;
67+ uint32_t shaderId = 0;
68+ std::string shaderName = "";
69+ db::CodeData VERT = {};
70+ db::CodeData FRAG = {};
71+ db::CodeData LUA = {};
72+ std::string currentFile = "";
6373
6474 gui::ConsoleLog *cmd;
6575 db::Locale *i18n;
6676
6777 std::function<void()> compile;
6878 std::function<void()> save;
79+ std::function<void()> create;
6980 };
変更 main.cc
@@ -75,7 +75,7 @@
7575 window.MakeContextCurrent();
7676 glfw.SwapInterval(1);
7777
78- GlfwInfo glfwInfo = { &glfw, &window, true, false, false, false };
78+ Info info = { &glfw, &window, true, false, false, false };
7979
8080 #ifndef PRODUCTION_BUILD
8181 bool showDemo = true;
@@ -104,11 +104,11 @@
104104
105105 // 言語
106106 db::Locale i18n(&db);
107- glfwInfo.i18n = &i18n;
107+ info.i18n = &i18n;
108108
109109 // コンソール
110110 gui::ConsoleLog cmd;
111- glfwInfo.cmd = &cmd;
111+ info.cmd = &cmd;
112112
113113 // ビューポート
114114 gui::ViewPort viewport;
@@ -119,38 +119,38 @@
119119
120120 // データベースからシェーダーとLuaコードの受け取り
121121 vector<db::ShaderData> codeMap = db::GetAllShaders(db);
122- u32 shaderId;
123- string shaderName;
124- db::CodeData VERT = {};
125- db::CodeData FRAG = {};
126- db::CodeData LUA = {};
122+ info.shaderId;
123+ info.shaderName;
124+ info.VERT = {};
125+ info.FRAG = {};
126+ info.LUA = {};
127127
128128 for (const auto &c : codeMap) {
129- shaderId = c.id;
130- shaderName = c.name;
131- VERT = c.vertexShader;
132- FRAG = c.fragmentShader;
133- LUA = c.luaCode;
129+ info.shaderId = c.id;
130+ info.shaderName = c.name;
131+ info.VERT = c.vertexShader;
132+ info.FRAG = c.fragmentShader;
133+ info.LUA = c.luaCode;
134134 }
135135
136- string title = shaderName + "(" + glfwInfo.i18n->GetWord("editorvertshader") + ")";
137- gui::Editor vertEditor((title + "###VertexEditor").c_str(), "VertexEditor", VERT.code, gui::Glsl, ge.GetCjkFont(), ge.GetMonoFont());
136+ string title = info.shaderName + "(" + info.i18n->GetWord("editorvertshader") + ")";
137+ gui::Editor vertEditor((title + "###VertexEditor").c_str(), "VertexEditor", info.VERT.code, gui::Glsl, ge.GetCjkFont(), ge.GetMonoFont());
138138
139- title = shaderName + "(" + glfwInfo.i18n->GetWord("editorfragshader") + ")";
140- gui::Editor fragEditor((title + "###FragmentEditor").c_str(), "FragmentEditor", FRAG.code, gui::Glsl, ge.GetCjkFont(), ge.GetMonoFont());
139+ title = info.shaderName + "(" + info.i18n->GetWord("editorfragshader") + ")";
140+ gui::Editor fragEditor((title + "###FragmentEditor").c_str(), "FragmentEditor", info.FRAG.code, gui::Glsl, ge.GetCjkFont(), ge.GetMonoFont());
141141
142- title = shaderName + "(" + glfwInfo.i18n->GetWord("editorlua") + ")";
143- gui::Editor luaEditor((title + "###LuaEditor").c_str(), "LuaEditor", LUA.code, gui::Lua, ge.GetCjkFont(), ge.GetMonoFont());
142+ title = info.shaderName + "(" + info.i18n->GetWord("editorlua") + ")";
143+ gui::Editor luaEditor((title + "###LuaEditor").c_str(), "LuaEditor", info.LUA.code, gui::Lua, ge.GetCjkFont(), ge.GetMonoFont());
144144
145145 // シェーダーをコンパイル
146- Shader vertexShader(VERT.code, GL_VERTEX_SHADER);
147- Shader fragmentShader(FRAG.code, GL_FRAGMENT_SHADER);
146+ Shader vertexShader(info.VERT.code, GL_VERTEX_SHADER);
147+ Shader fragmentShader(info.FRAG.code, GL_FRAGMENT_SHADER);
148148
149149 // シェーダープログラムをリンク
150150 Program shaderProgram(vertexShader, fragmentShader);
151151
152152 // 頂点データはLuaから受け取る
153- lua::LuaEngine luaEngine(LUA.code, &shaderProgram, &glfwInfo);
153+ lua::LuaEngine luaEngine(info.LUA.code, &shaderProgram, &info);
154154 auto &mesh = luaEngine.GetMesh();
155155
156156 VertexArrays VAO(1);
@@ -174,19 +174,20 @@
174174 gui::Settings settings;
175175
176176 // メインレンダリングループ
177- while (!window.ShouldClose() && glfwInfo.isRunning) {
178- glfwInfo.compile = [&]() {
179- VERT.code = vertEditor.Get().GetText();
180- FRAG.code = fragEditor.Get().GetText();
181- LUA.code = luaEditor.Get().GetText();
177+ while (!window.ShouldClose() && info.isRunning) {
178+#pragma region Lambda
179+ info.compile = [&]() {
180+ info.VERT.code = vertEditor.Get().GetText();
181+ info.FRAG.code = fragEditor.Get().GetText();
182+ info.LUA.code = luaEditor.Get().GetText();
182183
183184 try {
184185 try {
185- if (!luaEngine.Validate(LUA.code)) {
186+ if (!luaEngine.Validate(info.LUA.code)) {
186187 gui::LogEntry entry;
187188 entry.type = gui::LogType::Error;
188- entry.text = glfwInfo.i18n->GetWord("consolelogerrorluainvalidcomp");
189- glfwInfo.cmd->Add(entry);
189+ entry.text = info.i18n->GetWord("consolelogerrorluainvalidcomp");
190+ info.cmd->Add(entry);
190191 std::cerr << entry.text << std::endl;
191192 return;
192193 }
@@ -194,17 +195,17 @@
194195 gui::LogEntry entry;
195196 entry.type = gui::LogType::Error;
196197 entry.text = e.what();
197- glfwInfo.cmd->Add(entry);
198+ info.cmd->Add(entry);
198199 std::cerr << entry.text << std::endl;
199- entry.text = glfwInfo.i18n->GetWord("consolelogerrorluainvalidcomp");
200- glfwInfo.cmd->Add(entry);
200+ entry.text = info.i18n->GetWord("consolelogerrorluainvalidcomp");
201+ info.cmd->Add(entry);
201202 std::cerr << entry.text << std::endl;
202203 return;
203204 }
204205
205- shaderProgram.Reload(VERT.code, FRAG.code);
206+ shaderProgram.Reload(info.VERT.code, info.FRAG.code);
206207 luaEngine.SetProgram(&shaderProgram);
207- luaEngine.Reload(LUA.code);
208+ luaEngine.Reload(info.LUA.code);
208209 {
209210 lua::LuaMesh newMesh = luaEngine.GetMesh();
210211
@@ -237,33 +238,43 @@
237238
238239 gui::LogEntry entry;
239240 entry.type = gui::LogType::Info;
240- entry.text = glfwInfo.i18n->GetWord("consoleloginfocompileok");
241- glfwInfo.cmd->Add(entry);
241+ entry.text = info.i18n->GetWord("consoleloginfocompileok");
242+ info.cmd->Add(entry);
242243 std::cout << entry.text << std::endl;
243244 } catch (const std::exception &e) {
244245 gui::LogEntry entry;
245246 entry.type = gui::LogType::Error;
246247 entry.text = e.what();
247- glfwInfo.cmd->Add(entry);
248+ info.cmd->Add(entry);
248249 std::cerr << entry.text << std::endl;
249- entry.text = glfwInfo.i18n->GetWord("consolelogerrorluainvalidcomp");
250- glfwInfo.cmd->Add(entry);
250+ entry.text = info.i18n->GetWord("consolelogerrorluainvalidcomp");
251+ info.cmd->Add(entry);
251252 std::cerr << entry.text << std::endl;
252253 }
253254 };
254255
255- glfwInfo.save = [&]() {
256- VERT.code = vertEditor.Get().GetText();
257- FRAG.code = fragEditor.Get().GetText();
258- LUA.code = luaEditor.Get().GetText();
256+ info.save = [&]() {
257+ if (info.shaderId == 0) {
258+ gui::LogEntry entry;
259+ entry.type = gui::LogType::Warning;
260+ std::cout << entry.text << std::endl;
261+ entry.text = "TODO: 保存ダイアログボックス関数は開発中・・・";
262+ info.cmd->Add(entry);
263+ std::cout << entry.text << std::endl;
264+ return;
265+ }
259266
267+ info.VERT.code = vertEditor.Get().GetText();
268+ info.FRAG.code = fragEditor.Get().GetText();
269+ info.LUA.code = luaEditor.Get().GetText();
270+
260271 try {
261272 try {
262- if (!luaEngine.Validate(LUA.code)) {
273+ if (!luaEngine.Validate(info.LUA.code)) {
263274 gui::LogEntry entry;
264275 entry.type = gui::LogType::Error;
265- entry.text = glfwInfo.i18n->GetWord("consolelogerrorluainvalidsave");
266- glfwInfo.cmd->Add(entry);
276+ entry.text = info.i18n->GetWord("consolelogerrorluainvalidsave");
277+ info.cmd->Add(entry);
267278 std::cout << entry.text << std::endl;
268279 return;
269280 }
@@ -271,81 +282,133 @@
271282 gui::LogEntry entry;
272283 entry.type = gui::LogType::Error;
273284 entry.text = e.what();
274- glfwInfo.cmd->Add(entry);
285+ info.cmd->Add(entry);
275286 std::cout << entry.text << std::endl;
276- entry.text = glfwInfo.i18n->GetWord("consolelogerrorluainvalidsave");
277- glfwInfo.cmd->Add(entry);
287+ entry.text = info.i18n->GetWord("consolelogerrorluainvalidsave");
288+ info.cmd->Add(entry);
278289 std::cout << entry.text << std::endl;
279290 return;
280291 }
281292
282- db::SaveCode(db, VERT);
283- db::SaveCode(db, FRAG);
284- db::SaveCode(db, LUA);
293+ db::SaveCode(db, info.VERT);
294+ db::SaveCode(db, info.FRAG);
295+ db::SaveCode(db, info.LUA);
285296
286297 gui::LogEntry entry;
287298 entry.type = gui::LogType::Info;
288- entry.text = glfwInfo.i18n->GetWord("consoleloginfosaveok");
289- glfwInfo.cmd->Add(entry);
299+ entry.text = info.i18n->GetWord("consoleloginfosaveok");
300+ info.cmd->Add(entry);
290301 std::cout << entry.text << std::endl;
291302 } catch (const std::exception &e) {
292303 gui::LogEntry entry;
293304 entry.type = gui::LogType::Error;
294305 entry.text = e.what();
295- glfwInfo.cmd->Add(entry);
306+ info.cmd->Add(entry);
296307 std::cout << entry.text << std::endl;
297- entry.text = glfwInfo.i18n->GetWord("consolelogerrorluainvalidsave");
298- glfwInfo.cmd->Add(entry);
308+ entry.text = info.i18n->GetWord("consolelogerrorluainvalidsave");
309+ info.cmd->Add(entry);
299310 std::cout << entry.text << std::endl;
300311 }
301312 };
302313
314+ info.create = [&]() {
315+ gui::NewShader newShader(&info);
316+ auto shdr = newShader.Make();
317+
318+ info.shaderId = shdr.id;
319+ info.shaderName = shdr.name;
320+ info.VERT = shdr.vertexShader;
321+ info.FRAG = shdr.fragmentShader;
322+ info.LUA = shdr.luaCode;
323+
324+ vertEditor.SetCode(info.VERT.code);
325+ string nTit = info.shaderName + "(" + info.i18n->GetWord("editorvertshader") + ")";
326+ vertEditor.SetTitle(nTit + "###VertexEditor");
327+
328+ fragEditor.SetCode(info.FRAG.code);
329+ nTit = info.shaderName + "(" + info.i18n->GetWord("editorfragshader") + ")";
330+ fragEditor.SetTitle(nTit + "###FragmentEditor");
331+
332+ luaEditor.SetCode(info.LUA.code);
333+ nTit = info.shaderName + "(" + info.i18n->GetWord("editorlua") + ")";
334+ luaEditor.SetTitle(nTit + "###LuaEditor");
335+
336+ info.compile();
337+
338+ gui::LogEntry entry;
339+ entry.type = gui::LogType::Info;
340+ entry.text = info.i18n->GetWord("consoleloginfocreateok") + ", ID: " + std::to_string(info.shaderId);
341+ info.cmd->Add(entry);
342+ std::cout << entry.text << std::endl;
343+ };
344+#pragma endregion
345+
303346 glfw.PollEvents();
304347
305348 bool isManualKey = window.GetKey(GLFW_KEY_F1);
306349 bool isCompileKey = window.GetKey(GLFW_KEY_F5);
350+
307351 bool ctrlMod = (window.GetKey(GLFW_KEY_LEFT_CONTROL) == GLFW_PRESS || window.GetKey(GLFW_KEY_RIGHT_CONTROL) == GLFW_PRESS);
352+ bool shiftMod = (window.GetKey(GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS || window.GetKey(GLFW_KEY_RIGHT_SHIFT) == GLFW_PRESS);
353+ //bool altMod = (window.GetKey(GLFW_KEY_LEFT_ALT) == GLFW_PRESS || window.GetKey(GLFW_KEY_RIGHT_ALT) == GLFW_PRESS);
354+
355+ bool isNewKey = (window.GetKey(GLFW_KEY_N) == GLFW_PRESS && ctrlMod);
356+ bool isOpenKey = (window.GetKey(GLFW_KEY_O) == GLFW_PRESS && ctrlMod);
308357 bool isSaveKey = (window.GetKey(GLFW_KEY_S) == GLFW_PRESS && ctrlMod);
358+ bool isSaveAsKey = (window.GetKey(GLFW_KEY_S) == GLFW_PRESS && ctrlMod && shiftMod);
309359 bool isQuitKey = (window.GetKey(GLFW_KEY_Q) == GLFW_PRESS && ctrlMod);
310360 bool isAboutKey = (window.GetKey(GLFW_KEY_H) == GLFW_PRESS && ctrlMod);
311361 bool isSettingsKey = (window.GetKey(GLFW_KEY_COMMA) == GLFW_PRESS && ctrlMod);
312362
313363 if (!isHold) {
314364 if (isCompileKey) {
315- glfwInfo.compile();
365+ info.compile();
316366 }
317367
368+ if (isNewKey) {
369+ info.create();
370+ }
371+
372+ if (isOpenKey) {}
373+
318374 if (isManualKey) {
319- glfwInfo.isManual = true;
375+ info.isManual = true;
320376 }
321377
322378 if (isSettingsKey) {
323- glfwInfo.isSettings = true;
379+ info.isSettings = true;
324380 }
325381
326382 if (isAboutKey) {
327- glfwInfo.isAbout = true;
383+ info.isAbout = true;
328384 }
329385
330386 if (isSaveKey) {
331- glfwInfo.save();
387+ info.save();
332388 }
333389
334390 if (isQuitKey) {
335- glfwInfo.isRunning = false;
391+ info.isRunning = false;
336392 }
337393 }
338394
339- isHold = isSaveKey || isCompileKey || isAboutKey || isQuitKey || isManualKey || isSettingsKey;
395+ isHold = isSaveKey ||
396+ isCompileKey ||
397+ isAboutKey ||
398+ isQuitKey ||
399+ isManualKey ||
400+ isSettingsKey ||
401+ isNewKey ||
402+ isOpenKey;
340403
341- if (glfwInfo.isLangChange) {
342- string nTit = shaderName + "(" + glfwInfo.i18n->GetWord("editorvertshader") + ")";
404+ if (info.isLangChange) {
405+ string nTit = info.shaderName + "(" + info.i18n->GetWord("editorvertshader") + ")";
343406 vertEditor.SetTitle(nTit + "###VertexEditor");
344- nTit = shaderName + "(" + glfwInfo.i18n->GetWord("editorfragshader") + ")";
407+ nTit = info.shaderName + "(" + info.i18n->GetWord("editorfragshader") + ")";
345408 fragEditor.SetTitle(nTit + "###FragmentEditor");
346- nTit = shaderName + "(" + glfwInfo.i18n->GetWord("editorlua") + ")";
409+ nTit = info.shaderName + "(" + info.i18n->GetWord("editorlua") + ")";
347410 luaEditor.SetTitle(nTit + "###LuaEditor");
348- glfwInfo.isLangChange = false;
411+ info.isLangChange = false;
349412 }
350413
351414 if (window.GetAttrib(glfwpp::Attributes::Iconified) != 0) {
@@ -353,7 +416,7 @@
353416 continue;
354417 }
355418
356- gui::showTitleBar(glfwInfo);
419+ gui::showTitleBar(info);
357420
358421 #ifndef PRODUCTION_BUILD
359422 if (showDemo) ImGui::ShowDemoWindow(&showDemo);
@@ -362,12 +425,12 @@
362425 vertEditor.Render();
363426 fragEditor.Render();
364427 luaEditor.Render();
365- glfwInfo.cmd->Draw(glfwInfo, glfwInfo.i18n->GetWord("editorconsole").c_str());
366- about.Draw(glfwInfo);
367- settings.Draw(glfwInfo);
368- manual.Draw(glfwInfo);
428+ info.cmd->Draw(info, info.i18n->GetWord("editorconsole").c_str());
429+ about.Draw(info);
430+ settings.Draw(info);
431+ manual.Draw(info);
369432
370- viewport.Draw(glfwInfo);
433+ viewport.Draw(info);
371434
372435 ImGui::Render();
373436
@@ -244,6 +244,8 @@
244244 createWord(db, 2, "consoleloginfosaveok", "Shaders and Lua have been saved.");
245245 createWord(db, 1, "consoleloginfolangchangeok", "言語を変更しました。");
246246 createWord(db, 2, "consoleloginfolangchangeok", "Language has been changed.");
247+ createWord(db, 1, "consoleloginfocreateok", "新しいシェーダーを作成しました。保存するには、「CTRL + S」を押して下さい。");
248+ createWord(db, 2, "consoleloginfocreateok", "New shader has been created. In order to save, press \"CTRL + S\".");
247249 }
248250
249251 i64 shaderId = 0;
@@ -39,16 +39,16 @@
3939 #include <database/locale.hh>
4040
4141 namespace gui {
42- void About::Draw(GlfwInfo &glfw) {
43- if (!glfw.isAbout) return;
42+ void About::Draw(Info &info) {
43+ if (!info.isAbout) return;
4444
4545 ImGuiWindowFlags flags = 0;
4646 ImGui::SetNextWindowSize({400, 300}, ImGuiCond_Appearing);
47- ImGui::Begin(glfw.i18n->GetWord("helpabout").c_str(), &glfw.isAbout, flags);
48- string name = "Shader Playground " + glfw.version;
47+ ImGui::Begin(info.i18n->GetWord("helpabout").c_str(), &info.isAbout, flags);
48+ string name = "Shader Playground " + info.version;
4949 string copyright;
5050 string developer;
51- if (glfw.i18n->GetCurrentLanguage().code == "ja_JP") {
51+ if (info.i18n->GetCurrentLanguage().code == "ja_JP") {
5252 copyright = "© 2026 - 076スタジオ合同会社";
5353 developer = "開発者:テクニカル諏訪子";
5454 } else {
@@ -74,7 +74,7 @@
7474 winSize.y - 40.f
7575 });
7676
77- if (ImGui::Button("OK", { btnW, btnH })) glfw.isAbout = false;
77+ if (ImGui::Button("OK", { btnW, btnH })) info.isAbout = false;
7878 ImGui::End();
7979 }
8080 } // namespace gui
@@ -44,7 +44,7 @@
4444 m_Lines.push_back(entry);
4545 }
4646
47- void ConsoleLog::Draw(GlfwInfo &info, cstr title) {
47+ void ConsoleLog::Draw(Info &info, cstr title) {
4848 ImGui::Begin((string(title) + "###Console").c_str());
4949 if (ImGui::Button(info.i18n->GetWord("editorconsoleclear").c_str())) Clear();
5050 ImGui::Separator();
@@ -39,31 +39,31 @@
3939 #include <database/locale.hh>
4040
4141 namespace gui {
42- void Manual::Draw(GlfwInfo &glfw) {
43- if (!glfw.isManual) return;
42+ void Manual::Draw(Info &info) {
43+ if (!info.isManual) return;
4444
4545 ImGuiWindowFlags flags = ImGuiWindowFlags_NoCollapse;
4646
4747 ImGui::SetNextWindowSize({ 600, 700 }, ImGuiCond_Appearing);
48- ImGui::Begin(glfw.i18n->GetWord("helpmanual").c_str(), &glfw.isManual, flags);
48+ ImGui::Begin(info.i18n->GetWord("helpmanual").c_str(), &info.isManual, flags);
4949
5050 if (ImGui::BeginTabBar("ManualTabs")) {
51- if (ImGui::BeginTabItem(glfw.i18n->GetWord("helpmanualoverview").c_str())) {
51+ if (ImGui::BeginTabItem(info.i18n->GetWord("helpmanualoverview").c_str())) {
5252 m_CurPage = "index";
5353 ImGui::EndTabItem();
5454 }
5555
56- if (ImGui::BeginTabItem(glfw.i18n->GetWord("helpmanualshader").c_str())) {
56+ if (ImGui::BeginTabItem(info.i18n->GetWord("helpmanualshader").c_str())) {
5757 m_CurPage = "shader";
5858 ImGui::EndTabItem();
5959 }
6060
61- if (ImGui::BeginTabItem(glfw.i18n->GetWord("helpmanuallua").c_str())) {
61+ if (ImGui::BeginTabItem(info.i18n->GetWord("helpmanuallua").c_str())) {
6262 m_CurPage = "lua";
6363 ImGui::EndTabItem();
6464 }
6565
66- if (ImGui::BeginTabItem(glfw.i18n->GetWord("helpmanualhotkey").c_str())) {
66+ if (ImGui::BeginTabItem(info.i18n->GetWord("helpmanualhotkey").c_str())) {
6767 m_CurPage = "hotkeys";
6868 ImGui::EndTabItem();
6969 }
@@ -76,7 +76,7 @@
7676 ImGui::BeginChild("ManualContent", ImVec2(0, 0), 0, ImGuiWindowFlags_HorizontalScrollbar);
7777
7878 if (m_CurPage == "index") {
79- if (glfw.i18n->GetCurrentLanguage().code == "ja_JP") {
79+ if (info.i18n->GetCurrentLanguage().code == "ja_JP") {
8080 ImGui::TextWrapped("Shader Playgroundへようこそ!");
8181 ImGui::Dummy(ImVec2(0, 10));
8282 renderMarkdown(R"(# 基本操作
@@ -0,0 +1,116 @@
1+/*
2+# 076 License
3+
4+Copyright (c) テクニカル諏訪子
5+
6+Permission is hereby granted to any person obtaining a copy of the software
7+Shader Playground (the "Software") to use, modify, merge, copy, publish, distribute,
8+sublicense, and/or sell copies of the Software, subject to the following conditions:
9+
10+ 1. **Origin Attribution**:
11+ - You must not misrepresent the origin of the Software; you must not claim
12+ you created the original Software.
13+ - If the Software is used in a product, you must either:
14+ a. Provide clear attribution in the product's documentation, user interface,
15+ or other visible areas, **OR**
16+ b. Pay the original developers a fee they specify in writing.
17+ 2. **Usage Restriction**:
18+ - The Software, or any derivative works, dependencies, or libraries
19+ incorporating it, must not be used for censorship or to suppress freedom of
20+ speech, expression, or creativity. Prohibited uses include, but are not
21+ limited to:
22+ - Censorship of so-called "hate speech", visuals, non-mainstream opinions,
23+ ideas, or objective reality.
24+ - Tools or systems designed to restrict access to information or
25+ artistic works.
26+ 3. **Notice Preservation**:
27+ - This license and the above copyright notice must remain intact in all copies
28+ of the source code.
29+
30+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
31+INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
32+PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
33+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
34+CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
35+OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
36+*/
37+#include <gui/newshader.hh>
38+#include <database/locale.hh>
39+
40+namespace gui {
41+ NewShader::NewShader(Info *info) : m_Info(info) {}
42+ NewShader::~NewShader() {}
43+
44+ db::ShaderData NewShader::Make() {
45+ db::ShaderData newShader = {};
46+ auto curLang = m_Info->i18n->GetCurrentLanguage().code;
47+ newShader.id = 0;
48+ if (curLang == "ja_JP") newShader.name = "(名無し)";
49+ else newShader.name = "(Unnamed)";
50+ newShader.description = "";
51+
52+ newShader.vertexShader.id = 0;
53+ newShader.vertexShader.type = db::ShaderCodeType::GlslVertex;
54+ newShader.vertexShader.code = getDefaultVert();
55+ newShader.vertexShader.filename = "";
56+
57+ newShader.fragmentShader.id = 0;
58+ newShader.fragmentShader.type = db::ShaderCodeType::GlslFragment;
59+ newShader.fragmentShader.code = getDefaultFrag();
60+ newShader.fragmentShader.filename = "";
61+
62+ newShader.luaCode.id = 0;
63+ newShader.luaCode.type = db::ShaderCodeType::Lua;
64+ newShader.luaCode.code = getDefaultLua();
65+ newShader.luaCode.filename = "";
66+
67+ return newShader;
68+ }
69+
70+ ///////////////////////////
71+
72+ string NewShader::getDefaultVert() {
73+ return R"(#version 460 core
74+
75+layout(location = 0) in vec2 aPosition;
76+layout(location = 1) in vec3 aColor;
77+out vec3 vColor;
78+
79+void main() {
80+ vColor = aColor;
81+ gl_Position = vec4(aPosition, 0.0, 1.0);
82+})";
83+ }
84+
85+ string NewShader::getDefaultFrag() {
86+ return R"(#version 460 core
87+
88+in vec3 vColor;
89+out vec4 out_color;
90+
91+void main() {
92+ out_color = vec4(vColor, 1.0);
93+})";
94+ }
95+
96+ string NewShader::getDefaultLua() {
97+ return R"(local mesh = {
98+ vertices = {
99+ 0, .5, 1, 0, 0,
100+ -.5, -.5, 0, 1, 0,
101+ .5, -.5, 0, 0, 1
102+ },
103+ indices = { 0, 1, 2 },
104+
105+ attributes = {
106+ { location = 0, size = 2, stride = 20, offset = 0 }, -- position
107+ { location = 1, size = 3, stride = 20, offset = 8 } -- uv
108+ }
109+}
110+
111+le.gfx.set_mesh(mesh)
112+
113+function update()
114+end)";
115+ }
116+} // namespace gui
@@ -0,0 +1,40 @@
1+/*
2+# 076 License
3+
4+Copyright (c) テクニカル諏訪子
5+
6+Permission is hereby granted to any person obtaining a copy of the software
7+Shader Playground (the "Software") to use, modify, merge, copy, publish, distribute,
8+sublicense, and/or sell copies of the Software, subject to the following conditions:
9+
10+ 1. **Origin Attribution**:
11+ - You must not misrepresent the origin of the Software; you must not claim
12+ you created the original Software.
13+ - If the Software is used in a product, you must either:
14+ a. Provide clear attribution in the product's documentation, user interface,
15+ or other visible areas, **OR**
16+ b. Pay the original developers a fee they specify in writing.
17+ 2. **Usage Restriction**:
18+ - The Software, or any derivative works, dependencies, or libraries
19+ incorporating it, must not be used for censorship or to suppress freedom of
20+ speech, expression, or creativity. Prohibited uses include, but are not
21+ limited to:
22+ - Censorship of so-called "hate speech", visuals, non-mainstream opinions,
23+ ideas, or objective reality.
24+ - Tools or systems designed to restrict access to information or
25+ artistic works.
26+ 3. **Notice Preservation**:
27+ - This license and the above copyright notice must remain intact in all copies
28+ of the source code.
29+
30+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
31+INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
32+PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
33+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
34+CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
35+OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
36+*/
37+#include <gui/openshader.hh>
38+
39+namespace gui {
40+} // namespace gui
@@ -0,0 +1,40 @@
1+/*
2+# 076 License
3+
4+Copyright (c) テクニカル諏訪子
5+
6+Permission is hereby granted to any person obtaining a copy of the software
7+Shader Playground (the "Software") to use, modify, merge, copy, publish, distribute,
8+sublicense, and/or sell copies of the Software, subject to the following conditions:
9+
10+ 1. **Origin Attribution**:
11+ - You must not misrepresent the origin of the Software; you must not claim
12+ you created the original Software.
13+ - If the Software is used in a product, you must either:
14+ a. Provide clear attribution in the product's documentation, user interface,
15+ or other visible areas, **OR**
16+ b. Pay the original developers a fee they specify in writing.
17+ 2. **Usage Restriction**:
18+ - The Software, or any derivative works, dependencies, or libraries
19+ incorporating it, must not be used for censorship or to suppress freedom of
20+ speech, expression, or creativity. Prohibited uses include, but are not
21+ limited to:
22+ - Censorship of so-called "hate speech", visuals, non-mainstream opinions,
23+ ideas, or objective reality.
24+ - Tools or systems designed to restrict access to information or
25+ artistic works.
26+ 3. **Notice Preservation**:
27+ - This license and the above copyright notice must remain intact in all copies
28+ of the source code.
29+
30+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
31+INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
32+PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
33+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
34+CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
35+OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
36+*/
37+#include <gui/saveasshader.hh>
38+
39+namespace gui {
40+} // namespace gui
@@ -41,18 +41,18 @@
4141 #include <imgui.h>
4242
4343 namespace gui {
44- void Settings::Draw(GlfwInfo &glfw) {
45- if (!glfw.isSettings) return;
44+ void Settings::Draw(Info &info) {
45+ if (!info.isSettings) return;
4646
4747 ImGuiWindowFlags flags = 0;
4848 ImGui::SetNextWindowSize({ 400, 300 }, ImGuiCond_Appearing);
49- ImGui::Begin(glfw.i18n->GetWord("settings").c_str(), &glfw.isSettings, flags);
49+ ImGui::Begin(info.i18n->GetWord("settings").c_str(), &info.isSettings, flags);
5050
5151 ImGui::Text("言語 / Language");
5252 ImGui::SameLine();
5353 cstr items[] = { "日本語 (ja_JP)", "English (en_US)" };
5454 const i32 itemCount = IM_COUNTOF(items);
55- i32 curId = glfw.i18n->GetCurrentLanguage().id;
55+ i32 curId = info.i18n->GetCurrentLanguage().id;
5656 static i32 sel = (curId >= 1) ? curId - 1 : 0;
5757
5858 sel = (curId >= 1 && curId <= itemCount) ? curId - 1 : 0;
@@ -63,11 +63,11 @@
6363 const bool isSel = (sel == n);
6464 if (ImGui::Selectable(items[n], isSel)) {
6565 sel = n;
66- glfw.i18n->SetLanguage(n + 1);
66+ info.i18n->SetLanguage(n + 1);
6767 gui::LogEntry entry;
6868 entry.type = gui::LogType::Info;
69- entry.text = glfw.i18n->GetWord("consoleloginfolangchangeok");
70- glfw.cmd->Add(entry);
69+ entry.text = info.i18n->GetWord("consoleloginfolangchangeok");
70+ info.cmd->Add(entry);
7171 }
7272
7373 if (isSel) {
@@ -88,7 +88,7 @@
8888 winSize.y - 40.f
8989 });
9090
91- if (ImGui::Button("OK", { btnW, btnH })) glfw.isSettings = false;
91+ if (ImGui::Button("OK", { btnW, btnH })) info.isSettings = false;
9292 ImGui::End();
9393 }
9494 } // namespace gui
@@ -44,7 +44,7 @@
4444 #include <ctime>
4545
4646 namespace gui {
47- void showTitleBar(GlfwInfo &glfw) {
47+ void showTitleBar(Info &info) {
4848 ImGui_ImplOpenGL3_NewFrame();
4949 ImGui_ImplGlfw_NewFrame();
5050 ImGui::NewFrame();
@@ -123,9 +123,11 @@
123123 ImGui::End();
124124
125125 if (ImGui::BeginMainMenuBar()) {
126- if (ImGui::BeginMenu(glfw.i18n->GetWord("file").c_str())) {
127- if (ImGui::MenuItem(glfw.i18n->GetWord("filenew").c_str(), "CTRL+N", false, false)) {}
128- if (ImGui::MenuItem(glfw.i18n->GetWord("fileopen").c_str(), "Ctrl+O", false, false)) {}
126+ if (ImGui::BeginMenu(info.i18n->GetWord("file").c_str())) {
127+ if (ImGui::MenuItem(info.i18n->GetWord("filenew").c_str(), "CTRL+N")) {
128+ info.create();
129+ }
130+ if (ImGui::MenuItem(info.i18n->GetWord("fileopen").c_str(), "Ctrl+O", false, false)) {}
129131 //if (ImGui::BeginMenu("最近使った物")) {
130132 // ImGui::MenuItem("fish_hat.c");
131133 // ImGui::MenuItem("fish_hat.inl");
@@ -137,45 +139,45 @@
137139 // }
138140 // ImGui::EndMenu();
139141 //}
140- if (ImGui::MenuItem(glfw.i18n->GetWord("filesave").c_str(), "Ctrl+S")) {
141- glfw.save();
142+ if (ImGui::MenuItem(info.i18n->GetWord("filesave").c_str(), "Ctrl+S")) {
143+ info.save();
142144 }
143145
144146 ImGui::Separator();
145- if (ImGui::MenuItem(glfw.i18n->GetWord("quit").c_str(), "CTRL+Q")) {
146- glfw.isRunning = false;
147+ if (ImGui::MenuItem(info.i18n->GetWord("quit").c_str(), "CTRL+Q")) {
148+ info.isRunning = false;
147149 }
148150 ImGui::EndMenu();
149151 }
150152
151- if (ImGui::BeginMenu(glfw.i18n->GetWord("edit").c_str())) {
152- if (ImGui::MenuItem(glfw.i18n->GetWord("editundo").c_str(), "Ctrl+Z", false, false)) {}
153- if (ImGui::MenuItem(glfw.i18n->GetWord("editredo").c_str(), "Ctrl+Y", false, false)) {}
153+ if (ImGui::BeginMenu(info.i18n->GetWord("edit").c_str())) {
154+ if (ImGui::MenuItem(info.i18n->GetWord("editundo").c_str(), "Ctrl+Z", false, false)) {}
155+ if (ImGui::MenuItem(info.i18n->GetWord("editredo").c_str(), "Ctrl+Y", false, false)) {}
154156 ImGui::Separator();
155- if (ImGui::MenuItem(glfw.i18n->GetWord("editcut").c_str(), "Ctrl+X", false, false)) {}
156- if (ImGui::MenuItem(glfw.i18n->GetWord("editcopy").c_str(), "Ctrl+C", false, false)) {}
157- if (ImGui::MenuItem(glfw.i18n->GetWord("editpaste").c_str(), "Ctrl+V", false, false)) {}
158- if (ImGui::MenuItem(glfw.i18n->GetWord("editduplicate").c_str(), "Ctrl+D", false, false)) {}
157+ if (ImGui::MenuItem(info.i18n->GetWord("editcut").c_str(), "Ctrl+X", false, false)) {}
158+ if (ImGui::MenuItem(info.i18n->GetWord("editcopy").c_str(), "Ctrl+C", false, false)) {}
159+ if (ImGui::MenuItem(info.i18n->GetWord("editpaste").c_str(), "Ctrl+V", false, false)) {}
160+ if (ImGui::MenuItem(info.i18n->GetWord("editduplicate").c_str(), "Ctrl+D", false, false)) {}
159161 ImGui::Separator();
160- if (ImGui::MenuItem(glfw.i18n->GetWord("settings").c_str(), "Ctrl+,")) {
161- glfw.isSettings = true;
162+ if (ImGui::MenuItem(info.i18n->GetWord("settings").c_str(), "Ctrl+,")) {
163+ info.isSettings = true;
162164 }
163165 ImGui::EndMenu();
164166 }
165167
166- if (ImGui::BeginMenu(glfw.i18n->GetWord("build").c_str())) {
167- if (ImGui::MenuItem(glfw.i18n->GetWord("buildcompile").c_str(), "F5")) {
168- glfw.compile();
168+ if (ImGui::BeginMenu(info.i18n->GetWord("build").c_str())) {
169+ if (ImGui::MenuItem(info.i18n->GetWord("buildcompile").c_str(), "F5")) {
170+ info.compile();
169171 }
170172 ImGui::EndMenu();
171173 }
172174
173- if (ImGui::BeginMenu(glfw.i18n->GetWord("help").c_str())) {
174- if (ImGui::MenuItem(glfw.i18n->GetWord("helpmanual").c_str(), "F1")) {
175- glfw.isManual = true;
175+ if (ImGui::BeginMenu(info.i18n->GetWord("help").c_str())) {
176+ if (ImGui::MenuItem(info.i18n->GetWord("helpmanual").c_str(), "F1")) {
177+ info.isManual = true;
176178 }
177- if (ImGui::MenuItem(glfw.i18n->GetWord("helpabout").c_str(), "CTRL+H")) {
178- glfw.isAbout = true;
179+ if (ImGui::MenuItem(info.i18n->GetWord("helpabout").c_str(), "CTRL+H")) {
180+ info.isAbout = true;
179181 }
180182 ImGui::EndMenu();
181183 }
@@ -183,12 +185,12 @@
183185 ImGui::SameLine();
184186
185187 f32 side;
186- if (glfw.i18n->GetCurrentLanguage().code == "ja_JP") side = 379.f;
188+ if (info.i18n->GetCurrentLanguage().code == "ja_JP") side = 379.f;
187189 else side = 380.f;
188190
189191 ImGui::SetCursorPosX(ImGui::GetWindowWidth() - side);
190192
191- string fmt = glfw.i18n->GetWord("currentfps") + ": %.3f ms/frame (%.1f FPS)";
193+ string fmt = info.i18n->GetWord("currentfps") + ": %.3f ms/frame (%.1f FPS)";
192194 ImGui::Text(fmt.c_str(), 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
193195
194196 ImGui::SameLine();
@@ -114,8 +114,8 @@
114114 );
115115 }
116116
117- void ViewPort::Draw(GlfwInfo &glfw) {
118- string tit = glfw.i18n->GetWord("editorviewport") + "###View";
117+ void ViewPort::Draw(Info &info) {
118+ string tit = info.i18n->GetWord("editorviewport") + "###View";
119119 ImGui::Begin(tit.c_str());
120120
121121 ImVec2 avail = ImGui::GetContentRegionAvail();
@@ -45,10 +45,10 @@
4545 #include <gui/consolelog.hh>
4646
4747 namespace lua {
48- LuaEngine::LuaEngine(const string &code, Program *prog, GlfwInfo *glfwInfo)
48+ LuaEngine::LuaEngine(const string &code, Program *prog, Info *info)
4949 : m_Code(code)
5050 , m_Program(prog)
51- , m_GlfwInfo(glfwInfo)
51+ , m_Info(info)
5252 {
5353 m_Lua = MakeAPI();
5454 Execute(m_Lua);
@@ -105,7 +105,7 @@
105105 gui::LogEntry entry = {};
106106 entry.type = gui::LogType::Error;
107107 entry.text = err.what();
108- m_GlfwInfo->cmd->Add(entry);
108+ m_Info->cmd->Add(entry);
109109 std::cerr << err.what() << std::endl;
110110 }
111111
@@ -113,7 +113,7 @@
113113 gui::LogEntry entry = {};
114114 entry.type = gui::LogType::Error;
115115 entry.text = err.what();
116- m_GlfwInfo->cmd->Add(entry);
116+ m_Info->cmd->Add(entry);
117117 std::cerr << err.what() << std::endl;
118118 }
119119
@@ -402,7 +402,7 @@
402402 gui::LogEntry entry = {};
403403 entry.type = gui::LogType::Normal;
404404 entry.text = out;
405- m_GlfwInfo->cmd->Add(entry); (entry);
405+ m_Info->cmd->Add(entry); (entry);
406406 std::cerr << entry.text << std::endl;
407407 };
408408 }
@@ -411,11 +411,11 @@
411411 lua["le"]["sys"] = lua.create_table();
412412
413413 lua["le"]["sys"]["get_time"] = [&]() -> f32 {
414- return (f32)m_GlfwInfo->instance->GetTime();
414+ return (f32)m_Info->instance->GetTime();
415415 };
416416
417417 lua["le"]["sys"]["get_delta_time"] = [&]() -> f32 {
418- f32 now = (f32)m_GlfwInfo->instance->GetTime();
418+ f32 now = (f32)m_Info->instance->GetTime();
419419 f32 delta = now - m_LastTime;
420420 m_LastTime = now;
421421 if (delta > 1.f / 5) delta = 1.f / 5;
@@ -423,12 +423,12 @@
423423 };
424424
425425 lua["le"]["sys"]["get_timer_frequency"] = [&]() -> u64 {
426- return m_GlfwInfo->instance->GetTimerFrequency();
426+ return m_Info->instance->GetTimerFrequency();
427427 };
428428
429429 lua["le"]["sys"]["get_resolution"] = [&]() -> Vector2i {
430430 Vector2i size = {};
431- m_GlfwInfo->window->GetSize(&size.pos.x, &size.pos.y);
431+ m_Info->window->GetSize(&size.pos.x, &size.pos.y);
432432 return size;
433433 };
434434
@@ -442,12 +442,12 @@
442442
443443 lua["le"]["io"]["get_mouse"] = [&]() -> Vector2d {
444444 Vector2d cursor{};
445- m_GlfwInfo->window->GetCursorPos(&cursor.pos.x, &cursor.pos.y);
445+ m_Info->window->GetCursorPos(&cursor.pos.x, &cursor.pos.y);
446446 return cursor;
447447 };
448448
449449 lua["le"]["io"]["is_key_down"] = [&](int key) -> bool {
450- return m_GlfwInfo->window->GetKey(key) == GLFW_PRESS;
450+ return m_Info->window->GetKey(key) == GLFW_PRESS;
451451 };
452452 }
453453