Perhaps the call to ActivateContext should be moved outside of the if block since there are other gl calls in the function. Then you could move the glDeleteRenderbuffers block before the gdi section and combine the ENTER_GL/LEAVE_GL blocks into one.
- Allan