CoreImage effect loads only with OS X 10.4.0 through 10.4.5. It crashes 10.4.6 currently.
[ITKit.git] / ITWindowEffect.m
index 300819d..a99f54a 100644 (file)
@@ -1,12 +1,14 @@
 #import "ITWindowEffect.h"
 #import "ITTransientStatusWindow.h"
-
+#import <OpenGL/gl.h>
+#import <OpenGL/glu.h>
+#import <OpenGL/glext.h>
 
 @implementation ITWindowEffect
 
 + (NSArray *)effectClasses
 {
-    NSArray *classes = [NSArray arrayWithObjects:
+    NSMutableArray *classes = [[NSArray arrayWithObjects:
         NSClassFromString(@"ITCutWindowEffect"),
         NSClassFromString(@"ITDissolveWindowEffect"),
         NSClassFromString(@"ITSlideHorizontallyWindowEffect"),
         NSClassFromString(@"ITZoomWindowEffect"),
         NSClassFromString(@"ITSpinWindowEffect"),
         NSClassFromString(@"ITSpinAndZoomWindowEffect"),
-               NSClassFromString(@"ITCoreImageWindowEffect"),
-        nil];
-        
-    return classes;
+        nil] mutableCopy];
+       
+       long version;
+       if ((Gestalt(gestaltSystemVersion, &version) == noErr) && (version >= 4160) && (version < 4166)) {
+               NSOpenGLView *view = [[NSOpenGLView alloc] initWithFrame:NSMakeRect(0, 0, 1, 1) pixelFormat:[NSOpenGLView defaultPixelFormat]];
+               if ([view openGLContext]) {
+                       NSString *string = [NSString stringWithCString:glGetString(GL_EXTENSIONS)];
+                       NSRange result = [string rangeOfString:@"ARB_fragment_program"];
+                       if (result.location != NSNotFound) {
+                               [classes addObject:NSClassFromString(@"ITCoreImageWindowEffect")];
+                       }
+               }
+               [view release];
+       }
+       
+    return [classes autorelease];
 }
 
 - (id)initWithWindow:(NSWindow *)window