Thank you for replieing…
I know that i missunderstood something here, but the link (which i alread know) dosn’t really help me.
I tried a lot of versions since hours, like i.e. a shader with this input:
in vec2 T2F_in;
in vec4 C4F_in;
in vec3 N3F_in;
in vec3 V3F_in;
and c-code like this:
int stride = 0;
for (int i = 0; i < list.size; i+=2) stride += list[i][0]; stride = stride * sizeof(GLfloat);
for (int i = 0; i < list.size; i+=2) { int pos = 0;
GLint tffInput = glGetAttribLocation (curPRG, (char*)list[1]); CheckGL("glGetAttribLocation");
glEnableVertexAttribArray (tffInput); CheckGL("glEnableVertexAttribArray");
glVertexAttribPointer (tffInput, list[i][0], .............
Also i red a lot of references, but sometimes my english is not good enough. Also i did not stdied programming. So smetimes the terminology is too complicated for me.
But what sould i do? The program crashes, or - as best result - i’ve got the first two values.
Im tired of recomiling hundrets of times with different values for stride and offset and different versions of inputs.
My complete function (full fo trash) is currentl this one:
void ParsePrepareFeedback (clsControl *Control, clsLst &list) { CheckGL("Errors left in cue");
// wxMessageBox("ParsePrepareFeedback");
if (!Control->cVAO) { // wxMessageBox("ParsePrepareFeedback 2"); //return;
Control->cVAO = new clsVAO (1000, GL_T2F_C4F_N3F_V3F);
GLfloat *fp = Control->cVAO->Open (1000, GL_T2F_C4F_N3F_V3F);
//wxMessageBox(tostr(Control->cVAO->NumV * Control->cVAO->Stride));
for (int i=0; i < Control->cVAO->NumV * Control->cVAO->Stride / sizeof(float); i++) fp[i] = 0;
Control->cVAO->Close();
}
// wxMessageBox("ParsePrepareFeedback 3");
int numPrims = Control->cVAO->NumV;
int numVerts = numPrims * 1 /*GL_POINTS*/;
int bufSize = numVerts * Control->cVAO->Stride/*GL_T2F_C4F_N3F_V3F*/; CheckGL("Error left in cue");
//// VAO erzeugen (ist standard. Ggf. wird default benutzt)
// GLuint vao;
// glGenVertexArrays (1, &vao);
// glBindVertexArray (vao); CheckGL("VAO-Creation");
// VBO von array" erzeugen
GLuint vbo = Control->cVAO->VBO;
// glGenBuffers (1, &vbo);
glBindBuffer (GL_ARRAY_BUFFER, vbo);
// glBufferData (GL_ARRAY_BUFFER, numPrims, NULL/*data*/, GL_STATIC_DRAW); CheckGL("VBO-Creation");
// GLfloat *sfp = Control->cVAO->Open();
// Übergabeadress für Attribut "inValue" ermitteln
int stride = 0;
// for (int i = 0; i < list.size; i+=2) stride += list[i][0]; stride = stride * sizeof(GLfloat);
Print("Stride: "+tostr(stride));
// for (int i = 0; i < list.size; i+=2) { int pos = 0;
GLint tffInput = glGetAttribLocation (curPRG, "tff_in"); CheckGL("glGetAttribLocation");
// Print(wxString("Index of ") + (char*)list[i+1] + ": "+tostr(tffInput));
glEnableVertexAttribArray (tffInput+0); CheckGL("glEnableVertexAttribArray");
glVertexAttribPointer (tffInput+0, 2, GL_FLOAT, GL_FALSE, 48, 0); CheckGL("glVertexAttribPointer");
glEnableVertexAttribArray (tffInput+1);
glVertexAttribPointer (tffInput+1, 4, GL_FLOAT, GL_FALSE, 48, (GLvoid*) (2 * sizeof(GLfloat)) ); CheckGL("glVertexAttribPointer");
glEnableVertexAttribArray (tffInput+2);
glVertexAttribPointer (tffInput+2, 3, GL_FLOAT, GL_FALSE, 48, (GLvoid*) (6 * sizeof(GLfloat)) ); CheckGL("glVertexAttribPointer");
glEnableVertexAttribArray (tffInput+3);
glVertexAttribPointer (tffInput+3, 3, GL_FLOAT, GL_FALSE, 48, (GLvoid*) (9 * sizeof(GLfloat)) ); CheckGL("glVertexAttribPointer");
// }
// Control->cVAO->Close();
glBindBuffer (GL_ARRAY_BUFFER, vbo);
// return;
// Gleich großen Zielbuffer erzeugen mit
GLuint tbo;
glGenBuffers (1, &tbo);
glBindBuffer (GL_ARRAY_BUFFER, tbo);
glBufferData (GL_ARRAY_BUFFER, bufSize, NULL, GL_STATIC_READ); CheckGL("TBO-Creation");
// PROZESS:
glEnable (GL_RASTERIZER_DISCARD); CheckGL("glEnable(GL_RASTERIZER_DISCARD)");
glBindBufferBase (GL_TRANSFORM_FEEDBACK_BUFFER, 0, tbo); CheckGL("glBindBufferBase");
glBeginTransformFeedback(GL_POINTS); CheckGL("glBeginTransformFeedback");
glDrawArrays (GL_POINTS, 0, numPrims); CheckGL("glDrawArrays");
glEndTransformFeedback(); CheckGL("glEndTransformFeedback");
glFlush (); CheckGL("glFlush");
// Alles freigeben, bis auf tbo mit Ergebnis
// glBindBuffer (GL_ARRAY_BUFFER, 0);
// glDeleteBuffers (1, &vbo);
// glDeleteVertexArrays (1, &vao);
// Ergebnis in cVAO übertragen:
if (!Control->cVAO) Control->cVAO = new clsVAO (numVerts, GL_T2F_C4F_N3F_V3F);
GLfloat *fp = Control->cVAO->Open (numVerts, GL_T2F_C4F_N3F_V3F);
glGetBufferSubData (GL_TRANSFORM_FEEDBACK_BUFFER, 0, bufSize, fp );
Print("
" + tostr(fp[ 0]) + " - " + tostr(fp[ 1])
+ "
" + tostr(fp[ 2]) + " - " + tostr(fp[ 3]) + " - " + tostr(fp[ 4]) + " - " + tostr(fp[ 5])
+ "
" + tostr(fp[ 6]) + " - " + tostr(fp[ 7]) + " - " + tostr(fp[ 8])
+ "
" + tostr(fp[ 9]) + " - " + tostr(fp[10]) + " - " + tostr(fp[11]));
Control->cVAO->Close ();
// tbo freigeben
glDeleteBuffers (1, &tbo);
glUseProgram (0);
}
But as i alread said (and as you maybe see) i tried around a lot, without success…
Best,
Frank