author | Sam Lantinga <slouken@libsdl.org> |
Fri, 08 Apr 2011 13:03:26 -0700 | |
changeset 5535 | 96594ac5fd1a |
parent 5527 | 9a03d2300486 |
child 6001 | 3ae3d1e58d59 |
permissions | -rw-r--r-- |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 |
/* |
5535
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5527
diff
changeset
|
2 |
Simple DirectMedia Layer |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5527
diff
changeset
|
3 |
Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org> |
5262 | 4 |
|
5535
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5527
diff
changeset
|
5 |
This software is provided 'as-is', without any express or implied |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5527
diff
changeset
|
6 |
warranty. In no event will the authors be held liable for any damages |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5527
diff
changeset
|
7 |
arising from the use of this software. |
5262 | 8 |
|
5535
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5527
diff
changeset
|
9 |
Permission is granted to anyone to use this software for any purpose, |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5527
diff
changeset
|
10 |
including commercial applications, and to alter it and redistribute it |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5527
diff
changeset
|
11 |
freely, subject to the following restrictions: |
5262 | 12 |
|
5535
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5527
diff
changeset
|
13 |
1. The origin of this software must not be misrepresented; you must not |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5527
diff
changeset
|
14 |
claim that you wrote the original software. If you use this software |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5527
diff
changeset
|
15 |
in a product, an acknowledgment in the product documentation would be |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5527
diff
changeset
|
16 |
appreciated but is not required. |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5527
diff
changeset
|
17 |
2. Altered source versions must be plainly marked as such, and must not be |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5527
diff
changeset
|
18 |
misrepresented as being the original software. |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5527
diff
changeset
|
19 |
3. This notice may not be removed or altered from any source distribution. |
5262 | 20 |
*/ |
2765
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 |
#import <QuartzCore/QuartzCore.h> |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
23 |
#import <OpenGLES/EAGLDrawable.h> |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
24 |
#import "SDL_uikitopenglview.h" |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
25 |
|
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
26 |
@interface SDL_uikitopenglview (privateMethods) |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
27 |
|
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
28 |
- (BOOL) createFramebuffer; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
29 |
- (void) destroyFramebuffer; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
30 |
|
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
31 |
@end |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
32 |
|
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 |
@implementation SDL_uikitopenglview |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
35 |
|
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
36 |
@synthesize context; |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
37 |
|
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
38 |
+ (Class)layerClass { |
5129 | 39 |
return [CAEAGLLayer class]; |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
40 |
} |
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 |
- (id)initWithFrame:(CGRect)frame \ |
5129 | 43 |
retainBacking:(BOOL)retained \ |
44 |
rBits:(int)rBits \ |
|
45 |
gBits:(int)gBits \ |
|
46 |
bBits:(int)bBits \ |
|
47 |
aBits:(int)aBits \ |
|
48 |
depthBits:(int)depthBits \ |
|
5209
115fff0641ee
Prefer the OpenGL ES 2.0 context when it's available, make it possible to create an OpenGL 2.0 context on iPhoneOS
Sam Lantinga <slouken@libsdl.org>
parents:
5132
diff
changeset
|
49 |
majorVersion:(int)majorVersion \ |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
50 |
{ |
5129 | 51 |
NSString *colorFormat=nil; |
52 |
BOOL useDepthBuffer; |
|
53 |
||
54 |
if (rBits == 8 && gBits == 8 && bBits == 8) { |
|
55 |
/* if user specifically requests rbg888 or some color format higher than 16bpp */ |
|
56 |
colorFormat = kEAGLColorFormatRGBA8; |
|
57 |
} |
|
58 |
else { |
|
59 |
/* default case (faster) */ |
|
60 |
colorFormat = kEAGLColorFormatRGB565; |
|
61 |
} |
|
62 |
||
5527
9a03d2300486
iOS: Correctly resize renderbuffers when rotating orientation.
Ryan C. Gordon <icculus@icculus.org>
parents:
5520
diff
changeset
|
63 |
depthBufferFormat = 0; |
9a03d2300486
iOS: Correctly resize renderbuffers when rotating orientation.
Ryan C. Gordon <icculus@icculus.org>
parents:
5520
diff
changeset
|
64 |
|
5129 | 65 |
if (depthBits == 24) { |
66 |
useDepthBuffer = YES; |
|
67 |
depthBufferFormat = GL_DEPTH_COMPONENT24_OES; |
|
68 |
} |
|
69 |
else if (depthBits == 0) { |
|
70 |
useDepthBuffer = NO; |
|
71 |
} |
|
72 |
else { |
|
73 |
/* default case when depth buffer is not disabled */ |
|
74 |
/* |
|
75 |
strange, even when we use this, we seem to get a 24 bit depth buffer on iPhone. |
|
76 |
perhaps that's the only depth format iPhone actually supports |
|
77 |
*/ |
|
78 |
useDepthBuffer = YES; |
|
79 |
depthBufferFormat = GL_DEPTH_COMPONENT16_OES; |
|
80 |
} |
|
81 |
||
82 |
if ((self = [super initWithFrame:frame])) { |
|
83 |
// Get the layer |
|
84 |
CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer; |
|
85 |
||
86 |
eaglLayer.opaque = YES; |
|
87 |
eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys: |
|
88 |
[NSNumber numberWithBool: retained], kEAGLDrawablePropertyRetainedBacking, colorFormat, kEAGLDrawablePropertyColorFormat, nil]; |
|
89 |
||
5209
115fff0641ee
Prefer the OpenGL ES 2.0 context when it's available, make it possible to create an OpenGL 2.0 context on iPhoneOS
Sam Lantinga <slouken@libsdl.org>
parents:
5132
diff
changeset
|
90 |
if (majorVersion > 1) { |
115fff0641ee
Prefer the OpenGL ES 2.0 context when it's available, make it possible to create an OpenGL 2.0 context on iPhoneOS
Sam Lantinga <slouken@libsdl.org>
parents:
5132
diff
changeset
|
91 |
context = [[EAGLContext alloc] initWithAPI: kEAGLRenderingAPIOpenGLES2]; |
115fff0641ee
Prefer the OpenGL ES 2.0 context when it's available, make it possible to create an OpenGL 2.0 context on iPhoneOS
Sam Lantinga <slouken@libsdl.org>
parents:
5132
diff
changeset
|
92 |
} else { |
115fff0641ee
Prefer the OpenGL ES 2.0 context when it's available, make it possible to create an OpenGL 2.0 context on iPhoneOS
Sam Lantinga <slouken@libsdl.org>
parents:
5132
diff
changeset
|
93 |
context = [[EAGLContext alloc] initWithAPI: kEAGLRenderingAPIOpenGLES1]; |
115fff0641ee
Prefer the OpenGL ES 2.0 context when it's available, make it possible to create an OpenGL 2.0 context on iPhoneOS
Sam Lantinga <slouken@libsdl.org>
parents:
5132
diff
changeset
|
94 |
} |
5129 | 95 |
if (!context || ![EAGLContext setCurrentContext:context]) { |
96 |
[self release]; |
|
97 |
return nil; |
|
98 |
} |
|
99 |
||
100 |
/* create the buffers */ |
|
101 |
glGenFramebuffersOES(1, &viewFramebuffer); |
|
102 |
glGenRenderbuffersOES(1, &viewRenderbuffer); |
|
103 |
||
104 |
glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer); |
|
105 |
glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer); |
|
106 |
[context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(CAEAGLLayer*)self.layer]; |
|
107 |
glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, viewRenderbuffer); |
|
108 |
||
109 |
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth); |
|
110 |
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight); |
|
5527
9a03d2300486
iOS: Correctly resize renderbuffers when rotating orientation.
Ryan C. Gordon <icculus@icculus.org>
parents:
5520
diff
changeset
|
111 |
|
5129 | 112 |
if (useDepthBuffer) { |
113 |
glGenRenderbuffersOES(1, &depthRenderbuffer); |
|
114 |
glBindRenderbufferOES(GL_RENDERBUFFER_OES, depthRenderbuffer); |
|
115 |
glRenderbufferStorageOES(GL_RENDERBUFFER_OES, depthBufferFormat, backingWidth, backingHeight); |
|
116 |
glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, depthRenderbuffer); |
|
117 |
} |
|
118 |
||
119 |
if(glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES) { |
|
120 |
return NO; |
|
121 |
} |
|
122 |
/* end create buffers */ |
|
5130
ec13e48ee0d9
Fixed bug #1112 (retina display support)
Sam Lantinga <slouken@libsdl.org>
parents:
5129
diff
changeset
|
123 |
|
5520
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5262
diff
changeset
|
124 |
// !!! FIXME: use the screen this is on! |
5130
ec13e48ee0d9
Fixed bug #1112 (retina display support)
Sam Lantinga <slouken@libsdl.org>
parents:
5129
diff
changeset
|
125 |
/* Use the main screen scale (for retina display support) */ |
ec13e48ee0d9
Fixed bug #1112 (retina display support)
Sam Lantinga <slouken@libsdl.org>
parents:
5129
diff
changeset
|
126 |
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) |
ec13e48ee0d9
Fixed bug #1112 (retina display support)
Sam Lantinga <slouken@libsdl.org>
parents:
5129
diff
changeset
|
127 |
self.contentScaleFactor = [UIScreen mainScreen].scale; |
5520
09b500e0656d
Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents:
5262
diff
changeset
|
128 |
|
5527
9a03d2300486
iOS: Correctly resize renderbuffers when rotating orientation.
Ryan C. Gordon <icculus@icculus.org>
parents:
5520
diff
changeset
|
129 |
self.autoresizingMask = 0; // don't allow autoresize, since we need to do some magic in -(void)updateFrame. |
5129 | 130 |
} |
131 |
return self; |
|
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
132 |
} |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
133 |
|
5527
9a03d2300486
iOS: Correctly resize renderbuffers when rotating orientation.
Ryan C. Gordon <icculus@icculus.org>
parents:
5520
diff
changeset
|
134 |
- (void)updateFrame { |
9a03d2300486
iOS: Correctly resize renderbuffers when rotating orientation.
Ryan C. Gordon <icculus@icculus.org>
parents:
5520
diff
changeset
|
135 |
glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer); |
9a03d2300486
iOS: Correctly resize renderbuffers when rotating orientation.
Ryan C. Gordon <icculus@icculus.org>
parents:
5520
diff
changeset
|
136 |
glBindRenderbufferOES(GL_RENDERBUFFER_OES, 0); |
9a03d2300486
iOS: Correctly resize renderbuffers when rotating orientation.
Ryan C. Gordon <icculus@icculus.org>
parents:
5520
diff
changeset
|
137 |
glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, 0); |
9a03d2300486
iOS: Correctly resize renderbuffers when rotating orientation.
Ryan C. Gordon <icculus@icculus.org>
parents:
5520
diff
changeset
|
138 |
glDeleteRenderbuffersOES(1, &viewRenderbuffer); |
9a03d2300486
iOS: Correctly resize renderbuffers when rotating orientation.
Ryan C. Gordon <icculus@icculus.org>
parents:
5520
diff
changeset
|
139 |
|
9a03d2300486
iOS: Correctly resize renderbuffers when rotating orientation.
Ryan C. Gordon <icculus@icculus.org>
parents:
5520
diff
changeset
|
140 |
glGenRenderbuffersOES(1, &viewRenderbuffer); |
9a03d2300486
iOS: Correctly resize renderbuffers when rotating orientation.
Ryan C. Gordon <icculus@icculus.org>
parents:
5520
diff
changeset
|
141 |
glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer); |
9a03d2300486
iOS: Correctly resize renderbuffers when rotating orientation.
Ryan C. Gordon <icculus@icculus.org>
parents:
5520
diff
changeset
|
142 |
[context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(CAEAGLLayer*)self.layer]; |
9a03d2300486
iOS: Correctly resize renderbuffers when rotating orientation.
Ryan C. Gordon <icculus@icculus.org>
parents:
5520
diff
changeset
|
143 |
glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, viewRenderbuffer); |
9a03d2300486
iOS: Correctly resize renderbuffers when rotating orientation.
Ryan C. Gordon <icculus@icculus.org>
parents:
5520
diff
changeset
|
144 |
|
9a03d2300486
iOS: Correctly resize renderbuffers when rotating orientation.
Ryan C. Gordon <icculus@icculus.org>
parents:
5520
diff
changeset
|
145 |
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth); |
9a03d2300486
iOS: Correctly resize renderbuffers when rotating orientation.
Ryan C. Gordon <icculus@icculus.org>
parents:
5520
diff
changeset
|
146 |
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight); |
9a03d2300486
iOS: Correctly resize renderbuffers when rotating orientation.
Ryan C. Gordon <icculus@icculus.org>
parents:
5520
diff
changeset
|
147 |
|
9a03d2300486
iOS: Correctly resize renderbuffers when rotating orientation.
Ryan C. Gordon <icculus@icculus.org>
parents:
5520
diff
changeset
|
148 |
if (depthRenderbuffer != 0) { |
9a03d2300486
iOS: Correctly resize renderbuffers when rotating orientation.
Ryan C. Gordon <icculus@icculus.org>
parents:
5520
diff
changeset
|
149 |
glBindRenderbufferOES(GL_RENDERBUFFER_OES, depthRenderbuffer); |
9a03d2300486
iOS: Correctly resize renderbuffers when rotating orientation.
Ryan C. Gordon <icculus@icculus.org>
parents:
5520
diff
changeset
|
150 |
glRenderbufferStorageOES(GL_RENDERBUFFER_OES, depthBufferFormat, backingWidth, backingHeight); |
9a03d2300486
iOS: Correctly resize renderbuffers when rotating orientation.
Ryan C. Gordon <icculus@icculus.org>
parents:
5520
diff
changeset
|
151 |
} |
9a03d2300486
iOS: Correctly resize renderbuffers when rotating orientation.
Ryan C. Gordon <icculus@icculus.org>
parents:
5520
diff
changeset
|
152 |
|
9a03d2300486
iOS: Correctly resize renderbuffers when rotating orientation.
Ryan C. Gordon <icculus@icculus.org>
parents:
5520
diff
changeset
|
153 |
// !!! FIXME: use the screen this is on! |
9a03d2300486
iOS: Correctly resize renderbuffers when rotating orientation.
Ryan C. Gordon <icculus@icculus.org>
parents:
5520
diff
changeset
|
154 |
/* Use the main screen scale (for retina display support) */ |
9a03d2300486
iOS: Correctly resize renderbuffers when rotating orientation.
Ryan C. Gordon <icculus@icculus.org>
parents:
5520
diff
changeset
|
155 |
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) |
9a03d2300486
iOS: Correctly resize renderbuffers when rotating orientation.
Ryan C. Gordon <icculus@icculus.org>
parents:
5520
diff
changeset
|
156 |
self.contentScaleFactor = [UIScreen mainScreen].scale; |
9a03d2300486
iOS: Correctly resize renderbuffers when rotating orientation.
Ryan C. Gordon <icculus@icculus.org>
parents:
5520
diff
changeset
|
157 |
} |
9a03d2300486
iOS: Correctly resize renderbuffers when rotating orientation.
Ryan C. Gordon <icculus@icculus.org>
parents:
5520
diff
changeset
|
158 |
|
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
159 |
- (void)setCurrentContext { |
5129 | 160 |
[EAGLContext setCurrentContext:context]; |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
161 |
} |
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 |
|
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
164 |
- (void)swapBuffers { |
5129 | 165 |
glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer); |
166 |
[context presentRenderbuffer:GL_RENDERBUFFER_OES]; |
|
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
167 |
} |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
168 |
|
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
169 |
|
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
170 |
- (void)layoutSubviews { |
5129 | 171 |
[EAGLContext setCurrentContext:context]; |
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
172 |
} |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
173 |
|
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
174 |
- (void)destroyFramebuffer { |
5129 | 175 |
glDeleteFramebuffersOES(1, &viewFramebuffer); |
176 |
viewFramebuffer = 0; |
|
177 |
glDeleteRenderbuffersOES(1, &viewRenderbuffer); |
|
178 |
viewRenderbuffer = 0; |
|
179 |
||
180 |
if (depthRenderbuffer) { |
|
181 |
glDeleteRenderbuffersOES(1, &depthRenderbuffer); |
|
182 |
depthRenderbuffer = 0; |
|
183 |
} |
|
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
184 |
} |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
185 |
|
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
186 |
|
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
187 |
- (void)dealloc { |
5129 | 188 |
[self destroyFramebuffer]; |
189 |
if ([EAGLContext currentContext] == context) { |
|
190 |
[EAGLContext setCurrentContext:nil]; |
|
191 |
} |
|
192 |
[context release]; |
|
193 |
[super dealloc]; |
|
2765
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
194 |
} |
f55c87ae336b
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
195 |
|
2859 | 196 |
@end |
5132 | 197 |
|
198 |
/* vi: set ts=4 sw=4 expandtab: */ |