Skip to content

Commit

Permalink
Merge branch 'main' into render-refactor
Browse files Browse the repository at this point in the history
# Conflicts:
#	vclib/render/src/vclib/glfw/viewer_window.cpp
  • Loading branch information
alemuntoni committed Jan 9, 2025
2 parents 4a3aa67 + 8cb5010 commit 36c7594
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 53 deletions.
2 changes: 1 addition & 1 deletion examples/render/910-viewer-imgui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#* VCLib *
#* Visual Computing Library *
#* *
#* Copyright(C) 2021-2024 *
#* Copyright(C) 2021-2025 *
#* Visual Computing Lab *
#* ISTI - Italian National Research Council *
#* *
Expand Down
12 changes: 6 additions & 6 deletions examples/render/910-viewer-imgui/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,28 @@
* VCLib *
* Visual Computing Library *
* *
* Copyright(C) 2021-2024 *
* Copyright(C) 2021-2025 *
* Visual Computing Lab *
* ISTI - Italian National Research Council *
* *
* All rights reserved. *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 3 of the License, or *
* it under the terms of the Mozilla Public License Version 2.0 as published *
* by the Mozilla Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) *
* for more details. *
* Mozilla Public License Version 2.0 *
* (https://www.mozilla.org/en-US/MPL/2.0/) for more details. *
****************************************************************************/

#include "get_drawable_mesh.h"

#include <vclib/glfw_imgui/viewer_window_imgui.h>
#include <imgui.h>
#include <vclib/glfw_imgui/viewer_window_imgui.h>

class ImguiDemo : public vcl::glfw::ViewerWindowImgui
{
Expand Down
3 changes: 1 addition & 2 deletions examples/render/common/get_drawable_mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ inline vcl::DrawableMesh<MeshType> getDrawableMesh(
const std::string& filename = "bimba.obj")
{
// load a mesh:
MeshType m =
vcl::load<MeshType>(VCLIB_EXAMPLE_MESHES_PATH "/" + filename);
MeshType m = vcl::load<MeshType>(VCLIB_EXAMPLE_MESHES_PATH "/" + filename);
vcl::updatePerVertexAndFaceNormals(m);

// enable the vertex color of the mesh and set it to gray
Expand Down
2 changes: 1 addition & 1 deletion vclib/render/3rdparty/imgui.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#* VCLib *
#* Visual Computing Library *
#* *
#* Copyright(C) 2021-2024 *
#* Copyright(C) 2021-2025 *
#* Visual Computing Lab *
#* ISTI - Italian National Research Council *
#* *
Expand Down
6 changes: 3 additions & 3 deletions vclib/render/include/vclib/bgfx_imgui/imgui_impl_bgfx.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE
*/

#ifndef IMGUI_IMPL_BGFX_H
#define IMGUI_IMPL_BGFX_H
#ifndef VCL_BGFX_IMGUI_IMGUI_IMPL_BGFX_H
#define VCL_BGFX_IMGUI_IMGUI_IMPL_BGFX_H

#include <bgfx/bgfx.h>
#include <imgui.h>
Expand Down Expand Up @@ -137,4 +137,4 @@ namespace ImGui

} // namespace ImGui

#endif // IMGUI_IMPL_BGFX_H
#endif // VCL_BGFX_IMGUI_IMGUI_IMPL_BGFX_H
22 changes: 10 additions & 12 deletions vclib/render/include/vclib/glfw_imgui_old/viewer_window_imgui.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* VCLib *
* Visual Computing Library *
* *
* Copyright(C) 2021-2024 *
* Copyright(C) 2021-2025 *
* Visual Computing Lab *
* ISTI - Italian National Research Council *
* *
Expand All @@ -20,8 +20,8 @@
* (https://www.mozilla.org/en-US/MPL/2.0/) for more details. *
****************************************************************************/

#ifndef VCL_EXT_GLFW_VIEWER_WINDOW_IMGUI_H
#define VCL_EXT_GLFW_VIEWER_WINDOW_IMGUI_H
#ifndef VCL_GLFW_IMGUI_VIEWER_WINDOW_IMGUI_H
#define VCL_GLFW_IMGUI_VIEWER_WINDOW_IMGUI_H

#include <vclib/glfw/viewer_window.h>

Expand Down Expand Up @@ -56,10 +56,10 @@ class ViewerWindowImgui : public ViewerWindow
// callback override to handle imgui events
void glfwKeyCallback(
GLFWwindow* win,
int key,
int scancode,
int action,
int mods) override;
int key,
int scancode,
int action,
int mods) override;

void glfwMouseButtonCallback(
GLFWwindow* win,
Expand All @@ -69,12 +69,10 @@ class ViewerWindowImgui : public ViewerWindow

void glfwCursorPosCallback(GLFWwindow*, double xpos, double ypos) override;

void glfwScrollCallback(
GLFWwindow* win,
double xoffset,
double yoffset) override;
void glfwScrollCallback(GLFWwindow* win, double xoffset, double yoffset)
override;
};

} // namespace vcl::glfw

#endif // VCL_EXT_GLFW_VIEWER_WINDOW_H
#endif // VCL_GLFW_IMGUI_VIEWER_WINDOW_IMGUI_H
54 changes: 26 additions & 28 deletions vclib/render/src/vclib/glfw_imgui_old/viewer_window_imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* VCLib *
* Visual Computing Library *
* *
* Copyright(C) 2021-2024 *
* Copyright(C) 2021-2025 *
* Visual Computing Lab *
* ISTI - Italian National Research Council *
* *
Expand All @@ -20,7 +20,6 @@
* (https://www.mozilla.org/en-US/MPL/2.0/) for more details. *
****************************************************************************/


#ifdef VCLIB_RENDER_BACKEND_OPENGL2
#include <imgui_impl_opengl2.h>
#elif defined(VCLIB_RENDER_BACKEND_BGFX)
Expand All @@ -36,22 +35,19 @@ ViewerWindowImgui::ViewerWindowImgui(
const std::string& windowTitle,
uint width,
uint height,
void*) :
ViewerWindow(v, windowTitle, width, height)
void*) : ViewerWindow(v, windowTitle, width, height)
{
}

ViewerWindowImgui::ViewerWindowImgui(
const std::string& windowTitle,
uint width,
uint height,
void*) :
vcl::glfw::ViewerWindow(windowTitle, width, height)
void*) : vcl::glfw::ViewerWindow(windowTitle, width, height)
{
}

ViewerWindowImgui::ViewerWindowImgui(void* parent) :
ViewerWindow(parent)
ViewerWindowImgui::ViewerWindowImgui(void* parent) : ViewerWindow(parent)
{
}

Expand Down Expand Up @@ -82,8 +78,7 @@ void ViewerWindowImgui::show()
while (!glfwWindowShouldClose(mWindow)) {
glfwPollEvents();
// slow down rendering if window is minimized
if (glfwGetWindowAttrib(mWindow, GLFW_ICONIFIED) != 0)
{
if (glfwGetWindowAttrib(mWindow, GLFW_ICONIFIED) != 0) {
ImGui_ImplGlfw_Sleep(10);
continue;
}
Expand Down Expand Up @@ -133,30 +128,33 @@ using Base = ViewerWindow;

void ViewerWindowImgui::glfwKeyCallback(
GLFWwindow* win,
int key,
int scancode,
int action,
int mods)
{
const auto & io = ImGui::GetIO();
if (!io.WantCaptureKeyboard)
Base::glfwKeyCallback(win, key, scancode, action, mods);
}
int key,
int scancode,
int action,
int mods)
{
const auto& io = ImGui::GetIO();
if (!io.WantCaptureKeyboard)
Base::glfwKeyCallback(win, key, scancode, action, mods);
}

void ViewerWindowImgui::glfwMouseButtonCallback(
GLFWwindow* win,
int button,
int action,
int mods)
{
const auto & io = ImGui::GetIO();
if (!io.WantCaptureMouse)
Base::glfwMouseButtonCallback(win, button, action, mods);
}
{
const auto& io = ImGui::GetIO();
if (!io.WantCaptureMouse)
Base::glfwMouseButtonCallback(win, button, action, mods);
}

void ViewerWindowImgui::glfwCursorPosCallback(GLFWwindow*, double xpos, double ypos)
void ViewerWindowImgui::glfwCursorPosCallback(
GLFWwindow*,
double xpos,
double ypos)
{
const auto & io = ImGui::GetIO();
const auto& io = ImGui::GetIO();
if (!io.WantCaptureMouse)
Base::glfwCursorPosCallback(nullptr, xpos, ypos);
}
Expand All @@ -165,8 +163,8 @@ void ViewerWindowImgui::glfwScrollCallback(
GLFWwindow*,
double xoffset,
double yoffset)
{
const auto & io = ImGui::GetIO();
{
const auto& io = ImGui::GetIO();
if (!io.WantCaptureMouse)
Base::glfwScrollCallback(nullptr, xoffset, yoffset);
}
Expand Down

0 comments on commit 36c7594

Please sign in to comment.