annotate src/video/uikit/SDL_uikitopenglview.m @ 5148:2f44e6969a59

Split the rendering API out into a separate header file.
author Sam Lantinga <slouken@libsdl.org>
date Tue, 01 Feb 2011 15:02:21 -0800
parents 5f09cb749d75
children 115fff0641ee
rev   line source
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1 /*
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
2859
99210400e8b9 Updated copyright date
Sam Lantinga <slouken@libsdl.org>
parents: 2765
diff changeset
3 Copyright (C) 1997-2009 Sam Lantinga
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
6 modify it under the terms of the GNU Lesser General Public
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
8 version 2.1 of the License, or (at your option) any later version.
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
9
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
13 Lesser General Public License for more details.
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
14
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
15 You should have received a copy of the GNU Lesser General Public
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
16 License along with this library; if not, write to the Free Software
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
18
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
19 Sam Lantinga
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
20 slouken@libsdl.org
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
21 */
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
22
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
23 #import <QuartzCore/QuartzCore.h>
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
24 #import <OpenGLES/EAGLDrawable.h>
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
25 #import "SDL_uikitopenglview.h"
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
26
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
27 @interface SDL_uikitopenglview (privateMethods)
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
28
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
29 - (BOOL) createFramebuffer;
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
30 - (void) destroyFramebuffer;
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
31
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
32 @end
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
33
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
34
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
35 @implementation SDL_uikitopenglview
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
36
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
37 @synthesize context;
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
38
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
39 + (Class)layerClass {
5132
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
40 return [CAEAGLLayer class];
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
41 }
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
42
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
43 - (id)initWithFrame:(CGRect)frame \
5132
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
44 retainBacking:(BOOL)retained \
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
45 rBits:(int)rBits \
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
46 gBits:(int)gBits \
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
47 bBits:(int)bBits \
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
48 aBits:(int)aBits \
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
49 depthBits:(int)depthBits \
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
50 {
5132
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
51 NSString *colorFormat=nil;
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
52 GLuint depthBufferFormat;
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
53 BOOL useDepthBuffer;
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
54
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
55 if (rBits == 8 && gBits == 8 && bBits == 8) {
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
56 /* if user specifically requests rbg888 or some color format higher than 16bpp */
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
57 colorFormat = kEAGLColorFormatRGBA8;
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
58 }
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
59 else {
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
60 /* default case (faster) */
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
61 colorFormat = kEAGLColorFormatRGB565;
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
62 }
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
63
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
64 if (depthBits == 24) {
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
65 useDepthBuffer = YES;
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
66 depthBufferFormat = GL_DEPTH_COMPONENT24_OES;
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
67 }
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
68 else if (depthBits == 0) {
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
69 useDepthBuffer = NO;
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
70 }
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
71 else {
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
72 /* default case when depth buffer is not disabled */
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
73 /*
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
74 strange, even when we use this, we seem to get a 24 bit depth buffer on iPhone.
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
75 perhaps that's the only depth format iPhone actually supports
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
76 */
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
77 useDepthBuffer = YES;
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
78 depthBufferFormat = GL_DEPTH_COMPONENT16_OES;
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
79 }
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
80
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
81 if ((self = [super initWithFrame:frame])) {
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
82 // Get the layer
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
83 CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer;
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
84
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
85 eaglLayer.opaque = YES;
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
86 eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
87 [NSNumber numberWithBool: retained], kEAGLDrawablePropertyRetainedBacking, colorFormat, kEAGLDrawablePropertyColorFormat, nil];
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
88
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
89 context = [[EAGLContext alloc] initWithAPI: kEAGLRenderingAPIOpenGLES1];
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
90
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
91 if (!context || ![EAGLContext setCurrentContext:context]) {
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
92 [self release];
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
93 return nil;
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
94 }
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
95
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
96 /* create the buffers */
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
97 glGenFramebuffersOES(1, &viewFramebuffer);
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
98 glGenRenderbuffersOES(1, &viewRenderbuffer);
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
99
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
100 glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer);
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
101 glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
102 [context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(CAEAGLLayer*)self.layer];
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
103 glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, viewRenderbuffer);
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
104
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
105 glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth);
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
106 glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight);
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
107
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
108 if (useDepthBuffer) {
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
109 glGenRenderbuffersOES(1, &depthRenderbuffer);
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
110 glBindRenderbufferOES(GL_RENDERBUFFER_OES, depthRenderbuffer);
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
111 glRenderbufferStorageOES(GL_RENDERBUFFER_OES, depthBufferFormat, backingWidth, backingHeight);
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
112 glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, depthRenderbuffer);
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
113 }
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
114
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
115 if(glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES) {
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
116 return NO;
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
117 }
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
118 /* end create buffers */
5133
ec13e48ee0d9 Fixed bug #1112 (retina display support)
Sam Lantinga <slouken@libsdl.org>
parents: 5132
diff changeset
119
ec13e48ee0d9 Fixed bug #1112 (retina display support)
Sam Lantinga <slouken@libsdl.org>
parents: 5132
diff changeset
120 /* Use the main screen scale (for retina display support) */
ec13e48ee0d9 Fixed bug #1112 (retina display support)
Sam Lantinga <slouken@libsdl.org>
parents: 5132
diff changeset
121 if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)])
ec13e48ee0d9 Fixed bug #1112 (retina display support)
Sam Lantinga <slouken@libsdl.org>
parents: 5132
diff changeset
122 self.contentScaleFactor = [UIScreen mainScreen].scale;
5132
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
123 }
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
124 return self;
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
125 }
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
126
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
127 - (void)setCurrentContext {
5132
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
128 [EAGLContext setCurrentContext:context];
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
129 }
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
130
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
131
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
132 - (void)swapBuffers {
5132
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
133 glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
134 [context presentRenderbuffer:GL_RENDERBUFFER_OES];
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
135 }
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
136
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
137
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
138 - (void)layoutSubviews {
5132
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
139 [EAGLContext setCurrentContext:context];
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
140 }
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
141
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
142 - (void)destroyFramebuffer {
5132
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
143 glDeleteFramebuffersOES(1, &viewFramebuffer);
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
144 viewFramebuffer = 0;
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
145 glDeleteRenderbuffersOES(1, &viewRenderbuffer);
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
146 viewRenderbuffer = 0;
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
147
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
148 if (depthRenderbuffer) {
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
149 glDeleteRenderbuffersOES(1, &depthRenderbuffer);
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
150 depthRenderbuffer = 0;
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
151 }
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
152 }
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
153
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
154
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
155 - (void)dealloc {
5132
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
156 [self destroyFramebuffer];
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
157 if ([EAGLContext currentContext] == context) {
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
158 [EAGLContext setCurrentContext:nil];
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
159 }
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
160 [context release];
5690ebc772c7 Fixed spacing
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
161 [super dealloc];
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
162 }
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
163
2859
99210400e8b9 Updated copyright date
Sam Lantinga <slouken@libsdl.org>
parents: 2765
diff changeset
164 @end
5135
5f09cb749d75 Added vim spacing hints
Sam Lantinga <slouken@libsdl.org>
parents: 5133
diff changeset
165
5f09cb749d75 Added vim spacing hints
Sam Lantinga <slouken@libsdl.org>
parents: 5133
diff changeset
166 /* vi: set ts=4 sw=4 expandtab: */