Original Post
I need to take sections of several source textures, and render them onto a destination texture, then each time through the render loop, i just draw the destination texture to my screen.
It is working now... in a way, just one little problem, that I really cant seem to figure out.
Lets imagine that my destination texture is empty (transparent even)
If i blit a solid texture onto destination
then i blit a texture with some transparency onto destination
somehow the transparency is blitted also, so that my destination ends up with 'holes' in if, where the transparency was copied.
is there a way to blit only the color values and not the transparency in the source textures.
here is my code for the blit, dont know if it helps
[source lang="cpp"]void cDuGlobals::GLBlit(int srcx,int srcy,int srcw,int srch,sDuTexture* src,int dstx,int dsty,sDuTexture* dst)
{
GLuint fboName;
glGenFramebuffers(1, &fboName);
// enable this frame buffer as the current frame buffer
glBindFramebuffer(GL_FRAMEBUFFER, fboName);// attach the textures to the frame buffer
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, src->textureID, 0);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, dst->textureID, 0);
GLenum fboStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER);
if (fboStatus != GL_FRAMEBUFFER_COMPLETE)
{
printf("FrameBuffer incomplete: 0x%x\n", fboStatus);
return;
}
glReadBuffer(GL_COLOR_ATTACHMENT0);
GLenum bufferlist[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2 };
glDrawBuffers(1, &bufferlist[1]);
glBlitFramebuffer(srcx,srcy,srcx+srcw,srcy+srch,dstx,dsty,dstx+srcw,dsty+srch,GL_COLOR_BUFFER_BIT,GL_NEAREST);
//glBlitFramebuffer(srcx,srcy,srcx+srcw-1,srcy+srch-1,dstx,dsty,dstx+srcw-1,dsty+srch-1,GL_COLOR_BUFFER_BIT,GL_NEAREST);
glDeleteFramebuffers(1, &fboName);
}
[/source]
Thanks for any help
It is working now... in a way, just one little problem, that I really cant seem to figure out.
Lets imagine that my destination texture is empty (transparent even)
If i blit a solid texture onto destination
then i blit a texture with some transparency onto destination
somehow the transparency is blitted also, so that my destination ends up with 'holes' in if, where the transparency was copied.
is there a way to blit only the color values and not the transparency in the source textures.
here is my code for the blit, dont know if it helps
[source lang="cpp"]void cDuGlobals::GLBlit(int srcx,int srcy,int srcw,int srch,sDuTexture* src,int dstx,int dsty,sDuTexture* dst)
{
GLuint fboName;
glGenFramebuffers(1, &fboName);
// enable this frame buffer as the current frame buffer
glBindFramebuffer(GL_FRAMEBUFFER, fboName);// attach the textures to the frame buffer
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, src->textureID, 0);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, dst->textureID, 0);
GLenum fboStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER);
if (fboStatus != GL_FRAMEBUFFER_COMPLETE)
{
printf("FrameBuffer incomplete: 0x%x\n", fboStatus);
return;
}
glReadBuffer(GL_COLOR_ATTACHMENT0);
GLenum bufferlist[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2 };
glDrawBuffers(1, &bufferlist[1]);
glBlitFramebuffer(srcx,srcy,srcx+srcw,srcy+srch,dstx,dsty,dstx+srcw,dsty+srch,GL_COLOR_BUFFER_BIT,GL_NEAREST);
//glBlitFramebuffer(srcx,srcy,srcx+srcw-1,srcy+srch-1,dstx,dsty,dstx+srcw-1,dsty+srch-1,GL_COLOR_BUFFER_BIT,GL_NEAREST);
glDeleteFramebuffers(1, &fboName);
}
[/source]
Thanks for any help