Skip to content

Commit

Permalink
[render] all render examples use generic getDrawableMesh function imp…
Browse files Browse the repository at this point in the history
…lemented in common
  • Loading branch information
alemuntoni committed Jan 8, 2025
1 parent 2ceb50e commit 3f7e7de
Show file tree
Hide file tree
Showing 18 changed files with 54 additions and 350 deletions.
2 changes: 1 addition & 1 deletion examples/render/01-viewer/bgfx/glfw/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ int main(int argc, char** argv)
vcl::glfw::ViewerWindow tw("Viewer GLFW");

// load and set up a drawable mesh
vcl::DrawableMesh<vcl::TriMesh> drawable = getDrawableMesh();
vcl::DrawableMesh<vcl::TriMesh> drawable = getDrawableMesh<vcl::TriMesh>();

// add the drawable mesh to the scene
// the viewer will own **a copy** of the drawable mesh
Expand Down
2 changes: 1 addition & 1 deletion examples/render/01-viewer/bgfx/qt/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ int main(int argc, char** argv)
vcl::qt::ViewerWidget tw("Viewer Qt");

// load and set up a drawable mesh
vcl::DrawableMesh<vcl::TriMesh> drawable = getDrawableMesh();
vcl::DrawableMesh<vcl::TriMesh> drawable = getDrawableMesh<vcl::TriMesh>();

// add the drawable mesh to the scene
// the viewer will own **a copy** of the drawable mesh
Expand Down
16 changes: 1 addition & 15 deletions examples/render/01-viewer/opengl2/glfw/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ int main(int argc, char** argv)
vcl::glfw::ViewerWindow tw("Viewer GLFW");

// load and set up a drawable mesh
vcl::DrawableMesh<vcl::TriMesh> drawable = getDrawableMesh();
vcl::DrawableMesh<vcl::TriMesh> drawable = getDrawableMesh<vcl::TriMesh>();

drawable.color() = vcl::Color::Yellow;
drawable.updateBuffers();
Expand All @@ -47,19 +47,5 @@ int main(int argc, char** argv)

tw.show();

// vcl::glfw::ViewerWindow tw2("Viewer GLFW");

// // load and set up a drawable mesh
// vcl::DrawableMesh<vcl::TriMesh> drawable2 =
// getDrawableMesh("greek_helmet.obj");

// // add the drawable mesh to the scene
// // the viewer will own **a copy** of the drawable mesh
// tw2.pushDrawableObject(drawable2);

// tw2.fitScene();

// tw2.show();

return 0;
}
16 changes: 1 addition & 15 deletions examples/render/01-viewer/opengl2/qt/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ int main(int argc, char** argv)
vcl::qt::ViewerWidget tw("Viewer Qt");

// load and set up a drawable mesh
vcl::DrawableMesh<vcl::TriMesh> drawable = getDrawableMesh();
vcl::DrawableMesh<vcl::TriMesh> drawable = getDrawableMesh<vcl::TriMesh>();

// add the drawable mesh to the scene
// the viewer will own **a copy** of the drawable mesh
Expand All @@ -42,19 +42,5 @@ int main(int argc, char** argv)

tw.show();

// vcl::qt::ViewerWidget tw2("Viewer Qt");

// // load and set up a drawable mesh
// vcl::DrawableMesh<vcl::TriMesh> drawable2 =
// getDrawableMesh("greek_helmet.obj");

// // add the drawable mesh to the scene
// // the viewer will own **a copy** of the drawable mesh
// tw2.pushDrawableObject(drawable2);

// tw2.fitScene();

// tw2.show();

return app.exec();
}
5 changes: 1 addition & 4 deletions examples/render/02-mesh-viewer/bgfx/qt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,10 @@ project(vclib-render-example-${EXAMPLE_NAME})
### Build settings
set(CMAKE_CXX_STANDARD 20)

set(HEADERS
common.h)

set(SOURCES
main.cpp)

# will create a target called 'vclib-render-example-${EXAMPLE_NAME}'
vclib_add_example(${EXAMPLE_NAME}
VCLIB_MODULE render
SOURCES ${HEADERS} ${SOURCES})
SOURCES ${SOURCES})
77 changes: 0 additions & 77 deletions examples/render/02-mesh-viewer/bgfx/qt/common.h

This file was deleted.

19 changes: 15 additions & 4 deletions examples/render/02-mesh-viewer/bgfx/qt/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
* (https://www.mozilla.org/en-US/MPL/2.0/) for more details. *
****************************************************************************/

#include <QApplication>
#include "get_drawable_mesh.h"

#include <vclib/qt/mesh_viewer.h>

#include "common.h"
#include <QApplication>

int main(int argc, char** argv)
{
Expand All @@ -33,10 +33,21 @@ int main(int argc, char** argv)
vcl::qt::MeshViewer mv;

// load and set up a drawable mesh
auto drawable = getDrawableMesh<vcl::TriMesh>();
auto m = getDrawableMesh<vcl::TriMesh>("TextureDouble.ply");

m.enablePerFaceColor();
for (auto& f : m.faces()) {
if (f.index() % 3 == 0)
f.color() = vcl::Color::Red;
else if (f.index() % 3 == 1)
f.color() = vcl::Color::Green;
else
f.color() = vcl::Color::Blue;
}
m.updateBuffers();

auto v = std::make_shared<vcl::DrawableObjectVector>();
v->pushBack(drawable);
v->pushBack(m);

mv.setDrawableObjectVector(v);

Expand Down
5 changes: 1 addition & 4 deletions examples/render/02-mesh-viewer/opengl2/qt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,10 @@ project(vclib-render-example-${EXAMPLE_NAME})
### Build settings
set(CMAKE_CXX_STANDARD 20)

set(HEADERS
common.h)

set(SOURCES
main.cpp)

# will create a target called 'vclib-render-example-${EXAMPLE_NAME}'
vclib_add_example(${EXAMPLE_NAME}
VCLIB_MODULE render
SOURCES ${HEADERS} ${SOURCES})
SOURCES ${SOURCES})
77 changes: 0 additions & 77 deletions examples/render/02-mesh-viewer/opengl2/qt/common.h

This file was deleted.

19 changes: 15 additions & 4 deletions examples/render/02-mesh-viewer/opengl2/qt/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
* (https://www.mozilla.org/en-US/MPL/2.0/) for more details. *
****************************************************************************/

#include <QApplication>
#include "get_drawable_mesh.h"

#include <vclib/qt/mesh_viewer.h>

#include "common.h"
#include <QApplication>

int main(int argc, char** argv)
{
Expand All @@ -33,10 +33,21 @@ int main(int argc, char** argv)
vcl::qt::MeshViewer mv;

// load and set up a drawable mesh
auto drawable = getDrawableMesh<vcl::TriMesh>();
auto m = getDrawableMesh<vcl::TriMesh>("TextureDouble.ply");

m.enablePerFaceColor();
for (auto& f : m.faces()) {
if (f.index() % 3 == 0)
f.color() = vcl::Color::Red;
else if (f.index() % 3 == 1)
f.color() = vcl::Color::Green;
else
f.color() = vcl::Color::Blue;
}
m.updateBuffers();

auto v = std::make_shared<vcl::DrawableObjectVector>();
v->pushBack(drawable);
v->pushBack(m);

mv.setDrawableObjectVector(v);

Expand Down
5 changes: 1 addition & 4 deletions examples/render/03-viewer-with-text/bgfx/glfw/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,10 @@ project(vclib-render-example-${EXAMPLE_NAME})
### Build settings
set(CMAKE_CXX_STANDARD 20)

set(HEADERS
common.h)

set(SOURCES
main.cpp)

# will create a target called 'vclib-render-example-${EXAMPLE_NAME}'
vclib_add_example(${EXAMPLE_NAME}
VCLIB_MODULE render
SOURCES ${HEADERS} ${SOURCES})
SOURCES ${SOURCES})
Loading

0 comments on commit 3f7e7de

Please sign in to comment.