Okay, so here's my problem. I'm trying to render points (GL_POINTS) to a 3D texture but get an INVALID_OPERATION on either of glDrawArraysInstanced or glDrawArrays. Here's what's happening:

1) create a vbo of a list of points and two extra floats for texture coordinates that i use in my shader. that's 5 floats per point, 3 for position, 2 for texture coordinates
2) create a 256x256x256 3d texture of internal format GL_RGBA8 to render to
3)set viewport to the width and height of my 3d texture (each layer's width and height). 256x256
4) on the frame buffer object I already have created I call glFramebufferTexture( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, 3Dtexture, 0 ) to bind all layers of the texture. Also, I enable that color attachment as the only draw buffer using glDrawBuffers(...)
5) call glDrawArrays or glDrawArraysInstanced with my vbo bound using GL_POINTS. get an invalid operation from opengl. (if I replace this step with glClear, the clear call works and clears my texture)
6) unbind the frame buffer

I am using a geometry program that outputs gl_Layer so that each fragment knows where it's going in the 3D texture. The program compiles and links correctly. The program is bound before I call glDrawArrays / glDrawArraysInstanced. The frame buffer is also frame buffer complete.

I really need to be able to output gl_Layer in my geometry program and I just can't figure out why this is not working.

I've checked to see if my VBO is proper and it seems to be. I've uploaded contiguous data where every 20 bytes defines a point to render with the first 12 bytes the position and the next 8 the texture coordinates. Also, setting glVertexAttribPointer is called correctly for both the positions and texture coordinates (correct start offset and stride). Also, both vertex attribute arrays are enabled.

I really don't know what's going on. Does the overview of the process make sense? Is there something I'm missing there?

when trying to unbind the texture. The specs say that binding 0 should just unbind (like all other bind calls in GL).

Any ideas there?

Alfonse Reinheart

12-02-2009, 12:04 PM

I believe the correct way to unbind something from an attachment is to call glFramebufferRenderbuffer with a renderbuffer name of 0. The spec specifically says that passing 0 is acceptable to that function and will cause unattachment, while the spec does not say this for glFramebufferTexture (of any kind).

... If <texture> is zero, any image or array of images attached to the
attachment point named by <attachment> is detached, and the state of the
attachment point is reset to its initial values. <level> is ignored if
<texture> is zero.

jpack

12-02-2009, 01:25 PM

Exactly, so what else could go wrong here?

Brolingstanz

12-02-2009, 02:59 PM

Now that you've discovered a simple yet significant mistake in your shader code there's now the specter of similar miscues darkening the door to enlightenment IMHO.

jpack

12-02-2009, 03:12 PM

I doubt a shader has anything to do with unbinding a texture from a framebuffer but okay

Vertex shader:
----------------------
#version 150 core

in vec3 in_Position;
in vec2 in_MaskTextureCoordinates;

out vec2 ex_MaskTextureCoordinates;
out vec3 ex_DepthPropogatedPosition;