@@ -148,9 +148,16 @@ -(BOOL)isComplete
148
148
@end
149
149
150
150
@implementation CCGLView {
151
- CCTouchEvent* _touchEvent;
151
+ CCTouchEvent* _touchEvent;
152
152
NSMutableArray *_fences;
153
153
154
+ EAGLContext *_context;
155
+
156
+ NSString *_pixelFormat;
157
+ GLuint _depthFormat;
158
+ BOOL _preserveBackbuffer;
159
+ BOOL _discardFramebufferSupported;
160
+
154
161
GLuint _depthBuffer;
155
162
GLuint _colorRenderbuffer;
156
163
GLuint _defaultFramebuffer;
@@ -205,9 +212,12 @@ - (id) initWithFrame:(CGRect)frame pixelFormat:(NSString*)format depthFormat:(GL
205
212
_pixelFormat = format;
206
213
_depthFormat = depth;
207
214
_multiSampling = sampling;
208
- _requestedSamples = nSamples;
209
215
_preserveBackbuffer = retained;
210
216
217
+ GLint maxSamplesAllowed;
218
+ glGetIntegerv (GL_MAX_SAMPLES_APPLE, &maxSamplesAllowed);
219
+ _msaaSamples = MIN (maxSamplesAllowed, nSamples);
220
+
211
221
// Default to "retina" being enabled.
212
222
self.contentScaleFactor = [UIScreen mainScreen ].scale ;
213
223
@@ -236,8 +246,7 @@ -(id) initWithCoder:(NSCoder *)aDecoder
236
246
_pixelFormat = kEAGLColorFormatRGB565 ;
237
247
_depthFormat = 0 ; // GL_DEPTH_COMPONENT24;
238
248
_multiSampling= NO ;
239
- _requestedSamples = 0 ;
240
- _size = [eaglLayer bounds ].size ;
249
+ _msaaSamples = 0 ;
241
250
242
251
if ( ! [self setupSurfaceWithSharegroup: nil ] ) {
243
252
return nil ;
@@ -280,10 +289,6 @@ -(BOOL) setupSurfaceWithSharegroup:(EAGLSharegroup*)sharegroup
280
289
glFramebufferRenderbuffer (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, _colorRenderbuffer);
281
290
282
291
if (_multiSampling){
283
- GLint maxSamplesAllowed;
284
- glGetIntegerv (GL_MAX_SAMPLES_APPLE, &maxSamplesAllowed);
285
- _msaaSamples = MIN (maxSamplesAllowed, _requestedSamples);
286
-
287
292
/* Create the MSAA framebuffer (offscreen) */
288
293
glGenFramebuffers (1 , &_msaaFramebuffer);
289
294
glBindFramebuffer (GL_FRAMEBUFFER, _msaaFramebuffer);
@@ -359,11 +364,10 @@ -(void)resizeFromLayer:(CAEAGLLayer *)layer
359
364
- (void ) layoutSubviews
360
365
{
361
366
[self resizeFromLayer: (CAEAGLLayer*)self .layer];
362
- _size = CGSizeMake ( _backingWidth, _backingHeight);
363
367
364
368
// Issue #914 #924
365
369
CCDirector *director = [CCDirector sharedDirector ];
366
- [director reshapeProjection: _size ];
370
+ [director reshapeProjection: CGSizeMake ( _backingWidth, _backingHeight) ];
367
371
368
372
// Avoid flicker. Issue #350
369
373
// Only draw if there is something to draw, otherwise it actually creates a flicker of the current glClearColor
@@ -477,6 +481,15 @@ -(void)presentFrame
477
481
CC_CHECK_GL_ERROR_DEBUG ();
478
482
}
479
483
484
+ -(GLuint)fbo
485
+ {
486
+ if (_multiSampling){
487
+ return _msaaFramebuffer;
488
+ } else {
489
+ return _defaultFramebuffer;
490
+ }
491
+ }
492
+
480
493
-(GLenum)convertPixelFormat : (NSString *)pixelFormat
481
494
{
482
495
if ([pixelFormat isEqualToString: @" EAGLColorFormat565" ]){
0 commit comments