]> git.tdb.fi Git - r2c2.git/commitdiff
Make better use of GL::Pipeline
authorMikko Rasa <tdb@tdb.fi>
Thu, 16 Sep 2010 19:42:27 +0000 (19:42 +0000)
committerMikko Rasa <tdb@tdb.fi>
Thu, 16 Sep 2010 19:42:27 +0000 (19:42 +0000)
Double the amount of segments in curved tracks
Adapt to mspgl changes

source/3d/endpoint.cpp
source/3d/tracktype.cpp
source/designer/designer.cpp
source/engineer/engineer.cpp

index c11f45f9bced45a8ff5ca857d78f513b3d0329bc..77a8af8af9cabdabf870accafa07d8ee657152bd 100644 (file)
@@ -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;
index a5e06665b3d589a5116a72d693beca5851beee0d..6dab43c4f7d59de418bcbbe8622fba641298e7d4 100644 (file)
@@ -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<unsigned>(plen*16)+1 : 1);
+       unsigned nsegs = (part.is_curved() ? static_cast<unsigned>(plen*32)+1 : 1);
 
        unsigned n_points = profile.get_n_points();
        for(unsigned i=0; i<=nsegs; ++i)
index c9c045af2e253d9091d89cefa964b17618b12a58..eb2af23d06f48884927fc7ce1ccc1e4d440349c8 100644 (file)
@@ -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)
index ff13b6e2d654c042dde30bb6bf46db39acf6d823..b6651342f2137bd24a58b94b5de0e0da21c913b2 100644 (file)
@@ -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();
        {