Skip to content

Commit 51f0a80

Browse files
committed
Merge branch 'render-dev'
2 parents 566e99a + 0a6c9ea commit 51f0a80

File tree

15 files changed

+862
-30
lines changed

15 files changed

+862
-30
lines changed

examples/render/910-viewer-imgui/CMakeLists.txt

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,9 @@
2222

2323
cmake_minimum_required(VERSION 3.24)
2424

25-
set(EXAMPLE_NAME 910-viewer-glfw-imgui)
26-
project(vclib-render-example-${EXAMPLE_NAME})
27-
28-
### Build settings
29-
set(CMAKE_CXX_STANDARD 20)
30-
31-
set(SOURCES
32-
main.cpp)
33-
34-
# will create a target called 'vclib-render-example-${EXAMPLE_NAME}'
35-
vclib_add_example(${EXAMPLE_NAME}
36-
VCLIB_MODULE render
37-
SOURCES ${SOURCES})
25+
if (TARGET vclib-3rd-glfw)
26+
add_subdirectory(glfw)
27+
endif()
28+
if (TARGET vclib-3rd-qt)
29+
add_subdirectory(qt)
30+
endif()
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#*****************************************************************************
2+
#* VCLib *
3+
#* Visual Computing Library *
4+
#* *
5+
#* Copyright(C) 2021-2025 *
6+
#* Visual Computing Lab *
7+
#* ISTI - Italian National Research Council *
8+
#* *
9+
#* All rights reserved. *
10+
#* *
11+
#* This program is free software; you can redistribute it and/or modify *
12+
#* it under the terms of the Mozilla Public License Version 2.0 as published *
13+
#* by the Mozilla Foundation; either version 2 of the License, or *
14+
#* (at your option) any later version. *
15+
#* *
16+
#* This program is distributed in the hope that it will be useful, *
17+
#* but WITHOUT ANY WARRANTY; without even the implied warranty of *
18+
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
19+
#* Mozilla Public License Version 2.0 *
20+
#* (https://www.mozilla.org/en-US/MPL/2.0/) for more details. *
21+
#****************************************************************************/
22+
23+
cmake_minimum_required(VERSION 3.24)
24+
25+
set(EXAMPLE_NAME 910-viewer-imgui-glfw)
26+
project(vclib-render-example-${EXAMPLE_NAME})
27+
28+
### Build settings
29+
set(CMAKE_CXX_STANDARD 20)
30+
31+
set(SOURCES
32+
main.cpp)
33+
34+
# will create a target called 'vclib-render-example-${EXAMPLE_NAME}'
35+
vclib_add_example(${EXAMPLE_NAME}
36+
VCLIB_MODULE render
37+
SOURCES ${SOURCES})

examples/render/910-viewer-imgui/main.cpp renamed to examples/render/910-viewer-imgui/glfw/main.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@
2222

2323
#include "get_drawable_mesh.h"
2424

25-
#include <imgui.h>
2625
#include <vclib/glfw_imgui/viewer_window_imgui.h>
2726

27+
#include <imgui.h>
28+
2829
class ImguiDemo : public vcl::glfw::ViewerWindowImgui
2930
{
3031
public:
@@ -44,7 +45,7 @@ class ImguiDemo : public vcl::glfw::ViewerWindowImgui
4445

4546
int main(int argc, char** argv)
4647
{
47-
ImguiDemo tw("Viewer GLFW");
48+
ImguiDemo tw("Viewer ImGui GLFW");
4849

4950
// load and set up a drawable mesh
5051
vcl::DrawableMesh<vcl::TriMesh> drawable = getDrawableMesh<vcl::TriMesh>();
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#*****************************************************************************
2+
#* VCLib *
3+
#* Visual Computing Library *
4+
#* *
5+
#* Copyright(C) 2021-2025 *
6+
#* Visual Computing Lab *
7+
#* ISTI - Italian National Research Council *
8+
#* *
9+
#* All rights reserved. *
10+
#* *
11+
#* This program is free software; you can redistribute it and/or modify *
12+
#* it under the terms of the Mozilla Public License Version 2.0 as published *
13+
#* by the Mozilla Foundation; either version 2 of the License, or *
14+
#* (at your option) any later version. *
15+
#* *
16+
#* This program is distributed in the hope that it will be useful, *
17+
#* but WITHOUT ANY WARRANTY; without even the implied warranty of *
18+
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
19+
#* Mozilla Public License Version 2.0 *
20+
#* (https://www.mozilla.org/en-US/MPL/2.0/) for more details. *
21+
#****************************************************************************/
22+
23+
cmake_minimum_required(VERSION 3.24)
24+
25+
set(EXAMPLE_NAME 910-viewer-imgui-qt)
26+
project(vclib-render-example-${EXAMPLE_NAME})
27+
28+
### Build settings
29+
set(CMAKE_CXX_STANDARD 20)
30+
31+
set(SOURCES
32+
main.cpp)
33+
34+
# will create a target called 'vclib-render-example-${EXAMPLE_NAME}'
35+
vclib_add_example(${EXAMPLE_NAME}
36+
VCLIB_MODULE render
37+
SOURCES ${SOURCES})
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*****************************************************************************
2+
* VCLib *
3+
* Visual Computing Library *
4+
* *
5+
* Copyright(C) 2021-2025 *
6+
* Visual Computing Lab *
7+
* ISTI - Italian National Research Council *
8+
* *
9+
* All rights reserved. *
10+
* *
11+
* This program is free software; you can redistribute it and/or modify *
12+
* it under the terms of the Mozilla Public License Version 2.0 as published *
13+
* by the Mozilla Foundation; either version 2 of the License, or *
14+
* (at your option) any later version. *
15+
* *
16+
* This program is distributed in the hope that it will be useful, *
17+
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
18+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
19+
* Mozilla Public License Version 2.0 *
20+
* (https://www.mozilla.org/en-US/MPL/2.0/) for more details. *
21+
****************************************************************************/
22+
23+
#include "get_drawable_mesh.h"
24+
25+
#include <vclib/qt_imgui/viewer_widget_imgui.h>
26+
27+
#include <imgui.h>
28+
29+
#include <QApplication>
30+
31+
class ImguiDemo : public vcl::qt::ViewerWidgetImgui
32+
{
33+
public:
34+
ImguiDemo(const std::string& windowTitle)
35+
: vcl::qt::ViewerWidgetImgui(windowTitle)
36+
{
37+
}
38+
39+
void draw() override
40+
{
41+
// imgui demo window
42+
ImGui::ShowDemoWindow();
43+
44+
// draw the scene
45+
ViewerWidgetImgui::draw();
46+
}
47+
};
48+
49+
int main(int argc, char** argv)
50+
{
51+
// FIXME #2 - Crash when closing window on Ubuntu
52+
53+
QApplication app(argc, argv);
54+
55+
ImguiDemo tw("Viewer ImGui Qt");
56+
57+
// load and set up a drawable mesh
58+
vcl::DrawableMesh<vcl::TriMesh> drawable = getDrawableMesh<vcl::TriMesh>();
59+
60+
// add the drawable mesh to the scene
61+
// the viewer will own **a copy** of the drawable mesh
62+
tw.pushDrawableObject(drawable);
63+
64+
tw.fitScene();
65+
66+
tw.show();
67+
68+
return app.exec();
69+
}

examples/render/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ if (TARGET vclib-processing)
4747
add_subdirectory(800-processing-main-window)
4848
endif()
4949

50-
if(TARGET vclib-3rd-imgui AND TARGET vclib-3rd-glfw)
50+
if(TARGET vclib-3rd-imgui)
5151
add_subdirectory(910-viewer-imgui)
5252
endif()
5353

vclib/render/CMakeLists.txt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#* VCLib *
33
#* Visual Computing Library *
44
#* *
5-
#* Copyright(C) 2021-2024 *
5+
#* Copyright(C) 2021-2025 *
66
#* Visual Computing Lab *
77
#* ISTI - Italian National Research Council *
88
#* *
@@ -122,6 +122,16 @@ if (TARGET vclib-3rd-qt)
122122
list(APPEND FORMS ${FORMS_QT})
123123

124124
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} PREFIX "Forms Files" FILES ${FORMS})
125+
126+
if (TARGET vclib-3rd-imgui)
127+
file(GLOB_RECURSE HEADERS_QT_IMGUI CONFIGURE_DEPENDS
128+
"include/vclib/qt_imgui/*.h")
129+
list(APPEND HEADERS ${HEADERS_QT_IMGUI})
130+
131+
file(GLOB_RECURSE SOURCES_QT_IMGUI CONFIGURE_DEPENDS
132+
"src/vclib/qt_imgui/*.cpp")
133+
list(APPEND SOURCES ${SOURCES_QT_IMGUI})
134+
endif()
125135
endif()
126136

127137
# todo: this is a terrible hack

vclib/render/include/vclib/qt/viewer_widget.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,14 @@ class ViewerWidget : public EventManagerWidget, public vcl::ViewerCanvas
5555

5656
void onKeyPress(Key::Enum key) override;
5757

58-
private:
58+
protected:
5959
#if defined(VCLIB_RENDER_BACKEND_BGFX)
6060
void paintEvent(QPaintEvent* event) override;
6161
#elif defined(VCLIB_RENDER_BACKEND_OPENGL2)
6262
void paintGL() override;
6363
#endif
6464

65+
private:
6566
void showScreenShotDialog();
6667
};
6768

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*****************************************************************************
2+
* VCLib *
3+
* Visual Computing Library *
4+
* *
5+
* Copyright(C) 2021-2025 *
6+
* Visual Computing Lab *
7+
* ISTI - Italian National Research Council *
8+
* *
9+
* All rights reserved. *
10+
* *
11+
* This program is free software; you can redistribute it and/or modify *
12+
* it under the terms of the Mozilla Public License Version 2.0 as published *
13+
* by the Mozilla Foundation; either version 2 of the License, or *
14+
* (at your option) any later version. *
15+
* *
16+
* This program is distributed in the hope that it will be useful, *
17+
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
18+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
19+
* Mozilla Public License Version 2.0 *
20+
* (https://www.mozilla.org/en-US/MPL/2.0/) for more details. *
21+
****************************************************************************/
22+
23+
#ifndef IMGUI_IMPL_QT_H
24+
#define IMGUI_IMPL_QT_H
25+
26+
#include <QWidget>
27+
#include <imgui.h>
28+
#ifndef IMGUI_DISABLE
29+
30+
IMGUI_IMPL_API bool ImGui_ImplQt_Init(QWidget* widget);
31+
IMGUI_IMPL_API void ImGui_ImplQt_Shutdown();
32+
IMGUI_IMPL_API void ImGui_ImplQt_NewFrame();
33+
34+
#endif // IMGUI_DISABLE
35+
#endif // IMGUI_IMPL_QT_H
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*****************************************************************************
2+
* VCLib *
3+
* Visual Computing Library *
4+
* *
5+
* Copyright(C) 2021-2025 *
6+
* Visual Computing Lab *
7+
* ISTI - Italian National Research Council *
8+
* *
9+
* All rights reserved. *
10+
* *
11+
* This program is free software; you can redistribute it and/or modify *
12+
* it under the terms of the Mozilla Public License Version 2.0 as published *
13+
* by the Mozilla Foundation; either version 2 of the License, or *
14+
* (at your option) any later version. *
15+
* *
16+
* This program is distributed in the hope that it will be useful, *
17+
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
18+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
19+
* Mozilla Public License Version 2.0 *
20+
* (https://www.mozilla.org/en-US/MPL/2.0/) for more details. *
21+
****************************************************************************/
22+
23+
#ifndef VCL_EXT_VIEWER_WIDGET_IMGUI_H
24+
#define VCL_EXT_VIEWER_WIDGET_IMGUI_H
25+
26+
#include <vclib/qt/viewer_widget.h>
27+
28+
namespace vcl::qt {
29+
30+
class ViewerWidgetImgui : public ViewerWidget
31+
{
32+
public:
33+
ViewerWidgetImgui(
34+
const std::shared_ptr<DrawableObjectVector>& v,
35+
uint width = 1024,
36+
uint height = 768,
37+
const std::string& windowTitle = "",
38+
QWidget* parent = nullptr);
39+
40+
ViewerWidgetImgui(
41+
const std::string& windowTitle = "Minimal Viewer",
42+
uint width = 1024,
43+
uint height = 768,
44+
QWidget* parent = nullptr);
45+
46+
ViewerWidgetImgui(QWidget* parent);
47+
48+
~ViewerWidgetImgui();
49+
50+
#if defined(VCLIB_RENDER_BACKEND_OPENGL2)
51+
void initializeGL() override;
52+
#endif
53+
54+
protected:
55+
virtual void initImGui();
56+
virtual void shutdownImGui();
57+
58+
#if defined(VCLIB_RENDER_BACKEND_BGFX)
59+
void paintEvent(QPaintEvent* event) override;
60+
#elif defined(VCLIB_RENDER_BACKEND_OPENGL2)
61+
void paintGL() override;
62+
#endif
63+
};
64+
65+
} // namespace vcl::qt
66+
67+
#endif // VCL_EXT_VIEWER_WIDGET_IMGUI_H

vclib/render/src/vclib/bgfx_imgui/imgui_impl_bgfx.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ struct OcornutImguiContext
283283
// NO style
284284
// setupStyle(true);
285285

286-
io.BackendPlatformName = "imgui_impl_bgfx";
286+
io.BackendRendererName = "imgui_impl_bgfx";
287287

288288
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset;
289289

0 commit comments

Comments
 (0)