-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathKinemeGLDepthBufferAlphaThresholdPatch.m
60 lines (45 loc) · 1.22 KB
/
KinemeGLDepthBufferAlphaThresholdPatch.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
#import <OpenGL/CGLMacro.h>
#import "KinemeGLDepthBufferAlphaThresholdPatch.h"
@implementation KinemeGLDepthBufferAlphaThresholdPatch : 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)
{
[inputThreshold setMinDoubleValue:0.0];
[inputThreshold setMaxDoubleValue:1.0];
[[self userInfo] setObject:@"Kineme GL Depth Buffer Alpha Threshold" forKey:@"name"];
}
return self;
}
- (BOOL)execute:(QCOpenGLContext *)context time:(double)time arguments:(NSDictionary *)arguments
{
GLfloat oldThreshold;
GLint oldFunction;
GLboolean alphaTestEnabled;
CGLContextObj cgl_ctx = [context CGLContextObj];
glGetFloatv(GL_ALPHA_TEST_REF,&oldThreshold);
glGetIntegerv(GL_ALPHA_TEST_FUNC, &oldFunction);
glAlphaFunc(GL_GREATER, [inputThreshold doubleValue]);
alphaTestEnabled = glIsEnabled(GL_ALPHA_TEST);
if(!alphaTestEnabled)
glEnable(GL_ALPHA_TEST);
[self executeSubpatches:time arguments:arguments];
if(!alphaTestEnabled)
glDisable(GL_ALPHA_TEST);
glAlphaFunc(oldFunction, oldThreshold);
return YES;
}
@end