0

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.

genpfault
  • 51,148
  • 11
  • 85
  • 139
  • When are you performing these operations? IIRC, `GLKView` won't actually do anything to its framebuffer until it's ready to draw, in which case calling `glGetIntegerv(GL_DEPTH_BITS)` etc before `drawRect` or `glkView:drawInRect:` happens wouldn't show the change. – rickster Feb 13 '15 at 17:49
  • I performe in didFinishLaunchingWithOptions: first I create GLKView and do setDrawable_xxx_Format in the **same** time! In the next line of code! After sereval amount of time **after** drawRect I do glGetIntegerv and get this strange result. How can I understand if GLKView is ready to draw or not? Should I call glGetIntegerv before or after it is ready for draw? – Andrey Mironov Feb 16 '15 at 06:23

0 Answers0