~gimaker/peekabot/coord-sys-default

« back to all changes in this revision

Viewing changes to src/renderer/api/LineBasedProxy.cc

  • Committer: Staffan Gimåker
  • Date: 2009-06-29 10:09:26 UTC
  • mfrom: (665.1.39 renderer-redux)
  • Revision ID: staffan@gimaker.se-20090629100926-ju5kx8jwzy422rwu
Merged the renderer-redux branch.

This represents a major overhaul to the rendering engine, with a less contrived
design and better performance. Both memory and CPU utilization should be 
better in general.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright Staffan Gimåker 2008-2009.
 
3
 *
 
4
 * ---
 
5
 *
 
6
 * This file is part of peekabot.
 
7
 *
 
8
 * peekabot is free software; you can redistribute it and/or modify
 
9
 * it under the terms of the GNU General Public License as published by
 
10
 * the Free Software Foundation; either version 2 of the License, or
 
11
 * (at your option) any later version.
 
12
 *
 
13
 * peekabot is distributed in the hope that it will be useful,
 
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
 * GNU General Public License for more details.
 
17
 *
 
18
 * You should have received a copy of the GNU General Public License
 
19
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
20
 */
 
21
 
 
22
#include "LineBasedProxy.hh"
 
23
#include "../SceneAction.hh"
 
24
#include "../Scene.hh"
 
25
#include "../LineBased.hh"
 
26
#include "../Entity.hh"
 
27
 
 
28
 
 
29
using namespace peekabot;
 
30
using namespace peekabot::renderer;
 
31
using namespace peekabot::renderer::api;
 
32
 
 
33
 
 
34
LineBasedProxy::LineBasedProxy(Renderer &renderer)
 
35
    : ObjectEntityProxy(renderer)
 
36
{
 
37
}
 
38
 
 
39
 
 
40
void LineBasedProxy::set_line_style(
 
41
    float line_width,
 
42
    uint16_t stipple_pattern,
 
43
    int stipple_factor)
 
44
{
 
45
    class SetLineStyle : public SceneAction
 
46
    {
 
47
    public:
 
48
        SetLineStyle(EntityID id,
 
49
                     float line_width,
 
50
                     uint16_t stipple_pattern,
 
51
                     int stipple_factor)
 
52
            : m_id(id),
 
53
              m_line_width(line_width),
 
54
              m_stipple_pattern(stipple_pattern),
 
55
              m_stipple_factor(stipple_factor) {}
 
56
 
 
57
        virtual void execute(SceneAction::Context &context)
 
58
        {
 
59
            context.scene().get_entity<LineBased>(m_id)->set_line_style(
 
60
                m_line_width,
 
61
                m_stipple_pattern,
 
62
                m_stipple_factor);
 
63
        }
 
64
 
 
65
    private:
 
66
        const EntityID m_id;
 
67
        const float m_line_width;
 
68
        const uint16_t m_stipple_pattern;
 
69
        const int m_stipple_factor;
 
70
    };
 
71
 
 
72
    dispatch(
 
73
        new SetLineStyle(
 
74
            entity_id(), line_width, stipple_pattern, stipple_factor));
 
75
}