File: clearcolor.hpp

package info (click to toggle)
openmw 0.49.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 33,992 kB
  • sloc: cpp: 372,479; xml: 2,149; sh: 1,403; python: 797; makefile: 26
file content (53 lines) | stat: -rw-r--r-- 1,330 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#ifndef OPENMW_COMPONENTS_SCENEUTIL_CLEARCOLOR_H
#define OPENMW_COMPONENTS_SCENEUTIL_CLEARCOLOR_H

#include <osg/StateAttribute>
#include <osg/Vec4f>

namespace SceneUtil
{
    class ClearColor : public osg::StateAttribute
    {
    public:
        ClearColor()
            : mMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
        {
        }
        ClearColor(const osg::Vec4f& color, GLbitfield mask)
            : mColor(color)
            , mMask(mask)
        {
        }

        ClearColor(const ClearColor& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY)
            : osg::StateAttribute(copy, copyop)
            , mColor(copy.mColor)
            , mMask(copy.mMask)
        {
        }

        META_StateAttribute(fx, ClearColor, static_cast<osg::StateAttribute::Type>(100))

        int compare(const StateAttribute& sa) const override
        {
            COMPARE_StateAttribute_Types(ClearColor, sa);

            COMPARE_StateAttribute_Parameter(mColor);
            COMPARE_StateAttribute_Parameter(mMask);

            return 0;
        }

        void apply(osg::State& state) const override
        {
            glClearColor(mColor[0], mColor[1], mColor[2], mColor[3]);
            glClear(mMask);
        }

    private:
        osg::Vec4f mColor;
        GLbitfield mMask;
    };
}

#endif