X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=sidebyside;f=demos%2Fdesertpillars%2Fsource%2Fdesertpillars.cpp;h=bfb25f30c6b5c3564dee3746955ace47ddf8bf51;hb=HEAD;hp=432c91663dbb4b7b53446a66b00be9ba2e391c0d;hpb=33577fd6ef75f1c3af77720fde351459727ca68c;p=libs%2Fgl.git diff --git a/demos/desertpillars/source/desertpillars.cpp b/demos/desertpillars/source/desertpillars.cpp index 432c9166..bfb25f30 100644 --- a/demos/desertpillars/source/desertpillars.cpp +++ b/demos/desertpillars/source/desertpillars.cpp @@ -4,7 +4,6 @@ #include #include #include -#include #include #include #include "desertpillars.h" @@ -16,17 +15,15 @@ DesertPillars::Options::Options() { wnd_opts.width = 1920; wnd_opts.height = 1080; - gl_opts.gl_version_major = Graphics::GLOptions::LATEST_VERSION; - gl_opts.core_profile = true; } DesertPillars::DesertPillars(int, char **): window(display, opts.wnd_opts), - gl_ctx(window, opts.gl_opts), + gl_device(window), keyboard(window), - view(window, gl_ctx), - camera(resources.get("Camera.camera")), + resources(&res_mgr), + view(window), lighting(resources.get("Desert.lightn")), sphere(resources.get("Sphere.object")), sphere_morph(0.0f), @@ -42,45 +39,17 @@ DesertPillars::DesertPillars(int, char **): window.signal_close.connect(sigc::bind(sigc::mem_fun(this, &DesertPillars::exit), 0)); keyboard.signal_button_press.connect(sigc::bind_return(sigc::mem_fun(this, &DesertPillars::key_press), false)); - env_seq = make_unique(); - env_seq->set_clear_enabled(true); - env_seq->set_debug_name("Environment sequence"); - - global_env = make_unique(32, GL::RGB16F, 2, content, *env_seq); - global_env->set_fixed_position(GL::Vector3(0.0f, 0.0f, 0.0f)); - global_env->set_debug_name("Global environment"); - - sky = make_unique(*global_env, sun); - sky->set_debug_name("Sky"); - - shadow_seq = make_unique(); - shadow_seq->set_clear_enabled(true); - shadow_seq->set_debug_name("Shadow sequence"); - GL::Sequence::Step *step = &shadow_seq->add_step("shadow", content); - step->set_depth_test(GL::LEQUAL); - - shadow_seq_thsm = make_unique(); - shadow_seq_thsm->set_clear_enabled(true); - shadow_seq_thsm->set_debug_name("Shadow sequence"); - step = &shadow_seq_thsm->add_step("shadow_thsm", content); - step->set_depth_test(GL::LEQUAL); - - shadow_map = make_unique(6144, 4096, *sky, lighting); - shadow_map->set_debug_name("Shadow map"); - shadow_map->add_light(sun, 4096, *shadow_seq); - shadow_map->add_light(resources.get("Wisp.light"), 2048, *shadow_seq_thsm); - shadow_map->set_target(GL::Vector3(0.0f, 0.0f, 0.0f), 20.0f); - GL::SequenceBuilder seq_bld(resources.get("Desert.seq")); - seq_bld.set_renderable("content", *shadow_map); + seq_bld.set_renderable("content", content); seq_bld.set_debug_name("Main sequence"); sequence.reset(seq_bld.build(view)); - step = &env_seq->add_step("", *shadow_map); - step->set_lighting(&lighting); - step->set_depth_test(GL::LEQUAL); + GL::SequenceBuilder env_bld(resources.get("Desert_environment.seq")); + env_bld.set_renderable("content", *sequence->get_steps().front().get_renderable()); + env_bld.set_debug_name("Environment sequence"); + env_seq.reset(env_bld.build()); - env_map = make_unique(256, GL::RGB16F, 7, sphere, *env_seq); + env_map = make_unique(256, GL::RGBA16F, 7, sphere, *env_seq); env_map->set_debug_name("Environment map"); sphere.set_matrix(GL::Matrix::translation(GL::Vector3(0.0f, 0.0f, 3.3f))); @@ -88,6 +57,7 @@ DesertPillars::DesertPillars(int, char **): content.add(*env_map); content.add(flare); + camera.copy_parameters(resources.get("Camera.camera")); camera.set_debug_name("Main camera"); view.set_content(sequence.get()); @@ -151,6 +121,7 @@ void DesertPillars::tick() flare.set_matrix(GL::Matrix::translation(p)); display.tick(); + res_mgr.tick(); view.render(); } @@ -167,13 +138,15 @@ void DesertPillars::key_press(unsigned key) } -DesertPillars::Resources::Resources() +DesertPillars::Resources::Resources(GL::ResourceManager *rm) { FS::Path base_dir = FS::get_sys_data_dir()/"demos"/"desertpillars"/"data"; source.add_directory(base_dir); source.add_directory(base_dir/"textures"); source.add_directory(base_dir/"exported"); add_source(source); + + set_resource_manager(rm); }