RSS

(root)/iphone/common : 73 : 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 23:18:22
Revision ID: dognotdog@gmail.com-20100810211822-dr963e78lkbsk96c
now allows variable format for vertex arrays; fixes bug with shared VAs not being properly initialized; adds method to remove normals from VA, to save memory and bandwidth; adds some threading fixes in GLESView, as well as more thorough state management

Show diffs side-by-side

added added

removed removed

87
87
 
88
88
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
89
89
 
 
90
        glBindTexture(GL_TEXTURE_2D, 0);
 
91
 
90
92
        free(spriteData);
91
93
}
92
94
 
122
124
 
123
125
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
124
126
 
 
127
        glBindTexture(GL_TEXTURE_2D, 0);
 
128
 
125
129
        free(spriteData);
126
130
}
127
131
 
154
158
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, doFilter ? (doMipmap ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR) : GL_NEAREST);
155
159
 
156
160
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, doFilter ? GL_LINEAR : GL_NEAREST);
 
161
        
 
162
        glBindTexture(GL_TEXTURE_2D, 0);
157
163
}
158
164
 
159
165
- (void) loadTextureFromBitmapNamed: (NSString*) name texName: (GLuint*) texname repeat: (BOOL) doRepeat mipmap: (BOOL) doMipmap filter: (BOOL) doFilter
310
316
{
311
317
    [self stopAnimation];
312
318
        
313
 
        [VertexArray releaseSharedObjects];
 
319
//      [VertexArray releaseSharedObjects];
314
320
    
315
321
    if ([EAGLContext currentContext] == context)
316
 
        [EAGLContext setCurrentContext:nil];
 
322
        [EAGLContext setCurrentContext: nil];
317
323
    
318
324
    [context release];  
319
325
    [super dealloc];
366
372
{
367
373
        [super drawRect: rect];
368
374
        
369
 
        [self drawView];
 
375
//      [self drawView];
370
376
 
371
377
//      [[UIColor clearColor] set];
372
378
//      UIRectFill(rect);
379
385
 
380
386
- (void) displayLinkCallback: (CADisplayLink*) sender
381
387
{
382
 
        @synchronized(self)
383
 
        {
384
 
                if (displayThread && [displayThread isCancelled])
385
 
                {
386
 
                        [displayLink invalidate];
387
 
                        displayLink = nil;
388
 
                        
389
 
                        CFRunLoopStop([[NSRunLoop currentRunLoop] getCFRunLoop]);
390
 
                        
391
 
                        return;
392
 
                }
393
 
        }
394
 
 
395
388
        [self animationCallback];
396
389
}
397
390
 
407
400
                [displayLink addToRunLoop: [NSRunLoop currentRunLoop] forMode: NSRunLoopCommonModes];
408
401
        }
409
402
        
410
 
        [runLoop run];
 
403
        while (displayThreadShouldRun)
 
404
        {
 
405
                NSAutoreleasePool* pool2 = [[NSAutoreleasePool alloc] init];
 
406
                [runLoop runUntilDate: [NSDate dateWithTimeIntervalSinceNow: 1.0]];
 
407
                [pool2 drain];
 
408
        }
 
409
        
 
410
        @synchronized(self)
 
411
        {
 
412
                [displayLink invalidate];
 
413
                displayLink = nil;
 
414
        }
411
415
        
412
416
        [EAGLContext setCurrentContext: nil];
413
417
        
414
418
        [pool drain];
 
419
//      [NSThread exit];
415
420
}
416
421
 
417
422
- (void)startAnimation: (BOOL) threaded
422
427
 
423
428
                if (threaded)
424
429
                {
 
430
                        displayThreadShouldRun = YES;
425
431
                        displayThread = [[NSThread alloc] initWithTarget: self selector: @selector(displayThreadMain:) object: nil];
426
432
                        
427
433
                        [displayThread start];
442
448
        {
443
449
                [displayLink invalidate];
444
450
                displayLink = nil;
445
 
                
446
 
                if (displayThread)
 
451
        }
 
452
        if (displayThread)
 
453
        {
 
454
                displayThreadShouldRun = NO;
 
455
                while ([displayThread isExecuting])
 
456
                        usleep(1);
 
457
                @synchronized(self)
447
458
                {
448
 
                        [displayThread cancel];
449
 
                        while (![displayThread isFinished])
450
 
                                usleep(0);
451
459
                        [displayThread release];
452
460
                        displayThread = nil;
453
461
                }
483
491
                NSLog(@"%f %f %f %f", self.frame.origin.x, self.frame.origin.y, self.frame.size.width, self.frame.size.height);
484
492
        return NO;
485
493
    }
486
 
    
 
494
 
 
495
    glBindRenderbuffer(GL_RENDERBUFFER, 0);
 
496
    glBindFramebuffer(GL_FRAMEBUFFER, 0);
 
497
 
487
498
    return YES;
488
499
}
489
500
 

Loggerhead 1.17 is a web-based interface for Bazaar branches