Jump to content
  • Advertisement
Sign in to follow this  
SnakeHunta

OpenGL [solved] render to 3d texture and glFrameBufferTexture(..)

This topic is 3185 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

SOLVED: First my geometry shader problem plus not having to unbind the layered texture. It will be unbound once you try to bind any other texture. Okay, so here's my problem. I'm trying to render 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) on the frame buffer object I already have created I call glFramebufferTexture( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, texture, 0 ) to bind all layers of the texture 4) 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) 5) 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 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 points are proper and they are. Also, setting glVertexAttribPointer is called correctly for both the positions and texture coordinates. Also, both vertex attribute arrays are enabled. This is all done using opengl 3.2 with latest nvidia drivers Edit1: the viewport is also being set to 256x256 before anything happens.
vBuff = glGenBuffers(1);
float vertexData[] = { 0.55, 0.24, 0.123, 0.5, 0.5,
                 0.57, 0.24, 0.123, 0.51, 0.5,
                    ...... // 400 of these
                 };

glBindBuffer(GL_ARRAY_BUFFER, vBuff);
glBufferData( GL_ARRAY_BUFFER, 8000, vertexData, GL_DYNAMIC_DRAW);
glVertexAttribPointer( 0, 3, GL_FLOAT, GL_FALSE, 20, 0);
glEnableVertexAttribArray( 0 );
glVertexAttribPointer( 1, 2, GL_FLOAT, GL_FALSE, 20, 12);
glEnableVertexAttribArray( 1 );

texture3D = glGenTextures(1);
glBindTexture( GL_TEXTURE_3D, texture3D );
glTexImage3D( GL_TEXTURE_3D, 0, GL_RGBA8, 256, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);

// framebufferId I have, I'll skip creation code cause I know it's 100% correct
// It's bound

glBindFramebuffer( GL_FRAMEBUFFER, framebufferId );

glFrameBufferTexture( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, texture3D, 0 );

drawBuffers[] = { GL_COLOR_ATTACHMENT0 };
glDrawBuffers( drawBuffers );

glBindTexture( GL_TEXTURE_3D, 0);

glEnable( GL_BLEND );
glBlendFunc( GL_SRC_ALPHA, GL_ONE );

glViewport( 0, 0, 256, 256 );

// Setup shader program uniforms
// This involves binding some textures setting their uniforms, and setting other uniforms 

glDrawArrays( GL_POINTS, 0, 400 );
// or
// glDrawArraysInstanced( GL_POINTS, 0, 400, 2 );
// both give invalid operation
[Edited by - SnakeHunta on December 3, 2009 1:35:05 PM]

Share this post


Link to post
Share on other sites
Advertisement
I actually just solved most of my problem 10 seconds ago. ( I would've edited the post so as to not bump but this becomes a new problem. )

My geometry shader in the out layout block was not specifying the max_vertices

I had: layout(points) out;
But needed: layout(points, max_vertices=32) out;

Slight oversight.

HOWEVER, now I get an 'invalid value' on


glBindFramebufferTexture( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, 0, 0)


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

Any ideas there?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!