Login  Register

Re: MultiDrawElements

Posted by elect on Jan 14, 2016; 2:53pm
URL: https://forum.jogamp.org/MultiDrawElements-tp4036014p4036031.html

James wrote
Thanks a lot that works
You'r welcome, I should have seen since the begin. Opengl needed an array of offset to start the n-th element drawing from, and that was the base vertex..

James wrote
what would array be if data was packed has following

            250.0f, 250.0f, 0.0f, 1.0f, // 0 right top
            250.0f, 350.0f, 0.0f, 1.0f, // 1 right bottom - reused
            150.0f, 350.0f, 0.0f, 1.0f, // 2 left bottom
            150.0f, 250.0f, 0.0f, 1.0f, // 3 left top - reused

            1.0f, 0.0f, 0.0f, 1.0f,
            1.0f, 0.0f, 0.0f, 1.0f,
            1.0f, 0.0f, 0.0f, 1.0f,
            1.0f, 0.0f, 0.0f, 1.0f,

            450.0f, 250.0f, 0.0f, 1.0f,
            450.0f, 350.0f, 0.0f, 1.0f,
            350.0f, 350.0f, 0.0f, 1.0f,
            350.0f, 250.0f, 0.0f, 1.0f,

            0.0f, 1.0f, 0.0f, 1.0f,
            0.0f, 1.0f, 0.0f, 1.0f,
            0.0f, 1.0f, 0.0f, 1.0f,
            0.0f, 1.0f, 0.0f, 1.0f,

            650.0f, 250.0f, 0.0f, 1.0f,
            650.0f, 350.0f, 0.0f, 1.0f,
            550.0f, 350.0f, 0.0f, 1.0f,
            550.0f, 250.0f, 0.0f, 1.0f,

            0.0f, 0.0f, 1.0f, 1.0f,
            0.0f, 0.0f, 1.0f, 1.0f,
            0.0f, 0.0f, 1.0f, 1.0f,
            0.0f, 0.0f, 1.0f, 1.0f

tried 0, 8 , 16 but draws green, blue then black from left to right instead of red green blue from left to right (red square drawn last instead of first and is black)
If [0,8,16] doesnt work then I guess you can't do like that with glMultiDrawElementsBaseVertex, either interleaved (the best since it exploits data locality)

position0, color0,
position1, color1,
position2, color2

or one after each other

position0,
position1,
position2,
color0,
color1,
color2

or separate

position0,
position1,
position2

color0,
color1,
color2

or (I think) glMultiDrawElementsIndirect