source: trunk/src/lol/gpu/renderer.h @ 2768

Last change on this file since 2768 was 2768, checked in by sam, 8 years ago

gpu: framebuffers now use the g_render object to restore viewport data.

File size: 3.0 KB
Line 
1//
2// Lol Engine
3//
4// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net>
5//   This program is free software; you can redistribute it and/or
6//   modify it under the terms of the Do What The Fuck You Want To
7//   Public License, Version 2, as published by Sam Hocevar. See
8//   http://www.wtfpl.net/ for more details.
9//
10
11//
12// The Renderer class
13// ------------------
14//
15
16#if !defined __LOL_RENDERER_H__
17#define __LOL_RENDERER_H__
18
19namespace lol
20{
21
22class RendererData;
23
24/* A safe enum to indicate the blending factors. */
25struct BlendFunc
26{
27    enum Value
28    {
29        Disabled,
30        Zero,
31        One,
32        SrcColor,
33        OneMinusSrcColor,
34        DstColor,
35        OneMinusDstColor,
36        SrcAlpha,
37        OneMinusSrcAlpha,
38        DstAlpha,
39        OneMinusDstAlpha,
40        ConstantColor,
41        OneMinusConstantColor,
42        ConstantAlpha,
43        OneMinusConstantAlpha,
44    }
45    m_value;
46
47    inline BlendFunc() : m_value(Zero) {}
48    inline BlendFunc(Value v) : m_value(v) {}
49    inline operator Value() { return m_value; }
50};
51
52/* A safe enum to indicate the face culling mode. */
53struct CullMode
54{
55    enum Value
56    {
57        Disabled,
58        Clockwise,
59        CounterClockwise,
60    }
61    m_value;
62
63    inline CullMode() : m_value(Disabled) {}
64    inline CullMode(Value v) : m_value(v) {}
65    inline operator Value() { return m_value; }
66};
67
68/* A safe enum to indicate the depth test mode. */
69struct DepthFunc
70{
71    enum Value
72    {
73        Disabled,
74        Never,
75        Less,
76        Equal,
77        LessOrEqual,
78        Greater,
79        NotEqual,
80        GreaterOrEqual,
81        Always,
82    }
83    m_value;
84
85    inline DepthFunc() : m_value(Disabled) {}
86    inline DepthFunc(Value v) : m_value(v) {}
87    inline operator Value() { return m_value; }
88};
89
90/* A safe enum to indicate the alpha test mode. */
91struct AlphaFunc
92{
93    enum Value
94    {
95        Disabled,
96        Never,
97        Less,
98        Equal,
99        LessOrEqual,
100        Greater,
101        NotEqual,
102        GreaterOrEqual,
103        Always,
104    }
105    m_value;
106
107    inline AlphaFunc() : m_value(Disabled) {}
108    inline AlphaFunc(Value v) : m_value(v) {}
109    inline operator Value() { return m_value; }
110};
111
112class Renderer
113{
114private:
115    /* Only the Video class can create a renderer for now. */
116    friend class Video;
117
118    Renderer(ivec2 size);
119    ~Renderer();
120
121public:
122    void SetViewport(ibox2 viewport);
123    ibox2 GetViewport() const;
124
125    void SetClearColor(vec4 color);
126    vec4 GetClearColor() const;
127
128    void SetClearDepth(float depth);
129    float GetClearDepth() const;
130
131    void SetAlphaFunc(AlphaFunc func, float alpha);
132    AlphaFunc GetAlphaFunc() const;
133    float GetAlphaValue() const;
134
135    void SetBlendFunc(BlendFunc src, BlendFunc dst);
136    BlendFunc GetBlendFuncSrc() const;
137    BlendFunc GetBlendFuncDst() const;
138
139    void SetDepthFunc(DepthFunc func);
140    DepthFunc GetDepthFunc() const;
141
142    void SetFaceCulling(CullMode mode);
143    CullMode GetFaceCulling() const;
144
145private:
146    RendererData *m_data;
147};
148
149extern Renderer *g_renderer;
150
151} /* namespace lol */
152
153#endif // __LOL_RENDERER_H__
154
Note: See TracBrowser for help on using the repository browser.