MCPcopy Create free account
hub / github.com/SFML/SFML / createFrameBuffer

Method createFrameBuffer

src/SFML/Graphics/RenderTextureImplFBO.cpp:397–506  ·  view source on GitHub ↗

///////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

395
396////////////////////////////////////////////////////////////
397bool RenderTextureImplFBO::createFrameBuffer()
398{
399 // Create the framebuffer object
400 auto frameBuffer = std::make_shared<FrameBufferObject>();
401
402 if (!frameBuffer->object)
403 {
404 err() << "Impossible to create render texture (failed to create the frame buffer object)" << std::endl;
405 return false;
406 }
407 glCheck(GLEXT_glBindFramebuffer(GLEXT_GL_FRAMEBUFFER, frameBuffer->object));
408
409 // Link the depth/stencil renderbuffer to the frame buffer
410 if (!m_multisample && m_depthStencilBuffer)
411 {
412 if (m_depth)
413 {
414 glCheck(GLEXT_glFramebufferRenderbuffer(GLEXT_GL_FRAMEBUFFER,
415 GLEXT_GL_DEPTH_ATTACHMENT,
416 GLEXT_GL_RENDERBUFFER,
417 m_depthStencilBuffer));
418 }
419
420 if (m_stencil)
421 {
422 glCheck(GLEXT_glFramebufferRenderbuffer(GLEXT_GL_FRAMEBUFFER,
423 GLEXT_GL_STENCIL_ATTACHMENT,
424 GLEXT_GL_RENDERBUFFER,
425 m_depthStencilBuffer));
426 }
427 }
428
429 // Link the texture to the frame buffer
430 glCheck(GLEXT_glFramebufferTexture2D(GLEXT_GL_FRAMEBUFFER, GLEXT_GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_textureId, 0));
431
432 // A final check, just to be sure...
433 if (glCheck(GLEXT_glCheckFramebufferStatus(GLEXT_GL_FRAMEBUFFER)) != GLEXT_GL_FRAMEBUFFER_COMPLETE)
434 {
435 glCheck(GLEXT_glBindFramebuffer(GLEXT_GL_FRAMEBUFFER, 0));
436 err() << "Impossible to create render texture (failed to link the target texture to the frame buffer)" << std::endl;
437 return false;
438 }
439
440 // Insert the FBO into our map
441 m_frameBuffers.try_emplace(Context::getActiveContextId(), frameBuffer);
442
443 // Register the object with the current context so it is automatically destroyed
444 registerUnsharedGlObject(std::move(frameBuffer));
445
446#ifndef SFML_OPENGL_ES
447
448 if (m_multisample)
449 {
450 // Create the multisample framebuffer object
451 auto multisampleFrameBuffer = std::make_shared<FrameBufferObject>();
452
453 if (!multisampleFrameBuffer->object)
454 {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected