Lefora Free Forum
Loading
748 views

OpenGL View only updates on window resize...

Page 1
1–3
rookie - member
3 posts

I have a cocoa project that includes an OpenGL View.  The OpenGL View does its required drawing (I've stepped through the code) at the correct times, but the View is only updated when I resize the window.

All the drawing codes end with glFlush().

Also, in trying to fix the problem, I tried adding [ self setNeedsDisplay: YES ] ; before doing the draw, and I also tried having my control object calling [pOpenGLView setNeedsDisplay: YES ] ;, both to no avail.  I do not think double buffering is even on, but even if it were, then resizing the window shouldn't result in a swapbuffers(), correct?

Has anyone seen behaviour like this?  Any ideas?  Could it be some weird windows setting?  (I created the OpenGL view in Interface Builder).

I'm using XCode 3.1 and Leopard 10.5.8.

Thanks to anyone who can help - I tried the official Apple development mailing lists but no one ever "approved" my post, so I never got any response.

- Jeff


rookie - member
3 posts

I should even mention that I have a periodic timer call back, but nothing the timer can do will actually result in the OpenGL View updating itself (although it does the OpenGL calls.)  Whereas, all the other Cocoa controls DO get updated in real time when I change their values.

- Jeff

rookie - member
3 posts

OK, I figured out what was wrong.  In Interface Builder, I had actually selected double buffering, and I was drawing to the back buffer.  For some unknown reason, many different GUI events had the effect of causing a swap buffer after the glFlush, but I had no such swapbuffer command.

I found to my amazement, that in OpenGL Cocoa there appears to be NO implementation of swapbuffers!  I could see no way to explicitly tell the context to switch.

Luckily, it seems like there is at least some sort of buffering going on as part of the GUI itself, because when I set it to single buffer mode, I didn't notice any flickering.

Anyone out there know how to do swapbuffers() in Cocoa?

Thanks,
- Jeff

P.S. Yes - there is an aglswapBuffers command, but that's deprecated Carbon...

Page 1
1–3

Locked Topic


You must be a member to post in this forum

Join Now!