background:
Based on TDA4, SDK7.03, QNX system, to achieve off-screen rendering
I have an initialization function, mainly for off-screen rendering initialization (FBO)
void InitFrameBuffer()
{
//Src texture: off-screen rendering FBO
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &m_nSvDefaultFbo);
glGenTextures(1, &m_nSvTextureSrc);
glBindTexture(GL_TEXTURE_2D, m_nSvTextureSrc);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 480, 720, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
glBindTexture(GL_TEXTURE_2D, 0);
glGenFramebuffers(1, &m_nSvFbo);
glBindFramebuffer(GL_FRAMEBUFFER, m_nSvbo);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_nSvTextureSrc, 0);
glBindFramebuffer(GL_FRAMEBUFFER, m_nSvDefaultFbo);
//Dst texture 1: used to save the historical frame texture-the previous frame
glGenTextures(1, &m_nSvTextureLast1);
glBindTexture(GL_TEXTURE_2D, m_nSvTextureLast1);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 480, 720, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
glBindTexture(GL_TEXTURE_2D, 0);
//Dst texture 2: used to save the historical frame texture-the previous frame of the previous frame
glGenTextures(1, &m_nSvTextureLast2);
glBindTexture(GL_TEXTURE_2D, m_nSvTextureLast2);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 480, 720, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
glBindTexture(GL_TEXTURE_2D, 0);
}
Then I have a Run function, mainly for off-screen rendering
void Run()
{
glBindFramebuffer(GL_FRAMEBUFFER, m_nSvFbo);
... ...
DrawImage1();
... ...
DrawImage2();
... ...
glBindFramebuffer(GL_FRAMEBUFFER, 0);
Draw(m_nSvTextureSrc);
problem:
//Here I want to save m_nSvTextureSrc to another texture for use in the next Run drawing
//m_nSvTextureLast1 = m_nSvTextureSrc;
//m_nSvTextureLast2 = m_nSvTextureLast1;
//Equivalent to continuously saving 2 frames of history texture
//How to do it?
//It doesn't seem right to adopt the following strategy
/*glBindFramebuffer(GL_FRAMEBUFFER, m_nSvFbo);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_nSvTextureSrc, 0);
glBindTexture(GL_TEXTURE_2D, m_nSvTextureLast1);
glCopyTexSubImage2D(GL_TEXTURE_2D,0,0,0,0,0,480, 720);//Report 0x501:GL_INVALID_VALUE
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glBindTexture(GL_TEXTURE_2D, 0);*/
}