MCPcopy Create free account
hub / github.com/OGRECave/ogre / bind

Method bind

RenderSystems/GLES2/src/OgreGLES2FrameBufferObject.cpp:204–259  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

202 }
203
204 bool GLES2FrameBufferObject::bind(bool recreateIfNeeded)
205 {
206 GLRenderSystemCommon* rs = static_cast<GLRenderSystemCommon*>(Root::getSingleton().getRenderSystem());
207 GLContext* currentContext = rs->_getCurrentContext();
208 if(mContext && mContext != currentContext) // FBO is unusable with current context, destroy it
209 {
210 if(mFB != 0)
211 rs->_destroyFbo(mContext, mFB);
212 if(mMultisampleFB != 0)
213 rs->_destroyFbo(mContext, mMultisampleFB);
214
215 mContext = 0;
216 mFB = 0;
217 mMultisampleFB = 0;
218 }
219
220 if(!mContext && recreateIfNeeded) // create FBO lazy or recreate after destruction
221 {
222 mContext = currentContext;
223
224 // Generate framebuffer object
225 OGRE_CHECK_GL_ERROR(glGenFramebuffers(1, &mFB));
226
227 // Check if multisampling supported
228 if(rs->hasMinGLVersion(3, 0))
229 {
230 // Check samples supported
231 GLint maxSamples;
232 OGRE_CHECK_GL_ERROR(glGetIntegerv(GL_MAX_SAMPLES_APPLE, &maxSamples));
233 mNumSamples = std::min(mNumSamples, maxSamples);
234 }
235 else
236 {
237 mNumSamples = 0;
238 }
239
240 // Will we need a second FBO to do multisampling?
241 if (mNumSamples)
242 {
243 OGRE_CHECK_GL_ERROR(glGenFramebuffers(1, &mMultisampleFB));
244 }
245 else
246 {
247 mMultisampleFB = 0;
248 }
249
250 // Re-initialise
251 if(mColour[0].buffer)
252 initialise();
253 }
254
255 if(mContext)
256 OGRE_CHECK_GL_ERROR(glBindFramebuffer(GL_FRAMEBUFFER, mMultisampleFB ? mMultisampleFB : mFB));
257
258 return mContext != 0;
259 }
260
261 void GLES2FrameBufferObject::swapBuffers()

Callers 2

_renderMethod · 0.45
bindRenderTargetMethod · 0.45

Calls 4

getRenderSystemMethod · 0.80
hasMinGLVersionMethod · 0.80
initialiseFunction · 0.50
_destroyFboMethod · 0.45

Tested by

no test coverage detected