Search code examples
copengl-esopengl-es-2.0stencil-buffer

openGL ES 2 - Is there a way to attach a stencil buffer with a different resolution than the target texture?


I have an input texture in a certain resolution, and a target texture (attached as GL_COLOR_ATTACHMENT0) which is in a bigger resolution. I am using glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST) to upscale the input and draw some stuff on the target.

I have a buffer which is in the same resolution as my input that I would like to use as GL_STENCIL_ATTACHMENT. Is it possible to attach it somehow without getting an error of GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS?


Solution

  • It is not possible to attach textures with different sizes to a framebuffer.

    The OpenGL-ES 2.0 Spec states in Section 4.4:

    The framebuffer object target is said to be framebuffer complete [...] if all the following conditons are true:

    • All attached images have the same width and height.

    If this is not the case, the framebuffer status has to return FRAMEBUFFER_INCOMPLETE_DIMENSIONS.