Jump to content
  • Advertisement
Sign in to follow this  

Transform Feedback returns empty data

This topic is 1417 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

Hey everyone!


EDIT: Oh, excuse me, after panically posting something here I managed it out, like always, sorry again. I simply forgot to glBindBufferBase before glGetBufferSubData, now it's perfect!(  I think, lol ). I hope this will be useful for someone. Sorry and Thanks again!


I am using terrain displacement method in GLSL, so I want to get the data from it to game core and use it. ( Don't ask me why I am using displacement in GLSL, it's just easier and I can't get that good results in main code, lol ).


So, I got vertex array/buffer objects. Here's what I do:

    // Initialization code

    glGenVertexArrays( ...
    glBindVertexArray( .... ...
    // Bind generated data here. ( X, 0.0f, Z )

    glGenBuffers( 1, &m_transformFeedback );
    glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, m_transformFeedback);
    glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, m_map_size * sizeof( ncVec3 ), NULL, GL_DYNAMIC_COPY);
    glGenQueries(1, &m_transformFeedbackQuery); // Temp, eats a lot of performance.

So this works okay, no errors. And here's how I render this:

    // Bind vertex array with vertex buffers ( vertices, normals, uvs ).
    // Drawing now.
    glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, m_transformFeedback);
    glBeginQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, m_transformFeedbackQuery); // temp
    glDrawArrays( GL_TRIANGLE_STRIP, 0, m_map_size );

    glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, 0);
     GLuint primitives;
    glGetQueryObjectuiv(m_transformFeedbackQuery, GL_QUERY_RESULT, &primitives);
    g_Core->Print( LOG_INFO, "%i primitives written.\n", primitives );
// HERE I GOT NOTHING! It returns 1.0, 1.0, 1.0 or just 0.0, 0.0, 0.0
// tmapData is allocated or just static array, no difference, same result.
    glGetBufferSubData( GL_TRANSFORM_FEEDBACK_BUFFER, 0, sizeof(tmapData), tmapData );
// Random numbers.
    g_Core->Print( LOG_INFO, "%f %f %f\n", tmapData[53].x, tmapData[353].y, tmapData[3534].z );

Shader code:

        glAttachProgram( vert and fragments )
        const char * names[] = { "VertexOut" };
        // GL_INTERLEAVED_ATTRIBS or GL_SEPARATED_ATTRIBS, not working yet :(
        glTransformFeedbackVaryings( program, 1, names, GL_INTERLEAVED_ATTRIBS );
        glLinkProgram( ...

// Vertex shader:
out vec3 vertexOut;        

         vec4 map_data = texture( gSampler[4], hmap_coord );
	float displacement = u_map_scale * map_data.r;
	 vertex.y += displacement;
	vertexOut = vertex; // Even tried to vertexOut = vec3(10.0, 10.0, 10.0);

What could be problem? I am only using vertex and fragment shader, no geometry ( don't want to )

Thanks in advance!

Edited by NekoCode

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!