我正在尝试复制SDK生成的纹理,它们仅向我提供ID。 我希望将该纹理复制到在Ogre中创建的纹理。
我尝试了以下操作,因为我得到了空白的黑色图像。
Src纹理是mTextureId,目标纹理是tID。
创建上下文:
mOgreContext = Core::ViewarGeneralMaster::getSingleton()->getViewarMaster()->context();
self.mEAGLContext = mOgreContext->getContext();
contextB = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1
sharegroup:self.mEAGLContext.sharegroup];
if (!contextB || ![EAGLContext setCurrentContext:contextB]) {
// Handle errors here
}
SixDegreesSDK_Initialize(contextB);
glGenFramebuffers(1, &fboId);
在主循环中
if ( mTextureId == 0 )
{
mTextureId = SixDegreesSDK_GetBackgroundTexture();
NSLog( @"Texture id: %d", mTextureId );
}
Core::Resolution resolution = Core::EnvironmentInformation::getSingleton()->getScreenResolution();
glActiveTexture(GLenum(GL_TEXTURE0));
// 1. Ensure context A is not bound to the texture
[EAGLContext setCurrentContext:self.mEAGLContext];
glBindTexture(GL_TEXTURE_2D, 0);
// 2. Call flush on context A
glFlush();
// 3. Modify the texture on context B
[EAGLContext setCurrentContext:contextB];
glBindTexture(GL_TEXTURE_2D, mTextureId);
glBindFramebuffer(GL_FRAMEBUFFER, fboId);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mTextureId, 0);
//
// Modify the texture data here
//
// 4. Call flush on context B
glFlush();
// 5. Rebind the texture on context A
[EAGLContext setCurrentContext:self.mEAGLContext];
glBindTexture(GL_TEXTURE_2D, tId);
glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, width, height, 0);
glFlush();