]> git.tdb.fi Git - libs/gl.git/blob - source/blend.cpp
Drop Id tags and copyright notices from files
[libs/gl.git] / source / blend.cpp
1 #include "blend.h"
2 #include "extension.h"
3 #include "version_1_2.h"
4
5 namespace Msp {
6 namespace GL {
7
8 Blend::Blend():
9         eq(ADD),
10         src_factor(ONE),
11         dst_factor(ZERO)
12 { }
13
14 Blend::Blend(BlendFactor sf, BlendFactor df):
15         eq(ADD),
16         src_factor(sf),
17         dst_factor(df)
18 { }
19
20 Blend::Blend(BlendEquation e, BlendFactor sf, BlendFactor df):
21         eq(e),
22         src_factor(sf),
23         dst_factor(df)
24 {
25         if(eq!=ADD)
26                 static RequireVersion _ver(1, 2);
27 }
28
29 void Blend::bind() const
30 {
31         if(set_current(this))
32         {
33                 glEnable(GL_BLEND);
34                 if(glBlendEquation)
35                         glBlendEquation(eq);
36                 glBlendFunc(src_factor, dst_factor);
37         }
38 }
39
40 void Blend::unbind()
41 {
42         if(set_current(0))
43                 glDisable(GL_BLEND);
44 }
45
46 const Blend &Blend::alpha()
47 {
48         static Blend blend(SRC_ALPHA, ONE_MINUS_SRC_ALPHA);
49         return blend;
50 }
51
52 } // namespace GL
53 } // namespace Msp