Jump to content
  • Advertisement
Sign in to follow this  

how to use opengl transform feedback, I always get 0 in the buffers

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

I'm a beginner in OpenGL, I was trying to use transform feedback to retrieve data from vertex shader for debugging as my perspective matrix seemed to be miscalculated. But after all efforts I did, I still got nothing in the transform feedback buffer. Can anyone help me figure out which step I did wrong? Thanks in advance!
Following is snippet of my code of setting up transform feedback:

//vertex to be passed into shader
const float vertexPos[] =
0.75f, 0.75f, 0.0f, 1.0f,
0.75f, -0.75f, 0.0f, 1.0f,
-0.75f, -0.75f, 0.0f, 1.0f

//set up transform feedback
const char *variableName = "retrieve";//the variable to be retrieved in vertex shader
float dateFromShader[16];//for receive the retrieved data
GLuint tf_bo;// transform feedback buffer id

glTransformFeedbackVaryings(shaderProgram, 1, &variableName, GL_INTERLEAVED_ATTRIBS);

glGenBuffers(1, &tf_bo);
glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, tf_bo);// Is this necessary to call glBindBuffer before glBindBufferBase?
glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, tf_bo);

//retrieve data from vertex shader
glDrawArrays(GL_TRIANGLES, 0, 3);//

glBindBuffer(GL_ARRAY_BUFFER, tf_bo);
glGetBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(float) * 16, dataFromShader);
glBindBuffer(GL_ARRAY_BUFFER, 0);

and my vertex shader is like this:

#version 420

layout(location = 0) in vec4 position;

uniform mat4 perspectiveMatrix;
out mat4 retrieve;

void main()
gl_Position = perspectiveMatrix * position;

retrieve = perspectiveMatrix;
Edited by sobeit

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!