27#include <easy3d/viewer/viewer.h>
28#include <easy3d/renderer/vertex_array_object.h>
29#include <easy3d/renderer/drawable_triangles.h>
30#include <easy3d/util/resource.h>
31#include <easy3d/util/initializer.h>
38int main(
int argc,
char **argv) {
46 Viewer viewer(EXAMPLE_TITLE);
51 const std::vector<vec3> &points = resource::bunny_vertices;
53 const std::vector<unsigned int> &indices = resource::bunny_indices;
61 surface->update_vertex_buffer(points,
true);
65 surface->update_element_buffer(indices);
80 void* pointer = VertexArrayObject::map_buffer(GL_ARRAY_BUFFER, surface->vertex_buffer(), GL_WRITE_ONLY);
82 vec3* vertices =
reinterpret_cast<vec3*
>(pointer);
86 static float total_scale = 1.0f;
88 if (total_scale > 1.5f) {
89 scale = 1.0f / total_scale;
95 for (std::size_t i=0; i<points.size(); ++i)
96 vertices[i].z *= scale;
99 VertexArrayObject::unmap_buffer(GL_ARRAY_BUFFER, surface->vertex_buffer());
The drawable for rendering a set of triangles, e.g., the surface of a triangular mesh.
Definition: drawable_triangles.h:46
The built-in Easy3D viewer.
Definition: viewer.h:61
bool add_drawable(Drawable *drawable)
Add a drawable to the viewer to be visualized. After a drawable being added to the viewer,...
Definition: viewer.cpp:1302
void fit_screen(const easy3d::Model *model=nullptr)
Moves the camera so that the entire scene or the active model is centered on the screen at a proper s...
Definition: viewer.cpp:1337
std::function< bool(Viewer *viewer)> animation_func_
Function called at an equal interval for animation.
Definition: viewer.h:468
void set_animation(bool b)
Enable/Disable animation.
Definition: viewer.cpp:1193
int run(bool see_all=true)
Run the viewer.
Definition: viewer.cpp:1090
void update() const
Update the display (i.e., repaint).
Definition: viewer.cpp:631
Definition: collider.cpp:182
void initialize(bool use_log_file, bool use_setting_file, const std::string &resource_dir)
Initialization of Easy3D.
Definition: initializer.cpp:35