Commit 57bc440b authored by Ryan C. Gordon's avatar Ryan C. Gordon

More cleanup in SDL_uikitopenglview.m

parent ac5be095
...@@ -43,37 +43,22 @@ ...@@ -43,37 +43,22 @@
stencilBits:(int)stencilBits stencilBits:(int)stencilBits
majorVersion:(int)majorVersion majorVersion:(int)majorVersion
{ {
const BOOL useStencilBuffer = (stencilBits != 0);
const BOOL useDepthBuffer = (depthBits != 0);
NSString *colorFormat = nil;
if (rBits == 8 && gBits == 8 && bBits == 8) {
/* if user specifically requests rbg888 or some color format higher than 16bpp */
colorFormat = kEAGLColorFormatRGBA8;
}
else {
/* default case (faster) */
colorFormat = kEAGLColorFormatRGB565;
}
depthBufferFormat = 0; depthBufferFormat = 0;
if (useDepthBuffer) { if ((self = [super initWithFrame:frame])) {
if (depthBits == 24) { const BOOL useStencilBuffer = (stencilBits != 0);
depthBufferFormat = GL_DEPTH_COMPONENT24_OES; const BOOL useDepthBuffer = (depthBits != 0);
} NSString *colorFormat = nil;
else {
/* default case when depth buffer is not disabled */ if (rBits == 8 && gBits == 8 && bBits == 8) {
/* /* if user specifically requests rbg888 or some color format higher than 16bpp */
strange, even when we use this, we seem to get a 24 bit depth buffer on iPhone. colorFormat = kEAGLColorFormatRGBA8;
perhaps that's the only depth format iPhone actually supports } else {
*/ /* default case (faster) */
depthBufferFormat = GL_DEPTH_COMPONENT16_OES; colorFormat = kEAGLColorFormatRGB565;
} }
}
if ((self = [super initWithFrame:frame])) { /* Get the layer */
// Get the layer
CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer; CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer;
eaglLayer.opaque = YES; eaglLayer.opaque = YES;
...@@ -104,10 +89,13 @@ ...@@ -104,10 +89,13 @@
if ((useDepthBuffer) || (useStencilBuffer)) { if ((useDepthBuffer) || (useStencilBuffer)) {
if (useStencilBuffer) { if (useStencilBuffer) {
// Apparently you need to pack stencil and depth into one buffer. /* Apparently you need to pack stencil and depth into one buffer. */
// !!! FIXME: this is the only thing (currently) supported. May not always be true.
depthBufferFormat = GL_DEPTH24_STENCIL8_OES; depthBufferFormat = GL_DEPTH24_STENCIL8_OES;
} else if (useDepthBuffer) {
/* iOS only has 24-bit depth buffers, even with GL_DEPTH_COMPONENT16_OES */
depthBufferFormat = GL_DEPTH_COMPONENT24_OES;
} }
glGenRenderbuffersOES(1, &depthRenderbuffer); glGenRenderbuffersOES(1, &depthRenderbuffer);
glBindRenderbufferOES(GL_RENDERBUFFER_OES, depthRenderbuffer); glBindRenderbufferOES(GL_RENDERBUFFER_OES, depthRenderbuffer);
glRenderbufferStorageOES(GL_RENDERBUFFER_OES, depthBufferFormat, backingWidth, backingHeight); glRenderbufferStorageOES(GL_RENDERBUFFER_OES, depthBufferFormat, backingWidth, backingHeight);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment