Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If <code>glReadPixels</code> is too slow for you, then <code>glCopyTexImage2D</code> and <code>glCopyTexSubImage2D</code> aren’t going to be a whole lot faster. On platforms with support for framebuffer objects, like iOS, the recommended (i.e. faster) way to get GPU-rendered image data into a texture is to use that texture as the color attachment for a framebuffer object and render directly into it. That said, if you still want to pursue this method, here’s what you need to do to fix it:</p> <p>First, you’re passing bad arguments to <code>glCopyTexImage2D</code>. The third argument, <code>internalformat</code>, should probably be <code>GL_RGBA</code> instead of <code>0</code>. If you had called <code>glGetError</code> after calling <code>glCopyTexImage2D</code>, you would probably have gotten <code>GL_INVALID_OPERATION</code>. See the OpenGL ES 1.1 man pages for <a href="http://www.khronos.org/opengles/sdk/1.1/docs/man/glCopyTexImage2D.xml" rel="noreferrer">glCopyTexImage2D</a> and <a href="http://www.khronos.org/opengles/sdk/1.1/docs/man/glCopyTexSubImage2D.xml" rel="noreferrer">glCopyTexSubImage2D</a>.</p> <p>Second, as you’ve already observed, <code>glCopyTexImage2D</code> requires its width and height arguments to be power-of-two as well. The correct way to deal with this is to allocate a texture image using <code>glTexImage2D</code> (you can pass <code>NULL</code> for <code>pixels</code> here), then use <code>glCopyTexSubImage2D</code> to copy your framebuffer contents into a rectangle. Note that <code>glCopyTexSubImage2D</code> doesn’t take an <code>internalformat</code> argument—because it’s updating a subrectangle of a texture, it uses the texture’s existing format.</p> <p>For the record, glGetTexImage doesn’t exist in OpenGL ES 1.1 or 2.0, which is why you’re getting an implicit declaration.</p>
 

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