00001
00002 #ifdef RT_IOS
00003 #ifdef __OBJC__
00004
00005 #include "IOSApplicationDelegate.h"
00006 #include "RendergroupEAGLView.h"
00007 #include "RendergroupIOSGLView.h"
00008 #include "Renderbuffer.h"
00009 #include "Framebuffer.h"
00010
00011 using namespace RenderTools;
00012
00013 RendergroupEAGLView * s_instance = nil;
00014
00015 void rendergroupEAGLViewDrawView( void ){
00016 [s_instance drawView];
00017 }
00018
00019 void rendergroupEAGLViewSetNeedsDisplay( void ){
00020 [s_instance setNeedsDisplay];
00021 }
00022
00023 void rendergroupEAGLViewStartTimer( void ){
00024 [s_instance startAnimation];
00025 }
00026
00027 void rendergroupEAGLViewStopTimer( void ){
00028 [s_instance stopAnimation];
00029 }
00030
00031 void rendergroupEAGLViewSetContext( void ){
00032 [ EAGLContext setCurrentContext:s_instance.m_context ];
00033 }
00034
00035 void rendergroupEAGLViewSaveFramebufferToPhotosAlbum( void ){
00036 [ s_instance saveFramebufferToPhotosAlbum ];
00037 }
00038
00039 void rendergroupEAGLViewSaveFramebuffer( void ){
00040 [ s_instance saveFramebufferToDefault ];
00041 }
00042
00043 UIImage * rendergroupEAGLViewGetFramebufferImage( void ){
00044 [ EAGLContext setCurrentContext:s_instance.m_context ];
00045 return [ s_instance createFramebufferImage ];
00046 }
00047
00048 RendergroupEAGLView * getRendergroupEAGLView( void ){
00049 return( s_instance );
00050 }
00051
00052 GLuint rendergroupEAGLViewGetDefaultFramebufferID( void ){
00053 return( s_instance.m_defaultFramebuffer );
00054 }
00055
00056 GLuint rendergroupEAGLViewGetDefaultRenderbufferID( void ){
00057 return( s_instance.m_defaultRenderbuffer );
00058 }
00059
00060 @implementation RendergroupEAGLView
00061
00062 @synthesize m_animating;
00063 @dynamic m_animationFrameInterval;
00064 @synthesize m_context;
00065 @synthesize m_animationTimer;
00066 @synthesize m_defaultFramebuffer;
00067 @synthesize m_defaultRenderbuffer;
00068 @synthesize m_framebufferWidth;
00069 @synthesize m_framebufferHeight;
00070
00071 + (Class)layerClass {
00072 return [CAEAGLLayer class];
00073 }
00074
00075 - (id)initWithFrame:(CGRect)frame {
00076
00077 m_defaultFramebuffer = 0;
00078 m_defaultRenderbuffer = 0;
00079 m_animating = FALSE;
00080 m_displayLinkSupported = FALSE;
00081 m_animationFrameInterval = 1;
00082 m_displayLink = nil;
00083 m_animationTimer = nil;
00084
00085 if( ( self = [ super initWithFrame:frame ] ) ){
00086
00087 if( s_instance != nil ){
00088 Error::error( Error::ITEM_ALREADY_EXISTS, __FILE__, __LINE__ );
00089 }
00090
00091 s_instance = self;
00092
00093 CAEAGLLayer * eaglLayer = (CAEAGLLayer *)self.layer;
00094
00095 eaglLayer.opaque = YES;
00096 eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:
00097 [NSNumber numberWithBool:FALSE], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil];
00098 #ifdef RT_GLES2
00099 m_context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
00100 #elif RT_GLES1
00101 m_context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1];
00102 #endif
00103
00104 if( ! m_context || ! [EAGLContext setCurrentContext:m_context ] ){
00105 [self release];
00106 return nil;
00107 }
00108
00109
00110
00111 NSString *reqSysVer = @"3.1";
00112 NSString *currSysVer = [[UIDevice currentDevice] systemVersion];
00113 if( [ currSysVer compare:reqSysVer options:NSNumericSearch ] != NSOrderedAscending ){
00114 m_displayLinkSupported = TRUE;
00115 }
00116
00117 m_holdingTouches = [[NSMutableArray alloc] init];
00118
00119 if( glIsBuffer( m_defaultFramebuffer ) == GL_FALSE ){
00120 glGenFramebuffers( 1, & m_defaultFramebuffer );
00121 }
00122 if( glIsBuffer( m_defaultRenderbuffer ) == GL_FALSE ){
00123 glGenRenderbuffers( 1, & m_defaultRenderbuffer );
00124 }
00125
00126 glBindFramebuffer( GL_FRAMEBUFFER, m_defaultFramebuffer );
00127 glBindRenderbuffer( GL_RENDERBUFFER, m_defaultRenderbuffer );
00128
00129 glFramebufferRenderbuffer( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_defaultRenderbuffer );
00130
00131 [m_context renderbufferStorage:GL_RENDERBUFFER fromDrawable:eaglLayer ];
00132
00133 glGetRenderbufferParameteriv( GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, & m_framebufferWidth );
00134 glGetRenderbufferParameteriv( GL_RENDERBUFFER, GL_RENDERBUFFER_HEIGHT, & m_framebufferHeight );
00135
00136 #ifdef USE_MULTISAMPLING
00138 if( glIsBuffer( m_msaaFramebuffer ) == GL_FALSE ){
00139 glGenFramebuffers( 1, & m_msaaFramebuffer);
00140 }
00141 if( glIsBuffer( m_msaaRenderbuffer ) == GL_FALSE ){
00142 glGenRenderbuffers( 1, & m_msaaRenderbuffer);
00143 }
00144
00145 glBindFramebuffer( GL_FRAMEBUFFER, m_msaaFramebuffer);
00146 glBindRenderbuffer( GL_RENDERBUFFER, m_msaaRenderbuffer );
00147
00148 glRenderbufferStorageMultisampleAPPLE( GL_RENDERBUFFER, 4, GL_RGBA8_OES, m_framebufferWidth, m_framebufferHeight );
00149 glFramebufferRenderbuffer( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_msaaRenderbuffer );
00150 glGenRenderbuffers( 1, & m_msaaDepthbuffer );
00151 glBindRenderbuffer(GL_RENDERBUFFER, m_msaaDepthbuffer );
00152 glRenderbufferStorageMultisampleAPPLE( GL_RENDERBUFFER, 4, GL_DEPTH_COMPONENT16, m_framebufferWidth, m_framebufferHeight );
00153 glFramebufferRenderbuffer( GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_msaaDepthbuffer );
00154
00155 Framebuffer::setDefaultFramebufferID( m_msaaFramebuffer );
00156 Framebuffer::setDefaultDrawbufferID( m_msaaFramebuffer );
00157 Framebuffer::setDefaultReadbufferID( m_defaultFramebuffer );
00158 Renderbuffer::setDefaultColorbufferID( m_msaaRenderbuffer );
00159 Renderbuffer::setDefaultDepthbufferID( m_msaaDepthbuffer );
00160 #else
00161 Framebuffer::setDefaultFramebufferID( m_defaultFramebuffer );
00162 Framebuffer::setDefaultDrawbufferID( m_defaultFramebuffer );
00163 Framebuffer::setDefaultReadbufferID( m_defaultFramebuffer );
00164 Renderbuffer::setDefaultColorbufferID( m_defaultRenderbuffer );
00165 #endif
00166
00167 [ EAGLContext setCurrentContext:m_context ];
00168
00169 getRendergroupIOSGLViewInstance()->setSize( m_framebufferWidth, m_framebufferHeight );
00170
00171
00172 }
00173 return self;
00174 }
00175
00176 - (void)holdTouch:(NSTimer *)timer {
00177 UITouch * to = [ timer userInfo ];
00178
00179 CGPoint location = [to locationInView:[to view]];
00180 CGPoint previousLocation = [to previousLocationInView:[to view]];
00181
00182 TouchPoint tp = getRendergroupIOSGLViewInstance()->getTouchPoint( (unsigned long)to );
00183 tp.setHolding( tp.getHolding() + 0.05f );
00184
00186 if( tp.getHolding() > 1.0 ){
00187 [ m_holdingTouches removeObject:timer ];
00188 [ timer invalidate ];
00189 }
00190 else{
00191 [ EAGLContext setCurrentContext:m_context ];
00192 getRendergroupIOSGLViewInstance()->touchHolding( (unsigned long)to, tp );
00193 }
00194 }
00195
00196 - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
00197 if( getRendergroupIOSGLViewInstance() ){
00198 vector< TouchPoint > myTouches;
00199 vector< TouchIndex > myIndices;
00200 for( int i = 0; i < [[touches allObjects] count]; i++ ){
00201 UITouch * to = [[touches allObjects] objectAtIndex:i];
00202 CGPoint location = [to locationInView:[to view]];
00203 CGPoint previousLocation = [to previousLocationInView:[to view]];
00204
00205 myIndices.push_back( (unsigned long)to );
00206 myTouches.push_back( TouchPoint( Vec2( location.x, location.y ), Vec2( previousLocation.x, previousLocation.y ), [to tapCount], [to timestamp] ) );
00207
00208 vector< NSTimer * > deleteTimers;
00209 for( NSTimer * t in m_holdingTouches ){
00210 if( [ t userInfo ] == to ){
00211 deleteTimers.push_back( t );
00212 }
00213 }
00214
00215 for( unsigned int j = 0; j < deleteTimers.size(); j++ ){
00216 NSTimer * t = deleteTimers[ j ];
00217 [ m_holdingTouches removeObject:t ];
00218 [ t invalidate ];
00219 }
00220
00221 NSTimer * timer = [NSTimer scheduledTimerWithTimeInterval:0.05f
00222 target:self
00223 selector:@selector(holdTouch:)
00224 userInfo:to
00225 repeats:YES];
00226
00227 [m_holdingTouches addObject:timer];
00228 }
00229 [ EAGLContext setCurrentContext:m_context ];
00230 getRendergroupIOSGLViewInstance()->touchesBegan( myIndices, myTouches );
00231 }
00232 }
00233
00234 - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
00235 if( getRendergroupIOSGLViewInstance() ){
00236 vector< TouchPoint > myTouches;
00237 vector< TouchIndex > myIndices;
00238 for( int i = 0; i < [[touches allObjects] count]; i++ ){
00239 UITouch *to = [[touches allObjects] objectAtIndex:i];
00240
00241 CGPoint location = [to locationInView:[to view]];
00242 CGPoint previousLocation = [to previousLocationInView:[to view]];
00243 myIndices.push_back( (unsigned long)to );
00244 myTouches.push_back( TouchPoint( Vec2( location.x, location.y ), Vec2( previousLocation.x, previousLocation.y ), [to tapCount], [to timestamp] ) );
00245
00246 vector< NSTimer * > deleteTimers;
00247 for( NSTimer * t in m_holdingTouches ){
00248 if( [ t userInfo ] == to ){
00249 deleteTimers.push_back( t );
00250 }
00251 }
00252
00253 for( unsigned int j = 0; j < deleteTimers.size(); j++ ){
00254 NSTimer * t = deleteTimers[ j ];
00255 [ m_holdingTouches removeObject:t ];
00256 [ t invalidate ];
00257 }
00258
00259 NSTimer * timer = [NSTimer scheduledTimerWithTimeInterval:0.05f
00260 target:self
00261 selector:@selector(holdTouch:)
00262 userInfo:to
00263 repeats:YES];
00264
00265 [m_holdingTouches addObject:timer];
00266 }
00267 [ EAGLContext setCurrentContext:m_context ];
00268 getRendergroupIOSGLViewInstance()->touchesMoved( myIndices, myTouches );
00269 }
00270 }
00271
00272 - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
00273 if( getRendergroupIOSGLViewInstance() ){
00274 vector< TouchPoint > myTouches;
00275 vector< TouchIndex > myIndices;
00276 for( int i = 0; i < [[touches allObjects] count]; i++ ){
00277 UITouch *to = [[touches allObjects] objectAtIndex:i];
00278 CGPoint location = [to locationInView:[to view]];
00279 CGPoint previousLocation = [to previousLocationInView:[to view]];
00280 myIndices.push_back( (unsigned long)to );
00281 myTouches.push_back( TouchPoint( Vec2( location.x, location.y ), Vec2( previousLocation.x, previousLocation.y ), [to tapCount], [to timestamp] ) );
00282
00283 vector< NSTimer * > deleteTimers;
00284 for( NSTimer * t in m_holdingTouches ){
00285 if( [ t userInfo ] == to ){
00286 deleteTimers.push_back( t );
00287 }
00288 }
00289
00290 for( unsigned int j = 0; j < deleteTimers.size(); j++ ){
00291 NSTimer * t = deleteTimers[ j ];
00292 [ m_holdingTouches removeObject:t ];
00293 [ t invalidate ];
00294 }
00295 }
00296 [ EAGLContext setCurrentContext:m_context ];
00297 getRendergroupIOSGLViewInstance()->touchesEnded( myIndices, myTouches );
00298 }
00299 }
00300
00301 - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event{
00302 if( getRendergroupIOSGLViewInstance() ){
00303 vector< TouchPoint > myTouches;
00304 vector< TouchIndex > myIndices;
00305 for( int i = 0; i < [[touches allObjects] count]; i++ ){
00306 UITouch *to = [[touches allObjects] objectAtIndex:i];
00307 CGPoint location = [to locationInView:[to view]];
00308 CGPoint previousLocation = [to previousLocationInView:[to view]];
00309 myIndices.push_back( (unsigned long)to );
00310 myTouches.push_back( TouchPoint( Vec2( location.x, location.y ), Vec2( previousLocation.x, previousLocation.y ), [to tapCount], [to timestamp] ) );
00311
00312 vector< NSTimer * > deleteTimers;
00313 for( NSTimer * t in m_holdingTouches ){
00314 if( [ t userInfo ] == to ){
00315 deleteTimers.push_back( t );
00316 }
00317 }
00318
00319 for( unsigned int j = 0; j < deleteTimers.size(); j++ ){
00320 NSTimer * t = deleteTimers[ j ];
00321 [ m_holdingTouches removeObject:t ];
00322 [ t invalidate ];
00323 }
00324 }
00325 [ EAGLContext setCurrentContext:m_context ];
00326 getRendergroupIOSGLViewInstance()->touchesCancelled( myIndices, myTouches );
00327 }
00328 }
00329
00330 - (void)drawView {
00331
00332
00333 [ EAGLContext setCurrentContext:m_context ];
00334
00335
00336 #ifdef USE_MULTISAMPLING
00337 glBindFramebuffer( GL_FRAMEBUFFER, m_msaaFramebuffer );
00338 glBindRenderbuffer( GL_RENDERBUFFER, m_msaaRenderbuffer );
00339 #else
00340 glBindFramebuffer( GL_FRAMEBUFFER, m_defaultFramebuffer );
00341 glBindRenderbuffer( GL_RENDERBUFFER, m_defaultRenderbuffer );
00342 #endif
00343 getRendergroupIOSGLViewInstance()->onRender();
00344
00345 [ EAGLContext setCurrentContext:m_context ];
00346
00347 #ifdef USE_MULTISAMPLING
00348 glBindFramebuffer( GL_FRAMEBUFFER, m_msaaFramebuffer );
00349 glBindFramebuffer( GL_READ_FRAMEBUFFER_APPLE, m_msaaFramebuffer );
00350 glBindFramebuffer( GL_DRAW_FRAMEBUFFER_APPLE, m_defaultFramebuffer );
00351 glResolveMultisampleFramebufferAPPLE( );
00352 #else
00353 glBindFramebuffer( GL_FRAMEBUFFER, m_defaultFramebuffer );
00354 #endif
00355
00356 glBindRenderbuffer( GL_RENDERBUFFER, m_defaultRenderbuffer );
00357
00358 [ m_context presentRenderbuffer:GL_RENDERBUFFER ];
00359
00360 #ifdef USE_MULTISAMPLING
00361 GLenum attachments[] = { GL_DEPTH_ATTACHMENT_OES, GL_COLOR_ATTACHMENT0_OES };
00362 glDiscardFramebufferEXT( GL_READ_FRAMEBUFFER_APPLE, 2, attachments );
00363 #endif
00364
00365 UIWindow * external = getIOSApplicationExternalWindow();
00366 if( external ){
00367 UIImageView * imageView = [ external.subviews objectAtIndex:0 ];
00368 imageView.image = [ self createFramebufferImage ];
00369 }
00370
00371 Error::assertNoErrors( __FILE__, __LINE__ );
00372
00373 }
00374
00375 - (void)layoutSubviews {
00376 [self drawView];
00377 }
00378
00379 - (void)onTimer {
00380 getRendergroupIOSGLViewInstance()->onTimer();
00381
00382 if( getRendergroupIOSGLViewInstance()->needsUpdate() ){
00384 getRendergroupIOSGLViewInstance()->clearUpdateFlag();
00386 [self drawView];
00387 }
00388 }
00389
00390 - (void)startAnimation {
00391 if( ! m_animating ){
00392 if( m_displayLinkSupported ){
00393 m_displayLink = [ NSClassFromString( @"CADisplayLink" ) displayLinkWithTarget:self selector:@selector(onTimer) ];
00394 [ m_displayLink setFrameInterval:m_animationFrameInterval ];
00395 [ m_displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode ];
00396 }
00397 else{
00398 m_animationTimer = [NSTimer scheduledTimerWithTimeInterval:m_animationFrameInterval target:self selector:@selector(onTimer) userInfo:nil repeats:YES];
00399 }
00400 m_animating = TRUE;
00401 }
00402 }
00403
00404
00405 - (void)stopAnimation {
00406 if( m_animating ){
00407 if( m_displayLinkSupported ){
00408 [ m_displayLink invalidate ];
00409 m_displayLink = nil;
00410 }
00411 else {
00412 [ m_animationTimer invalidate ];
00413 m_animationTimer = nil;
00414 }
00415
00416 m_animating = FALSE;
00417 }
00418 }
00419
00420 - (NSInteger)animationFrameInterval {
00421 return m_animationFrameInterval;
00422 }
00423
00424 - (void)setAnimationTimer:(NSTimer *)newTimer {
00425 [ m_animationTimer invalidate ];
00426 m_animationTimer = newTimer;
00427 }
00428
00429 - (void)setAnimationFrameInterval:(NSInteger)frameInterval {
00430
00431
00432
00433
00434
00435
00436 if( frameInterval >= 1 ){
00437 m_animationFrameInterval = frameInterval;
00438 if( m_animating){
00439 [ self stopAnimation ];
00440 [ self startAnimation ];
00441 }
00442 }
00443 }
00444
00445 - (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
00446 return YES;
00447 }
00448
00449 - (UIImage *)createFramebufferImage {
00450
00451 NSInteger dataLength = m_framebufferWidth * m_framebufferHeight * 4;
00452 GLubyte * data = ( GLubyte * )malloc( dataLength * sizeof( GLubyte ) );
00453
00454 [ EAGLContext setCurrentContext:m_context ];
00455 glBindFramebuffer( GL_FRAMEBUFFER, m_defaultFramebuffer );
00456 glBindRenderbuffer( GL_RENDERBUFFER, m_defaultRenderbuffer );
00457
00458
00459 glPixelStorei( GL_PACK_ALIGNMENT, 4 );
00460 glReadPixels( 0, 0, m_framebufferWidth, m_framebufferHeight, GL_RGBA, GL_UNSIGNED_BYTE, data );
00461
00462
00463
00464
00465 CGDataProviderRef provider = CGDataProviderCreateWithData( NULL, data, dataLength, NULL );
00466 CGColorSpaceRef colorSpaceRef = CGColorSpaceCreateDeviceRGB();
00467 CGBitmapInfo bitmapInfo = kCGBitmapByteOrderDefault;
00468 CGColorRenderingIntent renderingIntent = kCGRenderingIntentDefault;
00469 CGImageRef iRef = CGImageCreate( m_framebufferWidth, m_framebufferHeight, 8, 32, 4 * m_framebufferWidth, colorSpaceRef, bitmapInfo, provider, NULL, NO, renderingIntent );
00470 UIGraphicsBeginImageContext( CGSizeMake( m_framebufferWidth, m_framebufferHeight ) );
00471 CGContextRef cgcontext = UIGraphicsGetCurrentContext();
00472
00473
00474
00475
00476 CGContextSetBlendMode( cgcontext, kCGBlendModeCopy );
00477 CGContextDrawImage( cgcontext, CGRectMake( 0.0, 0.0, m_framebufferWidth, m_framebufferHeight ), iRef );
00478
00479
00480 UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
00481
00482 UIGraphicsEndImageContext();
00483
00484
00485 free( data );
00486 CFRelease( colorSpaceRef );
00487
00488 return image;
00489 }
00490
00491 -( void )saveFramebufferToPhotosAlbum {
00492 UIImage * image = [ self createFramebufferImage ];
00493 UIImageWriteToSavedPhotosAlbum( image, self, @selector(imageSaved: didFinishSavingWithError: contextInfo:), nil );
00494 }
00495
00496 -( void )saveFramebufferToDefault {
00497 UIImage * image = [ self createFramebufferImage ];
00498 NSString * fileName = [ [ NSHomeDirectory() stringByAppendingPathComponent:@"Documents" ] stringByAppendingPathComponent:@"framebuffer.png" ];
00499 [ UIImagePNGRepresentation( image ) writeToFile:fileName atomically:YES ];
00500 }
00501
00502 - (void)imageSaved:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo {
00503 NSString *message;
00504 NSString *title;
00505 if( ! error ){
00506 title = @"Image saved to Photo Library";
00507 message = @"";
00508 } else {
00509 title = @"Error saving Image";
00510 message = [error description];
00511 }
00512 UIAlertView *alert = [[UIAlertView alloc] initWithTitle:title
00513 message:message
00514 delegate:nil
00515 cancelButtonTitle:@"OK"
00516 otherButtonTitles:nil];
00517 [alert show];
00518 [alert release];
00519 }
00520
00521 - (void)loadImage:( NSString * )url {
00522 UIImage * image = [ UIImage imageWithData:[ NSData dataWithContentsOfURL:[ NSURL URLWithString:url ] ] ];
00523 CGImageRef cgImage = image.CGImage;
00524 NSUInteger width = CGImageGetWidth( cgImage );
00525 NSUInteger height = CGImageGetHeight( cgImage );
00526 CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
00527 GLubyte * rawData = ( GLubyte * )malloc( height * width * 4 );
00528 NSUInteger bytesPerRow = 4 * width;
00529 NSUInteger bitsPerComponent = 8;
00530 CGContextRef context = CGBitmapContextCreate( rawData, width, height, bitsPerComponent, bytesPerRow, colorSpace, kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big);
00531 CGContextDrawImage( context, CGRectMake( 0, 0, width, height ), cgImage );
00532
00533
00534 RendergroupPtr group = Rendergroup::getRendergroup( 0 );
00535 if( group ){
00536 SamplerPtr sampler = group->findSampler( "ArtiFlyer" );
00537 if( sampler ){
00539 GLubyte * row = ( GLubyte * )malloc( bytesPerRow );
00540 for( int i = 0; i < height; i++ ){
00541 memcpy( row, & rawData[ i * bytesPerRow ], bytesPerRow );
00542 memcpy( & rawData[ i * bytesPerRow ], & rawData[ ( height - 1 - i ) * bytesPerRow ], bytesPerRow );
00543 memcpy( & rawData[ ( height - 1 - i ) * bytesPerRow ], row, bytesPerRow );
00544 }
00545 free( row );
00546
00547 SamplerPtr sampler = new Sampler( width, height, rawData );
00548 sampler->setName( "ArtiFlyer" );
00549 group->addSampler( sampler );
00550
00551 rendergroupEAGLViewDrawView();
00552 }
00553 }
00554 CGColorSpaceRelease( colorSpace );
00555 CGContextRelease( context );
00556 }
00557
00558 - (void)dealloc {
00559 [self stopAnimation];
00560 if( [EAGLContext currentContext] == m_context ){
00561 [EAGLContext setCurrentContext:nil];
00562 }
00563 [m_context release];
00564 [super dealloc];
00565 }
00566
00567 - (void)quit {
00568 [self stopAnimation];
00569
00570 getRendergroupIOSGLViewInstance()->stopTimer();
00571 getRendergroupIOSGLViewInstance()->onQuit();
00572
00573 [self dealloc];
00574 }
00575
00576 @end
00577
00578 #endif
00579 #endif
00580