Elaztek Developer Hub
Blamite Game Engine - blam!  00398.09.22.23.2015.blamite
The core library for the Blamite Game Engine.
opengl_shader_editor.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include "../../debug_ui.h"
4 
6 {
11  {
12  private:
13  /*BlamGLSLShaderProgram* active_program = NULL;
14 
15  void GenerateUniformControl(BlamGLSLShaderUniform* uniform)
16  {
17  switch (uniform->GetType())
18  {
19  case BlamShaderUniformType::U_Float1:
20  {
21  BlamShaderUniform1F* uniform_1f = (BlamShaderUniform1F*)uniform;
22  ImGui::DragFloat(uniform->GetName().c_str(), &uniform_1f->x);
23  break;
24  }
25  default:
26  {
27  ImGui::TextColored(ImVec4(1, 0, 0, 1), std::string("unsupported uniform type, cannot modify uniform '" + uniform->GetName() + "'").c_str());
28  break;
29  }
30  }
31  }
32 
33  void GenerateShaderProgramControl(BlamGLSLShaderProgram* program)
34  {
35  if (ImGui::BeginTabBar("shader_editor_tabs"))
36  {
37  if (ImGui::BeginTabItem("shader information"))
38  {
39  std::string shader_id = "id: " + program->GetID();
40  std::string shader_program_id = "gl program id: " + std::to_string(program->GetGLProgramID());
41 
42  ImGui::Text(shader_id.c_str());
43  ImGui::Text(shader_program_id.c_str());
44 
45  ImGui::EndTabItem();
46  }
47 
48  if (ImGui::BeginTabItem("shader settings"))
49  {
50  if (ImGui::Button("update uniforms"))
51  {
52  program->UpdateUniforms();
53  }
54 
55  ImGui::Separator();
56 
57  if (ImGui::CollapsingHeader("uniforms"))
58  {
59  for (int i = 0; i < program->GetUniforms()->size(); i++)
60  {
61  GenerateUniformControl(program->GetUniforms()->at(i));
62  }
63  }
64 
65  if (ImGui::CollapsingHeader("vertex attributes"))
66  {
67  ImGui::Text("not yet implemented");
68  }
69 
70  ImGui::EndTabItem();
71  }
72 
73  ImGui::EndTabBar();
74  }
75  }*/
76 
77  public:
78  void Draw()
79  {
80  if (show)
81  {
82  if (ImGui::Begin("Shader Editor", &show))
83  {
84  ImGui::Columns(2);
85 
86  ImGui::SetColumnWidth(0, (200.0f * *Blam::Globals::GetGlobalAsFloat("ui_scale_factor")));
87 
89  {
90  /*std::map<std::string, BlamGLSLShaderProgram*>* programs = Blam::Rendering::OpenGL::GetShaderPrograms();
91  std::map<std::string, BlamGLSLShaderProgram*>::iterator it;
92 
93  for (it = programs->begin(); it != programs->end(); it++)
94  {
95  bool is_active_item = false;
96 
97  if (it->second == active_program)
98  {
99  is_active_item = true;
100  }
101 
102  if (ImGui::Selectable(it->second->GetID().c_str(), is_active_item))
103  {
104  active_program = it->second;
105  }
106 
107  if (ImGui::IsItemHovered())
108  {
109  ImGui::BeginTooltip();
110  ImGui::PushTextWrapPos(450.0f);
111  ImGui::Text("shader information");
112  ImGui::Separator();
113 
114  std::string shader_id = "id: " + it->second->GetID();
115  std::string shader_program_id = "gl program id: " + std::to_string(it->second->GetGLProgramID());
116 
117  ImGui::Text(shader_id.c_str());
118  ImGui::Text(shader_program_id.c_str());
119 
120  ImGui::PopTextWrapPos();
121  ImGui::EndTooltip();
122  }
123  }*/
124 
126  }
127 
129 
130  ImGui::Text("opengl shader editor is no longer usable (todo: rework this to work with bgfx shaders)");
131  /*if (!active_program)
132  {
133  ImGui::Text("select a shader to modify");
134  }
135  else
136  {
137  GenerateShaderProgramControl(active_program);
138  }*/
139  }
140  ImGui::End();
141  }
142  }
143  };
144 }
ImGui::ListBoxFooter
IMGUI_API void ListBoxFooter()
Definition: imgui_widgets.cpp:5668
ImGui::NextColumn
IMGUI_API void NextColumn()
Definition: imgui_widgets.cpp:7445
Blam::Globals::GetGlobalAsFloat
BLAM float * GetGlobalAsFloat(std::string name)
Retrieves a global's value as a float.
Definition: globals.cpp:407
ImGui::End
IMGUI_API void End()
Definition: imgui.cpp:6016
ImGui::SetColumnWidth
IMGUI_API void SetColumnWidth(int column_index, float width)
Definition: imgui_widgets.cpp:7297
ImVec2
Definition: imgui.h:179
ImGui::Begin
IMGUI_API bool Begin(const char *name, bool *p_open=NULL, ImGuiWindowFlags flags=0)
Definition: imgui.cpp:5397
Blam::DebugUI::Windows::GLShaderEditor
Class for the OpenGL shader editor.
Definition: opengl_shader_editor.hpp:10
ImGui::GetColumnWidth
IMGUI_API float GetColumnWidth(int column_index=-1)
Definition: imgui_widgets.cpp:7262
ImGui::Text
IMGUI_API void Text(const char *fmt,...) IM_FMTARGS(1)
Definition: imgui_widgets.cpp:238
Blam::DebugUI::ImGUIDrawingGroup::show
bool show
Controls whether or not the group should be shown. May not be used in all groups.
Definition: debug_ui.h:362
Blam::DebugUI::ImGUIDrawingGroup
Class representing an ImGUI drawing group/draw list item.
Definition: debug_ui.h:359
ImGui::Columns
IMGUI_API void Columns(int count=1, const char *id=NULL, bool border=true)
Definition: imgui_widgets.cpp:7572
Blam::DebugUI::Windows
Legacy namespace to contain data for the legacy ImGUI console.
Definition: ui.h:26
ImGui::ListBoxHeader
IMGUI_API bool ListBoxHeader(const char *label, const ImVec2 &size=ImVec2(0, 0))
Definition: imgui_widgets.cpp:5614
Blam::DebugUI::Windows::GLShaderEditor::Draw
void Draw()
Draws the contents of the group.
Definition: opengl_shader_editor.hpp:78