OpenGL帧缓冲渲染在高分辨率下失败

时间:2017-08-05 20:50:21

标签: c++ opengl framebuffer

在我的代码中,我渲染了Mandelbrot分形,我注意到当我将分辨率从7680x4320提高到15360x8640时,输出图像变为空白,没有报告OpenGL错误。

尺寸在允许的16384x16384限制范围内,并且GPU内存没有溢出,因为我没有出现内存不足错误。

  • 我的GPU:英特尔(R)HD Graphics 4000,Build 10.18.10.4425
  • OpenGL版本:4.0.0

代码:

constexpr GLsizei Width  = 15360;
constexpr GLsizei Height = 8640;

// Note: I'm only using GLFW for the OpenGL context
glfwInit();
glfwWindowHint(GLFW_VISIBLE, GL_FALSE);
GLFWwindow* window = glfwCreateWindow(800, 600, "Mandelbrot Generator", nullptr, nullptr); // the resolution of the window is not important
glfwMakeContextCurrent(window);

// Note: I'm wrapping OpenGL calls to allow for glGetError() to be called for each func
// Code to generate framebuffer
gl::GenFramebuffers(1, &fbo);
gl::GenRenderbuffers(1, &rbo);
gl::BindRenderBuffer(rbo);
gl::SetRenderbufferStorage(gl::e_RGBA, Width, Height);
gl::BindFramebuffer(gl::e_DrawFramebuffer, fbo);
gl::SetFramebufferRenderBuffer(gl::e_DrawFramebuffer, gl::e_ColorAttachment0, rbo);

// Rendering
gl::BindFramebuffer(gl::e_DrawFramebuffer, fbo);
{
    gl::Clear(gl::e_ColorBufferBit);
    gl::SetViewport(0, 0, Width, Height);
    gl::BindBuffer(gl::e_ArrayBuffer, rect); // rect is a fullscreen quad
    gl::DrawArrays(gl::e_Triangles, 0, 6);
    gl::BindBuffer(gl::e_ArrayBuffer, 0);
}
gl::BindFramebuffer(gl::e_DrawFramebuffer, 0);

// Saving image
std::vector<GLubyte> pixels(Width * Height * 4);
{
    gl::BindFramebuffer(gl::e_ReadFramebuffer, fbo);
    gl::ReadPixels(0, 0, Width, Height, gl::e_RGBA, gl::e_UnsignedByte, pixels.data());
}
lodepng::encode("mandelbrot.png", pixels, Width, Height);

0 个答案:

没有答案