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 7028939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:28:22+00:00 2026-05-28T00:28:22+00:00

I have a terrain mesh stored in a VBO. The mesh is a grid

  • 0

I have a terrain mesh stored in a VBO. The mesh is a grid composed of right triangles. In other words, it looks like a rectilinear grid with diagonals. The width and height of the mesh are known, so it’s easy to calculate the vertex indices for a given XY or vice-versa.

The terrain mesh will be editable. My question concerns rebuffering the vertex data when the terrain is edited. I will be able to determine the rectangular region of vertices that are dirtied by any edit operation, so obviously I’d prefer to rebuffer only those and leave the rest alone.

The first thing that comes to mind is glBufferSubData. But I can’t come up with a way to lay out my VBO such that glBufferSubData would only affect the dirty vertices. For example, suppose my mesh is 5 x 5 vertices. (It would actually be much larger; this is just an example.) Like this:

 0  1  2  3  4
 5  6  7  8  9
10 11 12 13 14
15 16 17 18 19
20 21 22 23 24

(Each number in the diagram above represents the vertex’s offset from the start of the VBO.)

Suppose the 3 x 3 region in the center needs to be rebuffered. That means I want to hit vertices 6, 7, 8, 11, 12, 13, 16, 17, and 18. So I could call glBufferSubData starting at index 6 and ending at 18:

  0   1   2   3   4
  5  *6  *7  *8  *9
*10 *11 *12 *13 *14
*15 *16 *17 *18  19
 20  21  22  23  24

(In the diagram above, the vertices marked with * are rebuffered.)

Notice that vertices 10, 14, and 15 are not dirty, and yet they get rebuffered, because they’re in the range given to glBufferSubData. This strikes me as inefficient. For a large mesh, I’d be rebuffering way more data than I need to in most cases.

Is there a well-known solution to this problem? Should I call glBufferSubData once per row (which would solve the present problem, but would come with its own overhead)? Or is it standard just to buffer the full range and eat the cost of the unnecessary writing?

Also, terrain editing happens sometimes but not often. When it does, it will be animated, so the dirty vertices will have to be updated repeatedly while the animation is occurring. I’m thinking GL_DYNAMIC_DRAW would be good. Does this sound right?

  • 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-05-28T00:28:22+00:00Added an answer on May 28, 2026 at 12:28 am

    You shall use buffer object mapping. You can access to buffer object as a memory array, indeed accessing sparse vertices. The driver (hopefully) will optimize it for you.

    The use of GL_DYNAMIC_DRAW is correct.

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

Sidebar

Related Questions

I have terrain data stored as 16-bit png files. I would like to apply
I have a terrain mesh where just the Z value for each vertex needs
I have a terrain map which i would like to represent some data in.
In simple game, where map (terrain) is divided in grid cell I have soldier
Have a procedure which looks like Procedure TestProc(TVar1, TVar2 : variant); Begin TVar1 :=
I have a polygon and a terrain model (can be either grid or TIN).
I have coded a 3d-terrain engine with simplistic model engine on top of it.
I have a program which draws some terrain and simulates water flowing over it
I have an enum declared like so: var PlaceType = { PASSABLE_TERRAIN: 1, IMPASSABLE_TERRAIN:
I've been working on a simple tile-based terrain generator for fun, and have run

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.