// Inheritance exigences void TGBufferCanvas::Init() { // Drawable data m_output.width = m_width; m_output.height = m_height; // Creating the main frame buffer m_frameBuffer = CreateFrameBuffer(); BindFrameBuffer(m_frameBuffer); // Creating the textures // Memory allocation m_output.buffers.resize(5); // The abledo buffer TTextureInfo& albedo = m_output.buffers[0]; albedo.name = "albedo"; albedo.type = TTextureNature::COLOR; albedo.offset = 0; CreateTexture(albedo, m_width, m_height); BindToFrameBuffer(albedo); // The normal buffer TTextureInfo& normal = m_output.buffers[1]; normal.name = "normal"; normal.type = TTextureNature::COLOR; normal.offset = 1; CreateTexture(normal, m_width, m_height); BindToFrameBuffer(normal); // The specular buffer TTextureInfo& specular = m_output.buffers[2]; specular.name = "specular"; specular.type = TTextureNature::COLOR; specular.offset = 2; CreateTexture(specular, m_width, m_height); BindToFrameBuffer(specular); // Position Buffer TTextureInfo& position = m_output.buffers[3]; position.name = "position"; position.type = TTextureNature::COLOR; position.offset = 3; CreateTexture(position, m_width, m_height); BindToFrameBuffer(position); // Depth buffer TTextureInfo& depth = m_output.buffers[4]; depth.name = "depth"; depth.type = TTextureNature::DEPTH; depth.offset = 4; CreateTexture(depth, m_width, m_height); BindToFrameBuffer(depth); // Making sure everything is OK CheckFrameBuffer(); UnBindFrameBuffer(); }
bool CDVDVideoPPFFmpeg::Process(DVDVideoPicture* pPicture) { m_pSource = pPicture; if(m_pSource->format != RENDER_FMT_YUV420P) return false; if( !CheckInit(m_pSource->iWidth, m_pSource->iHeight) ) { CLog::Log(LOGERROR, "Initialization of ffmpeg postprocessing failed"); return false; } //If no target was set or we are using internal buffer, make sure it's correctly sized if(m_pTarget == &m_FrameBuffer || !m_pTarget) { if(CheckFrameBuffer(m_pSource)) m_pTarget = &m_FrameBuffer; else { m_pTarget = NULL; return false; } } int pict_type = (m_pSource->qscale_type != DVP_QSCALE_MPEG1) ? PP_PICT_TYPE_QP2 : 0; m_dll.pp_postprocess(m_pSource->data, m_pSource->iLineSize, m_pTarget->data, m_pTarget->iLineSize, m_pSource->iWidth, m_pSource->iHeight, m_pSource->qscale_table, m_pSource->qscale_stride, m_pMode, m_pContext, pict_type); //m_pSource->iFrameType); //Copy frame information over to target, but make sure it is set as allocated should decoder have forgotten m_pTarget->iFlags = m_pSource->iFlags | DVP_FLAG_ALLOCATED; if (m_deinterlace) m_pTarget->iFlags &= ~DVP_FLAG_INTERLACED; m_pTarget->iFrameType = m_pSource->iFrameType; m_pTarget->iRepeatPicture = m_pSource->iRepeatPicture;; m_pTarget->iDuration = m_pSource->iDuration; m_pTarget->qscale_table = m_pSource->qscale_table; m_pTarget->qscale_stride = m_pSource->qscale_stride; m_pTarget->qscale_type = m_pSource->qscale_type; m_pTarget->iDisplayHeight = m_pSource->iDisplayHeight; m_pTarget->iDisplayWidth = m_pSource->iDisplayWidth; m_pTarget->pts = m_pSource->pts; m_pTarget->iGroupId = m_pSource->iGroupId; m_pTarget->format = RENDER_FMT_YUV420P; return true; }
void clGLFrameBuffer::InitRenderTargetV( const ivec4& WidthHeightBitsPerChannel, const bool HasDepthBuffer ) { FColorBuffersParams = WidthHeightBitsPerChannel; FHasDepthBuffer = HasDepthBuffer; LGL3->glGenFramebuffers( 1, &FFrameBuffer ); Bind( 0 ); // new color buffer FColorBuffer = make_intrusive<clGLTexture>(); int Width = FColorBuffersParams[0]; int Height = FColorBuffersParams[1]; int BitsPerChan = FColorBuffersParams[2]; #if defined(OS_ANDROID) || defined(OS_EMSCRIPTEN) const Lenum InternalFormat = GL_RGBA; auto DepthFormat = GL_DEPTH_COMPONENT; #else const Lenum InternalFormat = GL_RGBA8; auto DepthFormat = GL_DEPTH_COMPONENT24; #endif FColorBuffer->SetFormat( GL_TEXTURE_2D, InternalFormat, GL_RGBA, Width, Height ); FColorBuffer->AttachToCurrentFB( GL_COLOR_ATTACHMENT0 ); // depth buffer if ( HasDepthBuffer ) { FDepthBuffer = make_intrusive<clGLTexture>(); int Width = FColorBuffersParams[0]; int Height = FColorBuffersParams[1]; FDepthBuffer->SetFormat( GL_TEXTURE_2D, DepthFormat, GL_DEPTH_COMPONENT, Width, Height ); FDepthBuffer->AttachToCurrentFB( GL_DEPTH_ATTACHMENT ); } CheckFrameBuffer(); UnBind(); }
bool MyCanvas::InitRes(){ //bool createOffsetFrame(uint &frameID, uint &textureID, int screensize, int flags){ bool depth= (kind==DEPTH); bool hide= (kind==DEPTH); bool use_depth= (kind==COLOR_AND_DEPTH ); int screensizex=GetHardRes(); int screensizey=GetHardRes(); if (ratio2x1) screensizex*=2; uint status=12345; if (glCheckFramebufferStatusEXT!=0) status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); switch(status) { case 12345: //printf("FrameBufferObject Extension not found! [hint: Update drivers] No shadows :(...\n"); return false; case GL_FRAMEBUFFER_COMPLETE_EXT: break; case GL_FRAMEBUFFER_UNSUPPORTED_EXT: //printf("FrameBufferObject not supported by your card! No shadows :(...\n"); return false; } // creiamo: glGenFramebuffersEXT(1, (GLuint *)(& (frameID[ currentRes ])) ); // frame buffer //if (textureID==666) glGenTextures(1, (GLuint *)(&(textureID[ currentRes ]) )); // settimao l'offset Frame glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, frameID[ currentRes ]); const int NTRIES=2; unsigned int tryme[NTRIES]={GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT16}; static GLuint dummydepth=666; for (int i=0; i<((depth||use_depth)?NTRIES:1); i++) { /**/ // initialize texture /**/ //glActiveTextureARB(GL_TEXTURE1_ARB); /**/ glBindTexture(GL_TEXTURE_2D, textureID[currentRes] ); /**/ glTexImage2D(GL_TEXTURE_2D, 0, /**/ (depth)?tryme[i] :GL_RGBA8, /**/ screensizex, screensizey, 0, /**/ (depth)?GL_DEPTH_COMPONENT:GL_RGBA, /**/ (depth)?GL_UNSIGNED_INT:GL_UNSIGNED_BYTE, /**/ 0 /**/ ); /**/ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); /**/ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_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); // attach texture to framebuffer depth or color buffer glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, (depth)?GL_DEPTH_ATTACHMENT_EXT:GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, textureID[currentRes], 0); if (depth) { /**/ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); /**/ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); /**/ glTexParameteri (GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE, GL_LUMINANCE); GLuint renderID; if (hide) { // TODO: render to buffer NONE glGenRenderbuffersEXT(1, &renderID ); // render buffer glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, renderID ); glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA, screensizex, screensizey); glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, renderID ); } } if (use_depth) { #if 0 // create dummy depth TEXTURE if (dummydepth==666); glGenTextures(1, &dummydepth); glBindTexture(GL_TEXTURE_2D, dummydepth ); glTexImage2D(GL_TEXTURE_2D, 0, tryme[i], screensizex, screensizey, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, 0 ); // attach it to framebuffer glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D,dummydepth, 0); #else // create dummy depth Renderbuffer (on card) if (dummydepth==666) glGenRenderbuffersEXT(1, &dummydepth); glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, dummydepth ); glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, tryme[i], screensizex, screensizey ); // attach it to framebuffer glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, dummydepth); #endif } dummydepth=666; if (CheckFrameBuffer()) { glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0 ); return true; } } glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0 ); return false; }
int main(int argc, char* argv[]) { CheckFrameBuffer(); return 0; }