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/MonsterzViewController.mm

    r731 r739  
    11//
    2 //  MonsterzViewController.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
     
    3133- (void)awakeFromNib
    3234{
    33         Ticker::Setup(30.0f);
    34         Video::Setup(320, 480);
    35        
    36         new Interface();
    37         new DebugFps(20, 20);
    38        
     35    Ticker::Setup(30.0f);
     36    Video::Setup(320, 480);
     37
     38    new Interface();
     39    new DebugFps(20, 20);
     40
    3941    EAGLContext *aContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1];
    4042    if (!aContext)
     
    4244    else if (![EAGLContext setCurrentContext:aContext])
    4345        NSLog(@"Failed to set ES context current");
    44    
    45         self.context = aContext;
    46         [aContext release];
    47        
     46
     47    self.context = aContext;
     48    [aContext release];
     49
    4850    [(EAGLView *)self.view setContext:context];
    4951    [(EAGLView *)self.view setFramebuffer];
    50    
     52
    5153    animating = FALSE;
    5254    animationFrameInterval = 1;
     
    5961    if ([EAGLContext currentContext] == context)
    6062        [EAGLContext setCurrentContext:nil];
    61    
     63
    6264    [context release];
    63    
    6465    [super dealloc];
    6566}
     
    6869{
    6970    [self startAnimation];
    70    
    7171    [super viewWillAppear:animated];
    7272}
     
    7575{
    7676    [self stopAnimation];
    77    
    7877    [super viewWillDisappear:animated];
    7978}
     
    8180- (void)viewDidUnload
    8281{
    83         [super viewDidUnload];
     82    [super viewDidUnload];
    8483
    8584    // Tear down context.
    8685    if ([EAGLContext currentContext] == context)
    8786        [EAGLContext setCurrentContext:nil];
    88         self.context = nil;     
     87    self.context = nil;
    8988}
    9089
     
    9695- (void)setAnimationFrameInterval:(NSInteger)frameInterval
    9796{
    98     /*
    99          Frame interval defines how many display frames must pass between each time the display link fires.
    100          The display link will only fire 30 times a second when the frame internal is two on a display that refreshes 60 times a second. The default frame interval setting of one will fire 60 times a second when the display refreshes at 60 times a second. A frame interval setting of less than one results in undefined behavior.
    101          */
     97    /* Frame interval defines how many display frames must pass between each
     98     * time the display link fires. The display link will only fire 30 times
     99     * a second when the frame internal is two on a display that refreshes
     100     * 60 times a second. The default frame interval setting of one will
     101     * fire 60 times a second when the display refreshes at 60 times a
     102     * second. A frame interval setting of less than one results in undefined
     103     * behavior. */
    102104    if (frameInterval >= 1)
    103105    {
    104106        animationFrameInterval = frameInterval;
    105        
     107
    106108        if (animating)
    107109        {
     
    120122        [aDisplayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
    121123        self.displayLink = aDisplayLink;
    122        
     124
    123125        animating = TRUE;
    124126    }
     
    138140{
    139141    [(EAGLView *)self.view setFramebuffer];
    140    
    141         Ticker::ClampFps();
    142         Ticker::TickGame();
    143         Ticker::TickDraw();
    144 
     142    Ticker::ClampFps();
     143    Ticker::TickGame();
     144    Ticker::TickDraw();
    145145    [(EAGLView *)self.view presentFramebuffer];
    146146}
     
    150150    // Releases the view if it doesn't have a superview.
    151151    [super didReceiveMemoryWarning];
    152    
    153152    // Release any cached data, images, etc. that aren't in use.
    154153}
    155154
    156155@end
     156
Note: See TracChangeset for help on using the changeset viewer.