Multisample Texture
A Multisample Texture is a Texture that can have multiple samples per pixel, thereby allowing it to be used in multisampled rendering. As they are textures, their multiple samples can also be fetched from shaders.
This article is a stub. You can help the OpenGL Wiki by expanding it. |
There are only two multisampled texture targets: 2D textures, and 2D array textures (GL_TEXTURE_2D_MULTISAMPLE and GL_TEXTURE_2D_ARRAY_MULTISAMPLE respectively).
Creating a multisample texture requires using glTexStorage2DMultisample, glTexStorage3DMultisample for 2D array textures (or the glTexImage*Multisample equivalents):
GLuint tex;
glGenTextures(1, &tex);
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, tex);
glTexStorage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 4, GL_RGBA8, w, h, GL_TRUE);
//Attach to an FBO:
glFramebufferTexture(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex, 0);
Similar functions are provided for using multisample render buffer with your frame buffer: e.g.: glRenderbufferStorageMultisample
You may use glBlitFramebuffer to perform a multisample resolve operation by copying to a non-multisampled framebuffer object.