294{
295 ImGui::Begin("Shading##ShadingManager", pOpen);
296
297 if(ImGui::Button("Compile Shaders"))
298 {
299 ReCompileShaders();
300 }
301
302 ImGui::SameLine();
303
304 if(ImGui::Button("Export GLSL"))
305 {
306 std::string path = ShowSaveFileDialog("*.glsl\0");
307
308 if(path.size() > 3)
309 {
310 SaveToFile(path, fragmentSource);
311 }
312 }
313
314 if(ImGui::Button("Print GLSL"))
315 {
316 std::cout << fragmentSource << std::endl;
317 }
318
319 ImGui::SameLine();
320
321 ImGui::SameLine();
322
323 if(ImGui::Checkbox("Optimize GLSL", &optimizeGLSL))
324 {
325 ReCompileShaders();
326 }
327
328
329
330
331 if(ImGui::CollapsingHeader("Logs"))
332 {
333 if(logs.size() > 0)
334 {
335 ImGui::Text("Logs:");
336
337 for(std::string &s : logs)
338 {
339 ImGui::Text(s.data());
340 }
341 }
342 }
343
344 if(ImGui::CollapsingHeader("Shader Nodes"))
345 {
346 if (ImGui::Button("Add Node##ShaderNodeMaker"))
347 {
348 ImGui::OpenPopup("NodeMakerDropped");
349 }
350
351 ImGui::SameLine();
352
353 if (ImGui::Button("Reset##ShaderNodeMaker"))
354 {
355 shaderNodeEditor->Reset();
356 ReCompileShaders();
357 }
358
359 ImGui::SameLine();
360
361 if (ImGui::Button("Export##ShaderNodeMaker"))
362 {
363 std::string file = ShowSaveFileDialog("*.terr3d");
364
365 if (file.size() > 3)
366 {
367 if (file.find(".terr3d") == std::string::npos)
368 {
369 file += ".terr3d";
370 }
371
372 SaveToFile(file, shaderNodeEditor->Save().
dump(4));
373 }
374 }
375
376 ImGui::SameLine();
377
378 if (ImGui::Button("Import##CPUNE"))
379 {
380 std::string file = ShowOpenFileDialog("*.terr3d");
381
382 if (file.size() > 3)
383 {
384 bool tmp = false;
385 shaderNodeEditor->Reset();
387 ReCompileShaders();
388 }
389 }
390
391 ImGui::SameLine();
392
393 if(ImGui::Button("Reload Nodes"))
394 {
395 LoadDefaultCustomNodes();
396 }
397
398 int nC = shaderNodeEditor->nodes.size();
399 int lC = shaderNodeEditor->links.size();
400 int pC = shaderNodeEditor->pins.size();
401 shaderNodeEditor->Render();
402
403 if ((nC != shaderNodeEditor->nodes.size()) || (lC != shaderNodeEditor->links.size()) || (pC != shaderNodeEditor->pins.size()))
404 {
405 ReCompileShaders();
406 }
407 }
408
409 if (ImGui::IsWindowFocused() && (((IsKeyDown(TERR3D_KEY_RIGHT_SHIFT) || IsKeyDown(TERR3D_KEY_LEFT_SHIFT)) && IsKeyDown(TERR3D_KEY_A)) || IsMouseButtonDown(TERR3D_MOUSE_BUTTON_MIDDLE)))
410 {
411 ImGui::OpenPopup("NodeMakerDropped");
412 }
413
414 if(ImGui::BeginPopup("NodeMakerDropped"))
415 {
416 if(ShowNodeMaker(shaderNodeEditor, fsh, shaderTextureManager, defaultCustomNodes))
417 {
418 ReCompileShaders();
419 }
420
421 if (ImGui::Button("Close##ShaderNodeMaker"))
422 {
423 ImGui::CloseCurrentPopup();
424 }
425
426 ImGui::EndPopup();
427 }
428
429 ImGui::End();
430}
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json parse(InputType &&i, const parser_callback_t cb=nullptr, const bool allow_exceptions=true, const bool ignore_comments=false)
deserialize from a compatible input
string_t dump(const int indent=-1, const char indent_char=' ', const bool ensure_ascii=false, const error_handler_t error_handler=error_handler_t::strict) const
serialization