-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmain.cpp
More file actions
73 lines (56 loc) · 1.81 KB
/
main.cpp
File metadata and controls
73 lines (56 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include <dim/dimension3D.hpp>
int main()
{
// Open the main window and initialize the libraries
dim::Window::open("App", 0.75f);
// Create the scenes
dim::Scene scene("Scene");
// Cameras and controllers
dim::PerspectiveCamera cam;
cam.set_position(dim::Vector3(0.f, 0.f, 3.f));
scene.set_camera(cam);
scene.set_controller(dim::OrbitController());
// Add lights
scene.add_light(dim::DirectionalLight(dim::Vector3(-1.f, -1.f, -1.f)));
// Create objects
dim::Object object_1(dim::Mesh::Sphere(256, 256), dim::Material(dim::Color(1.f, 0.1f, 0.1f), 0.1f, 0.5f, 0.6f, 30.f));
dim::Object object_2(dim::Mesh::Cone(256), dim::Material(dim::Color(0.1f, 1.f, 0.1f), 0.1f, 0.5f, 0.6f, 30.f));
object_2.move(dim::Vector3(1.1f, 0.f, 0.f));
dim::Object object_3(dim::Mesh::Cylinder(256), dim::Material(dim::Color(0.1f, 0.1f, 1.f), 0.1f, 0.5f, 0.6f, 30.f));
object_3.move(dim::Vector3(-1.1f, 0.f, 0.f));
// The example button color
float color[4] = { 1.f, 1.f, 1.f, 1.f };
// Main loop
while (dim::Window::running)
{
// Check events
sf::Event sf_event;
while (dim::Window::poll_event(sf_event))
{
dim::Window::check_events(sf_event);
scene.check_events(sf_event);
}
// Clear the screen
dim::Window::clear();
scene.clear();
// Update interactive stuff
dim::Window::update();
scene.update();
// Draw the objects
scene.draw(object_1);
scene.draw(object_2);
scene.draw(object_3);
// Display the scenes to the window
scene.display();
// The ImGui window and button example
ImGui::Begin("Menu");
ImGui::Button("Button");
ImGui::ColorPicker3("Color picker", color, ImGuiColorEditFlags_PickerHueWheel);
ImGui::End();
// Display the window to the screen
dim::Window::display();
}
// Close the main window and shut down the libraries
dim::Window::close();
return EXIT_SUCCESS;
}