Are glTexImage2D and glTexSubImage2D the only ways to pass a buffer of pixels to a texture?
At the moment I use in a setup function glTexImage2D passing null as the buffer, and then on the render loop I call glTexSubImage2D with the new buffer data on each iteration.
But knowing that the texture will not change any property such as the dimensions, is there any more efficient way to pass the actual pixel data to the rendering texture?
A texture is an OpenGL Object that contains one or more images that all have the same image format. A texture can be used in two ways: it can be the source of a texture access from a Shader, or it can be used as a render target.
The glTexSubImage2D function specifies a portion of an existing one-dimensional texture image.
in display() function : GLuint texture; texture = LoadTexture("bubble. png"); glBindTexture(GL_TEXTURE_2D, texture);
Overview. OpenGL PBO. OpenGL ARB_pixel_buffer_object extension is very close to ARB_vertex_buffer_object. It simply expands ARB_vertex_buffer_object extension in order to store not only vertex data but also pixel data into the buffer objects. This buffer object storing pixel data is called Pixel Buffer Object (PBO).
In modern OpenGL
there are 4 different methods to update 2D textures:
glTexImage2D
- the slowest one, recreates internal data structures.
glTexSubImage2D
- a bit faster, but can't change the parameters (size, pixel format) of the image.
Render-to-texture with FBO
- update texture entirely on GPU, very fast. Refer to this answer for more details: https://stackoverflow.com/a/10702468/1065190
Pixel Buffer Object PBO
- for fast uploads from CPU to GPU, not supported (yet) on OpenGL ES.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With