RSS

(root)/iphone/common : 70 : source/GLESView.m

To get this branch, use:
bzr branch /browse/iphone/common

« back to all changes in this revision

Viewing changes to source/GLESView.m

Dömötör Gulyás
2010-08-08 17:59:45
Revision ID: dognotdog@gmail.com-20100808155945-d5p1gehk7jjd3dzo
adds method to free VertexArray resources for shared objects; changes +sharedQuad to have the tex coords rightside up; adds support for VAO on hardware supporting it; changes GLESView animation to be driven by CADisplayLink; ES2Shader can now set arbitrarily named uniforms in shaders, also gets better error checking

Show diffs side-by-side

added added

removed removed

237
237
                [self release];
238
238
                return nil;
239
239
        }
240
 
        
241
 
        animationInterval = 1.0 / 100.0;
242
 
                
 
240
                        
 
241
        osVersion = [[[UIDevice currentDevice] systemVersion] floatValue];
 
242
 
243
243
        [self setupGraphicsForApi: [context API]];
244
244
 
245
245
    return self;
264
264
                [self release];
265
265
                return nil;
266
266
        }
 
267
                
 
268
        osVersion = [[[UIDevice currentDevice] systemVersion] floatValue];
267
269
        
268
 
        animationInterval = 1.0 / 100.0;
 
270
 
269
271
                
270
272
        [self setupGraphicsForApi: [context API]];
271
273
 
276
278
 
277
279
- (void) setupGraphicsForApi: (EAGLRenderingAPI) glApi
278
280
{
 
281
 
279
282
        glClearColor(0.0,0.0,1.0,1.0);
280
283
}
281
284
 
283
286
- (void)dealloc 
284
287
{
285
288
    [self stopAnimation];
 
289
        
 
290
        [VertexArray releaseSharedObjects];
286
291
    
287
292
    if ([EAGLContext currentContext] == context)
288
293
        [EAGLContext setCurrentContext:nil];
304
309
 
305
310
- (void) finishViewDrawing
306
311
{
 
312
 
 
313
        if (osVersion >= 4.0)
 
314
        {
 
315
                GLenum attachments[] = {GL_DEPTH_ATTACHMENT};
 
316
                glDiscardFramebufferEXT(GL_READ_FRAMEBUFFER_APPLE, 1, attachments);
 
317
        }
 
318
 
307
319
        glBindRenderbuffer(GL_RENDERBUFFER, viewRenderbuffer);
308
320
    [context presentRenderbuffer: GL_RENDERBUFFER];
309
321
        
332
344
 
333
345
- (void)animationCallback
334
346
{
335
 
 
336
 
}
337
 
 
 
347
}
 
348
 
 
349
 
 
350
- (void) displayLinkCallback: (CADisplayLink*) sender
 
351
{
 
352
        [self animationCallback];
 
353
}
338
354
 
339
355
- (void)startAnimation
340
356
{
341
 
    animationTimer = [NSTimer scheduledTimerWithTimeInterval:animationInterval target:self selector:@selector(animationCallback) userInfo:nil repeats:YES];
 
357
        [displayLink invalidate];
 
358
        displayLink = [CADisplayLink displayLinkWithTarget: self selector: @selector(displayLinkCallback:)];
 
359
        [displayLink addToRunLoop: [NSRunLoop currentRunLoop] forMode: NSRunLoopCommonModes];
 
360
 
342
361
}
343
362
 
344
363
 
345
364
- (void)stopAnimation
346
365
{
347
 
    animationTimer = nil;
348
 
}
349
 
 
350
 
 
351
 
- (void)setAnimationTimer:(NSTimer *)newTimer
352
 
{
353
 
    [animationTimer invalidate];
354
 
    animationTimer = newTimer;
355
 
}
356
 
 
357
 
 
358
 
- (void)setAnimationInterval:(NSTimeInterval)interval
359
 
{
360
 
    
361
 
    animationInterval = interval;
362
 
    if (animationTimer) {
363
 
        [self stopAnimation];
364
 
        [self startAnimation];
365
 
    }
 
366
        [displayLink invalidate];
 
367
        displayLink = nil;
366
368
}
367
369
 
368
370
 

Loggerhead 1.17 is a web-based interface for Bazaar branches