Example #1
0
bool PiGui::CircularSlider(const ImVec2 &center, float *v, float v_min, float v_max) {
	ImDrawList* draw_list = ImGui::GetWindowDrawList();
	ImGuiWindow* window = ImGui::GetCurrentWindow();
	const ImGuiID id = window->GetID("circularslider");
	draw_list->AddCircle(center, 17, ImColor(100, 100, 100), 128, 12.0);
	draw_list->PathArcTo(center, 17, 0, M_PI * 2.0 * (*v - v_min) / (v_max - v_min), 64);
	draw_list->PathStroke(ImColor(200,200,200), false, 12.0);
	return ImGui::SliderBehavior(ImRect(center.x - 17, center.y - 17, center.x + 17, center.y + 17), id, v, v_min, v_max, 1.0, 4);
}
Example #2
0
void renderComponent(EntityComponent *component) {
  ImGui::PushID(component);
  ImGui::AlignFirstTextHeightToWidgets();

  ImGui::PushStyleColor(ImGuiCol_Text, ImColor(1.0f,0.78f,0.58f,1.0f));
  bool node_open = ImGui::TreeNodeEx("Component", ImGuiTreeNodeFlags_DefaultOpen, "%s_%u", "component", component);
  ImGui::NextColumn();
  ImGui::AlignFirstTextHeightToWidgets();
  ImGui::Text(component->getType());
  ImGui::PopStyleColor();
  ImGui::NextColumn();

  int id = 0;

  if (node_open) {
    for (auto& property : component->m_properties) {
      ImGui::PushID(id++);

      ImGui::AlignFirstTextHeightToWidgets();
      ImGui::Bullet();
      ImGui::PushStyleColor(ImGuiCol_Text, ImColor(0.78f,0.58f,1.0f,1.0f));
      ImGui::Selectable(property.first);
      ImGui::NextColumn();
      ImGui::PushItemWidth(-1);

      switch (property.second.type) {
        case FLOAT:
        ImGui::SliderFloat("##value", (float *)property.second.p, property.second.min, property.second.max);
        break;
        case FLOAT3:
        ImGui::SliderFloat3("##value", (float *)property.second.p, property.second.min, property.second.max);
        break;
        case BOOLEAN:
        ImGui::Checkbox("##value", (bool *)property.second.p);
        break;
        case COLOR:
        ImGui::ColorEdit3("##value", (float *)property.second.p);
        break;
        case ANGLE:
        ImGui::SliderAngle("##value", (float *)property.second.p, property.second.min, property.second.max);
        break;
      }
      ImGui::PopStyleColor();

      ImGui::PopItemWidth();
      ImGui::NextColumn();

      ImGui::PopID();
    }
    ImGui::TreePop();
  }
  ImGui::PopID();
}
Example #3
0
void RoR::DrawImGuiSpinner(float& counter, const ImVec2 size, const float spacing, const float step_sec)
{
    // Hardcoded to 4 segments, counter is reset after full round (4 steps)
    // --------------------------------------------------------------------

    const ImU32 COLORS[] = { ImColor(255,255,255,255), ImColor(210,210,210,255), ImColor(120,120,120,255), ImColor(60,60,60,255) };

    // Update counter, determine coloring
    counter += ImGui::GetIO().DeltaTime;
    int color_start = 0; // Index to GUI_SPINNER_COLORS array for the top middle segment (segment 0)
    while (counter > (step_sec*4.f))
    {
        counter -= (step_sec*4.f);
    }

    if (counter > (step_sec*3.f))
    {
        color_start = 3;
    }
    else if (counter > (step_sec*2.f))
    {
        color_start = 2;
    }
    else if (counter > (step_sec))
    {
        color_start = 1;
    }

    // Draw segments
    ImDrawList* draw_list = ImGui::GetWindowDrawList();
    const ImVec2 pos = ImGui::GetCursorScreenPos();
    const float left = pos.x;
    const float top = pos.y;
    const float right = pos.x + size.x;
    const float bottom = pos.y + size.y;
    const float mid_x = pos.x + (size.x / 2.f);
    const float mid_y = pos.y + (size.y / 2.f);

    // NOTE: Enter vertices in clockwise order, otherwise anti-aliasing doesn't work and polygon is rasterized larger! -- Observed under OpenGL2 / OGRE 1.9

    // Top triangle, vertices: mid, left, right
    draw_list->AddTriangleFilled(ImVec2(mid_x, mid_y-spacing),   ImVec2(left + spacing, top),     ImVec2(right - spacing, top),     COLORS[color_start]);
    // Right triangle, vertices: mid, top, bottom
    draw_list->AddTriangleFilled(ImVec2(mid_x+spacing, mid_y),   ImVec2(right, top + spacing),    ImVec2(right, bottom - spacing),  COLORS[(color_start+3)%4]);
    // Bottom triangle, vertices: mid, right, left
    draw_list->AddTriangleFilled(ImVec2(mid_x, mid_y+spacing),   ImVec2(right - spacing, bottom), ImVec2(left + spacing, bottom),   COLORS[(color_start+2)%4]);
    // Left triangle, vertices: mid, bottom, top
    draw_list->AddTriangleFilled(ImVec2(mid_x-spacing, mid_y),   ImVec2(left, bottom - spacing),  ImVec2(left, top + spacing),      COLORS[(color_start+1)%4]);
}
Example #4
0
// ----------------------------------------------
void CTexture::renderUIDebug() {
	ImVec2 tex_screen_pos = ImGui::GetCursorScreenPos();
	float tex_w = IMAGE_W_DEBUG;
	float tex_h = IMAGE_H_DEBUG;
	static int zoom_w = 127;
	static int zoom_h = 127;
	ImTextureID tex_id = (ImTextureID*)res_view;
	ImGui::Image(tex_id, ImVec2(IMAGE_W_DEBUG, IMAGE_H_DEBUG));

	if (ImGui::IsItemHovered())
	{
		ImGui::BeginTooltip();
		float focus_sz = 32.0f;
		float focus_x = ImGui::GetMousePos().x - tex_screen_pos.x - focus_sz * 0.5f; if (focus_x < 0.0f) focus_x = 0.0f; else if (focus_x > tex_w - focus_sz) focus_x = tex_w - focus_sz;
		float focus_y = ImGui::GetMousePos().y - tex_screen_pos.y - focus_sz * 0.5f; if (focus_y < 0.0f) focus_y = 0.0f; else if (focus_y > tex_h - focus_sz) focus_y = tex_h - focus_sz;
		ImGui::Text("Min: (%.2f, %.2f)", focus_x, focus_y);
		ImGui::Text("Max: (%.2f, %.2f)", focus_x + focus_sz, focus_y + focus_sz);
		ImVec2 uv0 = ImVec2((focus_x) / tex_w, (focus_y) / tex_h);
		ImVec2 uv1 = ImVec2((focus_x + focus_sz) / tex_w, (focus_y + focus_sz) / tex_h);
		ImGui::Image(tex_id, ImVec2(zoom_w, zoom_h), uv0, uv1, ImColor(255, 255, 255, 255), ImColor(255, 255, 255, 128));
		ImGui::EndTooltip();
	}

	ImGui::DragInt("zoom with", &zoom_w);
	ImGui::DragInt("zoom height", &zoom_h);
	//renderTexture();

	if (ImGui::Button("new texture path")) {
		std::string newTexture = CImGuiModule::getFilePath();
		if (newTexture.size() > 2) { //not empty
			setName(newTexture.c_str());
			loadFullPath(getName().c_str());
		}
	}
}
Example #5
0
void Pyx::Graphics::Gui::ImGuiImpl::BuildLogsWindow()
{
    static bool logVisible = true;
    if (GImGui)
    {
        ImGuiState& g = *GImGui;
        ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(4, 1));
        ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
        ImGui::PushStyleVar(ImGuiStyleVar_Alpha, 0.95f);
        if (ImGui::Begin(XorStringA("##pyx_console_logs"), &logVisible, ImVec2(ImGui::GetIO().DisplaySize.x, 155), -1, ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_ShowBorders | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoSavedSettings))
        {
            ImGui::SetWindowPos(ImVec2(0, g.FontBaseSize + g.Style.FramePadding.y * 2.0f));
            ImGui::SetWindowSize(ImVec2(ImGui::GetIO().DisplaySize.x, ImGui::GetWindowHeight()));

            for (std::string& item : m_logsItems)
            {
                ImVec4 col = ImColor(255, 255, 255);
                ImGui::PushStyleColor(ImGuiCol_Text, col);
                ImGui::TextUnformatted(item.c_str());
                ImGui::PopStyleColor();
            }

            if (m_logScrollToEnd) ImGui::SetScrollHere();
            m_logScrollToEnd = false;


        }
        ImGui::End();
		ImGui::PopStyleVar(3);
    }
}
Example #6
0
		void draw() override {
			ImVec4 clear_color = ImColor(114, 144, 154);
			static float f = 0.0f;
			// ImGui::PushStyleVar(ImGuiStyleVar_Alpha, 0.5);
			// ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0.8, 0, 0, 0.5));
			ImGui::Begin("Test Window");
			ImGui::SetWindowSize(ImVec2(200, 400), ImGuiSetCond_Always);

			int count;
			const float* axes = glfwGetJoystickAxes(GLFW_JOYSTICK_1, &count);

			ImGui::Text(glfwGetJoystickName(GLFW_JOYSTICK_1));

			for(int i = 0; i < count; i++) {
				joyAx[i] = axes[i];
				char joyname[30];
				sprintf(joyname, "Axis %d", i);
            	ImGui::SliderFloat(joyname, &joyAx[i], -1.0f, 1.0f);
			}

            ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);

            ImGui::End();
            // ImGui::PopStyleColor();
		};
Example #7
0
void RenderScene()
{
	static bool show_overlay = false;
	static bool show_test_window = true;
	static bool show_another_window = false;
	static ImVec4 clear_col = ImColor(114, 144, 154);

	// 1. Show a simple window
	// Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets appears in a window automatically called "Debug"
	{
		static float f = 0.0f;
		ImGui::Text("Hello, world!");
		ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
		ImGui::ColorEdit3("clear color", (float*)&clear_col);
		if (ImGui::Button("Test Window")) show_test_window ^= 1;
		if (ImGui::Button("Another Window")) show_another_window ^= 1;
		ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
	}

	// 2. Show another simple window, this time using an explicit Begin/End pair
	if (show_another_window)
	{
		ImGui::SetNextWindowSize(ImVec2(200, 100), ImGuiSetCond_FirstUseEver);
		ImGui::Begin("Another Window", &show_another_window);
		ImGui::Text("Hello");
		ImGui::End();
	}

	// 3. Show the ImGui test window. Most of the sample code is in ImGui::ShowTestWindow()
	if (show_test_window)
	{
		ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiSetCond_FirstUseEver);
		ImGui::ShowTestWindow(&show_test_window);
	}

	static auto pressedPast = false, pressedNow = false;
	if (GetAsyncKeyState(VK_F11) & 0x8000)
	{
		pressedNow = true;
	}
	else
	{
		pressedPast = false;
		pressedNow = false;
	}

	if (!pressedPast && pressedNow)
	{
		show_overlay = !show_overlay;

		pressedPast = true;
	}

	if (show_overlay)
	{
		ImGui::Render();
	}
}
void GraphTimer::draw() {

    ImGui::Begin("Performance");

    std::string title = std::to_string(fps_vectors.at(0).at(counters.at(0)));

    std::vector<ImColor> colors = {
            ImColor(255, 255, 255),
            ImColor(255, 255,   0),
            ImColor(  0, 255, 255),
            ImColor(255,   0, 255),
            ImColor(255,   0,   0),
            ImColor(  0, 255,   0),
            ImColor(  0,   0, 255),
    };

    ImVec2 wh = ImGui::GetContentRegionAvail();
    wh.x -= wh.x * 0.15;
    sf::Vector2f graph_size(wh.x, wh.y);

    ImGui::PlotMultiLines(fps_vectors, title, labels, colors, 200, 0,
                          graph_size);

    ImGui::End();

}
Example #9
0
void DebugDraw::DrawString(int x, int y, const char *string, ...)
{
	va_list arg;
	va_start(arg, string);
	ImGui::Begin("Overlay", NULL, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoScrollbar);
	ImGui::SetCursorPos(b2Vec2(float(x), float(y)));
	ImGui::TextColoredV(ImColor(230, 153, 153, 255), string, arg);
	ImGui::End();
	va_end(arg);
}
Example #10
0
void DebugDraw::DrawString(const b2Vec2& pw, const char *string, ...)
{
	b2Vec2 ps = g_camera.ConvertWorldToScreen(pw);

	va_list arg;
	va_start(arg, string);
	ImGui::Begin("Overlay", NULL, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoScrollbar);
	ImGui::SetCursorPos(ps);
	ImGui::TextColoredV(ImColor(230, 153, 153, 255), string, arg);
	ImGui::End();
	va_end(arg);
}
Example #11
0
int main(int, char**)
{
    // Setup window
    glfwSetErrorCallback(error_callback);
    if (!glfwInit())
        exit(1);

    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);

    GLFWwindow* window = glfwCreateWindow(1280, 720, "Empty imgui program", NULL, NULL);
    glfwMakeContextCurrent(window);
    
    gl3wInit();

    // Setup ImGui binding
    ImGui_ImplGlfwGL3_Init(window, true);

    ImVec4 clear_color = ImColor(114, 144, 154);
    
    // Main loop
    while (!glfwWindowShouldClose(window))
    {
        
        ImGuiIO& io = ImGui::GetIO();
       
        glfwPollEvents();
       
        ImGui_ImplGlfwGL3_NewFrame();

        make_gui();

        // Rendering
        glViewport(0, 0, (int)io.DisplaySize.x, (int)io.DisplaySize.y);
        
        glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        ImGui::Render();
        
        glfwSwapBuffers(window);
        
    }

    // Cleanup
    ImGui_ImplGlfwGL3_Shutdown();
    glfwTerminate();

    return 0;
}
Example #12
0
MainWindow::MainWindow() {
    // Setup window
    glfwSetErrorCallback(on_error);
    if (!glfwInit())
        exit(1);

    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);

    GLFWwindow* window = glfwCreateWindow(1280, 720, "xds", NULL, NULL);

	if (window)
	{

		glfwMakeContextCurrent(window);
		gl3wInit();

		ImGui_ImplGlfwGL3_Init(window, true);


		while (!glfwWindowShouldClose(window))
		{
			ImGuiIO& io = ImGui::GetIO();
			glfwPollEvents();
			ImGui_ImplGlfwGL3_NewFrame();

			ImGui::SetNextWindowSize(ImVec2(400, 100), ImGuiSetCond_FirstUseEver);
			ImGui::Begin("Test Window");
			ImGui::Text("TODO: Move this to new thread so xds can run in the background.");
			ImGui::Text("Close the window to continue xds execution.");
			ImGui::End();

			// Rendering
			glViewport(0, 0, (int)io.DisplaySize.x, (int)io.DisplaySize.y);
			ImVec4 clear_color = ImColor(114, 144, 154);
			glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
			glClear(GL_COLOR_BUFFER_BIT);
			ImGui::Render();

			glfwSwapBuffers(window);
		}

		// Cleanup
		ImGui_ImplGlfwGL3_Shutdown();
		glfwTerminate();

	}
}
Example #13
0
void render_slider(rect location, float& clipping_dist)
{
    // Some trickery to display the control nicely
    static const int flags = ImGuiWindowFlags_NoCollapse
        | ImGuiWindowFlags_NoScrollbar
        | ImGuiWindowFlags_NoSavedSettings
        | ImGuiWindowFlags_NoTitleBar
        | ImGuiWindowFlags_NoResize
        | ImGuiWindowFlags_NoMove;
    const int pixels_to_buttom_of_stream_text = 25;
    const float slider_window_width = 30;

    ImGui::SetNextWindowPos({ location.x, location.y + pixels_to_buttom_of_stream_text });
    ImGui::SetNextWindowSize({ slider_window_width + 20, location.h - (pixels_to_buttom_of_stream_text * 2) });

    //Render the vertical slider
    ImGui::Begin("slider", nullptr, flags);
    ImGui::PushStyleColor(ImGuiCol_FrameBg, ImColor(215.f / 255, 215.0f / 255, 215.0f / 255));
    ImGui::PushStyleColor(ImGuiCol_SliderGrab, ImColor(215.f / 255, 215.0f / 255, 215.0f / 255));
    ImGui::PushStyleColor(ImGuiCol_SliderGrabActive, ImColor(215.f / 255, 215.0f / 255, 215.0f / 255));
    auto slider_size = ImVec2(slider_window_width / 2, location.h - (pixels_to_buttom_of_stream_text * 2) - 20);
    ImGui::VSliderFloat("", slider_size, &clipping_dist, 0.0f, 6.0f, "", 1.0f, true);
    if (ImGui::IsItemHovered())
        ImGui::SetTooltip("Depth Clipping Distance: %.3f", clipping_dist);
    ImGui::PopStyleColor(3);

    //Display bars next to slider
    float bars_dist = (slider_size.y / 6.0f);
    for (int i = 0; i <= 6; i++)
    {
        ImGui::SetCursorPos({ slider_size.x, i * bars_dist });
        std::string bar_text = "- " + std::to_string(6-i) + "m";
        ImGui::Text("%s", bar_text.c_str());
    }
    ImGui::End();
}
void MeshDecimationApp::handleGUI()
{
    static bool open = true;
    ImGui::SetNextWindowSize(ImVec2(250.0f, 600.0f));
    ImGui::SetNextWindowPos(ImVec2(0.f, 0.f));
    ImGui::PushStyleColor(ImGuiCol_WindowBg, ImColor(0.f, 0.f, 0.f, 0.f));
    ImGui::Begin("Test", &open, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoCollapse);
    
    guiVertexCountSlider();
    guiMeshSelection();
    guiShadingSelection();
    guiShowStats();

    ImGui::End();
    ImGui::PopStyleColor(1);
}
Example #15
0
//--------------------------------------------------------------
void ofApp::setup()
{
    ofSetLogLevel(OF_LOG_VERBOSE);
    
    //required call
    gui.setup();
    
    
    ImGui::GetIO().MouseDrawCursor = true;
    clear_color = ImColor(114, 144, 154);
    show_test_window = true;
    show_another_window = false;
    floatValue = 0.0f;
    


}
Example #16
0
static void renderStatusBar(const char* text, float statusSize) {
    const ImGuiIO& io = ImGui::GetIO();
    ImVec2 size = io.DisplaySize;
    float yPos = size.y - statusSize;

    ImGui::SetNextWindowPos(ImVec2(0.0f, yPos));
    ImGui::SetNextWindowSize(ImVec2(size.x, statusSize));

    bool show = true;

    ImGui::PushStyleColor(ImGuiCol_WindowBg, ImColor(40, 40, 40));

    ImGui::Begin("", &show, ImVec2(0, 0), true, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove);
    ImGui::SetCursorPos(ImVec2(2.0f, 4.0f));
    ImGui::Text("Status: %s", text);
    ImGui::End();

    ImGui::PopStyleColor();
}
Example #17
0
int main(int argc, char** argv) {
  glfwSetErrorCallback(glfwError);

  if (!glfwInit()) return 1;

  glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
  glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
  glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);

  GLFWmonitor* monitor = glfwGetPrimaryMonitor();
  const GLFWvidmode* mode = glfwGetVideoMode(monitor);

  GLFWwindow* window =
      glfwCreateWindow(mode->width, mode->height, "HumanDetection", NULL, NULL);
  glfwMakeContextCurrent(window);
  glewExperimental = GL_TRUE;
  glewInit();

  fhd_context detector;
  fhd_context_init(&detector, 512, 424, 8, 8);

  ImGui_ImplGlfwGL3_Init(window, true);
  ImGui::GetStyle().WindowRounding = 0.f;
  bool show_window = true;

  fhd_ui ui(&detector);

  if (argc > 1) {
    const char* train_database = argv[1];
    ui.train_mode = true;
    fhd_candidate_db_init(&ui.candidate_db, train_database);
  }

  ImVec4 clear_color = ImColor(218, 223, 225);
  while (!glfwWindowShouldClose(window)) {
    glfwPollEvents();

    if (ImGui::IsKeyPressed(GLFW_KEY_ESCAPE)) break;

    if (ui.train_mode) {
      if (ImGui::IsKeyPressed(GLFW_KEY_X)) {
        fhd_ui_clear_candidate_selection(&ui);
        ui.depth_frame = ui.frame_source->get_frame();
      }

      if (ImGui::IsKeyPressed(GLFW_KEY_SPACE)) {
        fhd_ui_commit_candidates(&ui);
      }
    } else {
      if (ui.update_enabled) {
        ui.depth_frame = ui.frame_source->get_frame();
      }
    }

    if (ui.depth_frame) {
      auto t1 = std::chrono::high_resolution_clock::now();
      fhd_run_pass(&detector, ui.depth_frame);
      auto t2 = std::chrono::high_resolution_clock::now();
      auto duration =
          std::chrono::duration_cast<std::chrono::microseconds>(t2 - t1);
      ui.detection_pass_time_ms = double(duration.count()) / 1000.0;
      fhd_ui_update(&ui, ui.depth_frame);
    }

    ImGui_ImplGlfwGL3_NewFrame();
    int display_w, display_h;
    glfwGetFramebufferSize(window, &display_w, &display_h);

    ImGui::SetNextWindowPos(ImVec2(0, 0));

    ImGuiWindowFlags flags = ImGuiWindowFlags_NoMove |
                             ImGuiWindowFlags_NoResize |
                             ImGuiWindowFlags_NoTitleBar;

    ImGui::Begin("foo", &show_window,
                 ImVec2(float(display_w), float(display_h)), -1.f, flags);

    ImGui::BeginChild("toolbar", ImVec2(300.f, float(display_h)));
    render_db_selection(&ui);
    render_classifier_selection(&ui);

    if (ui.train_mode) {
      ImGui::Text("*** TRAINING DB: %s ***", argv[1]);
    }

    ImGui::Text("detection pass time %.3f ms", ui.detection_pass_time_ms);
    ImGui::Text("frame source: %s", ui.database_name.c_str());
    ImGui::Text("frame %d/%d", ui.frame_source->current_frame(),
                ui.frame_source->total_frames());
    ImGui::Text("classifier: %s", ui.classifier_name.c_str());
    ImGui::Checkbox("update enabled", &ui.update_enabled);
    ImGui::SliderFloat("##det_thresh", &ui.detection_threshold, 0.f, 1.f,
                       "detection threshold %.3f");
    ImGui::InputFloat("seg k depth", &ui.fhd->depth_segmentation_threshold);
    ImGui::InputFloat("seg k normals", &ui.fhd->normal_segmentation_threshold);
    ImGui::SliderFloat("##min_reg_dim", &ui.fhd->min_region_size, 8.f, 100.f,
                       "min region dimension %.1f");
    ImGui::SliderFloat("##merge_dist_x", &ui.fhd->max_merge_distance, 0.1f, 2.f,
                       "max h merge dist (m) %.2f");
    ImGui::SliderFloat("##merge_dist_y", &ui.fhd->max_vertical_merge_distance,
                       0.1f, 3.f, "max v merge dist (m) %.2f");
    ImGui::SliderFloat("##min_inlier", &ui.fhd->min_inlier_fraction, 0.5f, 1.f,
                       "RANSAC min inlier ratio %.2f");
    ImGui::SliderFloat("##max_plane_dist", &ui.fhd->ransac_max_plane_distance,
                       0.01f, 1.f, "RANSAC max plane dist %.2f");
    ImGui::SliderFloat("##reg_height_min", &ui.fhd->min_region_height, 0.1f,
                       3.f, "min region height (m) %.2f");
    ImGui::SliderFloat("##reg_height_max", &ui.fhd->max_region_height, 0.1f,
                       3.f, "max region height (m) %.2f");
    ImGui::SliderFloat("##reg_width_min", &ui.fhd->min_region_width, 0.1f, 1.f,
                       "min region width (m) %.2f");
    ImGui::SliderFloat("##reg_width_max", &ui.fhd->max_region_height, 0.1f,
                       1.5f, "max region width (m) %.2f");
    ImGui::SliderInt("##min_depth_seg_size", &ui.fhd->min_depth_segment_size, 4,
                     200, "min depth seg size");
    ImGui::SliderInt("##min_normal_seg_size", &ui.fhd->min_normal_segment_size,
                     4, 200, "min normal seg size");
    ImGui::EndChild();

    ImGui::SameLine();

    ImGui::BeginGroup();

    ImDrawList* draw_list = ImGui::GetWindowDrawList();

    ImVec2 p = ImGui::GetCursorScreenPos();
    ImGui::Image((void*)intptr_t(ui.depth_texture.handle), ImVec2(512, 424));


    ImU32 rect_color = ImColor(240, 240, 20);
    for (int i = 0; i < detector.candidates_len; i++) {
      const fhd_candidate* candidate = &detector.candidates[i];
      if (candidate->weight >= 1.f) {
        const fhd_image_region region = candidate->depth_position;

        const float x = p.x + float(region.x);
        const float y = p.y + float(region.y);
        const float w = float(region.width);
        const float h = float(region.height);
        ImVec2 points[4] = {
          ImVec2(x, y),
          ImVec2(x + w, y),
          ImVec2(x + w, y + h),
          ImVec2(x, y + h)
        };
        draw_list->AddPolyline(points, 4, rect_color, true, 4.f, true);
      }
    }

    ImGui::BeginGroup();
    ImGui::Image((void*)intptr_t(ui.normals_texture.handle), ImVec2(256, 212));
    ImGui::SameLine();
    ImGui::Image((void*)intptr_t(ui.normals_seg_texture.handle),
                 ImVec2(256, 212));
    ImGui::EndGroup();

    ImGui::BeginGroup();
    ImGui::Image((void*)intptr_t(ui.downscaled_depth.handle), ImVec2(256, 212));
    ImGui::SameLine();
    ImGui::Image((void*)intptr_t(ui.depth_segmentation.handle),
                 ImVec2(256, 212));
    ImGui::EndGroup();

    ImGui::Image((void*)intptr_t(ui.filtered_regions.handle), ImVec2(256, 212));

    ImGui::EndGroup();

    ImGui::SameLine();

    ImGui::BeginGroup();

    if (ui.train_mode) {
      fhd_candidate_selection_grid(&ui, FHD_HOG_WIDTH * 2, FHD_HOG_HEIGHT * 2);
    } else {
      for (int i = 0; i < detector.candidates_len; i++) {
        fhd_texture* t = &ui.textures[i];
        ImGui::Image((void*)intptr_t(t->handle),
                     ImVec2(t->width * 2, t->height * 2));
        if (i % 7 < 6) ImGui::SameLine();
      }
    }

    ImGui::EndGroup();
    ImGui::End();

    glViewport(0, 0, display_w, display_h);
    glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
    glClear(GL_COLOR_BUFFER_BIT);

    ImGui::Render();
    glfwSwapBuffers(window);
  }

  if (ui.train_mode) {
    fhd_candidate_db_close(&ui.candidate_db);
  }

  fhd_texture_destroy(&ui.depth_texture);
  fhd_classifier_destroy(detector.classifier);
  ImGui_ImplGlfwGL3_Shutdown();
  glfwTerminate();

  return 0;
}
Example #18
0
	void TasksWidget::DrawUI ()
	{
		UpdateTasks();

		ImGui::SetNextWindowPos(ImVec2(0, 0), ImGuiSetCond_Always);

		ImVec2 const & display = ImGui::GetIO().DisplaySize;
		ImGui::SetNextWindowSize(display, ImGuiSetCond_Always);

		char name[256];
		codecvt_utf16_utf8(GetNameW(), name, 256);
		ImGui::Begin(name, &m_config.m_show, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize);

		Tasks & tasks = BlackBox::Instance().GetTasks();
//      std::string name2;
//				if (tasks.m_active)
//				{
//					codecvt_utf16_utf8(tasks.m_active->m_caption, name2); // @TODO: perf!
//					ImGui::Button(name2.c_str());
//				}
    ImGui::Separator();
    for (TaskInfo & t : m_tasks)
    {
      if (t.m_config && t.m_config->m_bbtasks == false)
        continue;

      char name[TaskInfo::e_captionLenMax];
      codecvt_utf16_utf8(t.m_caption, name, TaskInfo::e_captionLenMax);
      IconId const icoid = t.m_icoSmall;
      ImGui::Icon(icoid, ImColor(255, 255, 255, 255), ImColor(255, 255, 255, 128));
      if (!icoid.IsValid())
      {
        // @TODO: assign color to hwnd?
        ImGui::ColorButton(ImColor(0, 0, 128, 255));
      }
      ImGui::SameLine();

			ImGui::PushID(t.m_hwnd);
			// stick/unstick etc...
			ImGui::PopID();

      ImGui::SameLine();

      if (ImGui::Button(name))
      {
        tasks.Focus(t.m_hwnd);
      }
    }
    //ImGui::TreePop();

		ImGui::Separator();
// 		for (TaskInfo & t : m_ignored)
// 		{
// 			if (t.m_exclude)
// 				continue;
// 
// 			char name[TaskInfo::e_captionLenMax];
// 			codecvt_utf16_utf8(t.m_caption, name, TaskInfo::e_captionLenMax);
// 			IconId const icoid = t.m_icoSmall;
// 			ImGui::Icon(icoid, ImColor(255, 255, 255, 255), ImColor(255, 255, 255, 128));
// 			if (!icoid.IsValid())
// 			{
// 				// @TODO: assign color to hwnd?
// 				ImGui::ColorButton(ImColor(0, 0, 128, 255));
// 			}
// 			ImGui::SameLine();
// 
// 			ImGui::PushID(t.m_hwnd);
// 			if (ImGui::Button("u"))
// 			{
// 				tasks.MakeIgnored(t.m_hwnd);
// 			}
// 			ImGui::PopID();
// 
// 			ImGui::SameLine();
// 
// 			if (ImGui::Button(name))
// 			{
// 				tasks.Focus(t.m_hwnd);
// 			}
// 		}
		ImGui::End();
	}
Example #19
0
int main(int, char**)
{
    // Setup window
    glfwSetErrorCallback(error_callback);
    if (!glfwInit())
        exit(1);
    GLFWwindow* window = glfwCreateWindow(1280, 720, "ImGui OpenGL2 example", NULL, NULL);
    glfwMakeContextCurrent(window);

    // Setup ImGui binding
    ImGui_ImplGlfw_Init(window, true);


    bool show_test_window = true;
    bool show_another_window = false;
    ImVec4 clear_color = ImColor(114, 144, 154);

    // Main loop
    while (!glfwWindowShouldClose(window))
    {
        glfwPollEvents();
        ImGui_ImplGlfw_NewFrame();

        // 1. Show a simple window
        // Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets appears in a window automatically called "Debug"
        {
            static float f = 0.0f;
            ImGui::Text("Hello, world!");
            ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
            ImGui::ColorEdit3("clear color", (float*)&clear_color);
            if (ImGui::Button("Test Window")) show_test_window ^= 1;
            if (ImGui::Button("Another Window")) show_another_window ^= 1;
            ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
        }

        // 2. Show another simple window, this time using an explicit Begin/End pair
        if (show_another_window)
        {
            ImGui::SetNextWindowSize(ImVec2(200,100), ImGuiSetCond_FirstUseEver);
            ImGui::Begin("Another Window");
            ImGui::Text("Hello");
            ImGui::End();
        }

        // 3. Show the ImGui test window. Most of the sample code is in ImGui::ShowTestWindow()
        if (show_test_window)
        {
            ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiSetCond_FirstUseEver);
            ImGui::ShowTestWindow();
        }

        // Rendering
        int display_w, display_h;
        glfwGetFramebufferSize(window, &display_w, &display_h);
        glViewport(0, 0, display_w, display_h);
        glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
        glClear(GL_COLOR_BUFFER_BIT);
        
        //Needed to disable pipeline when using OpenGL 2 code on 3+
        glUseProgram(0);
        ImGui::Render();
        glfwSwapBuffers(window);
    }

    // Cleanup
    ImGui_ImplGlfw_Shutdown();
    glfwTerminate();

    return 0;
}
Example #20
0
int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
	// Initialize comctl
	CoInitializeEx(NULL, COINIT_MULTITHREADED);

	static const wchar_t *class_name = L"ImGui Example";

	// Create application window
	HINSTANCE instance = GetModuleHandle(NULL);
	HICON icon = LoadIcon(instance, MAKEINTRESOURCE(IDI_ICON1));
	WNDCLASSEX wc = {sizeof(WNDCLASSEX),
	                 CS_CLASSDC,
	                 WndProc,
	                 0L,
	                 0L,
	                 instance,
	                 icon,
	                 NULL,
	                 NULL,
	                 NULL,
	                 class_name,
	                 NULL};
	RegisterClassEx(&wc);
	HWND hwnd =
	    CreateWindow(class_name, _T("Open Board Viewer"), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT,
	                 CW_USEDEFAULT, 1280, 800, NULL, NULL, wc.hInstance, NULL);

	// Initialize Direct3D
	LPDIRECT3D9 pD3D;
	if ((pD3D = Direct3DCreate9(D3D_SDK_VERSION)) == NULL) {
		UnregisterClass(class_name, wc.hInstance);
		return 0;
	}
	ZeroMemory(&g_d3dpp, sizeof(g_d3dpp));
	g_d3dpp.Windowed = TRUE;
	g_d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
	g_d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
	g_d3dpp.EnableAutoDepthStencil = TRUE;
	g_d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
	g_d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_ONE;

	// Create the D3DDevice
	if (pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hwnd,
	                       D3DCREATE_HARDWARE_VERTEXPROCESSING, &g_d3dpp, &g_pd3dDevice) < 0) {
		pD3D->Release();
		UnregisterClass(class_name, wc.hInstance);
		return 0;
	}

	// Setup ImGui binding
	ImGui_ImplDX9_Init(hwnd, g_pd3dDevice);

	// Load Fonts
	// (there is a default font, this is only if you want to change it. see extra_fonts/README.txt
	// for more details)
	ImGuiIO &io = ImGui::GetIO();
	int ttf_size;
	unsigned char *ttf_data = LoadAsset(&ttf_size, ASSET_FIRA_SANS);
	ImFontConfig font_cfg{};
	font_cfg.FontDataOwnedByAtlas = false;
	io.Fonts->AddFontFromMemoryTTF(ttf_data, ttf_size, 20.0f, &font_cfg);
// io.Fonts->AddFontDefault();
// io.Fonts->AddFontFromFileTTF("../../extra_fonts/Cousine-Regular.ttf", 15.0f);
// io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 16.0f);
// io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyClean.ttf", 13.0f);
// io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f);
// io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL,
// io.Fonts->GetGlyphRangesJapanese());
#if 0
	// Get current flag
	int tmpFlag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);

	// Turn on leak-checking bit.
	tmpFlag |= _CRTDBG_CHECK_ALWAYS_DF;

	// Set flag to the new value.
	_CrtSetDbgFlag(tmpFlag);
#endif
	BoardView app{};

	bool show_test_window = true;
	bool show_another_window = false;
	ImVec4 clear_col = ImColor(20, 20, 30);

	// Main loop
	MSG msg;
	ZeroMemory(&msg, sizeof(msg));
	ShowWindow(hwnd, SW_SHOWDEFAULT);
	UpdateWindow(hwnd);
	while (msg.message != WM_QUIT) {
		if (PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE)) {
			TranslateMessage(&msg);
			DispatchMessage(&msg);
			continue;
		}
		ImGui_ImplDX9_NewFrame();
#if 0
		// 1. Show a simple window
		// Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets appears in a window
		// automatically called "Debug"
		{
			static float f = 0.0f;
			ImGui::Text("Hello, world!");
			ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
			ImGui::ColorEdit3("clear color", (float *)&clear_col);
			if (ImGui::Button("Test Window"))
				show_test_window ^= 1;
			if (ImGui::Button("Another Window"))
				show_another_window ^= 1;
			ImGui::Text("Application average %.3f ms/frame (%.1f FPS)",
			            1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
		}

		// 2. Show another simple window, this time using an explicit Begin/End pair
		if (show_another_window) {
			ImGui::SetNextWindowSize(ImVec2(200, 100), ImGuiSetCond_FirstUseEver);
			ImGui::Begin("Another Window", &show_another_window);
			ImGui::Text("Hello");
			ImGui::End();
		}

#endif
#if 0
		// 3. Show the ImGui test window. Most of the sample code is in ImGui::ShowTestWindow()
		if (show_test_window) {
			ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiSetCond_FirstUseEver);
			ImGui::ShowTestWindow(&show_test_window);
		}
#endif
		app.Update();
		if (app.m_wantsQuit) {
			PostMessage(hwnd, WM_QUIT, 0, 0);
		}

		// Rendering
		g_pd3dDevice->SetRenderState(D3DRS_ZENABLE, false);
		g_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, false);
		g_pd3dDevice->SetRenderState(D3DRS_SCISSORTESTENABLE, false);
		D3DCOLOR clear_col_dx =
		    D3DCOLOR_RGBA((int)(clear_col.x * 255.0f), (int)(clear_col.y * 255.0f),
		                  (int)(clear_col.z * 255.0f), (int)(clear_col.w * 255.0f));
		g_pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, clear_col_dx, 1.0f, 0);
		if (g_pd3dDevice->BeginScene() >= 0) {
			ImGui::Render();
			g_pd3dDevice->EndScene();
		}
		g_pd3dDevice->Present(NULL, NULL, NULL, NULL);
	}

	ImGui_ImplDX9_Shutdown();
	if (g_pd3dDevice)
		g_pd3dDevice->Release();
	if (pD3D)
		pD3D->Release();
	UnregisterClass(class_name, wc.hInstance);

	return 0;
}
Example #21
0
void MENode::draw(ImVec2 node_rect_min, ImVec2 NODE_WINDOW_PADDING, bool showPreview, float scale) {
    ImGui::SetCursorScreenPos(node_rect_min + NODE_WINDOW_PADDING);
    ImGui::BeginGroup();
    ImGui::TextColored(ImColor(255, 0, 0), "%s", this->Name.c_str());
    ImGui::EndGroup();
}
Example #22
0
int main(int argc, char** argv)
{
    if(argc != 2) {
        std::cout << "Usage:\n\t" << argv[0] << " IMAGE" << std::endl;
        return 1;
    }
    // Setup window
    glfwSetErrorCallback(error_callback);
    if (!glfwInit())
        return 1;
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
#if __APPLE__
    glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
#endif
    GLFWwindow* window = glfwCreateWindow(1280, 720, "HBVisionGraphEditor", NULL, NULL);
    glfwMakeContextCurrent(window);
    gl3wInit();

    // Setup ImGui binding
    ImGui_ImplGlfwGL3_Init(window, true);

    ImVec4 clear_color = ImColor(39, 40, 34);

    cv::Mat image = cv::imread(argv[1]);

    Solution solution(image);
    AlgSimple simple;
    Preview preview{solution};
    Preview preview2{solution};

    while (!glfwWindowShouldClose(window)) {
        if(!glfwGetWindowAttrib(window, GLFW_ICONIFIED) && glfwGetWindowAttrib(window, GLFW_VISIBLE)) {
            glfwPollEvents();
            ImGui_ImplGlfwGL3_NewFrame();

            // Settings
            ImGui::BeginMainMenuBar();
            int menuHeight = ImGui::GetTextLineHeightWithSpacing();
            if(ImGui::BeginMenu("File")) {
                if(ImGui::MenuItem("Quit")) {
                    glfwSetWindowShouldClose(window, GL_TRUE);
                }
                ImGui::EndMenu();
            }
            ImGui::EndMainMenuBar();

            bool open = false;
            ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0);
            ImGui::SetNextWindowPos(ImVec2(0, menuHeight));
            ImGui::SetNextWindowSize(ImVec2(400, ImGui::GetIO().DisplaySize.y - menuHeight));
            if (ImGui::Begin("###main", &open, ImVec2(0, 0), 0.5f,
                             ImGuiWindowFlags_NoTitleBar |
                             ImGuiWindowFlags_NoResize |
                             ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoBringToFrontOnFocus |
                             ImGuiWindowFlags_NoSavedSettings))
            {
                if (ImGui::TreeNodeEx("Solution", ImGuiTreeNodeFlags_DefaultOpen)) {
                    solution.draw();
                    ImGui::TreePop();
                }
                if (ImGui::TreeNodeEx("Algorithm", ImGuiTreeNodeFlags_DefaultOpen)) {
                    static int currentAlgorithm = 0;
                    ImGui::Combo("###AlgorithmCombo", &currentAlgorithm, "simple\0empty\0\0");
                    simple.draw();
                    ImGui::TreePop();
                }
                ImGui::Spacing();
                ImGui::Separator();
                ImGui::Spacing();
                if (ImGui::Button("Calculate Pattern", ImVec2(ImGui::GetContentRegionAvailWidth(), 20))) {
                    simple.calculate(solution);
                }
            }
            ImGui::End();
            ImGui::PopStyleVar();

            // Preview
            preview.draw(solution);
            preview2.draw(solution);

            // Rendering
            int display_w, display_h;
            glfwGetFramebufferSize(window, &display_w, &display_h);
            glViewport(0, 0, display_w, display_h);
            glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
            glClear(GL_COLOR_BUFFER_BIT);
            ImGui::Render();
            glfwSwapBuffers(window);
        } else {
            glfwWaitEvents();
        }
    }

    // Cleanup
    ImGui_ImplGlfwGL3_Shutdown();
    glfwTerminate();

    return 0;
}
Example #23
0
int main(int, char**)
{
    // Setup window
    glfwSetErrorCallback(error_callback);
    if (!glfwInit())
        exit(1);
    GLFWwindow* window = glfwCreateWindow(1280, 720, "ImGui OpenGL2 example", NULL, NULL);
    glfwMakeContextCurrent(window);

    // Setup ImGui binding
    ImGui_ImplGlfw_Init(window, true);

    // Load Fonts
    // (see extra_fonts/README.txt for more details)
    //ImGuiIO& io = ImGui::GetIO();
    //io.Fonts->AddFontDefault();
    //io.Fonts->AddFontFromFileTTF("../../extra_fonts/Cousine-Regular.ttf", 15.0f);
    //io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 16.0f);
    //io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyClean.ttf", 13.0f);
    //io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f);
    //io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());

    // Merge glyphs from multiple fonts into one (e.g. combine default font with another with Chinese glyphs, or add icons)
    //ImWchar icons_ranges[] = { 0xf000, 0xf3ff, 0 };
    //ImFontConfig icons_config; icons_config.MergeMode = true; icons_config.PixelSnapH = true;
    //io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 18.0f);
    //io.Fonts->AddFontFromFileTTF("../../extra_fonts/fontawesome-webfont.ttf", 18.0f, &icons_config, icons_ranges);

    bool show_test_window = true;
    bool show_another_window = false;
    ImVec4 clear_color = ImColor(114, 144, 154);

    // Main loop
    while (!glfwWindowShouldClose(window))
    {
        glfwPollEvents();
        ImGui_ImplGlfw_NewFrame();

        // 1. Show a simple window
        // Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets appears in a window automatically called "Debug"
        {
            static float f = 0.0f;
            ImGui::Text("Hello, world!");
            ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
            ImGui::ColorEdit3("clear color", (float*)&clear_color);
            if (ImGui::Button("Test Window")) show_test_window ^= 1;
            if (ImGui::Button("Another Window")) show_another_window ^= 1;
            ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
        }

        // 2. Show another simple window, this time using an explicit Begin/End pair
        if (show_another_window)
        {
            ImGui::SetNextWindowSize(ImVec2(200,100), ImGuiSetCond_FirstUseEver);
            ImGui::Begin("Another Window", &show_another_window);
            ImGui::Text("Hello");
            ImGui::End();
        }

        // 3. Show the ImGui test window. Most of the sample code is in ImGui::ShowTestWindow()
        if (show_test_window)
        {
            ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiSetCond_FirstUseEver);
            ImGui::ShowTestWindow(&show_test_window);
        }

        // Rendering
        int display_w, display_h;
        glfwGetFramebufferSize(window, &display_w, &display_h);
        glViewport(0, 0, display_w, display_h);
        glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
        glClear(GL_COLOR_BUFFER_BIT);
        ImGui::Render();
        glfwSwapBuffers(window);
    }

    // Cleanup
    ImGui_ImplGlfw_Shutdown();
    glfwTerminate();

    return 0;
}
Example #24
0
int PiGui::RadialPopupSelectMenu(const ImVec2& center, std::string popup_id, std::vector<ImTextureID> tex_ids, std::vector<std::pair<ImVec2,ImVec2>> uvs, unsigned int size, std::vector<std::string> tooltips)
{
	int ret = -1;

	// FIXME: Missing a call to query if Popup is open so we can move the PushStyleColor inside the BeginPopupBlock (e.g. IsPopupOpen() in imgui.cpp)
	// FIXME: Our PathFill function only handle convex polygons, so we can't have items spanning an arc too large else inner concave edge artifact is too visible, hence the ImMax(7,items_count)
	ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0,0,0,0));
	ImGui::PushStyleColor(ImGuiCol_PopupBg, ImVec4(0,0,0,0));
	ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0,0,0,0));
	if (ImGui::BeginPopup(popup_id.c_str())) {
		const ImVec2 drag_delta = ImVec2(ImGui::GetIO().MousePos.x - center.x, ImGui::GetIO().MousePos.y - center.y);
		const float drag_dist2 = drag_delta.x*drag_delta.x + drag_delta.y*drag_delta.y;

		const ImGuiStyle& style = ImGui::GetStyle();
		const float RADIUS_MIN = 20.0f;
		const float RADIUS_MAX = 90.0f;
		const float RADIUS_INTERACT_MIN = 20.0f;
		const int ITEMS_MIN = 5;
		const float border_inout = 12.0f;
		const float border_thickness = 4.0f;
		ImDrawList* draw_list = ImGui::GetWindowDrawList();
		draw_list->PushClipRectFullScreen();
		draw_list->PathArcTo(center, (RADIUS_MIN + RADIUS_MAX)*0.5f, 0.0f, IM_PI*2.0f*0.99f, 64);   // FIXME: 0.99f look like full arc with closed thick stroke has a bug now
		draw_list->PathStroke(ImColor(18,44,67,210), true, RADIUS_MAX - RADIUS_MIN);

		const float item_arc_span = 2*IM_PI / ImMax(ITEMS_MIN, tex_ids.size());
		float drag_angle = atan2f(drag_delta.y, drag_delta.x);
		if (drag_angle < -0.5f*item_arc_span)
			drag_angle += 2.0f*IM_PI;

		int item_hovered = -1;
		int item_n = 0;
		for(ImTextureID tex_id : tex_ids) {
			const char* tooltip = tooltips.at(item_n).c_str();
			const float inner_spacing = style.ItemInnerSpacing.x / RADIUS_MIN / 2;
			const float item_inner_ang_min = item_arc_span * (item_n - 0.5f + inner_spacing);
			const float item_inner_ang_max = item_arc_span * (item_n + 0.5f - inner_spacing);
			const float item_outer_ang_min = item_arc_span * (item_n - 0.5f + inner_spacing * (RADIUS_MIN / RADIUS_MAX));
			const float item_outer_ang_max = item_arc_span * (item_n + 0.5f - inner_spacing * (RADIUS_MIN / RADIUS_MAX));

			bool hovered = false;
			if (drag_dist2 >= RADIUS_INTERACT_MIN*RADIUS_INTERACT_MIN) {
				if (drag_angle >= item_inner_ang_min && drag_angle < item_inner_ang_max)
					hovered = true;
			}
			bool selected = false;

			int arc_segments = static_cast<int>((64 * item_arc_span / (2*IM_PI))) + 1;
			draw_list->PathArcTo(center, RADIUS_MAX - border_inout, item_outer_ang_min, item_outer_ang_max, arc_segments);
			draw_list->PathArcTo(center, RADIUS_MIN + border_inout, item_inner_ang_max, item_inner_ang_min, arc_segments);

			draw_list->PathFill(hovered ? ImColor(102,147,189) : selected ? ImColor(48,81,111) : ImColor(48,81,111));
			if(hovered) {
				// draw outer / inner extra segments
				draw_list->PathArcTo(center, RADIUS_MAX - border_thickness, item_outer_ang_min, item_outer_ang_max, arc_segments);
				draw_list->PathStroke(ImColor(102,147,189), false, border_thickness);
				draw_list->PathArcTo(center, RADIUS_MIN + border_thickness, item_outer_ang_min, item_outer_ang_max, arc_segments);
				draw_list->PathStroke(ImColor(102,147,189), false, border_thickness);
			}
			ImVec2 text_size = ImVec2(size, size);
			ImVec2 text_pos = ImVec2(
									 center.x + cosf((item_inner_ang_min + item_inner_ang_max) * 0.5f) * (RADIUS_MIN + RADIUS_MAX) * 0.5f - text_size.x * 0.5f,
									 center.y + sinf((item_inner_ang_min + item_inner_ang_max) * 0.5f) * (RADIUS_MIN + RADIUS_MAX) * 0.5f - text_size.y * 0.5f);
			draw_list->AddImage(tex_id, text_pos, ImVec2(text_pos.x+size,text_pos.y+size), uvs[item_n].first, uvs[item_n].second); ImGui::SameLine();
			if (hovered) {
				item_hovered = item_n;
				ImGui::SetTooltip("%s", tooltip);

			}
			item_n++;
		}
		draw_list->PopClipRect();

		if (ImGui::IsMouseReleased(1)) {
			ImGui::CloseCurrentPopup();
			if(item_hovered == -1)
				ret = -2;
			else
				ret = item_hovered;
		}
		ImGui::EndPopup();
	}
	ImGui::PopStyleColor(3);
	return ret;
}
Example #25
0
int main(int ac, const char **av)
{
	// Create application window
	WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, WndProc, 0L, 0L, GetModuleHandle(NULL), NULL, LoadCursor(NULL, IDC_ARROW), NULL, NULL, _T("Douceur"), NULL };
	RegisterClassEx(&wc);
	HWND hwnd = CreateWindow(_T("Douceur"), _T("Douceur"), WS_OVERLAPPEDWINDOW, 100, 100, 1280, 800, NULL, NULL, wc.hInstance, NULL);

	// Initialize Direct3D
	if (CreateDeviceD3D(hwnd) < 0)
	{
		CleanupDeviceD3D();
		UnregisterClass(_T("Douceur"), wc.hInstance);
		return 1;
	}

	// Show the window
	ShowWindow(hwnd, SW_SHOWDEFAULT);
	UpdateWindow(hwnd);

	// Setup ImGui binding
	ImGui_ImplDX11_Init(hwnd, g_pd3dDevice, g_pd3dDeviceContext);

	// Load Fonts
	// (there is a default font, this is only if you want to change it. see extra_fonts/README.txt for more details)
	//ImGuiIO& io = ImGui::GetIO();
	//io.Fonts->AddFontDefault();
	//io.Fonts->AddFontFromFileTTF("../../extra_fonts/Cousine-Regular.ttf", 15.0f);
	//io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 16.0f);
	//io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyClean.ttf", 13.0f);
	//io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f);
	//io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese());

	bool show_test_window = true;
	ImVec4 clear_col = ImColor(114, 144, 154);
	// Main loop
	MSG msg;
	ZeroMemory(&msg, sizeof(msg));

	std::string arduinoMsg;
	std::string arduinoDisplayMsg;
	bool messageEnded = true;

	FMOD::System *fmodSystem;
	FMOD::System_Create(&fmodSystem);

	FMOD::Sound        *sound = 0;
	FMOD::Channel      *channel = 0;
	FMOD::ChannelGroup *mastergroup = 0;

	fmodSystem->init(128, FMOD_INIT_NORMAL, 0);

	fmodSystem->getMasterChannelGroup(&mastergroup);

	fmodSystem->createSound("../DouceurExternal/audio-samples/Yamaha-1.wav", FMOD_LOOP_NORMAL, 0, &sound);

	unsigned int soundLength = 0;
	sound->getLength(&soundLength, FMOD_TIMEUNIT_MS);

	Serial arduino("COM6");
	Board  board(fmodSystem);

	while (msg.message != WM_QUIT)
	{
		fmodSystem->update();

		if (PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE))
		{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
			continue;
		}
		ImGui_ImplDX11_NewFrame();

		static bool first = true;
		static int from = 0;
		static int to = 400;
		static float freq = 1.f;
		static float pan = 0.f;
		static float pitch = 0.f;
		if (!first)
		{
			fmodSystem->playSound(sound, mastergroup, false, &channel);
			first = true;
			to = soundLength;
			channel->getFrequency(&freq);
			channel->getPitch(&pitch);
		}

		{
			ImGui::SetNextWindowPos(ImVec2(10, 10));
			ImGui::Begin("FPS", nullptr, ImVec2(0, 0), 0.3f, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoSavedSettings);
			ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
			ImGui::End();
		}

		if (false)
		{
			ImGui::Begin("SoloudTest");

			bool changed = ImGui::SliderInt("from", (int*)&from, 0, soundLength - 1);
			changed |= ImGui::SliderInt("to", (int*)&to, 1, soundLength);
			changed |= ImGui::SliderFloat("freq", &freq, 0, 500000.f);
			changed |= ImGui::SliderFloat("pan", &pan, -1.f, 1.f);
			changed |= ImGui::SliderFloat("pitch", &pitch, 0.f, 10.f);
			if (changed)
			{
				if (from >= to)
				{
					from = to - 1;
				}
				channel->setLoopPoints(from, FMOD_TIMEUNIT_MS, to, FMOD_TIMEUNIT_MS);
				channel->setFrequency(freq);
				channel->setPan(pan);
			}
			ImGui::End();
		}

		if (false)
		{
			ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiSetCond_FirstUseEver);     // Normally user code doesn't need/want to call it because positions are saved in .ini file anyway. Here we just want to make the demo initial state a bit more friendly!
			ImGui::ShowTestWindow(nullptr);
		}

		board.updateGui();

		//Arduino test
		{
			if (arduino.IsConnected())
			{
				if (ImGui::Begin("Arduino test"))
				{
					char buffer[2048];
					if (messageEnded)
					{
						arduino.WriteData("A", 1);
						messageEnded = false;
					}
					while (!messageEnded)
					{
						int count = arduino.ReadData(buffer, 2047);
						if (count)
						{
							buffer[count] = '\0';
							if (buffer[count - 1] == '@')
							{
								buffer[count - 1] = '\0';
								messageEnded = true;
							}
							arduinoMsg += buffer;
						}
						else
						{
							break;
						}
					}
					if (messageEnded)
					{
						board.updatePadsVoltage(arduinoMsg);

						arduinoDisplayMsg = arduinoMsg;
						arduinoMsg.clear();
					}
					ImGui::TextWrapped(arduinoDisplayMsg.c_str());
					ImGui::Text("Message size : %i", arduinoDisplayMsg.size());
				}
				ImGui::End();
				board.displayPadsVoltage();
			}
		}

		// Rendering
		g_pd3dDeviceContext->ClearRenderTargetView(g_mainRenderTargetView, (float*)&clear_col);
		ImGui::Render();
		g_pSwapChain->Present(0, 0);
	}

	ImGui_ImplDX11_Shutdown();
	CleanupDeviceD3D();
	UnregisterClass(_T("Douceur"), wc.hInstance);

	return EXIT_SUCCESS;
}
Example #26
0
void ModelLoader::OnUpdateUI()
{
	m_doorsUI->Render();

	if (ImGui::CollapsingHeader("Objects"))
	{
		//ImGui::LabelText("ZoneId", "%d", m_zoneId);
		//ImGui::LabelText("Models Loaded", "%d", m_models.size());
		//ImGui::LabelText("Filename", "%s", m_zoneFile.c_str());

		ImGui::Checkbox("Draw Bounding Boxes", &s_drawBoundingBoxes);
		if (s_drawBoundingBoxes)
			ImGui::Checkbox("All doors visible", &s_visibleOverride);

		if (ImGui::Button("View Doors"))
		{
			m_doorsUI->Show();
		}

		if (ImGui::TreeNode("##SwitchTable", "Door Objects"))
		{
			PDOORTABLE pDoorTable = (PDOORTABLE)pSwitchMgr;
			
			if (m_lastDoorTargetId >= 0)
			{
				PDOOR door = nullptr;
				for (DWORD count = 0; count < pDoorTable->NumEntries; count++)
				{
					if (pDoorTable->pDoor[count]->ID == m_lastDoorTargetId)
						door = pDoorTable->pDoor[count];
				}

				if (door)
				{
					ImGui::PushStyleColor(ImGuiCol_Text, ImColor(0, 255, 0));

					if (ImGui::TreeNode("Target Object", "Door Target: %s (%d)", door->Name, door->ID))
					{
						ImGui::PopStyleColor();

						RenderDoorObjectUI(door, true);

						ImGui::TreePop();
					}
					else
					{
						ImGui::PopStyleColor();
					}
				}
			}

			// temp for now, until we figure out where to put this...
			for (DWORD count = 0; count < pDoorTable->NumEntries; count++)
			{
				PDOOR door = pDoorTable->pDoor[count];
				ImGui::PushID(count);

				if (ImGui::TreeNode(door->Name, "%s (%d)", door->Name, door->ID))
				{
					RenderDoorObjectUI(door);

					ImGui::TreePop();
				}
				ImGui::PopID();
			}

			ImGui::TreePop();
		}

		if (ImGui::TreeNode("##ItemTable", "Ground Items"))
		{
			PGROUNDITEM pItem = *(PGROUNDITEM*)pItemList;
			while (pItem)
			{
				if (ImGui::TreeNode(pItem->Name, "%s (%d)", pItem->Name, pItem->DropID))
				{
					ImGui::LabelText("Id", "%d", pItem->ID);
					ImGui::LabelText("DropId", "%d", pItem->DropID);
					ImGui::LabelText("Name", "%s", pItem->Name);
					ImGui::LabelText("Heading", "%.2f", pItem->Heading);
					ImGui::DragFloat3("Position", &pItem->Y);

					ImGui::TreePop();
				}

				pItem = pItem->pNext;
			}

			ImGui::TreePop();
		}
	}
}
Example #27
0
void DoorsDebugUI::Render()
{
if (!m_showDoorsUI)
		return;

	ImGui::SetNextWindowSize(ImVec2(500, 120), ImGuiSetCond_FirstUseEver);
	if (!ImGui::Begin("EQ Doors", &m_showDoorsUI))
		return;

	PDOORTABLE pDoorTable = (PDOORTABLE)pSwitchMgr;

	ImGui::Text("%d door objects", pDoorTable->NumEntries);

	ImGui::Columns(6, "doorcolumns");
	ImGui::Separator();

	auto header = [this](const char* name, int id) {
		if (ImGui::Selectable(name, m_doorsSortColumn == id)) {
			m_sortReverse = (m_doorsSortColumn == id) ? !m_sortReverse : false;
			m_doorsSortColumn = id;
		}
		ImGui::NextColumn();
	};

	header("ID", Sort_ID);
	header("Name", Sort_Name);
	header("Type", Sort_Type);
	header("State", Sort_State);
	header("Distance", Sort_Distance);
	/* buttons */ ImGui::NextColumn();

	ImGui::Separator();

	std::vector<PDOOR> doors(pDoorTable->NumEntries);

	for (DWORD count = 0; count < pDoorTable->NumEntries; count++)
	{
		doors[count] = pDoorTable->pDoor[count];
	}

	std::sort(doors.begin(), doors.end(),
		[this](PDOOR a, PDOOR b) -> bool
	{
		bool less = false;
		if (m_doorsSortColumn == Sort_ID)
			less = a->ID < b->ID;
		else if (m_doorsSortColumn == Sort_Name)
			less = strcmp(a->Name, b->Name) < 0;
		else if (m_doorsSortColumn == Sort_Type)
			less = a->Type < b->Type;
		else if (m_doorsSortColumn == Sort_State)
			less = a->State < b->State;
		else if (m_doorsSortColumn == Sort_Distance)
			less = GetDistance(a) < GetDistance(b);
		
		return less;
	});

	if (m_sortReverse)
		std::reverse(doors.begin(), doors.end());

	for (auto iter = doors.begin(); iter != doors.end(); ++iter)
	{
		PDOOR door = *iter;

		ImGui::PushID(door->ID);

		bool targetted = (m_lastDoorTargetId == door->ID);
		if (targetted)
			ImGui::PushStyleColor(ImGuiCol_Text, ImColor(0, 255, 0));

		ImGui::Text("%d", door->ID); ImGui::NextColumn();

		if (ImGui::Selectable(door->Name, targetted))
		{
			CHAR temp[256];
			sprintf_s(temp, "/doortarget id %d", door->ID);

			// would be nice if there was an easier way to do this.
			EzCommand(temp);
		}
		ImGui::NextColumn();
		ImGui::Text("%d", door->Type); ImGui::NextColumn();
		ImGui::Text("%d", door->State); ImGui::NextColumn();
		ImGui::Text("%.2f", GetDistance(door)); ImGui::NextColumn();

		if (targetted)
			ImGui::PopStyleColor();

		if (ImGui::Button("Click"))
			ClickDoor(door);

		if (targetted)
		{
			ImGui::SameLine();
			ImGui::Text("<Target>");
		}

		if (IsSwitchStationary(door))
		{
			ImGui::SameLine();
			ImGui::Text("*stationary*");
		}

		ImGui::NextColumn();

		ImGui::PopID();
	}

	ImGui::Separator();
	ImGui::Columns(1);
	ImGui::Separator();

	ImGui::End();
}
void ComponentParticleSystem::OnLoad(Config* config) 
{
	init.max_particles = config->GetUInt("Max particles", 100);
    init.loop = config->GetBool("Loop", false);

    init.duration = config->GetFloat("Duration", 0.0f);
    init.life.Load("Life", *config);
    init.speed.Load("Speed", *config);
    init.size.Load("Size", *config);
    init.rotation.Load("Rotation", *config);
    init.gravity.Load("Gravity", *config);
    init.color = config->GetFloat4("Color", float4::one);

	init.whole_speed = config->GetFloat("Whole speed", 1.0f);

    emitter.particles_per_second = config->GetUInt("Particles per second", 0);
    emitter.particles_per_distance = config->GetUInt("Particles per distance", 0);
    shape.type = (ShapeType)config->GetUInt("Shape type", (uint)Circle);
    if(shape.type == Circle)
    {
        shape.radius = config->GetFloat("Circle radius", 1.0f);
    }
    else if(shape.type == Cone)
    {
        shape.radius = config->GetFloat("Cone radius", 1.0f);
        shape.angle = config->GetFloat("Cone angle", 0.0f);
    }


    speed_over_time.init = config->GetFloat3("Speed init", float3::zero);
    speed_over_time.end = config->GetFloat3("Speed end", float3::zero);
    speed_over_time.bezier = config->GetFloat4("Speed bezier", float4(0.0f, 1.0f, 0.0f, 1.0f));

    size_over_time.init = config->GetFloat("Size init", 1.0f);
    size_over_time.end = config->GetFloat("Size end", 1.0f);
    size_over_time.bezier = config->GetFloat4("Size bezier", float4(0.0f, 1.0f, 0.0f, 1.0f));

    color_over_time.gradient.clearMarks();

    uint count = config->GetArrayCount("Color over time");
    for(uint i=0; i< count; ++i)
    {
        Config mark = config->GetArray("Color over time", i);
        
        bool alpha = mark.GetBool("alpha", false);
        float position = mark.GetFloat("position", 0.0f); 
        if(alpha)
        {
            float color = mark.GetFloat("color", 1.0f); 
            color_over_time.gradient.addAlphaMark(position, color);
        }
        else
        {
            float4 color = mark.GetFloat4("color", float4::one); 
            color_over_time.gradient.addMark(position, ImColor(color.x, color.y, color.z, 1.0f));
        }
    }

    if(color_over_time.gradient.getMarks().empty())
    {
        color_over_time.gradient.addMark(0.0f, ImColor(1.0f, 1.0f, 1.0f, 1.0f));
    }

    SetTexture(config->GetUID("Texture", 0));

    texture_info.x_tiles = config->GetInt("Sheet x", 1);
    texture_info.y_tiles = config->GetInt("Sheet y", 1);
    texture_info.random = config->GetBool("Sheet random", false);
    texture_info.frame_over_time.init = config->GetFloat("Sheet init", 0.0f);
    texture_info.frame_over_time.end = config->GetFloat("Sheet end", 0.0f);
    texture_info.frame_over_time.bezier = config->GetFloat4("Sheet bezier", float4(0.0f, 1.0f, 0.0f, 1.0f));
    blend_mode = (RenderBlendMode)config->GetInt("Blend mode", (int)AdditiveBlend);
    layer = config->GetFloat("Layer", 0.0f);
}
Example #29
0
void ModelLoader::RenderDoorObjectUI(PDOOR door, bool target)
{
	auto model = m_modelData[door->ID];

	if (model)
	{
		bool visible = model->IsVisible();
		ImGui::Checkbox("Render", &visible); ImGui::SameLine();
		model->SetVisible(visible);

		bool highlight = model->IsHighlighted();
		ImGui::Checkbox("Highlight", &highlight);
		model->SetHighlight(highlight);
	}
	else
	{
		ImGui::TextColored(ImColor(255, 0, 0), "No Model Data");
	}

	if (target)
	{
		if (ImGui::TreeNode("Door Data"))
		{
			DumpDataUI(door, sizeof(_DOOR));

			ImGui::TreePop();
		}
		if (ImGui::TreeNode("Switch Data"))
		{
			DumpDataUI(door->pSwitch, sizeof(EQSWITCH));

			ImGui::TreePop();
		}
	}

	ImGui::Separator();

	ImGui::Text("ID: %d Type: %d State: %d", door->ID, door->Type, door->State);
	if (door->ZonePoint != -1)
	{
		const char* zone = GetTeleportName(door->ZonePoint);
		ImGui::TextColored(ImColor(255, 255, 0), "Zone Point: %s (%d)", zone, door->ZonePoint);
	}

	ImGui::DragFloat3("Position", &door->Y);
	ImGui::DragFloat("Heading", &door->Heading);
	ImGui::DragFloat("Angle", &door->DoorAngle);
	ImGui::LabelText("Scale", "%.2f", GetDoorScale(door));
	
	ImGui::DragFloat2("Top Speed 1", &door->TopSpeed1);

	ImGui::DragFloat3("Default Position", &door->DefaultY);
	ImGui::DragFloat("Default Heading", &door->DefaultHeading);
	ImGui::DragFloat("Default Angle", &door->DefaultDoorAngle);


	if (ImGui::Button("Target"))
	{
		CHAR temp[256];
		sprintf_s(temp, "/doortarget id %d", door->ID);

		// would be nice if there was an easier way to do this.
		EzCommand(temp);
	}

	ImGui::SameLine();

	if (ImGui::Button("Reset Position"))
	{
		door->X = door->DefaultX;
		door->Y = door->DefaultY;
		door->Z = door->DefaultZ;
		door->Heading = door->DefaultHeading;
	}

	ImGui::SameLine();

	if (ImGui::Button("Click"))
	{
		ClickDoor(door);
	}
}
Example #30
0
int main(int argc, char* argv[])
{
	{
		b3CommandLineArgs myArgs(argc, argv);


		app = new SimpleOpenGLApp("SimpleOpenGLApp", gWidth, gHeight);

		app->m_renderer->getActiveCamera()->setCameraDistance(13);
		app->m_renderer->getActiveCamera()->setCameraPitch(0);
		app->m_renderer->getActiveCamera()->setCameraTargetPosition(0, 0, 0);

		sOldKeyboardCB = app->m_window->getKeyboardCallback();
		app->m_window->setKeyboardCallback(MyKeyboardCallback);
		sOldMouseMoveCB = app->m_window->getMouseMoveCallback();
		app->m_window->setMouseMoveCallback(MyMouseMoveCallback);
		sOldMouseButtonCB = app->m_window->getMouseButtonCallback();
		app->m_window->setMouseButtonCallback(MyMouseButtonCallback);
		sOldWheelCB = app->m_window->getWheelCallback();
		app->m_window->setWheelCallback(MyWheelCallback);
		sOldResizeCB = app->m_window->getResizeCallback();
		app->m_window->setResizeCallback(MyResizeCallback);


		myArgs.GetCmdLineArgument("mp4_file", gVideoFileName);
		if (gVideoFileName)
			app->dumpFramesToVideo(gVideoFileName);

		myArgs.GetCmdLineArgument("png_file", gPngFileName);
		char fileName[1024];

		int textureWidth = 128;
		int textureHeight = 128;

		unsigned char*	image = new unsigned char[textureWidth*textureHeight * 4];


		int textureHandle = app->m_renderer->registerTexture(image, textureWidth, textureHeight);

		int cubeIndex = app->registerCubeShape(1, 1, 1);

		b3Vector3 pos = b3MakeVector3(0, 0, 0);
		b3Quaternion orn(0, 0, 0, 1);
		b3Vector3 color = b3MakeVector3(1, 0, 0);
		b3Vector3 scaling = b3MakeVector3 (1, 1, 1);
		app->m_renderer->registerGraphicsInstance(cubeIndex, pos, orn, color, scaling);
		app->m_renderer->writeTransforms();

		do
		{
			static int frameCount = 0;
			frameCount++;
			if (gPngFileName)
			{
				printf("gPngFileName=%s\n", gPngFileName);

				sprintf(fileName, "%s%d.png", gPngFileName, frameCount++);
				app->dumpNextFrameToPng(fileName);
			}

			
			


			//update the texels of the texture using a simple pattern, animated using frame index
			for (int y = 0; y < textureHeight; ++y)
			{
				const int	t = (y + frameCount) >> 4;
				unsigned char*	pi = image + y*textureWidth * 3;
				for (int x = 0; x < textureWidth; ++x)
				{
					const int		s = x >> 4;
					const unsigned char	b = 180;
					unsigned char			c = b + ((s + (t & 1)) & 1)*(255 - b);
					pi[0] = pi[1] = pi[2] = pi[3] = c; pi += 3;
				}
			}

			app->m_renderer->activateTexture(textureHandle);
			app->m_renderer->updateTexture(textureHandle, image);

			//float color[4] = { 255, 1, 1, 1 };
			//app->m_primRenderer->drawTexturedRect(100, 200, gWidth / 2 - 50, gHeight / 2 - 50, color, 0, 0, 1, 1, true);


			app->m_renderer->init();
			app->m_renderer->updateCamera(1);

			app->m_renderer->renderScene();
			app->drawGrid();
			char bla[1024];
			sprintf(bla, "Simple test frame %d", frameCount);

			//app->drawText(bla, 10, 10);

#ifdef B3_USE_IMGUI
			{
				bool show_test_window = true;
				bool show_another_window = false;
				ImVec4 clear_color = ImColor(114, 144, 154);

				 // Start the frame
				ImGuiIO& io = ImGui::GetIO();
				if (!g_FontTexture)
			        ImGui_ImplBullet_CreateDeviceObjects();

				io.DisplaySize = ImVec2((float)gWidth, (float)gHeight);
				io.DisplayFramebufferScale = ImVec2(gWidth > 0 ? ((float)1.) : 0, gHeight > 0 ? ((float)1.) : 0);
				io.DeltaTime = (float)(1.0f/60.0f);
				io.MousePos = ImVec2((float)gMouseX, (float)gMouseY);   
				io.RenderDrawListsFn = ImGui_ImplBullet_RenderDrawLists;


				for (int i=0;i<3;i++)
				{
					io.MouseDown[i] = g_MousePressed[i]|g_MousePressed2[i];
					g_MousePressed[i] = false;
				}

				io.MouseWheel = g_MouseWheel;

				ImGui::NewFrame();

				ImGui::ShowTestWindow();
				ImGui::ShowMetricsWindow();
				#if 0
				static float f = 0.0f;
				ImGui::Text("Hello, world!");
				ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
				ImGui::ColorEdit3("clear color", (float*)&clear_color);
				if (ImGui::Button("Test Window")) show_test_window ^= 1;
				if (ImGui::Button("Another Window")) show_another_window ^= 1;
				ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
				#endif
				ImGui::Render();
			}
#endif //B3_USE_IMGUI
			app->swapBuffer();
		} while (!app->m_window->requestedExit());



		delete app;

		delete[] image;
	}
	return 0;
}