Note that there are some explanatory texts on larger screens.

plurals
  1. POglReadPixels() sets GL_INVALID_OPERATION flag for no reason
    primarykey
    data
    text
    <p>I'm trying to implement color picking with FBO. I have multisampled FBO (fbo[0]) which I use to render the scene and I have non multisampled FBO (fbo[1]) which I use for color picking.</p> <p>The problem is: when I try to read pixel data from fbo[1] everything goes well until glReadPixels call which sets GL_INVALID_OPERATION flag. I've checked the manual and can't find the reason why.</p> <p>The code to create FBO:</p> <pre><code>glBindRenderbuffer(GL_RENDERBUFFER, rbo[0]); glRenderbufferStorageMultisample(GL_RENDERBUFFER, numSamples, GL_RGBA8, resolution[0], resolution[1]); glBindRenderbuffer(GL_RENDERBUFFER, rbo[1]); glRenderbufferStorageMultisample(GL_RENDERBUFFER, numSamples, GL_DEPTH24_STENCIL8, resolution[0], resolution[1]); glBindRenderbuffer(GL_RENDERBUFFER, rbo[2]); glRenderbufferStorage(GL_RENDERBUFFER, GL_R32UI, resolution[0], resolution[1]); glBindRenderbuffer(GL_RENDERBUFFER, rbo[3]); glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, resolution[0], resolution[1]); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo[1]); glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rbo[3]); glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo[2]); OGLChecker::checkFBO(GL_DRAW_FRAMEBUFFER); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo[0]); glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rbo[1]); glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo[0]); OGLChecker::checkFBO(GL_DRAW_FRAMEBUFFER); </code></pre> <p>My checker stays silent so the FBOs are complete. Next the picking code</p> <pre><code>glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo[1]); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); // bla, bla, bla // do the rendering unsigned int result; glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo[1]); int sb; glReadBuffer(GL_COLOR_ATTACHMENT0); glBindBuffer(GL_PIXEL_PACK_BUFFER, 0); glGetIntegerv(GL_SAMPLE_BUFFERS, &amp;sb); // glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); OGLChecker::getGlError(); std::cerr &lt;&lt; "Sample buffers " &lt;&lt; sb &lt;&lt; std::endl; glReadPixels(pos.x(), resolution.y() - pos.y(), 1, 1, GL_RED, GL_UNSIGNED_INT, &amp;result); OGLChecker::getGlError(); return result; </code></pre> <p>the output:</p> <pre><code>Sample buffers 0 OpenGL Error : Invalid Operation </code></pre> <p>The interesting fact that if I uncomment glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); then no error happens and pixels are read from screen (but I don't need this).</p> <p>What may be wrong here?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload