You didn’t do enough Googling. This might be enough for Transform Feedback. You would have to modify the suggested tutorial to use the code that I provided in the thread. The post also points to a geometry shader tutorial, although I haven’t used it. If you have a card that supports geometry shaders, you really should move away from ‘old-style’ shader syntax. G-Truc.net has an opengl sample pack which includes code for doing various things in opengl, including the use of geometry shaders.
I did know about the tutorial code by Shiben Bhattacharjee.
But I couldn’t get it to compile because of the glTransformFeedbackAttribs() in the original source.
Thanks to you, it compiles now – however, I don’t see the green points (i.e., the ones from the transform feedback buffer).
I do see the two red points moving, but not the green ones.
Any ideas, what might be wrong?
Is there any way I can read the transform feedback buffer back into main memory? (so that I can look at the values it contains?)
BTW: I didn’t know you can use glTransformFeedbackVaryingsEXT() on pre-defined vertex attributes …
(Oh, and I had to change the z-coord of the points to -0.3, because with -0.2 they were exactly on the near clipping plane, and thus apparently clipped away.)
Yes, I know about these samples, too – but they use new-style shader syntax, i.e., no pre-defined attributes; and I am developing on Mac OS X 10.6, so I believe I can’t use that, can I?
If that doesn’t make a difference, it maybe a bug. Given that you were getting colors at all with the first shaders would imply that Mac supports newer-styled shaders (GLSL 1.30+). You may have to fiddle with the points’ x and y coordinates until they show up, just like you fiddled with the z.
Is there any way I can read the transform feedback buffer back into main memory? (so that I can look at the values it contains?)
Since a transform feedback buffer is a buffer object, I think you would have to familiarize yourself with MapBuffer.
Yes, I know about these samples, too – but they use new-style shader syntax, i.e., no pre-defined attributes; and I am developing on Mac OS X 10.6, so I believe I can’t use that, can I?
You could understand what it’s doing and write a version that works for you. Copy-and-paste coding is bad; understanding is good.
The in and out keywords were introduced in GLSL 1.30, so if you are going to use GLSL 1.20 exclusively, you should make the necessary modifications (or use the code provided) to make the shaders GLSL 1.20 compliant.
I have managed to make the example work, at least with a pass-through geometry shader.
There is one funny thing now: when I resize the window, everything is gone!
Does anyone have an idea?
Here is the source code: http://zach.in.tu-clausthal.de/tmp/main.cpp
It is self-contained and uses only GLUT.
(I can also put the Makefile or an XCode project online, if you want.)
All kinds of hints, suggestions, and pointers will be appreciated!