Note that there are some explanatory texts on larger screens.

plurals
  1. POC++ - Buffer combining adding extra empty values
    primarykey
    data
    text
    <p>I am trying to fill two buffers, an index buffer object and a vertex buffer object in C++.</p> <pre><code>// Create the IBO and VBO data GLushort* iboData = new GLushort[polyProcessed * 3]; Vertex* vboData = new Vertex[vertProcessed]; int iboPos = 0; int vboPos = 0; // Create the VBO and IBO for(int i = 0; i &lt; fragMap[0x36]; i++) { // Copy the data to the IBO memcpy(iboData + iboPos, zmeshes[i].indices, zmeshes[i].numPoly * 3 * sizeof(GLushort));//sizeof(*zmeshes[i].indices)); // Advance the position iboPos += zmeshes[i].numPoly * 3 * sizeof(GLshort); // Copy the data to the VBO memcpy(vboData + vboPos, zmeshes[i].vertices, zmeshes[i].numVert * sizeof(Vertex));//sizeof(*zmeshes[i].vertices)); // Advance the position vboPos += zmeshes[i].numVert * sizeof(Vertex); errorLog.writeSuccess("Build log: VBO size %i VBO pos %i IBO size %i IBO pos %i", zmeshes[i].numVert * sizeof(Vertex), vboPos, zmeshes[i].numPoly * 3 * sizeof(GLshort), iboPos); } </code></pre> <p>It's simply getting the size of the data to be copied, copying it, and then advancing the position (where to put the next data in the buffer).</p> <p>I get an output like this:</p> <pre><code>&lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 1 &lt;---&gt; Index dump: 2 &lt;---&gt; Index dump: 2 &lt;---&gt; Index dump: 3 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 4 &lt;---&gt; Index dump: 5 &lt;---&gt; Index dump: 23 &lt;---&gt; Index dump: 23 &lt;---&gt; Index dump: 22 &lt;---&gt; Index dump: 4 &lt;---&gt; Index dump: 26 &lt;---&gt; Index dump: 6 &lt;---&gt; Index dump: 7 &lt;---&gt; Index dump: 7 &lt;---&gt; Index dump: 8 &lt;---&gt; Index dump: 26 &lt;---&gt; Index dump: 9 &lt;---&gt; Index dump: 34 &lt;---&gt; Index dump: 10 &lt;---&gt; Index dump: 10 &lt;---&gt; Index dump: 11 &lt;---&gt; Index dump: 9 &lt;---&gt; Index dump: 12 &lt;---&gt; Index dump: 25 &lt;---&gt; Index dump: 13 &lt;---&gt; Index dump: 13 &lt;---&gt; Index dump: 14 &lt;---&gt; Index dump: 12 &lt;---&gt; Index dump: 13 &lt;---&gt; Index dump: 25 &lt;---&gt; Index dump: 31 &lt;---&gt; Index dump: 31 &lt;---&gt; Index dump: 15 &lt;---&gt; Index dump: 13 &lt;---&gt; Index dump: 28 &lt;---&gt; Index dump: 33 &lt;---&gt; Index dump: 16 &lt;---&gt; Index dump: 36 &lt;---&gt; Index dump: 33 &lt;---&gt; Index dump: 35 &lt;---&gt; Index dump: 31 &lt;---&gt; Index dump: 24 &lt;---&gt; Index dump: 15 &lt;---&gt; Index dump: 17 &lt;---&gt; Index dump: 25 &lt;---&gt; Index dump: 18 &lt;---&gt; Index dump: 18 &lt;---&gt; Index dump: 25 &lt;---&gt; Index dump: 12 &lt;---&gt; Index dump: 27 &lt;---&gt; Index dump: 34 &lt;---&gt; Index dump: 9 &lt;---&gt; Index dump: 2 &lt;---&gt; Index dump: 1 &lt;---&gt; Index dump: 19 &lt;---&gt; Index dump: 30 &lt;---&gt; Index dump: 32 &lt;---&gt; Index dump: 20 &lt;---&gt; Index dump: 29 &lt;---&gt; Index dump: 25 &lt;---&gt; Index dump: 17 &lt;---&gt; Index dump: 17 &lt;---&gt; Index dump: 21 &lt;---&gt; Index dump: 29 &lt;---&gt; Index dump: 32 &lt;---&gt; Index dump: 26 &lt;---&gt; Index dump: 8 &lt;---&gt; Index dump: 8 &lt;---&gt; Index dump: 20 &lt;---&gt; Index dump: 32 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 &lt;---&gt; Index dump: 0 </code></pre> <p>This can be seen as the correct 72 values being copied in and 72 0's being copied in behind it. Did I do something wrong in the copying of my buffer or does this indicate a problem elsewhere?</p> <p>A further explanation:</p> <p>Mesh 1 - 72 indices Mesh 2 - 300 indices Mesh 3 - 45 indices.</p> <p>Using the function above, it produces a buffer that does this:</p> <p>[0]-[71] - Mesh 1 vertices all correct [72]-[142] - Empty [142]-[EndofBuffer] - Mesh 2</p> <p>It creates duplicate sizes filled with 0's.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. COYou say that there should only be 72 values. Are you sure that `fragMap[0x36]` is 72 during this loop? If it were greater than the number of elements in `zmeshes`, it would read past the end of `zmeshes` and write junk values to `iboData` and `vboData`. Alternately, the code that generated that index dump could be the one looping too many times. I'd check the value of the loop condition in both the loop above and in the one that generates the index dump, and confirm that they both match the number of elements that you're trying to copy from `zmeshes`.
      singulars
    2. CO@JoshTownzen fragMap is a map which keeps the number of fragments. I was looking for 0x36 fragments. The problem lies with the fact that every time I copy in the buffer, it is copying it in 'x' places past where it should where x is the size of the previous buffer. I updated my post to be more clear.
      singulars
    3. COJust to confirm, when you say "I was looking for 0x36 fragments", do you mean that you're looking for as many fragments as are listed in element 0x36 of `fragMap`? If so, I'd still suggest debugging the value of `fragMap[0x36]` to ensure that it contains the number that you're looking for. If instead you meant that you were looking for a literal 0x36 fragments (54, in decimal), then that's not what the loop above will do.
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload