From: Mikko Rasa Date: Thu, 16 Sep 2010 19:42:27 +0000 (+0000) Subject: Make better use of GL::Pipeline X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=0a09ce2f652314e221b88c5202795be1120c7229;p=r2c2.git Make better use of GL::Pipeline Double the amount of segments in curved tracks Adapt to mspgl changes --- diff --git a/source/3d/endpoint.cpp b/source/3d/endpoint.cpp index c11f45f..77a8af8 100644 --- a/source/3d/endpoint.cpp +++ b/source/3d/endpoint.cpp @@ -31,7 +31,7 @@ Endpoint3D::~Endpoint3D() void Endpoint3D::render(const GL::Tag &tag) const { - if(tag==0) + if(tag=="unlit") { Point p = track.get_track().get_endpoint_position(index); float a = track.get_track().get_endpoint_direction(index)+M_PI; diff --git a/source/3d/tracktype.cpp b/source/3d/tracktype.cpp index a5e0666..6dab43c 100644 --- a/source/3d/tracktype.cpp +++ b/source/3d/tracktype.cpp @@ -183,7 +183,7 @@ void TrackType3D::render(const GL::Tag &tag) const void TrackType3D::build_part(const TrackPart &part, const Profile &profile, const Point &offset, GL::MeshBuilder &bld, unsigned &base_index) { float plen = part.get_length(); - unsigned nsegs = (part.is_curved() ? static_cast(plen*16)+1 : 1); + unsigned nsegs = (part.is_curved() ? static_cast(plen*32)+1 : 1); unsigned n_points = profile.get_n_points(); for(unsigned i=0; i<=nsegs; ++i) diff --git a/source/designer/designer.cpp b/source/designer/designer.cpp index c9c045a..eb2af23 100644 --- a/source/designer/designer.cpp +++ b/source/designer/designer.cpp @@ -79,22 +79,25 @@ Designer::Designer(int argc, char **argv): } // Setup OpenGL - GL::enable(GL::DEPTH_TEST); - GL::enable(GL::BLEND); - GL::blend_func(GL::SRC_ALPHA, GL::ONE_MINUS_SRC_ALPHA); GL::enable(GL_CULL_FACE); pipeline = new GL::Pipeline(window.get_width(), window.get_height(), false); pipeline->set_camera(&camera); - pipeline->add_renderable(layout_3d->get_scene()); + pipeline->add_renderable_for_pass(layout_3d->get_scene(), 0); if(base_object) - pipeline->add_renderable(*base_object); + pipeline->add_renderable_for_pass(*base_object, 0); + pipeline->add_renderable_for_pass(layout_3d->get_endpoint_scene(), "unlit"); light.set_position(0, -0.259, 0.966, 0); lighting.attach(0, light); - GL::PipelinePass *pass = &pipeline->add_pass(GL::Tag()); + GL::PipelinePass *pass = &pipeline->add_pass(0); pass->lighting = &lighting; + pass->depth_test = &GL::DepthTest::lequal(); + + pass = &pipeline->add_pass("unlit"); + pass->depth_test = &GL::DepthTest::lequal(); + pass->blend = &GL::Blend::alpha(); camera.set_up_direction(GL::Vector3(0, 0, 1)); view_all(); @@ -201,6 +204,9 @@ void Designer::set_sensor_id() void Designer::edit_route(Route &r) { + if(!cur_route) + pipeline->add_renderable_for_pass(layout_3d->get_path_scene(), "unlit"); + cur_route = &r; show_route(r); } @@ -419,9 +425,7 @@ void Designer::apply_camera() void Designer::render() { - GL::clear(GL::COLOR_BUFFER_BIT|GL::DEPTH_BUFFER_BIT); - GL::enable(GL::DEPTH_TEST); - GL::Texture::unbind(); + GL::Framebuffer::system().clear(GL::COLOR_BUFFER_BIT|GL::DEPTH_BUFFER_BIT); if(mode==CATALOGUE) { @@ -431,14 +435,10 @@ void Designer::render() else { pipeline->render_all(); - layout_3d->get_endpoint_scene().render(); - if(cur_route) - layout_3d->get_path_scene().render(); GL::enable(GL_CULL_FACE); - GL::disable(GL::DEPTH_TEST); overlay->render(0); - GL::enable(GL::DEPTH_TEST); + GL::Bind bind_depth(GL::DepthTest::lequal()); manipulator.render(); if(mode==MEASURE) measure.render(); @@ -452,7 +452,9 @@ void Designer::render() GL::disable(GL::DEPTH_TEST); + GL::Bind bind_blend(GL::Blend::alpha()); root->render(); + GL::Texture::unbind(); } Track3D *Designer::pick_track(int x, int y) diff --git a/source/engineer/engineer.cpp b/source/engineer/engineer.cpp index ff13b6e..b665134 100644 --- a/source/engineer/engineer.cpp +++ b/source/engineer/engineer.cpp @@ -164,7 +164,7 @@ void Engineer::tick() status_timeout = Time::TimeStamp(); } - GL::clear(GL::COLOR_BUFFER_BIT|GL::DEPTH_BUFFER_BIT); + GL::Framebuffer::system().clear(GL::COLOR_BUFFER_BIT|GL::DEPTH_BUFFER_BIT); pipeline.render_all(); {