-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathKinemeGLLogicOpPatch.m
78 lines (62 loc) · 1.26 KB
/
KinemeGLLogicOpPatch.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
#import <OpenGL/CGLMacro.h>
#import "KinemeGLLogicOpPatch.h"
static const GLint modes[16] =
{
GL_CLEAR,
GL_SET,
GL_COPY,
GL_COPY_INVERTED,
GL_NOOP,
GL_INVERT,
GL_AND,
GL_NAND,
GL_OR,
GL_NOR,
GL_XOR,
GL_EQUIV,
GL_AND_REVERSE,
GL_AND_INVERTED,
GL_OR_REVERSE,
GL_OR_INVERTED
};
@implementation KinemeGLLogicOpPatch : QCPatch
+ (QCPatchExecutionMode)executionModeWithIdentifier:(id)fp8
{
return 1;
}
+ (BOOL)allowsSubpatchesWithIdentifier:(id)fp8
{
return YES;
}
+ (BOOL)isSafe
{
return YES;
}
- (id)initWithIdentifier:(id)fp8
{
self=[super initWithIdentifier:fp8];
if(self)
{
[inputMode setMaxIndexValue:15];
[inputMode setIndexValue:2];
[[self userInfo] setObject:@"Kineme GL Logic Op" forKey:@"name"];
}
return self;
}
- (BOOL)execute:(QCOpenGLContext *)context time:(double)time arguments:(NSDictionary *)arguments
{
CGLContextObj cgl_ctx = [context CGLContextObj];
GLint oldLogicOp;
GLboolean isEnabled;
glGetIntegerv(GL_LOGIC_OP_MODE,&oldLogicOp);
isEnabled = glIsEnabled(GL_COLOR_LOGIC_OP);
if(!isEnabled)
glEnable(GL_COLOR_LOGIC_OP);
glLogicOp(modes[ [inputMode indexValue] ]);
[self executeSubpatches:time arguments:arguments];
if(!isEnabled)
glDisable(GL_COLOR_LOGIC_OP);
glLogicOp(oldLogicOp);
return YES;
}
@end