Hi, I`m trying to resize my framebuffer which uses Multisample Textures with 4 samples.
When I call my resize method, the framebuffer just outputs a black color.
Here is my resize method:
GL.DeleteFramebuffer(id);
foreach (GLXTexture texture in colorAttachments)
{
texture.Resize(width, height, 0);
}
if (depthAttachment != null)
{
depthAttachment.Resize(width, height, 0);
}
if (stencilAttachment != null)
{
stencilAttachment.Resize(width, height, 0);
}
id = GL.GenFramebuffer();
Create(colorAttachments, depthAttachment, stencilAttachment);
You can see a “Create” method at the bottom. I can include the source code but it is working fine, because if I dont use “Resize” on a Texture, the framebuffer renders ok. It then renders to a texture, which is not the same size and, because of this, distorted.
The interesting stuff happens in the Textures “Resize” method. If I use any openGL texture operations like “GL.BindTexture” and “GL.TexImage2DMultisample” in my case, the output is turns black. No error is generated.
Here is the code (INFO: IsMutable is true, which means that I`m using GL.TexImage2DMultisample):
public override void Resize(int width, int height, int depth)
{
if (!IsReserved)
{
throw new NotSupportedException("This texture has to be created before resizing!");
}
if (width == 0 || height == 0)
{
throw new NotSupportedException("You can`t resize this image to 0 width or height!");
}
this.width = width;
this.height = height;
if (!IsMutable) // If the texture is not mutable it has to be destroyed completely
{
Destroy();
ReserveTextureID();
}
GL.BindTexture(TextureTarget.Texture2DMultisample, id);
if (IsMutable)
{
// TexTarget is GL_TEXTURE_2D_MULTISAMPLE in this class
GL.TexImage2DMultisample((TextureTargetMultisample)TexTarget, samples, internalFormat, width, height, fixedSampleLocations);
}
else
{
GL.TexStorage2DMultisample((TextureTargetMultisample2d)TexTarget, samples, (SizedInternalFormat)internalFormat, width, height, fixedSampleLocations);
}
//ApplyOptions(IsMutable); Dont apply any options to a 2D Multisample Texture
GetError(false); // Print errors
GL.BindTexture(TextureTarget.Texture2DMultisample, 0);
}
Here is the desired output, which I get if I dont resize the screen. (Only these Gray blocks)
[ATTACH=CONFIG]1548[/ATTACH]
After window resize:
[ATTACH=CONFIG]1546[/ATTACH]
And here I have removed the GL.BindTexture and GL.TexImage2DMultisample lines and then resized the window:
[ATTACH=CONFIG]1547[/ATTACH]
I tried this with Multisampled 2D Textures and only 2D Textures, both have the same effect.
Additional informations:
- The openGL context which created the textures and framebuffer is bound properly in the resize method.
- I`m using multiple draw buffers from GL_COLOR_ATTACHMENT0 to 3 which are bound using glDrawBuffers
- There is no Framebuffer error generated
- This PC has Intel® HD Graphics | Driver Version 9.17.10.2884