Skip to content

Instantly share code, notes, and snippets.

@elect86
Created March 16, 2016 15:39
Show Gist options
  • Save elect86/45877929ce8d977cae14 to your computer and use it in GitHub Desktop.
Save elect86/45877929ce8d977cae14 to your computer and use it in GitHub Desktop.
if (size.x != width || size.y != height) {
size.set(width, height);
if (textureName.get(0) != 0) {
gl4.glDeleteTextures(Texture.MAX, textureName);
}
textureName.position(Texture.COLOR);
gl4.glCreateTextures(GL_TEXTURE_2D_MULTISAMPLE, 1, textureName);
textureName.position(Texture.DEPTH);
gl4.glCreateTextures(GL_TEXTURE_2D, 1, textureName);
textureName.rewind();
gl4.glTextureParameteri(textureName.get(Texture.COLOR), GL_TEXTURE_BASE_LEVEL, 0);
gl4.glTextureParameteri(textureName.get(Texture.COLOR), GL_TEXTURE_MAX_LEVEL, 0);
gl4.glTextureStorage2DMultisample(
textureName.get(Texture.COLOR),
// samples,
1,
GL_RGBA8,
size.x, size.y,
false); // fixed sample locations
gl4.glTextureParameteri(textureName.get(Texture.DEPTH), GL_TEXTURE_BASE_LEVEL, 0);
gl4.glTextureParameteri(textureName.get(Texture.DEPTH), GL_TEXTURE_MAX_LEVEL, 0);
gl4.glTextureStorage2D(
textureName.get(Texture.DEPTH),
1, // levels
GL_DEPTH_COMPONENT32F,
size.x, size.y);
gl4.glNamedFramebufferTexture(
framebufferName.get(0),
GL_COLOR_ATTACHMENT0,
textureName.get(Texture.COLOR),
0); // level
gl4.glNamedFramebufferTexture(
framebufferName.get(0),
GL_DEPTH_ATTACHMENT,
textureName.get(Texture.DEPTH),
0); // level
if (gl4.glCheckNamedFramebufferStatus(framebufferName.get(0), GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
throw new Error("framebuffer " + framebufferName.get(0) + " incomplete");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment