Copying depth render buffer to depth bufferに従おうとしましたが、うまくいきません。これが私の完全な例です:
#include <GL/glew.h>
#include <GL/glfw.h>
#include <GL/glu.h>
#include <iostream>
typedef unsigned int uint;
int main()
{
if (glfwInit() != 1)
{
return 1;
}
const uint width = 256;
const uint height = 256;
if (glfwOpenWindow(width, height, 8, 8, 8, 0, 24, 0, GLFW_WINDOW) != 1)
{
return 1;
}
GLenum err = glewInit();
if (GLEW_OK != err)
{
std::cerr << glewGetErrorString(err) << std::endl;
return 1;
}
GLuint r;
glGenRenderbuffers(1, &r);
glBindRenderbuffer(GL_RENDERBUFFER, r);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24, width, height);
glBindRenderbuffer(GL_RENDERBUFFER, 0);
GLuint r2;
glGenRenderbuffers(1, &r2);
glBindRenderbuffer(GL_RENDERBUFFER, r2);
glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA4, width, height);
glBindRenderbuffer(GL_RENDERBUFFER, 0);
GLuint f;
glGenFramebuffers(1, &f);
glBindFramebuffer(GL_FRAMEBUFFER, f);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, r);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, r2);
std::cout << (glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE) << std::endl;
glBindFramebuffer(GL_FRAMEBUFFER, 0);
std::cout << gluErrorString(glGetError()) << std::endl;
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
glBindFramebuffer(GL_READ_FRAMEBUFFER, f);
glBlitFramebuffer(0, 0, width, height, 0, 0, width, height, GL_DEPTH_BUFFER_BIT, GL_NEAREST);
std::cout << gluErrorString(glGetError()) << std::endl;
return 0;
}
私が得る出力:
1
no error
invalid operation
24
inglfwOpenWindow
は深度ビットの数です。私は何を間違っていますか?