GLKView won't change pixel format

166 Views Asked by At

There is an issue of GLKView, I'm stuck here a lot. First, I create EAGLContext context and make it current:

EAGLContext* pOpenGLContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3];
if(!pOpenGLContext)
    return nil;
if(![EAGLContext setCurrentContext:pOpenGLContext])
    return nil;

Runs ok (I need version 3 so it sutes me)! Then I create GLKView, attached to previously created context:

GLKView* pOpenGLView = [[GLKView alloc] initWithFrame:Frame context:pOpenGLContext];

It's ok. But this code don't change anything at all :(

[pOpenGLView setDrawableColorFormat:GLKViewDrawableColorFormatRGBA8888];
[pOpenGLView setDrawableDepthFormat:GLKViewDrawableDepthFormat24];
[pOpenGLView setDrawableStencilFormat:GLKViewDrawableStencilFormatNone];
[pOpenGLView setDrawableMultisample:GLKViewDrawableMultisampleNone];

Then I do some final stuff:

pOpenGLView.delegate = self;
[pMainWindow addSubview:pOpenGLView];
...

However, after using GLKViewDrawableStencilFormatNone, I asks OpenGL for a depth and stencil formats... I get:

glGetIntegerv(GL_DEPTH_BITS, &OpenGLDepthBits);      // = 32 (I need 24)
glGetIntegerv(GL_STENCIL_BITS, &OpenGLStencilBits);  // =  8 (I need 0)

I need to turn stencil buffer off! I need to set 24-bit format depth buffer. I have try to do like this also:

pOpenGLView.drawableColorFormat = GLKViewDrawableColorFormatRGBA8888;
pOpenGLView.drawableDepthFormat = GLKViewDrawableDepthFormat24;
pOpenGLView.drawableStencilFormat = GLKViewDrawableStencilFormatNone;

How can I get it? What is wrong here? Thank you.

0

There are 0 best solutions below