OpenGL ES Template: createFramebuffer called several times? - Printable Version
+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: iPhone, iPad & iPod Game Development (/forum-11.html)
+--- Thread: OpenGL ES Template: createFramebuffer called several times? (/thread-8834.html)
OpenGL ES Template: createFramebuffer called several times? - SparkyNZ - Apr 13, 2011 06:01 PM
Hi, I'm having some difficulty understanding what the OpenGL ES template is trying to do.
I want to initialise my OpenGL matrix etc in one place. Up until now I've had an InitGL() call within my createFrameBuffer method. It wasn't until I noticed a bug on the iPhone that wasn't in the Windows version of my app that made me realise my InitGL() function was being called twice.
Since then I've hacked things somewhat by adding a global flag to stop my function being called twice.
Can somebody please tell me why mulitple calls to createFrameBuffer are made? Does this have something to do with the application splash screen display? (which I'm not displaying at present).
RE: OpenGL ES Template: createFramebuffer called several times? - iamflimflam1 - Apr 16, 2011 09:10 AM
The template is a bit of a mess in my opinion.
The reason you are seeing createFrameBuffer twice is because the layoutSubviews method on EAGLView deletes the frame buffer which causes createFrameBuffer to be called the next time setFrameBuffer is called (which is on every draw loop).
So the first call happens in the awakeFromNib of the controller which calls setFrameBuffer (which then calls createFrameBuffer).
And then when you view is actually laid out the layoutSubViews gets called which deletes the frame buffer which causes setFrameBuffer to regenerate them with a call to createFrameBuffer.
The reason layoutSubview deletes the frame buffer is because if your view changes size you'd want to regenerate the frame buffers to match the view size.
You are probably better off putting your one time initialisation code into the awakeFromNib call in the view controller.
RE: OpenGL ES Template: createFramebuffer called several times? - SparkyNZ - Apr 16, 2011 02:46 PM
Thanks FlimFlam.. Yeah I thought it was a right mess too. :-) Its funny that I've been switching back and forth between using an SDL main loop and OpenGL ES template instead.. Through the journey I've been pushed back into using SDL - for some reason SDL with the OpenGL ES template code was very glitchy and stuttery when I used it for audio alone. However.. there's always the possibility of me coming back to non-SDL code again so.. thanks for the help. I'll definitely move my one-off time code for sure.