0

GameViews in OpenTK-1.0 initialize the context in CreateFramebuffer() and destroy said context in DestroyFramebuffer(). What if I want to hold onto my VBOs and just create a bunch of new FBOs? For example, on rotation, I need to create newly sized FBOs, but I don't want to have to completely reload all my VBOs and I just don't understand how this would work without completely reimplementing all/most of GameView. I can't just override these two methods, because the base class does not expose a setter on Renderbuffer or Framebuffer. What am I missing here?

In sum: I want to rotate the device and get a new OpenTK-1.0 FBO, but not destroy the context. How do I go about this?

dan
  • 245
  • 4
  • 13

1 Answers1

1

CreateFramebuffer() creates an OpenGL context, not a framebuffer object. To create a FBO, call GL.GenFramebuffer(). To destroy it, use GL.DeleteFramebuffer().

Refer to the OpenGL wiki for more information. This is written for desktop OpenGL, but this article also applies to OpenGL ES.

The Fiddler
  • 2,726
  • 22
  • 28
  • Thanks for the answer. Your advice is definitely clear, and it is certainly the direction that I took (ie: managing it all myself). However, if I'm not mistaken, your answer also abandons OpenTK 1.0's GameView (as I was forced to do) as it manages the Renderbuffer and the Framebuffer and does not expose a setter on either handle. – dan Mar 10 '14 at 19:45
  • No, this is not entirely correct. [GameView.CreateFramebuffer()](https://github.com/mono/opentk/blob/rodo-consolidate-opentk/Source/OpenTK/Platform/Android/AndroidGameView.cs#L169) creates an Android OpenGL context, not an OpenGL renderbuffer or FBO. In other words, use GameView to create your OpenGL "window"; then use the regular GL.* API to create OpenGL resources (textures, FBOs, VBOs, etc.) These are orthogonal concepts. – The Fiddler Mar 10 '14 at 20:20
  • Understood. (Also - just to be make sure we're on the same page - I'm talking about Xamarin's OpenTK-1.0 which, as I understand it, may or may not differ from OpenTK proper). On iPhoneOSGameView, I see only a getter for the int Renderbuffer property. – dan Mar 10 '14 at 21:00
  • I'm not familiar with the iPhoneOSGameView, as it does not appear to be available in the monotouch branch of [mono/opentk](https://github.com/mono/opentk). I'm currently focusing on merging the Android code from mono/opentk into [opentk/opentk](https://github.com/opentk/opentk). – The Fiddler Mar 11 '14 at 00:21
  • A quick look into Apple's docs reveals that they provide [an EAGL API](https://developer.apple.com/library/ios/documentation/OpenGLES/Reference/EAGLContext_ClassRef/Reference/EAGLContext.html#//apple_ref/occ/instm/EAGLContext/presentRenderbuffer:) to display OpenGL renderbuffers directly (without first resolving to a texture, as you would do in regular OpenGL / ES.) Without the iPhoneOSGameView source code, I cannot tell if this functionality is supported in Xamarin's OpenTK. – The Fiddler Mar 11 '14 at 00:21
  • Yes, indeed. (I ended up using a GLKView instead of Xamarin's iPhoneOSGameView.) I think I confused the issue before by talking about FBOs and contexts in the same topic, when the crux of the problem is that iPhoneOSGameView seems to destroy the GraphicsContext on rotation. But yes, without the source for Xamarin's OpenTK-1.0 implementation, it's difficult to understand how/why it's destroying and creating the context on device rotations. – dan Mar 11 '14 at 22:46