Sign in to follow this  
mirkar

Transform Feedback problem

Recommended Posts

Hi,
I'm trying to port some code which is using transform feedback from Linux to Mac OSX. In Linux I was using NV_TRANSFORM_FEEDBACK but since new macbook has ATI I needed to rewrite the code to use EXT. In Linux was everything working fine. In Mac OS X I'm getting following seg-fault at line glDrawArrays(GL_POINTS, 0, numOfParticles):

The inferior stopped because it received a signal from the Operating System.

Signal name :
EXC_BAD_ACCESS
Signal meaning :
Could not access memory

Here is initialization of buffers:
[code]
glGenBuffers(1, &vboBuffID_1);
glBindBuffer(GL_ARRAY_BUFFER, vboBuffID_1);
glBufferData(GL_ARRAY_BUFFER, sizeof(GLuint)*numOfParticles*3, vboBuff_1, GL_DYNAMIC_DRAW_ARB);
glGenBuffers(1, &vboBuffID_2);
glBindBuffer(GL_ARRAY_BUFFER, vboBuffID_2);
glBufferData(GL_ARRAY_BUFFER, sizeof(GLuint)*numOfParticles*3, 0, GL_DYNAMIC_DRAW_ARB);
glBindBufferBaseEXT(GL_TRANSFORM_FEEDBACK_BUFFER_EXT, 0, vboBuffID_2);
glBindBufferBaseEXT(GL_TRANSFORM_FEEDBACK_BUFFER_EXT, 1, vboBuffID_1);
[/code]

Initialization of query and varying variable from vertex shader:
[code]
const char *vars[1] = { "vtxPosition" };
glTransformFeedbackVaryingsEXT(glslRain, 1, vars, GL_SEPARATE_ATTRIBS_EXT);
glGenQueries(1, &query);
[/code]

and here is code from redraw():
[code]
glBindBuffer(GL_ARRAY_BUFFER, vboBuffID_1);
glBufferData(GL_ARRAY_BUFFER, sizeof(GLuint)*numOfParticles*3, vboBuff_1, GL_DYNAMIC_DRAW_ARB);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, NULL);
glBeginTransformFeedbackEXT(GL_POINTS);
glBeginQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT, query);
glDrawArrays(GL_POINTS, 0, numOfParticles); // here is where I'm getting seg. fault
glEndQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT);
glEndTransformFeedbackEXT();
[/code]

Basically the plan is to animate vertices in shader and save the new positions to the second buffer (via transform feedback). Then I just switch the buffers, so I can simulate for example rain.

Any help more than appreciated...

Share this post


Link to post
Share on other sites
figured it out - the order of commands was not correct. Here is the correct one:

1) compile + attach shader
2) get varying variables from shader - glTransformFeedbackVaryingsEXT()
3) link shader program
4) create, bind VBO
5) setup transform_feedback - glBindBufferBaseEXT
6) then for in redraw() just use the same as is in the previous post

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this