void Gradient::platformDestroy() { #ifdef BUILDING_ON_TIGER CGShadingRelease(m_gradient); #else CGGradientRelease(m_gradient); #endif m_gradient = 0; }
void Gradient::platformDestroy() { #if USE_CG_SHADING CGShadingRelease(m_gradient); #else CGGradientRelease(m_gradient); #endif m_gradient = 0; }
void Gradient::platformDestroy() { CGGradientRelease(m_gradient); m_gradient = 0; }
static void initBackground(unsigned w, unsigned h, unsigned max) { CGColorSpaceRef colorspace; CGContextRef gc; unsigned char *data; float cx, cy; float radius, needle; data = (unsigned char *)malloc(w * h * 4); colorspace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB); gc = CGBitmapContextCreate(data, w, h, 8, w * 4, colorspace, kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host); cx = CENTERX * w; cy = CENTERY * h; radius = 0.5 * (w > h ? w : h); needle = radius * 0.85; // background CGContextTranslateCTM(gc, 0.0, h); CGContextScaleCTM(gc, 1.0, -1.0); CGContextClearRect(gc, CGRectMake(0, 0, w, h)); CGContextSetRGBFillColor(gc, 0.0, 0.0, 0.0, 0.7); CGContextAddArc(gc, cx, cy, radius, 0, 2*M_PI, false); CGContextFillPath(gc); CGGradientRef gradient; size_t num_locations = 2; CGFloat locations[2] = { 0.0, 1.0 }; CGFloat components[8] = { 1.0, 1.0, 1.0, 0.5, // Start color 0.0, 0.0, 0.0, 0.0 }; // End color gradient = CGGradientCreateWithColorComponents (colorspace, components, locations, num_locations); // top rim light CGContextSaveGState(gc); CGContextAddArc(gc, cx, cy, radius, 0, 2*M_PI, false); CGContextAddArc(gc, cx, cy, needle*1.05, 0, 2*M_PI, false); CGContextEOClip(gc); CGContextDrawRadialGradient (gc, gradient, CGPointMake(cx, cy*1.00), radius*1.01, CGPointMake(cx, cy*0.96), radius*0.98, 0); // bottom rim light CGContextDrawRadialGradient (gc, gradient, CGPointMake(cx, cy*1.00), radius*1.01, CGPointMake(cx, cy*1.04), radius*0.98, 0); // top bevel CGContextDrawRadialGradient (gc, gradient, CGPointMake(cx, cy*2.2), radius*0.2, CGPointMake(cx, cy*1.0), radius*1.0, 0); // bottom bevel CGContextRestoreGState(gc); CGContextSaveGState(gc); CGContextAddArc(gc, cx, cy, needle*1.05, 0, 2*M_PI, false); CGContextAddArc(gc, cx, cy, needle*0.96, 0, 2*M_PI, false); CGContextEOClip(gc); CGContextDrawRadialGradient (gc, gradient, CGPointMake(cx, cy* -.5), radius*0.2, CGPointMake(cx, cy*1.0), radius*1.0, 0); CGGradientRelease(gradient); CGContextRestoreGState(gc); CGContextSetRGBFillColor(gc, 0.9, 0.9, 1.0, 1.0); CGContextSetRGBStrokeColor(gc, 0.9, 0.9, 1.0, 1.0); CGContextSetLineCap(gc, kCGLineCapRound); // draw several glow passes, with the content offscreen CGContextTranslateCTM(gc, 0, OFFSCREEN - 10); CGContextSetShadowWithColor(gc, CGSizeMake(0, OFFSCREEN), 48.0, CGColorCreateGenericRGB(0.5, 0.5, 1.0, 0.7)); drawMarks(gc, w, h, max); CGContextTranslateCTM(gc, 0, 20); CGContextSetShadowWithColor(gc, CGSizeMake(0, OFFSCREEN), 48.0, CGColorCreateGenericRGB(0.5, 0.5, 1.0, 0.7)); drawMarks(gc, w, h, max); CGContextTranslateCTM(gc, -10, -10); CGContextSetShadowWithColor(gc, CGSizeMake(0, OFFSCREEN), 48.0, CGColorCreateGenericRGB(0.5, 0.5, 1.0, 0.7)); drawMarks(gc, w, h, max); CGContextTranslateCTM(gc, 20, 0); CGContextSetShadowWithColor(gc, CGSizeMake(0, OFFSCREEN), 48.0, CGColorCreateGenericRGB(0.5, 0.5, 1.0, 0.7)); drawMarks(gc, w, h, max); CGContextTranslateCTM(gc, -10, -OFFSCREEN); // draw real content CGContextSetShadowWithColor(gc, CGSizeMake(0, 1), 6.0, CGColorCreateGenericRGB(0.7, 0.7, 1.0, 0.9)); drawMarks(gc, w, h, max); glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8, w, h, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, data); CGContextRelease(gc); CGColorSpaceRelease(colorspace); free(data); }