Thanks for your reply.
Maybe it’s the point that i still mix up VAO and VBO. I’m still working with VBO(?) without client-specified attrbute-sets. I use normal GL_T2F_N3F_V3F-format.
I’ve a class (mostly for convenience), that manages the array. In this case only the constructor and “void clsVAO :: DrawInterleaved (GLint format, GLint DrawType)” is relevant, which is called width GL_T2F_N3F_V3F and GL_QUADS as parameters. The other functions are only needed for the csv-file-output (the currently commented out “//SaveAsCSV(“TEST_BUFFER.txt”);”-call), that i used this to check the array-data - seems okay, so far: T2F,N3F,V3F with correct T2F-values.
class clsVAO {
private:
GLint NumV, Format, attrItems, byteStride, bufBytes;
GLuint VBO;
GLfloat *Data;
void CalcSize (int numV, int format);
public:
clsVAO (GLint numV, GLint format = GL_T2F_N3F_V3F, GLfloat* data = NULL);
virtual ~clsVAO ();
number *Open (int numV = -1, int format = -1, GLfloat* data = NULL);
void Close ();
void DrawInterleaved (GLint format = GL_T2F_N3F_V3F, GLint DrawType = GL_QUADS);
[...]
void SaveAsCSV (wxString fNam);
};
void clsVAO::CalcSize (int numV, int format) {
NumV = numV; Format = format;
attrItems = Format < 1000 ? Format
: Format == GL_V2F ? 2
: Format == GL_V3F ? 3
// : Format == GL_C4UB_V2F ? 4 * sizeof(GLubyte) + 2 * sizeof(GLfloat)
// : Format == GL_C4UB_V3F ? 4 * sizeof(GLubyte) + 3 * sizeof(GLfloat)
: Format == GL_C3F_V3F ? 3 + 3
: Format == GL_N3F_V3F ? 3 + 3
: Format == GL_C4F_N3F_V3F ? 4 + 3 + 3
: Format == GL_T2F_V3F ? 2 + 3
: Format == GL_T4F_V4F ? 4 + 4
// : Format == GL_T2F_C4UB_V3F ? 2 + 4 * sizeof(GLubyte) + 3
: Format == GL_T2F_C3F_V3F ? 2 + 3 + 3
: Format == GL_T2F_N3F_V3F ? 2 + 3 + 3
: Format == GL_T2F_C4F_N3F_V3F ? 2 + 4 + 3 + 3
: Format == GL_T4F_C4F_N3F_V4F ? 4 + 4 + 3 + 4
: 1
;
byteStride = attrItems * sizeof(GLfloat);
bufBytes = NumV * byteStride;
}
clsVAO::~clsVAO () { glDeleteBuffers(1, &VBO); glBindBuffer (GL_ARRAY_BUFFER, 0); }
clsVAO:: clsVAO (int numV, int format, GLfloat* data) {
CalcSize (numV, format);
glGenBuffers (1, &VBO);
glBindBuffer (GL_ARRAY_BUFFER, VBO);
glEnableClientState (GL_VERTEX_ARRAY);
glBufferData (GL_ARRAY_BUFFER, bufBytes, data, GL_STATIC_DRAW);
}
void clsVAO::DrawInterleaved (GLint format, GLint DrawType) {
glBindBuffer (GL_ARRAY_BUFFER, VBO);
glInterleavedArrays (format, byteStride, NULL);
//SaveAsCSV("TEST_BUFFER.txt");
glDrawArrays (DrawType, 0 /*start*/, NumV);
glBindBuffer (GL_ARRAY_BUFFER, 0);
}
number* clsVAO::Open (int numV, int format, GLfloat* data) {
glBindBuffer (GL_ARRAY_BUFFER, VBO);
glEnableClientState (GL_VERTEX_ARRAY);
if (format > 0 && numV > 0 && (numV != NumV || format != Format)) {
CalcSize (numV, format);
glBufferData (GL_ARRAY_BUFFER, bufBytes, data, GL_STATIC_DRAW);
}
return (GLfloat*)glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE);
}
void clsVAO::Close () {
glUnmapBuffer (GL_ARRAY_BUFFER);
}
void clsVAO::SaveAsCSV (wxString fNam) {
wxString ret; ret.reserve(bufBytes * 10); GLfloat *fp = Open();
for (int vi = 0; vi < NumV; vi++) {
for (int ai = 0; ai < attrItems; ai++) ret += tostrp(*fp++) + ";"; ret += "
";
}
wxFile (fNam, wxFile::write).Write(ret); Close();
}