View Full Version : strange transform feedback problem
babis
07-09-2008, 01:15 PM
Hello,
I tried to implement transform feedback in my app, but I seem to be stuck in a seemingly weird situation (or stupid bug).
I want to record the GL_POSITION, without rasterizing.
The problem is :
If I use a vertex shader, hell breaks loose, numbers are whacko.
If I use fixed function for vertex shader, or fixed function for both vs & fs, everything is allright.
The shader I tried is the most minimalistic possible
( void main() {gl_Position = ftransform();} ). If a make a shader with the most minimal fs, and no vs ( to use fixed func ), then it works ok.
Where could the problem be?? Any ideas??
Thanks for reading,
babis
Seth Hoffert
07-09-2008, 01:45 PM
I assume you're executing the correct initial steps, but just to be sure, here's what I use in my (working) program right now:
int loc[] =
{
glGetVaryingLocationNV(programid, "gl_Position"),
glGetVaryingLocationNV(programid, "gl_FrontColor"),
};
glTransformFeedbackVaryingsNV(programid, 2, loc, GL_SEPARATE_ATTRIBS_NV);
Then, when I actually capture data,
glUseProgram(programid);
glBindBufferBaseNV(GL_TRANSFORM_FEEDBACK_BUFFER_NV , 0, outvbo[0]);
glBindBufferBaseNV(GL_TRANSFORM_FEEDBACK_BUFFER_NV , 1, outvbo[1]);
glEnable(GL_RASTERIZER_DISCARD_NV);
glBeginTransformFeedbackNV(GL_POINTS);
glBindBuffer(GL_ARRAY_BUFFER, attribvbo);
glVertexPointer(4, GL_FLOAT, 0, NULL);
glDrawArrays(GL_POINTS, 0, count);
glEndTransformFeedbackNV();
glDisable(GL_RASTERIZER_DISCARD_NV);
As always, ensure your transform feedback VBOs are large enough to hold the results.
Oddly enough, I've sometimes needed to clear the color buffer before using transform feedback, or else I get odd results when resizing the window (even though I'm not rasterizing).
babis
07-09-2008, 02:09 PM
Thanks HexCat for your quick answer.
I use almost the same steps.
Init :
// Set the transform feedback VBO
GLint att[3]= {GL_POSITION, 4, 0};
glGenBuffers(1,&_tgtVBO);
glBindBufferARB(GL_ARRAY_BUFFER_ARB,_tgtVBO);
glBufferDataARB(GL_ARRAY_BUFFER_ARB,_vnum*4*sizeof (float),0,GL_STATIC_DRAW_ARB);
glBindBufferARB(GL_ARRAY_BUFFER_ARB,0);
//record position attrib
glTransformFeedbackAttribsNV(1,att,GL_SEPARATE_ATT RIBS_NV);
Capture :
glBindBufferBaseNV(GL_TRANSFORM_FEEDBACK_BUFFER_NV , 0, _tgtVBO);
glBeginTransformFeedbackNV(GL_POINTS);
glEnable(GL_RASTERIZER_DISCARD_NV);
glBegin(GL_POINTS);
glVertex3f(-1,0.0,10.0);
glVertex3f(1,0.0,10.0);
glVertex3f(0.0,1,10.0);
glEnd();
glDisable(GL_RASTERIZER_DISCARD_NV);
glEndTransformFeedbackNV();
In the capture code, if I bind the shader before the above chunk, it has the problems I mentioned.
Seth Hoffert
07-09-2008, 02:12 PM
The glTransformFeedbackAttribsNV() function is only to be used with fixed function (or assembly shaders, as I just discovered from the specification (http://www.opengl.org/registry/specs/NV/transform_feedback.txt)). Try using glTransformFeedbackVaryingsNV() with a shader. :)
babis
07-09-2008, 02:23 PM
:D :D Thanks!!!
I misread that part,thanks again it works now!
Seth Hoffert
07-09-2008, 02:30 PM
I'm glad you got it working. :)
Powered by vBulletin® Version 4.2.3 Copyright © 2018 vBulletin Solutions, Inc. All rights reserved.