void AfterPresentSurfaceGLES(EAGLSurfaceDesc* surface) { if(surface->use32bitColor != UnityUse32bitDisplayBuffer()) { surface->use32bitColor = UnityUse32bitDisplayBuffer(); CreateSurfaceGLES(surface); GLES_CHK( glBindRenderbufferOES(GL_RENDERBUFFER_OES, surface->renderbuffer) ); } #if GL_APPLE_framebuffer_multisample if (_supportsMSAA) { const int desiredMSAASamples = UnityGetDesiredMSAASampleCount(MSAA_DEFAULT_SAMPLE_COUNT); if (surface->msaaSamples != desiredMSAASamples) { surface->msaaSamples = desiredMSAASamples; CreateSurfaceMultisampleBuffersGLES(surface); GLES_CHK( glBindRenderbufferOES(GL_RENDERBUFFER_OES, surface->renderbuffer) ); } if (surface->msaaSamples > 1) { UNITY_DBG_LOG (" glBindFramebufferOES (GL_FRAMEBUFFER_OES, %i); // PresentSurface\n", surface->msaaFramebuffer); GLES_CHK( glBindFramebufferOES(GL_FRAMEBUFFER_OES, surface->msaaFramebuffer) ); gDefaultFBO = surface->msaaFramebuffer; } } #endif }
void Screen::CreateHardwareSurfaces() { glGenFramebuffersOES(1, &frameBuffer); glGenRenderbuffersOES(1, &renderBuffer); glBindFramebufferOES(GL_FRAMEBUFFER_OES, frameBuffer); glBindRenderbufferOES(GL_RENDERBUFFER_OES, renderBuffer); iphPrepareGLContext(); glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, renderBuffer); glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &iWidth); glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &iHeight); #if SEED_ENABLE_DEPTH_TEST glGenRenderbuffersOES(1, &depthRenderbuffer); glBindRenderbufferOES(GL_RENDERBUFFER_OES, depthRenderbuffer); glRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_DEPTH_COMPONENT16_OES, iWidth, iHeight); glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, depthRenderbuffer); #endif // SEED_ENABLE_DEPTH_TEST if (iMode == LANDSCAPE || iMode == LANDSCAPE_GOOFY) { this->iModeWidth = this->iHeight; this->iModeHeight = this->iWidth; } else { this->iModeWidth = this->iHeight; this->iModeHeight = this->iWidth; } }
void OpenGLES1RenderManager::_generateOpenglBuffers() { #ifdef AURORA_IOS // Create & bind the color buffer so that the caller can allocate its space. glGenRenderbuffersOES(1, &m_colorRenderbuffer); glBindRenderbufferOES(GL_RENDERBUFFER_OES, m_colorRenderbuffer); // Create the depth buffer. glGenRenderbuffersOES(1, &m_depthRenderbuffer); glBindRenderbufferOES(GL_RENDERBUFFER_OES, m_depthRenderbuffer); glRenderbufferStorageOES(GL_RENDERBUFFER_OES,GL_DEPTH_COMPONENT16_OES,_width,_height); // Create the framebuffer object; attach the depth and color buffers. glGenFramebuffersOES(1, &m_framebuffer); glBindFramebufferOES(GL_FRAMEBUFFER_OES, m_framebuffer); glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, m_colorRenderbuffer); glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, m_depthRenderbuffer); // Bind the color buffer for rendering. glBindRenderbufferOES(GL_RENDERBUFFER_OES, m_colorRenderbuffer); #endif }
void CreateSurfaceGLES(EAGLSurfaceDesc* surface) { GLuint oldRenderbuffer; GLES_CHK( glGetIntegerv(GL_RENDERBUFFER_BINDING_OES, (GLint *) &oldRenderbuffer) ); DestroySurfaceGLES(surface); InitEAGLLayer(surface->eaglLayer, surface->use32bitColor); GLES_CHK( glGenRenderbuffersOES(1, &surface->renderbuffer) ); GLES_CHK( glBindRenderbufferOES(GL_RENDERBUFFER_OES, surface->renderbuffer) ); if( !AllocateRenderBufferStorageFromEAGLLayer(surface->eaglLayer) ) { GLES_CHK( glDeleteRenderbuffersOES(1, &surface->renderbuffer) ); GLES_CHK( glBindRenderbufferOES(GL_RENDERBUFFER_BINDING_OES, oldRenderbuffer) ); printf_console("FAILED allocating render buffer storage from gles context\n"); return; } GLES_CHK( glGenFramebuffersOES(1, &surface->framebuffer) ); UNITY_DBG_LOG ("glBindFramebufferOES(GL_FRAMEBUFFER_OES, %d) :: AppCtrl\n", surface->framebuffer); GLES_CHK( glBindFramebufferOES(GL_FRAMEBUFFER_OES, surface->framebuffer) ); gDefaultFBO = surface->framebuffer; UNITY_DBG_LOG ("glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, %d) :: AppCtrl\n", surface->renderbuffer); GLES_CHK( glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, surface->renderbuffer) ); CreateSurfaceMultisampleBuffersGLES(surface); }
void DestroySurfaceGLES(EAGLSurfaceDesc* surface) { if( surface->systemRenderbuffer ) { GLES_CHK( glBindRenderbufferOES(GL_RENDERBUFFER_OES, surface->systemRenderbuffer) ); DeallocateRenderBufferStorageFromEAGLLayer(); GLES_CHK( glBindRenderbufferOES(GL_RENDERBUFFER_OES, 0) ); GLES_CHK( glDeleteRenderbuffersOES(1, &surface->systemRenderbuffer) ); surface->systemRenderbuffer = 0; } if( surface->systemFramebuffer ) { GLES_CHK( glDeleteFramebuffersOES(1, &surface->systemFramebuffer) ); surface->systemFramebuffer = 0; } DestroyRenderingSurfaceGLES(surface); if(surface->depthbuffer) { GLES_CHK( glDeleteRenderbuffersOES(1, &surface->depthbuffer) ); surface->depthbuffer = 0; } }
/** Try a certain FBO format, and return the status. Also sets mDepthRB and mStencilRB. @returns true if this combo is supported false if this combo is not supported */ GLuint GLESFBOManager::_tryFormat(GLenum depthFormat, GLenum stencilFormat) { GLuint status, depthRB = 0, stencilRB = 0; if(depthFormat != GL_NONE) { /// Generate depth renderbuffer glGenRenderbuffersOES(1, &depthRB); /// Bind it to FBO glBindRenderbufferOES(GL_RENDERBUFFER_OES, depthRB); /// Allocate storage for depth buffer glRenderbufferStorageOES(GL_RENDERBUFFER_OES, depthFormat, PROBE_SIZE, PROBE_SIZE); /// Attach depth glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, depthRB); } // Stencil buffers aren't available on iPhone if(stencilFormat != GL_NONE) { /// Generate stencil renderbuffer glGenRenderbuffersOES(1, &stencilRB); /// Bind it to FBO glBindRenderbufferOES(GL_RENDERBUFFER_OES, stencilRB); /// Allocate storage for stencil buffer glRenderbufferStorageOES(GL_RENDERBUFFER_OES, stencilFormat, PROBE_SIZE, PROBE_SIZE); /// Attach stencil glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_STENCIL_ATTACHMENT_OES, GL_RENDERBUFFER_OES, stencilRB); } status = glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES); /// If status is negative, clean up // Detach and destroy glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, 0); glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_STENCIL_ATTACHMENT_OES, GL_RENDERBUFFER_OES, 0); if (depthRB) glDeleteRenderbuffersOES(1, &depthRB); if (stencilRB) glDeleteRenderbuffersOES(1, &stencilRB); return status == GL_FRAMEBUFFER_COMPLETE_OES; }
void CreateSurfaceMultisampleBuffersGLES(EAGLSurfaceDesc* surface) { UNITY_DBG_LOG ("CreateSurfaceMultisampleBuffers: samples=%i\n", surface->msaaSamples); GLES_CHK( glBindRenderbufferOES(GL_RENDERBUFFER_OES, surface->renderbuffer) ); UNITY_DBG_LOG ("glBindFramebufferOES(GL_FRAMEBUFFER_OES, %d) :: AppCtrl\n", surface->framebuffer); GLES_CHK( glBindFramebufferOES(GL_FRAMEBUFFER_OES, surface->framebuffer) ); gDefaultFBO = surface->framebuffer; DestroySurfaceMultisampleBuffersGLES(surface); GLES_CHK( glBindRenderbufferOES(GL_RENDERBUFFER_OES, surface->renderbuffer) ); UNITY_DBG_LOG ("glBindFramebufferOES(GL_FRAMEBUFFER_OES, %d) :: AppCtrl\n", surface->framebuffer); GLES_CHK( glBindFramebufferOES(GL_FRAMEBUFFER_OES, surface->framebuffer) ); #if GL_APPLE_framebuffer_multisample if(surface->msaaSamples > 1) { GLES_CHK( glGenRenderbuffersOES(1, &surface->msaaRenderbuffer) ); GLES_CHK( glBindRenderbufferOES(GL_RENDERBUFFER_OES, surface->msaaRenderbuffer) ); GLES_CHK( glGenFramebuffersOES(1, &surface->msaaFramebuffer) ); UNITY_DBG_LOG ("glBindFramebufferOES(GL_FRAMEBUFFER_OES, %d) :: AppCtrl\n", surface->msaaFramebuffer); GLES_CHK( glBindFramebufferOES(GL_FRAMEBUFFER_OES, surface->msaaFramebuffer) ); gDefaultFBO = surface->msaaFramebuffer; GLES_CHK( glRenderbufferStorageMultisampleAPPLE(GL_RENDERBUFFER_OES, surface->msaaSamples, surface->format, surface->w, surface->h) ); GLES_CHK( glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, surface->msaaRenderbuffer) ); if(surface->depthFormat) { GLES_CHK( glGenRenderbuffersOES(1, &surface->msaaDepthbuffer) ); GLES_CHK( glBindRenderbufferOES(GL_RENDERBUFFER_OES, surface->msaaDepthbuffer) ); GLES_CHK( glRenderbufferStorageMultisampleAPPLE(GL_RENDERBUFFER_OES, surface->msaaSamples, GL_DEPTH_COMPONENT16_OES, surface->w, surface->h) ); GLES_CHK( glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, surface->msaaDepthbuffer) ); } } else #endif { if(surface->depthFormat) { GLES_CHK( glGenRenderbuffersOES(1, &surface->depthbuffer) ); GLES_CHK( glBindRenderbufferOES(GL_RENDERBUFFER_OES, surface->depthbuffer) ); GLES_CHK( glRenderbufferStorageOES(GL_RENDERBUFFER_OES, surface->depthFormat, surface->w, surface->h) ); UNITY_DBG_LOG ("glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, %d) :: AppCtrl\n", surface->depthbuffer); GLES_CHK( glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, surface->depthbuffer) ); } } }
inline void VL_glBindRenderbuffer(GLenum target, GLuint renderbuffer) { if (glBindRenderbufferOES) glBindRenderbufferOES(target, renderbuffer); else VL_TRAP(); }
/** Try a certain packed depth/stencil format, and return the status. @returns true if this combo is supported false if this combo is not supported */ bool GLESFBOManager::_tryPackedFormat(GLenum packedFormat) { GLuint packedRB; /// Generate renderbuffer glGenRenderbuffersOES(1, &packedRB); /// Bind it to FBO glBindRenderbufferOES(GL_RENDERBUFFER_OES, packedRB); /// Allocate storage for buffer glRenderbufferStorageOES(GL_RENDERBUFFER_OES, packedFormat, PROBE_SIZE, PROBE_SIZE); /// Attach depth glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, packedRB); /// Attach stencil glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_STENCIL_ATTACHMENT_OES, GL_RENDERBUFFER_OES, packedRB); GLuint status = glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES); /// Detach and destroy glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, 0); glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_STENCIL_ATTACHMENT_OES, GL_RENDERBUFFER_OES, 0); glDeleteRenderbuffersOES(1, &packedRB); return status == GL_FRAMEBUFFER_COMPLETE_OES; }
RenderingEngine::RenderingEngine() { #ifndef MACOSX glGenRenderbuffersOES(1, &m_colorRenderbuffer); glBindRenderbufferOES(GL_RENDERBUFFER_OES, m_colorRenderbuffer); #endif }
void GLES11RenderEngine::bindImageAsFramebuffer(EGLImageKHR image, uint32_t* texName, uint32_t* fbName, uint32_t* status, bool useReadPixels, int reqWidth, int reqHeight) { GLuint tname, name; if (!useReadPixels) { // turn our EGLImage into a texture glGenTextures(1, &tname); glBindTexture(GL_TEXTURE_2D, tname); glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, (GLeglImageOES)image); // create a Framebuffer Object to render into glGenFramebuffersOES(1, &name); glBindFramebufferOES(GL_FRAMEBUFFER_OES, name); glFramebufferTexture2DOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_TEXTURE_2D, tname, 0); } else { // since we're going to use glReadPixels() anyways, // use an intermediate renderbuffer instead glGenRenderbuffersOES(1, &tname); glBindRenderbufferOES(GL_RENDERBUFFER_OES, tname); glRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_RGBA8_OES, reqWidth, reqHeight); // create a FBO to render into glGenFramebuffersOES(1, &name); glBindFramebufferOES(GL_FRAMEBUFFER_OES, name); glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, tname); } *status = glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES); *texName = tname; *fbName = name; }
RenderingEngine::RenderingEngine(IResourceManager* resourceManager) { m_resourceManager = resourceManager; m_offset = 0; glGenRenderbuffersOES(1, &m_colorRenderbuffer); glBindRenderbufferOES(GL_RENDERBUFFER_OES, m_colorRenderbuffer); }
OpenGLRTTexture::OpenGLRTTexture(unsigned int _texture, int width, int height) : mTextureID(_texture), mWidth(width), mHeight(height), mFBOID(0), mRBOID(0) { int miplevel = 0; glBindTexture(GL_TEXTURE_2D, mTextureID); //glGetTexLevelParameteriv(GL_TEXTURE_2D, miplevel, GL_TEXTURE_WIDTH, &mWidth); // Unsupported by OpenGL ES, using param //glGetTexLevelParameteriv(GL_TEXTURE_2D, miplevel, GL_TEXTURE_HEIGHT, &mHeight); // Unsupported by OpenGL ES, using param glBindTexture(GL_TEXTURE_2D, 0); mRenderTargetInfo.maximumDepth = 1.0f; mRenderTargetInfo.hOffset = 0; mRenderTargetInfo.vOffset = 0; mRenderTargetInfo.aspectCoef = float(mHeight) / float(mWidth); mRenderTargetInfo.pixScaleX = 1.0f / float(mWidth); mRenderTargetInfo.pixScaleY = 1.0f / float(mHeight); // create a framebuffer object, you need to delete them when program exits. glGenFramebuffersOES(1, &mFBOID); glBindFramebufferOES(GL_FRAMEBUFFER_OES, mFBOID); // create a renderbuffer object to store depth info // NOTE: A depth renderable image should be attached the FBO for depth test. // If we don't attach a depth renderable image to the FBO, then // the rendering output will be corrupted because of missing depth test. // If you also need stencil test for your rendering, then you must // attach additional image to the stencil attachement point, too. glGenRenderbuffersOES(1, &mRBOID); glBindRenderbufferOES(GL_RENDERBUFFER_OES, mRBOID); glRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_DEPTH_COMPONENT16_OES, mWidth, mHeight); glBindRenderbufferOES(GL_RENDERBUFFER_OES, 0); // attach a texture to FBO color attachement point glFramebufferTexture2DOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_TEXTURE_2D, mTextureID, 0); // attach a renderbuffer to depth attachment point glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, mRBOID); glBindFramebufferOES(GL_FRAMEBUFFER_OES, 0); }
void EJCanvasContextScreen::present() { glViewport(0, 0, viewportWidth, viewportHeight); #ifdef _WINDOWS glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0 ); glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0 ); #else glBindFramebufferOES(GL_FRAMEBUFFER_OES, 0 ); glBindRenderbufferOES(GL_RENDERBUFFER_OES, 0 ); #endif // [self flushBuffers]; EJCanvasContext::flushBuffers(); if( msaaEnabled ) { #ifdef _WINDOWS //Bind the MSAA and View frameBuffers and resolve glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, msaaFrameBuffer); glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, viewFrameBuffer); //glResolveMultisampleFramebufferAPPLE(); glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, viewRenderBuffer); // [[EJApp instance].glContext presentRenderbuffer:GL_RENDERBUFFER]; // EJApp::instance()->glContext->presentRenderbuffer(GL_RENDERBUFFER_OES); // presentRenderbuffer(GL_RENDERBUFFER_OES); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, msaaFrameBuffer); #else //Bind the MSAA and View frameBuffers and resolve glBindFramebufferOES(GL_FRAMEBUFFER_OES, msaaFrameBuffer); glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFrameBuffer); // glResolveMultisampleFramebufferAPPLE(); glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderBuffer); // [[EJApp instance].glContext presentRenderbuffer:GL_RENDERBUFFER]; // EJApp::instance()->glContext->presentRenderbuffer(GL_RENDERBUFFER_OES); // presentRenderbuffer(GL_RENDERBUFFER_OES); glBindFramebufferOES(GL_FRAMEBUFFER_OES, msaaFrameBuffer); #endif } else { } }
void RenderES1::setViewPort(int width, int height) { glGenRenderbuffersOES(1, &_render_buffer); glBindRenderbufferOES(GL_RENDERBUFFER_OES, _render_buffer); // glGenFramebuffersOES(1, &_frame_buffer); glBindFramebufferOES(GL_FRAMEBUFFER_OES, _frame_buffer); glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, _render_buffer); glViewport(0, 0, width, height); }
void GLESStateCacheManagerImp::bindGLBuffer(GLenum target, GLuint buffer, GLenum attach, bool force) { // Update GL if(target == GL_FRAMEBUFFER_OES) glBindFramebufferOES(target, buffer); else if(target == GL_RENDERBUFFER_OES) glBindRenderbufferOES(target, buffer); else glBindBuffer(target, buffer); GL_CHECK_ERROR }
void DestroySurfaceGLES(EAGLSurfaceDesc* surface) { if( surface->renderbuffer ) { GLES_CHK( glBindRenderbufferOES(GL_RENDERBUFFER_OES, surface->renderbuffer) ); DeallocateRenderBufferStorageFromEAGLLayer(); GLES_CHK( glBindRenderbufferOES(GL_RENDERBUFFER_OES, 0) ); GLES_CHK( glDeleteRenderbuffersOES(1, &surface->renderbuffer) ); surface->renderbuffer = 0; } if( surface->framebuffer ) { GLES_CHK( glDeleteFramebuffersOES(1, &surface->framebuffer) ); surface->framebuffer = 0; } DestroySurfaceMultisampleBuffersGLES(surface); }
void EJCanvasContext::create() { #ifdef _WINDOWS if( msaaEnabled ) { glGenFramebuffersEXT(1, &msaaFrameBuffer); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, msaaFrameBuffer); glGenRenderbuffersEXT(1, &msaaRenderBuffer); glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, msaaRenderBuffer); //glRenderbufferStorageMultisampleIMG(GL_RENDERBUFFER, msaaSamples, GL_RGBA8, bufferWidth, bufferHeight); glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER_EXT, msaaRenderBuffer); } glGenFramebuffersEXT(1, &viewFrameBuffer); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, viewFrameBuffer); glGenRenderbuffersEXT(1, &viewRenderBuffer); glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, viewRenderBuffer); #else if( msaaEnabled ) { glGenFramebuffersOES(1, &msaaFrameBuffer); glBindFramebufferOES(GL_FRAMEBUFFER_OES, msaaFrameBuffer); glGenRenderbuffersOES(1, &msaaRenderBuffer); glBindRenderbufferOES(GL_RENDERBUFFER_OES, msaaRenderBuffer); //glRenderbufferStorageMultisampleIMG(GL_RENDERBUFFER_OES, msaaSamples, GL_RGBA8_OES, bufferWidth, bufferHeight); glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, msaaRenderBuffer); } glGenFramebuffersOES(1, &viewFrameBuffer); glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFrameBuffer); glGenRenderbuffersOES(1, &viewRenderBuffer); glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderBuffer); #endif }
GL11Renderer::GL11Renderer() : m_framebuffer( 0 ), m_colorRenderbuffer( 0 ), m_depthRenderbuffer( 0 ), m_snowTextureId( 0 ), m_vertexBufferId( 0 ), m_colorBufferId( 0 ), m_pointSizeBufferId( 0 ), m_resourceLoader( CreateResourceLoader() ) { // Create and bind the color buffer so that the caller can allocate its space. glGenRenderbuffersOES( 1, &m_colorRenderbuffer ); glBindRenderbufferOES( GL_RENDERBUFFER_OES, m_colorRenderbuffer ); }
static bool try_as_render_buffer(EGLImageKHR img) { GLuint rbo; bool res; glGenRenderbuffersOES(1, &rbo); glBindRenderbufferOES(GL_RENDERBUFFER_OES, rbo); glEGLImageTargetRenderbufferStorageOES(GL_RENDERBUFFER_OES, img); res = piglit_check_gl_error(GL_NO_ERROR); glDeleteRenderbuffersOES(1, &rbo); return res; }
void EJCanvasContext::createStencilBufferOnce() { if( stencilBuffer ) { return; } #ifdef _WINDOWS glGenRenderbuffersEXT(1, &stencilBuffer); glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, stencilBuffer); if( msaaEnabled ) { glRenderbufferStorageMultisample(GL_RENDERBUFFER_EXT, msaaSamples, GL_DEPTH24_STENCIL8, bufferWidth, bufferHeight); } else { glRenderbufferStorage(GL_RENDERBUFFER_EXT, GL_DEPTH24_STENCIL8, bufferWidth, bufferHeight); } glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER_EXT, stencilBuffer); glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER_EXT, stencilBuffer); glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, msaaEnabled ? msaaRenderBuffer : viewRenderBuffer ); #else glGenRenderbuffersOES(1, &stencilBuffer); glBindRenderbufferOES(GL_RENDERBUFFER_OES, stencilBuffer); if( msaaEnabled ) { //glRenderbufferStorageMultisampleAPPLE(GL_RENDERBUFFER, msaaSamples, GL_DEPTH24_STENCIL8_OES, bufferWidth, bufferHeight); } else { glRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_DEPTH24_STENCIL8_OES, bufferWidth, bufferHeight); } glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, stencilBuffer); glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_STENCIL_ATTACHMENT_OES, GL_RENDERBUFFER_OES, stencilBuffer); glBindRenderbufferOES(GL_RENDERBUFFER_OES, msaaEnabled ? msaaRenderBuffer : viewRenderBuffer ); #endif glClear(GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); }
void GLESStateCacheManagerImp::bindGLBuffer(GLenum target, GLuint buffer, GLenum attach, bool force) { GLuint hash = target | (attach << 16); GLBindingMap::iterator i = mActiveBufferMap.find(hash); if (i == mActiveBufferMap.end()) { // Update GL if(target == GL_FRAMEBUFFER_OES) glBindFramebufferOES(target, buffer); else if(target == GL_RENDERBUFFER_OES) glBindRenderbufferOES(target, buffer); else glBindBuffer(target, buffer); GL_CHECK_ERROR // Haven't cached this state yet. Insert it into the map mActiveBufferMap.insert(GLBindingMap::value_type(hash, buffer)); } else { // Update the cached value if needed if((*i).second != buffer || force) { (*i).second = buffer; // Update GL if(target == GL_FRAMEBUFFER_OES) glBindFramebufferOES(target, buffer); else if(target == GL_RENDERBUFFER_OES) glBindRenderbufferOES(target, buffer); else glBindBuffer(target, buffer); GL_CHECK_ERROR } }
virtual GLenum createFBO(GLuint& framebuffer, GLuint& depthbuffer, GLuint& img, int width, int height) { // get currently bound fbo to reset to it later GLint current_fbo; glGetIntegerv(GL_FRAMEBUFFER_BINDING_OES, ¤t_fbo); // generate depth buffer glGenRenderbuffersOES(1, &depthbuffer); glBindRenderbufferOES(GL_RENDERBUFFER_OES, depthbuffer); glRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_DEPTH_COMPONENT16_OES, width, height); glBindRenderbufferOES(GL_RENDERBUFFER_OES, 0); // generate texture save target glGenTextures(1, &img); glBindTexture(GL_TEXTURE_2D, img); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8_OES, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); glBindTexture(GL_TEXTURE_2D, 0); // create framebuffer glGenFramebuffersOES(1, &framebuffer); glBindFramebufferOES(GL_FRAMEBUFFER_OES, framebuffer); glFramebufferTexture2DOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_TEXTURE_2D, img, 0); glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, depthbuffer); GLenum status = glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES); // unbind framebuffer glBindFramebufferOES(GL_FRAMEBUFFER_OES, (GLuint)current_fbo); return status; }
void sgTexture::makeRendertarget() { if(textype != GL_TEXTURE_2D || fbo != -1) return; if(sgRenderer::oglversion > 1) { #if defined __IOS__ glGenFramebuffers(1, &fbo); glBindFramebuffer(GL_FRAMEBUFFER, fbo); glBindTexture(textype, 0); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texid, 0); glClear(GL_COLOR_BUFFER_BIT); glGenRenderbuffers(1, &fbo_depth); glBindRenderbuffer(GL_RENDERBUFFER, fbo_depth); // glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8_OES, width, height); glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, width, height); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, fbo_depth); #else glGenFramebuffersEXT(1, &fbo); glBindFramebufferEXT(GL_FRAMEBUFFER, fbo); glBindTexture(textype, 0); glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texid, 0); glClear(GL_COLOR_BUFFER_BIT); glGenRenderbuffersEXT(1, &fbo_depth); glBindRenderbufferEXT(GL_RENDERBUFFER, fbo_depth); // glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8_OES, width, height); glRenderbufferStorageEXT(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, width, height); glFramebufferRenderbufferEXT(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, fbo_depth); #endif }else { #if defined __IOS__ glGenFramebuffersOES(1, &fbo); glBindFramebufferOES(GL_FRAMEBUFFER_OES, fbo); glBindTexture(GL_TEXTURE_2D, 0); glFramebufferTexture2DOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_TEXTURE_2D, texid, 0); glGenRenderbuffersOES(1, &fbo_depth); glBindRenderbufferOES(GL_RENDERBUFFER_OES, fbo_depth); glRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_DEPTH_COMPONENT16_OES, width, height); glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, fbo_depth); #endif } }
void AfterPresentSurfaceGLES(EAGLSurfaceDesc* surface) { if(surface->use32bitColor != UnityUse32bitDisplayBuffer()) { surface->use32bitColor = UnityUse32bitDisplayBuffer(); CreateSurfaceGLES(surface); GLES_CHK( glBindRenderbufferOES(GL_RENDERBUFFER_OES, surface->systemRenderbuffer) ); } if(NeedRecreateRenderingSurfaceGLES(surface)) { UnityGetRenderingResolution(&surface->targetW, &surface->targetH); surface->msaaSamples = UnityGetDesiredMSAASampleCount(MSAA_DEFAULT_SAMPLE_COUNT); CreateRenderingSurfaceGLES(surface); } }
FBO *createFBO(s32 width, s32 height, bool hd) { // save current FBO FBO *oldFBO = getFBOUsed(); GLuint framebuffer; GLuint depthRenderbuffer; width = width; height = height; s32 texturePtrId = createTexture(0, 0); setTexture(texturePtrId, width, height, 3, NULL); Texture *tex = getTexture(texturePtrId); // create depth renderbuffer glGenRenderbuffersOES(1, &depthRenderbuffer); glBindRenderbufferOES(GL_RENDERBUFFER_OES, depthRenderbuffer); glRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_DEPTH_COMPONENT16_OES, width, height); // bind framebuffer & attach texture glGenFramebuffersOES(1, &framebuffer); glBindFramebufferOES(GL_FRAMEBUFFER_OES, framebuffer); glFramebufferTexture2DOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_TEXTURE_2D, tex->mTextureId, 0); glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, depthRenderbuffer); // check binding if (glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES) { logError(TAG, "CRITICAL ERROR: FBO no complete"); return 0; } // save info into structure FBO *fbo = (FBO *)malloc(sizeof(FBO)); fbo->mFBO = framebuffer; fbo->mWidth = width; fbo->mHeight = height; fbo->mTexturePtrId = texturePtrId; fbo->mDepthRenderBuffer = depthRenderbuffer; // restore FBO useFBO(oldFBO); return fbo; }
//********* GLESRenderBuffer //----------------------------------------------------------------------------- GLESRenderBuffer::GLESRenderBuffer(GLenum format, size_t width, size_t height, GLsizei numSamples): GLESHardwarePixelBuffer(width, height, 1, GLESPixelUtil::getClosestOGREFormat(format, PF_A8R8G8B8),HBU_WRITE_ONLY) { mGLInternalFormat = format; // Generate renderbuffer glGenRenderbuffersOES(1, &mRenderbufferID); GL_CHECK_ERROR; // Bind it to FBO glBindRenderbufferOES(GL_RENDERBUFFER_OES, mRenderbufferID); GL_CHECK_ERROR; // Allocate storage for depth buffer if (numSamples <= 0) { glRenderbufferStorageOES(GL_RENDERBUFFER_OES, format, width, height); GL_CHECK_ERROR; } }
void EJCanvasContext::prepare() { //Bind the frameBuffer and vertexBuffer array #ifdef _WINDOWS glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, msaaEnabled ? msaaFrameBuffer : viewFrameBuffer ); glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, msaaEnabled ? msaaRenderBuffer : viewRenderBuffer ); #else glBindFramebufferOES(GL_FRAMEBUFFER_OES, msaaEnabled ? msaaFrameBuffer : viewFrameBuffer ); glBindRenderbufferOES(GL_RENDERBUFFER_OES, msaaEnabled ? msaaRenderBuffer : viewRenderBuffer ); #endif glViewport(0, 0, viewportWidth, viewportHeight); glMatrixMode(GL_PROJECTION); glLoadIdentity(); #ifdef _WINDOWS glOrtho(0, width, 0, height, -1, 1); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); #else glOrthof(0, width, 0, height, -1, 1); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); #endif EJCompositeOperation op = state->globalCompositeOperation; glBlendFunc( EJCompositeOperationFuncs[op].source, EJCompositeOperationFuncs[op].destination ); glDisable(GL_TEXTURE_2D); currentTexture = NULL; EJTexture::setSmoothScaling(imageSmoothingEnabled); bindVertexBuffer(); if( state->clipPath ) { glDepthFunc(GL_EQUAL); } else { glDepthFunc(GL_ALWAYS); } }
void glBindRenderbufferOESLogged(GLenum target, GLuint renderbuffer) { printf("glBindRenderbufferOES(%s, %u)\n", GLEnumName(target), renderbuffer); glBindRenderbufferOES(target, renderbuffer); }
RenderingEngine1::RenderingEngine1() { // Create & bind the color buffer so that the caller can allocate its space. glGenRenderbuffersOES(1, &m_renderbuffer); glBindRenderbufferOES(GL_RENDERBUFFER_OES, m_renderbuffer); }