11#include " config.hpp"
2+ #include " parametric_shapes.hpp"
3+ #include " core/Bonobo.h"
24#include " core/FPSCamera.h"
35#include " core/helpers.hpp"
4- #include " core/Log.h"
5- #include " core/LogView.h"
66#include " core/Misc.h"
77#include " core/node.hpp"
88#include " core/ShaderProgramManager.hpp"
9- #include " core/WindowManager.hpp"
109
1110#include < imgui.h>
1211#include < external/imgui_impl_glfw_gl3.h>
1918int main ()
2019{
2120 //
22- // Set up the logging system
21+ // Set up the framework
2322 //
24- Log::Init ();
25- Log::View::Init ();
23+ Bonobo framework;
2624
2725 //
2826 // Set up the camera
@@ -36,17 +34,14 @@ int main()
3634 camera.mMovementSpeed = 0 .25f * 12 .0f ;
3735
3836 //
39- // Set up the windowing system and create the window
37+ // Create the window
4038 //
41- WindowManager window_manager;
39+ WindowManager& window_manager = framework. GetWindowManager () ;
4240 WindowManager::WindowDatum window_datum{ input_handler, camera, config::resolution_x, config::resolution_y, 0 , 0 , 0 , 0 };
43- GLFWwindow* window = window_manager.CreateWindow (" EDAF80: Assignment 1" , window_datum, config::msaa_rate);
41+ GLFWwindow* window = window_manager.CreateGLFWWindow (" EDAF80: Assignment 1" , window_datum, config::msaa_rate);
4442 if (window == nullptr ) {
4543 LogError (" Failed to get a window: exiting." );
4644
47- Log::View::Destroy ();
48- Log::Destroy ();
49-
5045 return EXIT_FAILURE;
5146 }
5247
@@ -57,9 +52,6 @@ int main()
5752 if (objects.empty ()) {
5853 LogError (" Failed to load the sphere geometry: exiting." );
5954
60- Log::View::Destroy ();
61- Log::Destroy ();
62-
6355 return EXIT_FAILURE;
6456 }
6557 bonobo::mesh_data const & sphere = objects.front ();
@@ -69,12 +61,26 @@ int main()
6961 // Create the shader program
7062 //
7163 ShaderProgramManager program_manager;
72- GLuint shader = 0u ;
73- program_manager.CreateAndRegisterProgram ({ { ShaderType::vertex, " EDAF80/default.vert" },
64+ GLuint celestial_body_shader = 0u ;
65+ program_manager.CreateAndRegisterProgram (" Celestial Body" ,
66+ { { ShaderType::vertex, " EDAF80/default.vert" },
7467 { ShaderType::fragment, " EDAF80/default.frag" } },
75- shader);
76- if (shader == 0u ) {
77- LogError (" Failed to generate the shader program: exiting." );
68+ celestial_body_shader);
69+ if (celestial_body_shader == 0u ) {
70+ LogError (" Failed to generate the “Celestial Body” shader program: exiting." );
71+
72+ Log::View::Destroy ();
73+ Log::Destroy ();
74+
75+ return EXIT_FAILURE;
76+ }
77+ GLuint celestial_ring_shader = 0u ;
78+ program_manager.CreateAndRegisterProgram (" Celestial Ring" ,
79+ { { ShaderType::vertex, " EDAF80/celestial_ring.vert" },
80+ { ShaderType::fragment, " EDAF80/celestial_ring.frag" } },
81+ celestial_ring_shader);
82+ if (celestial_ring_shader == 0u ) {
83+ LogError (" Failed to generate the “Celestial Ring” shader program: exiting." );
7884
7985 Log::View::Destroy ();
8086 Log::Destroy ();
@@ -88,6 +94,8 @@ int main()
8894 //
8995 Node sun_node;
9096 sun_node.set_geometry (sphere);
97+ sun_node.set_program (&celestial_body_shader, [](GLuint /* program*/ ){});
98+ TRSTransformf& sun_transform_reference = sun_node.get_transform ();
9199 GLuint const sun_texture = bonobo::loadTexture2D (" sunmap.png" );
92100 sun_node.add_texture (" diffuse_texture" , sun_texture, GL_TEXTURE_2D);
93101 float const sun_spin_speed = glm::two_pi<float >() / 6 .0f ; // Full rotation in six seconds
@@ -168,7 +176,7 @@ int main()
168176 //
169177 // Update the transforms
170178 //
171- sun_node. rotate_y (sun_spin_speed * delta_time);
179+ sun_transform_reference. RotateY (sun_spin_speed * delta_time);
172180
173181
174182 //
@@ -178,7 +186,7 @@ int main()
178186 std::stack<glm::mat4> matrix_stack ({ glm::mat4 (1 .0f ) });
179187 // TODO: Replace this explicit rendering of the Sun with a
180188 // traversal of the scene graph and rendering of all its nodes.
181- sun_node.render (camera.GetWorldToClipMatrix (), sun_node. get_transform (), shader, [](GLuint /* program */ ){} );
189+ sun_node.render (camera.GetWorldToClipMatrix ());
182190
183191
184192 //
@@ -198,9 +206,5 @@ int main()
198206
199207 glDeleteTextures (1 , &sun_texture);
200208
201-
202- Log::View::Destroy ();
203- Log::Destroy ();
204-
205209 return EXIT_SUCCESS;
206210}
0 commit comments