纹理呈现黑色到大型FBO(qt QGLFramebufferObject)

时间:2015-04-20 10:26:07

标签: c++ qt opengl texture2d fbo

使用qt QGLFramebufferObject渲染纹理,当我使用FBO约2000x2000 widthxheight时,它正确显示,但当尺寸超过约2750x2750时,纹理显示为黑色。它适用于2000x3000或2800x2500,因此尺寸的产品必须小于约750万

这里渲染为fbo纹理代码:

makeCurrent();
saveGLState();
glDisable(GL_TEXTURE_2D);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glEnableClientState(GL_VERTEX_ARRAY);
glViewport(0, 0, figureFBO->size().width(), figureFBO->size().height());
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-1, 1, -1, 1, -1, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

figureFBO->bind();
{
    qglClearColor(Qt::yellow);
    glClear(GL_COLOR_BUFFER_BIT);
    qglColor(Qt::blue);
    glVertexPointer(2, GL_FLOAT, 0, vertices.constData());
    glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
}
figureFBO->release();
restoreGLState();

这里是从FBO显示纹理的代码

    makeCurrent();
    qglClearColor(Qt::darkRed);
    glClear(GL_COLOR_BUFFER_BIT);
    qglColor(Qt::white);
    glEnable(GL_TEXTURE_2D);
    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    glTexCoordPointer(2, GL_FLOAT, 0, textureVertices.constData());
    glVertexPointer(2, GL_FLOAT, 0, vertices.constData());
    glBindTexture(GL_TEXTURE_2D, figureFBO->texture());
    glDrawArrays(GL_TRIANGLE_FAN, 0, 4);

0 个答案:

没有答案