PDA

View Full Version : FBO cube map



glararan
02-01-2014, 05:00 AM
Hello,

I'm creating FBO cube map, but I'm getting error 1281 on glTexImage2D.

GPU: nVidia 650M


GLfuncs->glGenTextures(1, &textureId);
GLfuncs->glBindTexture(GL_TEXTURE_CUBE_MAP, textureId);

qDebug() << "1" << GLfuncs->glGetError();

GLfuncs->glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_NEAREST); qDebug() << "2" << GLfuncs->glGetError();
GLfuncs->glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_NEAREST); qDebug() << "3" << GLfuncs->glGetError();
GLfuncs->glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); qDebug() << "4" << GLfuncs->glGetError();
GLfuncs->glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); qDebug() << "5" << GLfuncs->glGetError();
GLfuncs->glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); qDebug() << "6" << GLfuncs->glGetError();
GLfuncs->glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_BASE_LEVEL, 0); qDebug() << "7" << GLfuncs->glGetError();
GLfuncs->glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAX_LEVEL, 0); qDebug() << "8" << GLfuncs->glGetError();

GLfuncs->glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGBA8, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL);
qDebug() << "9" << GLfuncs->glGetError();
GLfuncs->glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGBA8, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL);
qDebug() << "10" << GLfuncs->glGetError();
GLfuncs->glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGBA8, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL);
qDebug() << "11" << GLfuncs->glGetError();
GLfuncs->glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGBA8, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL);
qDebug() << "12" << GLfuncs->glGetError();
GLfuncs->glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGBA8, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL);
qDebug() << "13" << GLfuncs->glGetError();
GLfuncs->glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGBA8, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL);
qDebug() << "14" << GLfuncs->glGetError();

GLfuncs->glBindTexture(GL_TEXTURE_CUBE_MAP, 0);

GLfuncs->glGenTextures(1, &depthTextureId);
GLfuncs->glBindTexture(GL_TEXTURE_CUBE_MAP, depthTextureId);

GLfuncs->glTexImage2D(GL_TEXTURE_CUBE_MAP, 0, GL_DEPTH_COMPONENT24, width, height, 0, GL_DEPTH_COMPONENT, GL_FLOAT, NULL);

GLfuncs->glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
GLfuncs->glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
GLfuncs->glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
GLfuncs->glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
GLfuncs->glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);

GLfuncs->glBindTexture(GL_TEXTURE_CUBE_MAP, 0);

GLfuncs->glGenFramebuffers(1, &fbo);
GLfuncs->glBindFramebuffer(GL_FRAMEBUFFER, fbo);

for(GLuint face = 0; face < 6; ++face)
GLfuncs->glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, textureId, 0);

GLfuncs->glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depthTextureId, 0);

int i = GLfuncs->glCheckFramebufferStatus(GL_FRAMEBUFFER);

if(i != GL_FRAMEBUFFER_COMPLETE)
qDebug() << "Framebuffer is not OK, status=" << i;

GLfuncs->glBindFramebuffer(GL_FRAMEBUFFER, 0);

FBO status => 36054 2x
qDebug 9-14 => 1281 error

What's there for problem?

Thanks.