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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:28:41+00:00 2026-06-06T23:28:41+00:00

I use the following code to render a line, given the coordinates in data

  • 0

I use the following code to render a line, given the coordinates in data:

create and upload data:

nPoints = 3 # let's use three points as an example, in reality this would be 1000
data = [x1y1 x2y2 x3y3]

# upload data
glBufferData(GL_ARRAY_BUFFER, sizeof(data), data, mode)

draw the line:

# draw line
stride = 0
offset_to_first_vertex = 0
glVertexPointer(2, GL_FLOAT, stride, offset_to_first_vertex)

offset_to_first_vertex = 0    
glDrawArrays(GL_LINE_STRIP, offset_to_first_vertex, nPoints)

update y coordinate of 2nd point:

offset = 12
glBufferSubData(GL_ARRAY_BUFFER, offset, sizeof(new_data), new_data)

things become more complicated if I want to update the y coordinate of multiple points at the same time, e.g. of the 2nd and 3rd point:

offset = 12
glBufferSubData(GL_ARRAY_BUFFER, offset, sizeof(new_data), new_data)
offset = 20
glBufferSubData(GL_ARRAY_BUFFER, offset, sizeof(new_data), new_data)

Calling glBufferSubData is very expensive so I’d rather prefer to have one call and overwrite all values at the same time. Unfortunately, you can’t pass a stride value to glBufferSubData, which means that I can only overwrite a continuous part of memory.

I was thinking that maybe I need to re-organize my data in memory differently:

data = [x1x2x3y1y2y3]

This way I can overwrite multiple values with one call of glBufferSubData. However, if I do this, then I can’t render the points with glVertexPointer and glDrawArrays anymore.

Therefore my question:
What is the best way of updating multiple single coordinates of my line? How should I layout the data in memory? and how can I draw the line?

EDIT1: I could probably keep track of the x values and update multiple points by overwriting the corresponding x/y pairs. But I’d like to prevent this if possible.

EDIT2: is there a way to render a line two VBOs? let’s say one VBO keeps the x values and another one has the y values. It doesn’t seem like that’s possible.

  • 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-06T23:28:44+00:00Added an answer on June 6, 2026 at 11:28 pm

    Can you use shaders? I guess if you want you could have the x and y position as separate attributes, and then combine them in the shader (you could even put x and y in separate buffers).

    If in the fixed pipeline, you could check out glMapBuffer, which allows you to map the entire buffer to your local client. You can then update any of the values in any way that you want. I don’t know what the impact of performance will be for this.

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

Sidebar

Related Questions

I use following code: Create a retry policy, when error, retry after 1 second,
I use the following code try to create an array of string vectors, I
I use the following line of code to have Adobe Reader print my generated
I just use following code to add an image to my project, var paper
I use VS2010, C# to develop Silverlight 4 app, I use following code in
I have an array of objects, and i use following code to get in
I use the following code to crop an image according to a rectangular selection
I use the following code to copy a particular directory and its contents to
I use the following code to fill all empty keys in sub-arrays with ``
I use the following code... $mail = new PHPMailer(); $mail->IsSMTP(); // send via SMTP

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.