Oh, that explains a lot. …
I did not know this but for some reasons i suspected something like this - at least since i had to set a special gluexperimental (or something like this) -flag to avoid crashes usig glTranformfeebackveryings…
FYI: no, there doesn’t have to be an array. Your VAO can be completely empty, with no attached buffer objects, so long as you’re only using built-in input variables.
Okay… But, without “glBufferData(GL_ARRAY_BUFFER, size, data, …);”, with data might be NULL, it won’t work. As far as i understand this, the GPU is caused to allocate an array of type GL_ARRAY_BUFFER, and a given size.
So…
There is an existing array and one to be allocated - either as source or as destination. But there are needed always two, even if one isn’t filled with data (NULL-pointer). For me that means: giving a ram-pointer (sorry, don’t know how to express it better) will cause the CPU to tranfer data to GPU. Using NULL as data-pointer does not.
Now my destination is (re)written. Therefore i don’t care what is inside (tt may be trash-data from compleatly other things), but the source-data i need in some cases (when i use it as source for feedbacks).
As explained i have to allocate (glBufferData) the memory anyway. So i see no reason, why i sould not allocate a new destination instead of a temporary source, to simply swap pointers after drawing and to be free to use or to ignore / overwrite the previous data in the shader-program or to use it as feedback-souce.
So… what happens if you want to render two spheres in two different locations?
Again: Puh!
Almost nothing in my program is fixed. It has it’s own programming-lanuage, that is controlling everything. So, what happens if… depends on what you program, like i.e. this, which is one of the text-file interpreted by my interpreter to create vertex-arrays:
var Type = "MACRO";
var Title = 'Render TFF';
InitControl ( Type, __File, 'Array functions');
LinkTimer ( _T_THREAD_IDX_ARRAYS );
SetPosition ( x, y);
SetSize ( 1, 2);
var TitleBar = new titleBar ('_MD_BUTTONS_ALL', '_MD_STORE_TEXTURE_MENU');
TitleBar : ModuleMenu : CommandItem (20, "Save array as CSV");
TitleBar : ModuleMenu : CommandItem (21, "Save vertex-shader");
var OnMenu = '
if (caller.MenuValue == 20) {
SaveArray("txt", _DYNAMIC_FOLDER + "Array functions/" + CreateFileName("Vertex-array") );
};
if (caller.MenuValue == 21) {
Shader.VertexShader.Save(_DYNAMIC_FOLDER + "Array functions/" + (parent.CreateFileName("Vertex-shader")) );
};
';
var Shader = new IncludeShader ( 0, 0, (_DYNAMIC_FOLDER + "Array functions/shader/shader-vbo.txt"));
Shader : AddUniforms ('
uniform float DrawType;
uniform vec2 MapSize;
uniform vec2 Cc1;
uniform vec4 Cc2;
');
var vcW = new valAny ('Width', 3.0, 0, 3.0, 1, 500, 1, 24);
var vcH = new valAny ('Height', 6.0, 0, 3.0, 1, 500, 1, 24);
var vc1 = new valAny ('Cc1.x', 0.0, 1, 3.0, 0, 1, 0.01, 0.25);
var vc2 = new valAny ('Cc2.x', 3.0, 1, 3.0, 0, 1, 0.01, 1);
var vc3 = new valAny ('Cc2.y', 6.0, 1, 3.0, 0, 1, 0.01, 1);
var vc4 = new valAny ('Cc2.z', 9.0, 1, 3.0, -1, 1, 0.01, 0);
var vc5 = new valAny ('Cc2.r', 12.0, 1, 3.0, -1, 1, 0.01, 0);
var OnPrepare = '0;';
var OnNext = '
Shader . Apply ( "", GlobalUniforms, "tff_out", 8);
PrepareArray ( vcW.GetInt(), vcH.GetInt(), 4, "tff_in", GL_T2F_N3F_V3F);
Shader . glUniform ( "DrawType", GL_QUADS );
Shader . glUniform ( "MapSize", vcW.GetInt(), vcH.GetInt() );
Shader . glUniform ( "Cc1", vc1.Get01(), vc2.Get01() );
Shader . glUniform ( "Cc2", vc2.Get01(), vc3.Get01(), vc4.Get01(), vc5.Get01() );
RefeedArray ();
// ResetGL ();
';
var OnApply = '
DrawInterleaved ( GL_T2F_N3F_V3F, GL_QUADS );
';
So, if i want to use a sphere-vertex-array several times, i add several times
glPush();
glTranlate3f(vc1.GetValue(), vc2.GetValue(), vc3.GetValue());
DrawInterleaved ( GL_T2F_N3F_V3F, GL_QUADS );
glPop();
… to the OnApply-string. And the vertex-array will be drawn several times on different positions.
As all of this is kept in strings and interpreted by my interpreter at runtime. Therfore there is, just some copy/paste needed, to draw the same array several times.
Best,
Frank