Click here to Skip to main content
15,886,780 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am keeping multiple instances of an opengl view. When I release/remove one instance of view, it affects frame buffers and render buffers of all other instances of opengl view. I observed that call made to glDeleteFrameBuffer deletes frame buffer for all

I have created a small project to demonstrate my problem, which can be downloaded from GLEssentials_ModifiedToDemonstrateProblem.zip - Google Drive[^]

Two views (EAGLView) are added to the screen (viewcontroller).
“Frame Buffer Status” buttons prints status of buffers of each views like: “showFrameBufferStatus: glIsFramebuffer returned true”
“Remove” button removes view from view hierarchy. Hence deallocating the view from memory.


Steps to regenerate the problem:

Step 1:
Download and run the demo project (I used XCode 7.2 - IOS 8.4)

Step 2:
Touch the button “Frame Buffer Status” for second view.
It prints “showFrameBufferStatus: glIsFramebuffer returned true” to console.

Step 3:
Touch the button “Remove” for first view. It removes first view from view hierarchy and dealloc gets called for EAGLView and ES2Renderer

Step 4:
Touch “Frame Buffer Status” for second view.
It prints “showFrameBufferStatus: glIsFramebuffer returned false”. It means frame buffer is deleted for view2 while view1 is deallocated.


Now when glDeleteFramebuffers is commented out in ES2Renderer.m, and above steps are followed, final step shows that glIsFramebuffer returned true

Objective-C
//glDeleteFramebuffers(1, &defaultFBOName);


So root problem is glDeleteFramebuffers deletes frame buffers for both instances of ES2Render.

Note: The project is created by modifying GLEssential demo from apple (https://developer.apple.com/library/ios/samplecode/GLEssentials/Introduction/Intro.html[^])
Posted
Updated 28-Dec-15 17:49pm
v4

1 solution

got solution.
Before calling glDeleteFramebuffers, it is required to do set current context. following code fixed problem for me:
Objective-C
[EAGLContext setCurrentContext:self.context];
glDeleteFramebuffers(1, &defaultFBOName);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900