Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8306337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:18:42+00:00 2026-06-08T18:18:42+00:00

I am trying to fill two buffers, an index buffer object and a vertex

  • 0

I am trying to fill two buffers, an index buffer object and a vertex buffer object in C++.

// 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 < 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);
}

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).

I get an output like this:

<---> Index dump: 0
<---> Index dump: 1
<---> Index dump: 2
<---> Index dump: 2
<---> Index dump: 3
<---> Index dump: 0
<---> Index dump: 4
<---> Index dump: 5
<---> Index dump: 23
<---> Index dump: 23
<---> Index dump: 22
<---> Index dump: 4
<---> Index dump: 26
<---> Index dump: 6
<---> Index dump: 7
<---> Index dump: 7
<---> Index dump: 8
<---> Index dump: 26
<---> Index dump: 9
<---> Index dump: 34
<---> Index dump: 10
<---> Index dump: 10
<---> Index dump: 11
<---> Index dump: 9
<---> Index dump: 12
<---> Index dump: 25
<---> Index dump: 13
<---> Index dump: 13
<---> Index dump: 14
<---> Index dump: 12
<---> Index dump: 13
<---> Index dump: 25
<---> Index dump: 31
<---> Index dump: 31
<---> Index dump: 15
<---> Index dump: 13
<---> Index dump: 28
<---> Index dump: 33
<---> Index dump: 16
<---> Index dump: 36
<---> Index dump: 33
<---> Index dump: 35
<---> Index dump: 31
<---> Index dump: 24
<---> Index dump: 15
<---> Index dump: 17
<---> Index dump: 25
<---> Index dump: 18
<---> Index dump: 18
<---> Index dump: 25
<---> Index dump: 12
<---> Index dump: 27
<---> Index dump: 34
<---> Index dump: 9
<---> Index dump: 2
<---> Index dump: 1
<---> Index dump: 19
<---> Index dump: 30
<---> Index dump: 32
<---> Index dump: 20
<---> Index dump: 29
<---> Index dump: 25
<---> Index dump: 17
<---> Index dump: 17
<---> Index dump: 21
<---> Index dump: 29
<---> Index dump: 32
<---> Index dump: 26
<---> Index dump: 8
<---> Index dump: 8
<---> Index dump: 20
<---> Index dump: 32
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0
<---> Index dump: 0

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?

A further explanation:

Mesh 1 – 72 indices
Mesh 2 – 300 indices
Mesh 3 – 45 indices.

Using the function above, it produces a buffer that does this:

[0]-[71] – Mesh 1 vertices all correct
[72]-[142] – Empty
[142]-[EndofBuffer] – Mesh 2

It creates duplicate sizes filled with 0’s.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T18:18:44+00:00Added an answer on June 8, 2026 at 6:18 pm

    Since iboData is a GLushort*, then iboData+iboPos actually points to the memory location (int)iboData + iboPos * sizeof(GLushort). You’re confusing byte offsets with array offsets. In your two += statements, don’t multiply by the sizeof you used in memcpy, as iboPos records the GLushort offset, not the byte offset.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to setting up relational databases. I'm trying to create two tables in
I'm trying to create a fill in between two of these triangles, for example
I am trying to fill object[] with List<string> but I cannot figure out how
I am trying to fill a table with JSON data. When I run the
I am trying to create a LinearLayout with two Listviews and can not see
I'm trying to create a ListView with items that have two lines of text,
I'm trying to fill out two textfields and press a button programmatically that is
I have two questions: 1) I am trying to fill a form's fields with
I am trying to create an Activity for an Android app with two imageViews
I'm trying to make a WPF TextBox fill all available space between two buttons.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.