I think this is a stupid mistake on my part, but I’ve read the relevant sections of the manual several times and I still can’t figure out what I am doing wrong.
I want to use GL_FRAMEBUFFER_ATTACHMENT_LAYERED to verify that a 3D texture that I am attaching to my framebuffer is being attached correctly. In particular, I want to verify that the texture is attached as a layered texture. I want to make sure it is attached correctly so that I can use gl_Layer in my geometry shader. Here is the Java/LWJGL code I am using:
GL11.glEnable(GL12.GL_TEXTURE_3D);
// Create the framebuffer
int framebuffer = GL30.glGenFramebuffers();
// Create the 3d texture
int texture3d;
texture3d = GL11.glGenTextures();
GL11.glBindTexture(GL12.GL_TEXTURE_3D, texture3d);
GL11.glTexParameteri(GL12.GL_TEXTURE_3D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP);
GL11.glTexParameteri(GL12.GL_TEXTURE_3D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP);
GL11.glTexParameteri(GL12.GL_TEXTURE_3D, GL12.GL_TEXTURE_WRAP_R, GL11.GL_CLAMP);
GL11.glTexParameteri(GL12.GL_TEXTURE_3D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
GL11.glTexParameteri(GL12.GL_TEXTURE_3D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
GL12.glTexImage3D(GL12.GL_TEXTURE_3D, 0, GL11.GL_RGBA8, 32, 32, 32, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_INT, (IntBuffer) null);
GL11.glBindTexture(GL12.GL_TEXTURE_3D, 0);
// Attach the texture to the framebuffer
GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, framebuffer);
GL32.glFramebufferTexture(GL30.GL_FRAMEBUFFER, GL30.GL_COLOR_ATTACHMENT0, texture3d, 0);
// Check the result
int result = GL30.glGetFramebufferAttachmentParameter(GL30.GL_FRAMEBUFFER, GL30.GL_COLOR_ATTACHMENT0, GL32.GL_FRAMEBUFFER_ATTACHMENT_LAYERED); // THIS LINE OF CODE IS THE PROBLEM
The last line of code is the problem. It causes the following OpenGL error:
Exception: org.lwjgl.opengl.OpenGLException: Invalid enum (1280)
If I pass any of the other parameters specified in the OpenGL manual to glGetFramebufferAttachmentParameter() then everything works fine. For example, these parameters will work:
FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER
FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL
FRAMEBUFFER_ATTACHMENT_OBJECT_NAME
FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE
Only the GL_FRAMEBUFFER_ATTACHMENT_LAYERED parameter throws the “invalid enum” exception.
Here’s my runtime environment:
Windows 7 64-bit
Catalyst 10.12 (display driver only)
ATI Radeon HD 4850
JavaSE 1.6
LWJGL 2.6
Does anyone have any ideas on what I am doing wrong?
Thank you for reading this post.