~gimaker/peekabot/coord-sys-default

« back to all changes in this revision

Viewing changes to src/renderer/Statelet.hh

  • 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
1
/*
 
2
 * Copyright Staffan Gimåker 2007-2008.
 
3
 *
 
4
 * ---
 
5
 *
2
6
 * This file is part of peekabot.
3
7
 *
4
8
 * peekabot is free software; you can redistribute it and/or modify
15
19
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
20
 */
17
21
 
18
 
#ifndef __PEEKABOT_RENDERER_STATELET_HH
19
 
#define __PEEKABOT_RENDERER_STATELET_HH
 
22
#ifndef PEEKABOT_RENDERER_STATELET_HH_INCLUDED
 
23
#define PEEKABOT_RENDERER_STATELET_HH_INCLUDED
20
24
 
21
25
 
22
26
#include <GL/glew.h>
291
295
 
292
296
 
293
297
 
294
 
 
295
 
 
296
 
 
297
 
        class Transformation : public TypedStatelet<Transformation>
298
 
        {
299
 
            class TransformationImpl : public StateletImpl
300
 
            {
301
 
                const Matrix4r &m_transformation;
302
 
            public:
303
 
                TransformationImpl(const Matrix4r &transformation) throw()
304
 
                    : m_transformation(transformation) {}
305
 
 
306
 
                virtual void activate() throw()
307
 
                {
308
 
                    glPushMatrix();
309
 
                    glMultMatrixf(reinterpret_cast<const GLfloat *>(
310
 
                                      &m_transformation(0,0)));
311
 
                }
312
 
 
313
 
                virtual void deactivate() throw()
314
 
                {
315
 
                    glPopMatrix();
316
 
                }
317
 
            };
318
 
 
319
 
        public:
320
 
            Transformation(const Matrix4r &transformation) throw()
321
 
                : TypedStatelet<Transformation>(
322
 
                    boost::shared_ptr<StateletImpl>(
323
 
                        new TransformationImpl(transformation))) {}
324
 
 
325
 
            // This is dangerous/ugly.. passing a reference to a static matrix...
326
 
            Transformation() throw()
327
 
                : TypedStatelet<Transformation>(
328
 
                    boost::shared_ptr<StateletImpl>(
329
 
                        new TransformationImpl(Matrix4r::identity()))) {}
330
 
        };
331
 
 
332
 
 
333
 
 
334
298
        /**
335
299
         * \brief A statelet that toggles and controls blending.
336
300
         */
1226
1190
}
1227
1191
 
1228
1192
 
1229
 
#endif // __PEEKABOT_RENDERER_STATELET_HH
 
1193
#endif // PEEKABOT_RENDERER_STATELET_HH_INCLUDED