当前位置:编程学习 > wap >>

opengl es 2.0 render to texture的问题

// create the texture
GLuint texture;
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8,  width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);

关于Render to texture 看到iOS的opengl es 编程指南中的代码,如上所示,glTexImage2D函数中,最后一个参数为NULL,系统会自动的分配texture的空间吗?按照他的思路,我在执行中,老是检验FrameBuffer失败。

    GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER) ;
    if(status != GL_FRAMEBUFFER_COMPLETE) {
        NSLog(@"failed to make complete framebuffer object %x", status);
    } --------------------编程问答-------------------- 顶!!!!!!!!!!!!!!!!! --------------------编程问答-------------------- 搞明白了,系统会自动分配。

检验失败,是因为Texture的尺寸写错了。
补充:移动开发 ,  iPhone
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,