void FBO::generateDepthOnly() { destroy(); glGenTextures(1, &m_iTexDepthId); glBindTexture(m_eTextureType, m_iTexDepthId); //we create a special texture for depth glTexImage2D(m_eTextureType, 0, GL_DEPTH_COMPONENT, m_iWidth, m_iHeight, 0,GL_DEPTH_COMPONENT, GL_FLOAT, 0); glTexParameteri (m_eTextureType, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri (m_eTextureType, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(m_eTextureType, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameteri(m_eTextureType, GL_TEXTURE_WRAP_T, GL_CLAMP); glBindTexture(m_eTextureType, 0); //Generating ID glGenFramebuffersEXT(1, &m_iId); activate(); //We attach the texture to the depth attachment point glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,GL_DEPTH_ATTACHMENT_EXT,m_eTextureType, m_iTexDepthId, 0); //In order to avoid Color in the depth buffer glDrawBuffer(GL_NONE); glReadBuffer(GL_NONE); desactivate(); //Check FBO status if(!checkFramebufferStatus()) std::cerr<<"ERROR : FBO creation Fail "<<std::endl; //Depth Only m_iType = 1; }
void FBO::generateColorOnly(bool tex16f) { destroy(); //Generate the texture glGenTextures(1, &m_iTexId); glBindTexture(m_eTextureType, m_iTexId); glTexParameteri (m_eTextureType, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri (m_eTextureType, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(m_eTextureType, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(m_eTextureType, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(m_eTextureType, GL_GENERATE_MIPMAP, GL_TRUE); ///We need six Face for cube, or one for 2D if (m_eTextureType == GL_TEXTURE_CUBE_MAP) { glTexImage2D( GL_TEXTURE_CUBE_MAP_POSITIVE_X , 0, GL_RGBA8, m_iWidth, m_iHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); glTexImage2D( GL_TEXTURE_CUBE_MAP_POSITIVE_Y , 0, GL_RGBA8, m_iWidth, m_iHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); glTexImage2D( GL_TEXTURE_CUBE_MAP_POSITIVE_Z , 0, GL_RGBA8, m_iWidth, m_iHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); glTexImage2D( GL_TEXTURE_CUBE_MAP_NEGATIVE_X , 0, GL_RGBA8, m_iWidth, m_iHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); glTexImage2D( GL_TEXTURE_CUBE_MAP_NEGATIVE_Y , 0, GL_RGBA8, m_iWidth, m_iHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); glTexImage2D( GL_TEXTURE_CUBE_MAP_NEGATIVE_Z , 0, GL_RGBA8, m_iWidth, m_iHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); } else{ if(!tex16f) glTexImage2D(m_eTextureType, 0, GL_RGBA8, m_iWidth, m_iHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); else glTexImage2D(m_eTextureType, 0, GL_RGB16F_ARB, m_iWidth, m_iHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); } glBindTexture(m_eTextureType, 0); //Generate renderbuffer glGenRenderbuffersEXT(1, &m_iRenderId); glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, m_iRenderId); glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24, m_iWidth, m_iHeight); glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0); //Generating ID glGenFramebuffersEXT(1, &m_iId); activate(); // attach a texture to FBO color attachement point glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, m_eTextureType, m_iTexId, 0); // attach a renderbuffer to depth attachment point glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_iRenderId); desactivate(); //Check FBO status if(!checkFramebufferStatus()) std::cerr<<"ERROR : FBO creation Fail "<<std::endl; //Color Only m_iType = 0; }
TDCompound::~TDCompound (void) { if (id_displayed != td_notdispd) hideindestructor (); if (id_evented != GRTD_UNDEF) desactivate (); list <TDObj*> :: iterator li; for (li=ltd.begin() ; li!=ltd.end() ; li++) (*li)->ptdparent = NULL; }
TDObj::~TDObj (void) { if (id_displayed != td_notdispd) hideindestructor (); if (mouseflyover == this) // JDJDJDJD maybe we should check that mousebuttonfocus and ownergrabmouse need the same treatment ? mouseflyover = NULL; if (id_evented != GRTD_UNDEF) desactivate (); if (ptdparent != NULL) { bzouzerr << "WARNING - we have here some TDObj that is destroyed while still in some parent's list" << endl ; ptdparent->erase (id_ltdparent); } }
void FBO::generate() { // create a texture object for the depthmap glGenTextures(1, &m_iTexDepthId); glBindTexture(m_eTextureType, m_iTexDepthId); glTexParameterf(m_eTextureType, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameterf(m_eTextureType, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameterf(m_eTextureType, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameterf(m_eTextureType, GL_TEXTURE_WRAP_T, GL_CLAMP); glTexParameteri(m_eTextureType, GL_GENERATE_MIPMAP, GL_TRUE); glTexImage2D(m_eTextureType, 0, GL_DEPTH_COMPONENT, m_iWidth, m_iHeight, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, 0); glBindTexture(m_eTextureType, 0); // create a texture object glGenTextures(1, &m_iTexId); glBindTexture(m_eTextureType, m_iTexId); glTexParameterf(m_eTextureType, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameterf(m_eTextureType, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameterf(m_eTextureType, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameterf(m_eTextureType, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(m_eTextureType, GL_GENERATE_MIPMAP, GL_TRUE); glTexImage2D(m_eTextureType, 0, GL_RGBA8, m_iWidth, m_iHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); glBindTexture(m_eTextureType, 0); glGenFramebuffersEXT(1, &m_iId); activate(); // attach a texture to FBO color attachement point glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, m_eTextureType, m_iTexDepthId, 0); glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, m_eTextureType, m_iTexId, 0); desactivate(); //Check FBO status if(!checkFramebufferStatus()) std::cerr<<"ERROR : FBO creation Fail "<<std::endl; //Color + Depth m_iType = 2; }