Tutorial by Examples

A texture is a form of data storage that allows convenient access not just to particular data entries, but also to sample points mixing (interpolating) multiple entries together. In OpenGL textures can be used for many things, but most commonly it's mapping an image to a polygon (for example a tria...
You can attach an image in a texture to a framebuffer, so that you can render directly to that texture. glGenFramebuffers (1, &framebuffer); glBindFramebuffer (GL_FRAMEBUFFER, framebuffer); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, ...
You can read texture data with function glGetTexImage: char *outBuffer = malloc(buf_size); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, texture); glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, outBuffer); ...
If you bind a buffer to GL_PIXEL_UNPACK_BUFFER then the data parameter in glTexImage2D is a offset into that buffer. This means that the glTexImage2D doesn't need to wait for all the data to be copied out of the application's memory before it can return, reducing overhead in the main thread. glGen...
The vertex shader only accepts the texture coordinates as a vertex attribute and forwards the coordinates to the fragment shader. By default, it will also guarantee that the fragment will receive the properly interpolated coordinate based on its position in a triangle: layout (location = 0) in vec3...

Page 1 of 1