static Renderer *rend;
-static bool show_debug_gui;
-
bool app_init(int argc, char **argv)
{
float dt = (float)(time_msec - prev_msec) / 1000.0f;
prev_msec = time_msec;
- if(show_debug_gui) {
+ if(debug_gui) {
ImGui::GetIOPtr()->DeltaTime = dt;
ImGui::NewFrame();
-
- ImGui::ShowTestWindow();
}
if(opt.vr) {
draw_vrhands();
}
- if(show_debug_gui) {
+ if(debug_gui) {
ImGui::Render();
}
}
glUseProgram(0);
}
- if(show_debug_gui) {
+ if(debug_gui) {
ImGui::Render();
}
app_swap_buffers();
{
unsigned int mod = app_get_modifiers();
- if(show_debug_gui && !(pressed && (key == '`' || key == 27))) {
+ if(debug_gui && !(pressed && (key == '`' || key == 27))) {
debug_gui_key(key, pressed, mod);
return; // ignore all keystrokes when GUI is visible
}
break;
case '`':
- show_debug_gui = !show_debug_gui;
- show_message("debug gui %s", show_debug_gui ? "enabled" : "disabled");
+ debug_gui = !debug_gui;
+ show_message("debug gui %s", debug_gui ? "enabled" : "disabled");
break;
case 'm':
void app_mouse_button(int bn, bool pressed, int x, int y)
{
- if(show_debug_gui) {
+ if(debug_gui) {
debug_gui_mbutton(bn, pressed, x, y);
return; // ignore mouse events while GUI is visible
}
void app_mouse_motion(int x, int y)
{
- if(show_debug_gui) {
+ if(debug_gui) {
debug_gui_mmotion(x, y);
return; // ignore mouse events while GUI is visible
}
void app_mouse_wheel(int dir)
{
- if(show_debug_gui) {
+ if(debug_gui) {
debug_gui_wheel(dir);
}
}
static void render_func(ImDrawData *ddat);
+bool debug_gui, parent_expanded;
+
static ImGuiIO *io;
static Texture *tex;
#include "imgui/imgui.h"
+extern bool debug_gui;
+extern bool parent_expanded;
+
bool init_debug_gui();
void cleanup_debug_gui();
#include "treestore.h"
#include "logger.h"
#include "app.h"
+#include "dbg_gui.h"
#if defined(WIN32) || defined(__WIN32__)
#include <malloc.h>
void MetaScene::update(float dt)
{
+ bool expanded;
+ static char text[256];
+ if(debug_gui) {
+ ImGui::Begin("MetaScene nodes", 0, 0);
+ }
+
int nscn = scenes.size();
for(int i=0; i<nscn; i++) {
+
+ if(debug_gui) {
+ if(scenes[i]->name.empty()) {
+ sprintf(text, "scene %3d", i);
+ } else {
+ sprintf(text, "scene %3d: %s", i, scenes[i]->name.c_str());
+ }
+ expanded = parent_expanded = ImGui::TreeNode(text);
+ }
+
scenes[i]->update(dt);
+
+ if(debug_gui && expanded) {
+ ImGui::TreePop();
+ }
+ }
+
+ if(debug_gui) {
+ ImGui::End();
}
}
#include "scene.h"
#include "objmesh.h"
#include "app.h"
+#include "dbg_gui.h"
static void destroy_node_tree(SceneNode *n);
#include <vector>
#include <list>
+#include <string>
#include "mesh.h"
#include "snode.h"
#include "texture.h"
class Scene {
public:
+ std::string name;
+
MetaScene *metascn;
DataMap datamap;
}
info_log("Loading scene file: %s\n", fname);
+ if(this->name.empty()) {
+ this->name = std::string(fname);
+ }
const aiScene *aiscn = aiImportFile(fname, ppflags);
if(!aiscn) {
#include <algorithm>
#include "snode.h"
#include "objmesh.h"
+#include "dbg_gui.h"
SceneNode::SceneNode()
: scale(1, 1, 1)
void SceneNode::update(float dt)
{
+ bool expanded = false;
+
+ if(debug_gui) {
+ if(parent_expanded) {
+ int flags = children.empty() ? ImGuiTreeNodeFlags_Leaf : 0;
+ expanded = ImGui::TreeNodeEx(name ? name : "<nameless node>", flags);
+ }
+ }
+
update_node(dt);
int num = children.size();
for(int i=0; i<num; i++) {
+ parent_expanded = expanded;
children[i]->update(dt);
}
+
+ if(debug_gui && expanded) {
+ ImGui::TreePop();
+ }
}
void SceneNode::apply_xform()