-
Notifications
You must be signed in to change notification settings - Fork 8
/
KinemeGLBlendEquationPatch.m
95 lines (79 loc) · 1.71 KB
/
KinemeGLBlendEquationPatch.m
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*
* GLBlendEquation.m
* GLTools
*
* Created by Christopher Wright on 9/17/08.
* Copyright (c) 2008 Kosada Incorporated. All rights reserved.
*
*/
#import <OpenGL/CGLMacro.h>
#import "KinemeGLBlendEquationPatch.h"
@implementation KinemeGLBlendEquationPatch : QCPatch
+ (QCPatchExecutionMode)executionModeWithIdentifier:(id)fp8
{
return 1;
}
+ (BOOL)allowsSubpatchesWithIdentifier:(id)fp8
{
return YES;
}
+ (BOOL)isSafe
{
return YES;
}
- (id)initWithIdentifier:(id)fp8
{
if(self=[super initWithIdentifier:fp8])
{
[inputRGBEquation setMaxIndexValue: 4];
[inputAlphaEquation setMaxIndexValue: 4];
[[self userInfo] setObject:@"Kineme GL Blend Equation" forKey:@"name"];
}
return self;
}
- (BOOL)execute:(QCOpenGLContext *)context time:(double)time arguments:(NSDictionary *)arguments
{
GLint rgbEqu, alphaEqu, oldRGBEqu, oldAlphaEqu;
CGLContextObj cgl_ctx = [context CGLContextObj];
glGetIntegerv(GL_BLEND_EQUATION_RGB, &oldRGBEqu);
glGetIntegerv(GL_BLEND_EQUATION_ALPHA, &oldAlphaEqu);
switch([inputRGBEquation indexValue])
{
case 0:
rgbEqu = GL_FUNC_ADD;
break;
case 1:
rgbEqu = GL_FUNC_SUBTRACT;
break;
case 2:
rgbEqu = GL_FUNC_REVERSE_SUBTRACT;
break;
case 3:
rgbEqu = GL_MIN;
break;
case 4:
rgbEqu = GL_MAX;
}
switch([inputAlphaEquation indexValue])
{
case 0:
alphaEqu = GL_FUNC_ADD;
break;
case 1:
alphaEqu = GL_FUNC_SUBTRACT;
break;
case 2:
alphaEqu = GL_FUNC_REVERSE_SUBTRACT;
break;
case 3:
alphaEqu = GL_MIN;
break;
case 4:
alphaEqu = GL_MAX;
}
glBlendEquationSeparate(rgbEqu, alphaEqu);
[self executeSubpatches:time arguments:arguments];
glBlendEquationSeparate(oldRGBEqu, oldAlphaEqu);
return YES;
}
@end