annotate src/video/uikit/SDL_uikitopenglview.m @ 2445:d65e44861a15 gsoc2008_iphone

added comment
author Holmes Futrell <hfutrell@umail.ucsb.edu>
date Sat, 16 Aug 2008 00:09:10 +0000
parents 491958a6c881
children
rev   line source
2403
e9a1eed243c9 Added standard SDL header comments
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents: 2400
diff changeset
1 /*
e9a1eed243c9 Added standard SDL header comments
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents: 2400
diff changeset
2 SDL - Simple DirectMedia Layer
e9a1eed243c9 Added standard SDL header comments
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents: 2400
diff changeset
3 Copyright (C) 1997-2006 Sam Lantinga
e9a1eed243c9 Added standard SDL header comments
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents: 2400
diff changeset
4
e9a1eed243c9 Added standard SDL header comments
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents: 2400
diff changeset
5 This library is free software; you can redistribute it and/or
e9a1eed243c9 Added standard SDL header comments
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents: 2400
diff changeset
6 modify it under the terms of the GNU Lesser General Public
e9a1eed243c9 Added standard SDL header comments
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents: 2400
diff changeset
7 License as published by the Free Software Foundation; either
e9a1eed243c9 Added standard SDL header comments
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents: 2400
diff changeset
8 version 2.1 of the License, or (at your option) any later version.
e9a1eed243c9 Added standard SDL header comments
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents: 2400
diff changeset
9
e9a1eed243c9 Added standard SDL header comments
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents: 2400
diff changeset
10 This library is distributed in the hope that it will be useful,
e9a1eed243c9 Added standard SDL header comments
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents: 2400
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
e9a1eed243c9 Added standard SDL header comments
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents: 2400
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
e9a1eed243c9 Added standard SDL header comments
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents: 2400
diff changeset
13 Lesser General Public License for more details.
e9a1eed243c9 Added standard SDL header comments
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents: 2400
diff changeset
14
e9a1eed243c9 Added standard SDL header comments
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents: 2400
diff changeset
15 You should have received a copy of the GNU Lesser General Public
e9a1eed243c9 Added standard SDL header comments
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents: 2400
diff changeset
16 License along with this library; if not, write to the Free Software
e9a1eed243c9 Added standard SDL header comments
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents: 2400
diff changeset
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
e9a1eed243c9 Added standard SDL header comments
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents: 2400
diff changeset
18
e9a1eed243c9 Added standard SDL header comments
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents: 2400
diff changeset
19 Sam Lantinga
e9a1eed243c9 Added standard SDL header comments
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents: 2400
diff changeset
20 slouken@libsdl.org
e9a1eed243c9 Added standard SDL header comments
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents: 2400
diff changeset
21 */
2351
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
22
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
23 #import <QuartzCore/QuartzCore.h>
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
24 #import <OpenGLES/EAGLDrawable.h>
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
25 #import "SDL_uikitopenglview.h"
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
26
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
27 @interface SDL_uikitopenglview (privateMethods)
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
28
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
29 - (BOOL) createFramebuffer;
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
30 - (void) destroyFramebuffer;
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
31
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
32 @end
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
33
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
34
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
35 @implementation SDL_uikitopenglview
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
36
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
37 @synthesize context;
2445
d65e44861a15 added comment
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents: 2425
diff changeset
38
2351
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
39 + (Class)layerClass {
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
40 return [CAEAGLLayer class];
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
41 }
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
42
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
43 - (id)initWithFrame:(CGRect)frame \
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
44 retainBacking:(BOOL)retained \
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
45 rBits:(int)rBits \
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
46 gBits:(int)gBits \
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
47 bBits:(int)bBits \
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
48 aBits:(int)aBits \
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
49 depthBits:(int)depthBits \
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
50 {
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
51
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
52 NSString *colorFormat=nil;
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
53 GLuint depthBufferFormat;
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
54 BOOL useDepthBuffer;
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
55
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
56 if (rBits == 8 && gBits == 8 && bBits == 8) {
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
57 /* if user specifically requests rbg888 or some color format higher than 16bpp */
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
58 colorFormat = kEAGLColorFormatRGBA8;
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
59 }
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
60 else {
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
61 /* default case (faster) */
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
62 colorFormat = kEAGLColorFormatRGB565;
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
63 }
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
64
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
65 if (depthBits == 24) {
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
66 useDepthBuffer = YES;
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
67 depthBufferFormat = GL_DEPTH_COMPONENT24_OES;
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
68 }
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
69 else if (depthBits == 0) {
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
70 useDepthBuffer = NO;
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
71 }
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
72 else {
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
73 /* default case when depth buffer is not disabled */
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
74 /*
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
75 strange, even when we use this, we seem to get a 24 bit depth buffer on iPhone.
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
76 perhaps that's the only depth format iPhone actually supports
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
77 */
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
78 useDepthBuffer = YES;
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
79 depthBufferFormat = GL_DEPTH_COMPONENT16_OES;
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
80 }
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
81
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
82 if ((self = [super initWithFrame:frame])) {
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
83 // Get the layer
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
84 CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer;
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
85
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
86 eaglLayer.opaque = YES;
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
87 eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
88 [NSNumber numberWithBool: retained], kEAGLDrawablePropertyRetainedBacking, colorFormat, kEAGLDrawablePropertyColorFormat, nil];
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
89
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
90 context = [[EAGLContext alloc] initWithAPI: kEAGLRenderingAPIOpenGLES1];
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
91
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
92 if (!context || ![EAGLContext setCurrentContext:context]) {
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
93 [self release];
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
94 return nil;
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
95 }
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
96
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
97 /* create the buffers */
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
98 glGenFramebuffersOES(1, &viewFramebuffer);
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
99 glGenRenderbuffersOES(1, &viewRenderbuffer);
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
100
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
101 glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer);
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
102 glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
103 [context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(CAEAGLLayer*)self.layer];
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
104 glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, viewRenderbuffer);
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
105
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
106 glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth);
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
107 glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight);
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
108
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
109 if (useDepthBuffer) {
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
110 glGenRenderbuffersOES(1, &depthRenderbuffer);
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
111 glBindRenderbufferOES(GL_RENDERBUFFER_OES, depthRenderbuffer);
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
112 glRenderbufferStorageOES(GL_RENDERBUFFER_OES, depthBufferFormat, backingWidth, backingHeight);
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
113 glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, depthRenderbuffer);
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
114 }
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
115
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
116 if(glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES) {
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
117 return NO;
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
118 }
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
119 /* end create buffers */
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
120 }
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
121 return self;
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
122 }
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
123
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
124 - (void)setCurrentContext {
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
125 [EAGLContext setCurrentContext:context];
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
126 }
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
127
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
128
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
129 - (void)swapBuffers {
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
130 glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);
2425
491958a6c881 Removed log messages (printf and NSLog)
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents: 2411
diff changeset
131 [context presentRenderbuffer:GL_RENDERBUFFER_OES];
2351
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
132 }
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
133
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
134
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
135 - (void)layoutSubviews {
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
136 [EAGLContext setCurrentContext:context];
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
137 }
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
138
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
139 - (void)destroyFramebuffer {
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
140
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
141 glDeleteFramebuffersOES(1, &viewFramebuffer);
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
142 viewFramebuffer = 0;
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
143 glDeleteRenderbuffersOES(1, &viewRenderbuffer);
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
144 viewRenderbuffer = 0;
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
145
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
146 if (depthRenderbuffer) {
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
147 glDeleteRenderbuffersOES(1, &depthRenderbuffer);
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
148 depthRenderbuffer = 0;
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
149 }
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
150 }
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
151
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
152
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
153 - (void)dealloc {
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
154
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
155 [self destroyFramebuffer];
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
156 if ([EAGLContext currentContext] == context) {
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
157 [EAGLContext setCurrentContext:nil];
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
158 }
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
159 [context release];
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
160 [super dealloc];
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
161
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
162 }
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
163
d2a519d2cc57 SDL_uikitopenglview is an OpenGL ES View class based on the one found in Apple's OpenGL ES based application template. It's created from SDL_uikitopengles.m, normally.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
164 @end