Ignore:
Timestamp:
Mar 13, 2011, 1:58:53 AM (10 years ago)
Author:
sam
Message:

ios: clean up code.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/monsterz/ios/classes/EAGLView.m

    r731 r739  
    11//
    2 //  EAGLView.m
    3 //  Monsterz
     2// Monsterz
    43//
    5 //  Created by user on 05.03.11.
    6 //  Copyright 2011 __MyCompanyName__. All rights reserved.
     4// Copyright: (c) 2005-2011 Sam Hocevar <sam@hocevar.net>
     5//   This program is free software; you can redistribute it and/or
     6//   modify it under the terms of the Do What The Fuck You Want To
     7//   Public License, Version 2, as published by Sam Hocevar. See
     8//   http://sam.zoy.org/projects/COPYING.WTFPL for more details.
    79//
    810
     
    2628}
    2729
    28 //The EAGL view is stored in the nib file. When it's unarchived it's sent -initWithCoder:.
     30// The EAGL view is stored in the nib file. When it's unarchived it's sent
     31// -initWithCoder:.
    2932- (id)initWithCoder:(NSCoder*)coder
    3033{
    3134    self = [super initWithCoder:coder];
    32         if (self)
     35    if (self)
    3336    {
    3437        CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer;
    35        
     38
    3639        eaglLayer.opaque = TRUE;
    3740        eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:
     
    4043                                        nil];
    4144    }
    42    
     45
    4346    return self;
    4447}
     
    4649- (void)dealloc
    4750{
    48     [self deleteFramebuffer];   
     51    [self deleteFramebuffer];
    4952    [context release];
    50    
    5153    [super dealloc];
    5254}
     
    6264    {
    6365        [self deleteFramebuffer];
    64        
    6566        [context release];
    6667        context = [newContext retain];
    67        
    6868        [EAGLContext setCurrentContext:nil];
    6969    }
     
    7575    {
    7676        [EAGLContext setCurrentContext:context];
    77        
     77
    7878        // Create default framebuffer object.
    7979        glGenFramebuffers(1, &defaultFramebuffer);
    8080        glBindFramebuffer(GL_FRAMEBUFFER, defaultFramebuffer);
    81        
     81
    8282        // Create color render buffer and allocate backing store.
    8383        glGenRenderbuffers(1, &colorRenderbuffer);
     
    8686        glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, &framebufferWidth);
    8787        glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_HEIGHT, &framebufferHeight);
    88        
     88
    8989        glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, colorRenderbuffer);
    90        
     90
    9191        if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
    9292            NSLog(@"Failed to make complete framebuffer object %x", glCheckFramebufferStatus(GL_FRAMEBUFFER));
     
    9999    {
    100100        [EAGLContext setCurrentContext:context];
    101        
     101
    102102        if (defaultFramebuffer)
    103103        {
     
    105105            defaultFramebuffer = 0;
    106106        }
    107        
     107
    108108        if (colorRenderbuffer)
    109109        {
     
    119119    {
    120120        [EAGLContext setCurrentContext:context];
    121        
     121
    122122        if (!defaultFramebuffer)
    123123            [self createFramebuffer];
    124        
     124
    125125        glBindFramebuffer(GL_FRAMEBUFFER, defaultFramebuffer);
    126        
    127126        glViewport(0, 0, framebufferWidth, framebufferHeight);
    128127    }
     
    132131{
    133132    BOOL success = FALSE;
    134    
     133
    135134    if (context)
    136135    {
    137136        [EAGLContext setCurrentContext:context];
    138        
    139137        glBindRenderbuffer(GL_RENDERBUFFER, colorRenderbuffer);
    140        
    141138        success = [context presentRenderbuffer:GL_RENDERBUFFER];
    142139    }
    143    
     140
    144141    return success;
    145142}
     
    147144- (void)layoutSubviews
    148145{
    149     // The framebuffer will be re-created at the beginning of the next setFramebuffer method call.
     146    // The framebuffer will be re-created at the beginning of the next
     147    // setFramebuffer method call.
    150148    [self deleteFramebuffer];
    151149}
    152150
    153151@end
     152
Note: See TracChangeset for help on using the changeset viewer.