我通過IP鏈接發送一個opengl 3D場景到使用SDK 4.1構建的我的iPhone應用程序。我首先使用FBO渲染3D場景,然後用glReadPixels讀取它並將其發送給iphone應用程序。如果我將應用程序接收到的像素數據轉換爲UIImage,我發現它顯示正確。但是當我在使用opengl es 1.1(在iPhone 3G上)的glTexSubImage2D中使用相同的數據時,我什麼都看不到。任何想法可能會出錯?由於不支持glDrawPixels,因此我使用glTexSubImage2D。任何示例/教程來解決這個問題?感謝任何幫助。在opengl 1.1中使用glTexSubImage2D 1.1
在此先感謝。
Code -
- (id) initWithFrame: (CGRect) frame
{
.....
api = kEAGLRenderingAPIOpenGLES1;
m_context = [[EAGLContext alloc] initWithAPI:api];
glGenFramebuffersOES(1, &m_frameBuffer);
glBindFramebufferOES(GL_FRAMEBUFFER_OES, m_frameBuffer);
glGenRenderbuffersOES(1, &m_colorRenderbuffer);
glBindRenderbufferOES(GL_RENDERBUFFER_OES, m_colorRenderbuffer);
glGenTextures(1, &m_tex);
glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL);
....
}
- (void) drawView: (CADisplayLink*) displayLink
{
glBindTexture(GL_TEXTURE_2D, m_tex);
glTexSubImage2D(GL_TEXTURE_2D, 0,0,0,
WIDTH, HEIGHT,
GL_BGRA,
//GL_RGBA,
GL_UNSIGNED_BYTE,
m_pixelData);
const GLfloat quadVertices[] = {
-1.0f, -1.0f, 0.0f,
-1.0f, 1.0f, 0.0f,
1.0f, 1.0f, 0.0f,
1.0f, -1.0f, 0.0f,
-1.0f, -1.0f, 0.0f
};
// Sets up an array of values for the texture coordinates.
const GLfloat quadTexcoords[] = {
0.0f, 0.0f,
0.0f, 1.0f,
1.0f, 1.0f,
1.0f, 0.0f,
0.0f, 0.0f
};
glVertexPointer(3, GL_FLOAT, 0, quadVertices);
glEnableClientState(GL_VERTEX_ARRAY);
glTexCoordPointer(2, GL_FLOAT, 0, quadTexcoords);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glBindFramebufferOES(GL_FRAMEBUFFER_OES, m_frameBuffer);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 5);
glBindRenderbufferOES(GL_RENDERBUFFER_OES, m_colorRenderbuffer);
[m_context presentRenderbuffer:GL_RENDERBUFFER_OES];
}
哪裏是你的繪製調用? – Bahbar 2010-10-18 19:21:51
包括樣品繪製代碼 – 2010-10-19 09:26:15