RSS

(root)/iphone/common : 72 : 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-10 13:23:54
Revision ID: dognotdog@gmail.com-20100810112354-tculp6ef6iscoybl
introduces sharegroup and shared context for all GLESView instances

Show diffs side-by-side

added added

removed removed

55
55
- (BOOL) createFramebuffer;
56
56
@end
57
57
 
58
 
 
 
58
static EAGLContext* _sharedContext = nil;
59
59
 
60
60
@implementation GLESView
61
61
 
216
216
}
217
217
 
218
218
 
 
219
+ (EAGLSharegroup*) glSharegroup
 
220
{
 
221
        assert([NSThread isMainThread]);
 
222
 
 
223
        if (!_sharedContext)
 
224
        {
 
225
                _sharedContext = [[EAGLContext alloc] initWithAPI: kEAGLRenderingAPIOpenGLES2];
 
226
                if (!_sharedContext)
 
227
                        _sharedContext = [[EAGLContext alloc] initWithAPI: kEAGLRenderingAPIOpenGLES1];
 
228
        }
 
229
        return [_sharedContext sharegroup];
 
230
}
 
231
 
219
232
- (void) loadTextureFromPDFNamed: (NSString*) name texName: (GLuint*) texname width: (size_t) width height: (size_t) height repeat: (BOOL) doRepeat mipmap: (BOOL) doMipmap filter: (BOOL) doFilter
220
233
{
221
234
 
236
249
        eaglLayer.opaque = YES;
237
250
        eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithBool:NO], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil];
238
251
        
239
 
        context = [[EAGLContext alloc] initWithAPI: kEAGLRenderingAPIOpenGLES2];
 
252
        context = [[EAGLContext alloc] initWithAPI: kEAGLRenderingAPIOpenGLES2 sharegroup: [GLESView glSharegroup]];
240
253
        if (!context)
241
 
                context = [[EAGLContext alloc] initWithAPI: kEAGLRenderingAPIOpenGLES1];
 
254
                context = [[EAGLContext alloc] initWithAPI: kEAGLRenderingAPIOpenGLES1 sharegroup: [GLESView glSharegroup]];
242
255
        
243
256
        if (!context || ![EAGLContext setCurrentContext: context])
244
257
        {
396
409
        
397
410
        [runLoop run];
398
411
        
 
412
        [EAGLContext setCurrentContext: nil];
 
413
        
399
414
        [pool drain];
400
415
}
401
416
 
454
469
    glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, &backingWidth);
455
470
    glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_HEIGHT, &backingHeight);
456
471
    
457
 
    if (USE_DEPTH_BUFFER) {
 
472
    if (USE_DEPTH_BUFFER)
 
473
        {
458
474
        glGenRenderbuffers(1, &depthRenderbuffer);
459
475
        glBindRenderbuffer(GL_RENDERBUFFER, depthRenderbuffer);
460
476
        glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, backingWidth, backingHeight);
472
488
}
473
489
 
474
490
 
475
 
- (void)destroyFramebuffer {
 
491
- (void) destroyFramebuffer
 
492
{
476
493
    
477
494
    glDeleteFramebuffers(1, &viewFramebuffer);
478
495
    viewFramebuffer = 0;

Loggerhead 1.17 is a web-based interface for Bazaar branches