[QUOTE=art-ganseforth;1292707]With glTransformfeedbackvaryings, that are shader-varyings (like i.e. gl_vertex).
I’ve just lerned it myself with help of this forum, so i take the time to anwer you. Mybe this helps a bit:
On my system, there was a flag to be set before ibitializing OpenGL. Since i init with:
glewExperimental= TRUE; // needed for glew version under 1.3 - before glewInit()
GLenum err = glewInit();
if (GLEW_OK != err) { wxMessageBox("FATAL ERROR:
"+wxString(glewGetErrorString(err))); exit(0); }
…glTransformfeedbackvaryings doesn’t crash my program anyomre.
You don’t need a fragment-shader (you want to retrieve / calculate) vertices. Call glDisgardrastarizer(GL_TRUE); in order to do this.
On my systen (there were some discussions about this point), a fragement-shader has to be used anyway to prevent the shader-compiler to remove varyings that are not used.
The basic method for iterating one(!) array is this:
- use i.e. “in float tff_in[8];” and “out float tff_out[8];” in your vertex-shader.
- compile it and attach it to the program
- call glTransformfeedbackvaryings(“tff_out”);
- call glDiscardrastarizer(GL_TRUE); - might also be done later, i think
(-attach maybe fragment-shader - on my system no result without “in float tff_out[8];
out vec4 color;
void main(){
color[0]=tff_out[0];
};”)
- link program
After this, you have to think about the input, which is as simple as tricky. The point is that you have (in my example) an array eight floats named “tff_in”.
What yo’ll have to do is to apply at first the existence on an input named “tff_in” and after this a pointer to each of the array-items. Here is my code doing this:
GLint tffInput = glGetAttribLocation (curPRG, (char*)list[3]); CheckGL("glGetAttribLocation");
if (tffInput < 0) return;
for (int i = 0; i < numAttribs; i++) {
glEnableVertexAttribArray (tffInput + i); CheckGL("glEnableVertexAttribArray");
glVertexAttribPointer (tffInput + i, 1, GL_FLOAT, GL_FALSE, byteStride, (GLvoid*) (i * sizeof(GLfloat)) ); CheckGL("glVertexAttribPointer");
}
This was preparation. Now i to do someting like this:
void clsVAO::Refeed () { CheckGL("Errors left in cue");
// Create destination
GLuint dst;
glGenBuffers (1, &dst);
glBindBuffer (GL_ARRAY_BUFFER, dst);
glBufferData (GL_ARRAY_BUFFER, bufBytes, NULL, GL_STATIC_DRAW); CheckGL("TBO-Creation");
// PROCESS:
glEnable (GL_RASTERIZER_DISCARD); CheckGL("glEnable(GL_RASTERIZER_DISCARD)");
glBindBufferBase (GL_TRANSFORM_FEEDBACK_BUFFER, 0, dst); CheckGL("glBindBufferBase");
glBeginTransformFeedback(GL_POINTS); CheckGL("glBeginTransformFeedback");
glDrawArrays (GL_POINTS, 0, NumV); CheckGL("glDrawArrays");
glEndTransformFeedback (); CheckGL("glEndTransformFeedback");
glFlush (); CheckGL("glFlush");
// Swap
GLuint tmp = VBO; VBO = dst;
glDeleteBuffers (1, &tmp);
// Clear
glBindBuffer (GL_ARRAY_BUFFER, 0);
glDisable (GL_RASTERIZER_DISCARD); CheckGL("glEnable(GL_RASTERIZER_DISCARD)");
glUseProgram (0);
}
What results is an vertex-array-feedback. So, each of the inputs aof your fractal (like x,y,r,i with Mandebrodt), can be iterated by the shader-program doing someting with the incoming values and write the result to output in the same order (tff_in[3]->tff_out[3]).
Also you may look here: https://open.gl/feedback, which is short and helped a lot…
This was a path a to the start first steps, but it’s in the end simple. But note: Evrything that is not copy-pasted is wrote out of my head (just lerned some days ago). So no guaraty, for anything.
Best,
Frank
PS. Good idea. I’ll progam a Mandebrodt-vertex-shader now - just for testing, what i leaned the last days…[/QUOTE]
Hi Frank thanks for quick reply but your code is viable only for iterative fractals (Mandelbrot .etc)
The problem is that I want to draw recursive fractals like fractal tree fern…