3#include "../CustomRenderer/ImguiRenderer.h"
5#include "Foundation/Reflection/TypeDatabase.h"
14 extern std::string guiWindowTitle;
15 extern std::vector<size_t> guiIdsStack;
20 explicit ScopedIndent(
float spacing = 0.0f) : spacing(spacing)
22 ImGui::Indent(spacing);
27 ImGui::Unindent(spacing);
34 void guiBegin(
const std::string & title,
bool * show);
36 std::string getUniqueHeader(
const std::string & header);
39 void appendBytesize(std::string& out,
size_t byteSize);
42 bool containsInvariantCase(std::string_view str, std::string_view substr);
54 COGSCORE_DLL_API
void showTexture(
const Context * context,
class Renderer * renderer,
Texture * texture,
bool showTitle =
false);
55 COGSCORE_DLL_API
void showRenderTexture(
const Context * context,
class Renderer * renderer,
const struct RenderTexture * texture,
bool showTitle =
false);
57 COGSCORE_DLL_API
bool showMatrix(
const std::string & header, glm::mat4& m);
61 bool showEnum(
const std::string & header, T& currentItem);
66 bool showArray1D(
const std::string & header, std::span<T> array);
69 bool showArray2D(
const std::string & header, std::span<T> array);
72 bool showArray3D(
const std::string & header, std::span<T> array);
75 bool showArray4D(
const std::string & header, std::span<T> array);
77 COGSCORE_DLL_API
bool showArray3D(
const std::string & header, std::span<glm::vec3> array);
80 COGSCORE_DLL_API
void showMesh(
const Context * context,
Mesh * mesh,
const std::string & header);
83 COGSCORE_DLL_API
void showMaterialOptions(
const Context * context,
MaterialOptions * options,
const std::string & header);
90 COGSCORE_DLL_API
void showMaterialInstance(
const Context * context,
struct MaterialInstance * material,
const std::string & header);
93 COGSCORE_DLL_API
void showModel(
const Context * context,
Model * model,
const std::string & header);
100 auto & type = Cogs::Reflection::TypeDatabase::getType<T>();
101 size_t enums = type.getNumEnumerators();
102 std::vector<const char *> enumNames(enums);
103 std::vector<int> enumValues(enums);
105 int currentIndex = 0;
106 for (
size_t i = 0; i < enums; ++i) {
107 enumNames[i] = type.getEnumerator(i)->getName().c_str();
108 enumValues[i] = type.getEnumerator(i)->getValue();
110 if (enumValues[i] ==
static_cast<int>(currentItem)) {
111 currentIndex =
static_cast<int>(i);
115 if (ImGui::Combo(header.c_str(), ¤tIndex, enumNames.data(),
static_cast<int>(enumNames.size()))) {
116 currentItem =
static_cast<T
>(enumValues[currentIndex]);
126 ImGui::PushID(array.data());
128 bool changed =
false;
131 ImGui::Text(
"%s: Empty", header.c_str());
133 if (ImGui::TreeNode((header +
" [size=" + std::to_string(array.size()) +
"]").c_str())) {
136 for (
size_t i = 0; i < array.size(); i++) {
137 auto label = std::to_string(i);
139 if constexpr (std::is_same_v<T, const uint16_t>) {
140 ImGui::Text(
"%s: %u", label.c_str(), array[i]);
142 else if constexpr (std::is_same_v<T, uint16_t>) {
143 int value =
static_cast<int>(array[i]);
144 if (ImGui::DragInt(label.c_str(), &value)) {
146 array[i] =
static_cast<uint16_t
>(value);
149 else if constexpr (std::is_same_v<T, const int32_t>) {
150 ImGui::Text(
"%s: %d", label.c_str(), array[i]);
152 else if constexpr (std::is_same_v<T, int32_t>) {
153 if (ImGui::DragInt(label.c_str(), &array[i])) {
157 else if constexpr (std::is_same_v<T, const uint32_t>) {
158 ImGui::Text(
"%s: %u", label.c_str(), array[i]);
160 else if constexpr (std::is_same_v<T, uint32_t>) {
161 int value =
static_cast<int>(array[i]);
162 if (ImGui::DragInt(label.c_str(), &value)) {
164 array[i] =
static_cast<uint32_t
>(value);
167 else if constexpr (std::is_same_v<T, const float> || std::is_same_v<T, const double>) {
168 ImGui::Text(
"%s: %f", label.c_str(), array[i]);
170 else if constexpr (std::is_same_v<T, const float> || std::is_same_v<T, const double>) {
171 float value =
static_cast<float>(array[i]);
172 if (ImGui::DragFloat(label.c_str(), &value)) {
177 else if constexpr (
true) {
193bool Cogs::Core::showArray2D(
const std::string & header, std::span<T> array)
195 ImGui::PushID(array.data());
197 bool changed =
false;
200 ImGui::Text(
"%s: Empty", header.c_str());
202 if (ImGui::TreeNode((header +
" [size=" + std::to_string(array.size()) +
"]").c_str())) {
205 for (
size_t i = 0; i < array.size(); i+=2) {
206 auto label = std::to_string(i);
208 if constexpr (std::is_same_v<T, float>) {
209 if (ImGui::DragFloat2(label.c_str(), &array[i])) {
212 }
else if constexpr (std::is_same_v<T, int>) {
213 if (ImGui::DragInt2(label.c_str(), &array[i])) {
217 else if constexpr (
true) {
233bool Cogs::Core::showArray3D(
const std::string & header, std::span<T> array)
235 ImGui::PushID(array.data());
237 bool changed =
false;
240 ImGui::Text(
"%s: Empty", header.c_str());
242 if (ImGui::TreeNode((header +
" [size=" + std::to_string(array.size()) +
"]").c_str())) {
245 for (
size_t i = 0; i < array.size(); i+=3) {
246 auto label = std::to_string(i);
248 if constexpr (std::is_same_v<T, float>) {
249 if (ImGui::DragFloat3(label.c_str(), &array[i])) {
252 }
else if constexpr (std::is_same_v<T, int>) {
253 if (ImGui::DragInt3(label.c_str(), &array[i])) {
257 else if constexpr (
true) {
273bool Cogs::Core::showArray4D(
const std::string & header, std::span<T> array)
275 ImGui::PushID(array.data());
277 bool changed =
false;
280 ImGui::Text(
"%s: Empty", header.c_str());
282 if (ImGui::TreeNode((header +
" [size=" + std::to_string(array.size()) +
"]").c_str())) {
285 for (
size_t i = 0; i < array.size(); i+=4) {
286 auto label = std::to_string(i);
288 if constexpr (std::is_same_v<T, float>) {
289 if (ImGui::DragFloat4(label.c_str(), &array[i])) {
292 }
else if constexpr (std::is_same_v<T, int>) {
293 if (ImGui::DragInt4(label.c_str(), &array[i])) {
297 else if constexpr (
true) {
Container for components, providing composition of dynamic entities.
A Context instance contains all the services, systems and runtime components needed to use Cogs.
bool findHierarchyWithMatch(const Cogs::ComponentModel::Entity &entity, std::string_view entityNamePattern, std::string_view componentNamePattern)
bool showEnum(const std::string &header, T ¤tItem)
Show enumerator with edit option.
bool showArray1D(const std::string &header, std::span< T > array)
Contains all Cogs related functionality.
Material instances represent a specialized Material combined with state for all its buffers and prope...
Defines options for rendering using a material instance.
Meshes contain streams of vertex data in addition to index data and options defining geometry used fo...
Model resources define a template for a set of connected entities, with resources such as meshes,...
Texture resources contain raster bitmap data to use for texturing.