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

  • Home
  • SEARCH
  • 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 8394133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:58:47+00:00 2026-06-09T19:58:47+00:00

I am currently working on a 2d Top-down RPG written in Java 1.6 with

  • 0

I am currently working on a 2d Top-down RPG written in Java 1.6 with the LWJGL. I implemented the use of VBOs into my game and now I maintain two of them: one for vertex data and one for texture coords.

It’s all working fine except that I still don’t have a really logical way to update the Objects. As an example, if I want a certain tile to change its texture (change the texture coordinates inside the VBO in order to show another area of the Texture Sheet), I can’t see a way to only changing the texture coordinates that correspond to this single tile. All I can think of now is maybe filling up the buffers with all the data needed every loop and uploading them with glBufferData every frame. It works but does not seem to be the best way of doing it (or it does?).

Now, there is the glBufferSubData command which will not allocate new memory but only change the portion I tell it to change. The thing is I don’t know how to keep track of the area that has to be changed (the offset). LWJGL offers a glBufferSubData(target, offset, data); command, which only needs the beggining of the buffer to work. Is the offset something like an index?

So if I first upload these buffers to the VBO and then want to change the second value of the second float[]:

FloatBuffer vertexData = BufferUtils.createFloatBuffer(amountOfVertices * vertexSize);
vertexData.put(new float[]{100, 100, 300, 100, 300, 300, 100, 300});
vertexData.put(new float[]{400, 100, 600, 100, 600, 300, 400, 300});
vertexData.flip();

I would generate the new data, put it inside a small FloatBuffer and upload it with glBufferSubData(GL_VERTEX_ARRAY, 10, newFloatBuffer);? 10 is because I want to change values from the tenth old value on.

Is that right? Is there a better way to do it? And again: is it ok if I re-upload the whole data every frame?

  • 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-09T19:58:48+00:00Added an answer on June 9, 2026 at 7:58 pm

    LWJGL’s glBufferSubData() expects the offset as byte count, since one should be able to write arbitrary data to arbitrary buffer locations. If you want to update the float at index i, the offset would be i * 4, since java floats take, the very common, 4 bytes. All remaining buffer contents will be written, therefore, the target buffer is required to have a capacity of at least
    (i + floatBuffer.remaining()) * 4 bytes.
    For correct preparation, see the Buffers flip() method or use position(int) together with limit(int) to specify the remaining contents to be written.

    This updating strategy is OK as long as you don’t call glBufferSubData() too many times with temporary FloatBuffers.
    You could also have a second target buffer with equal size for swapping (ping pong), which one could map using MapBuffer() for an overall update, while the other one is in use.

    I’d rather hold a complete FloatBuffer at the client side and upload it at once using glBufferData() instead of calling glBufferSubData() many times. But without knowing some numbers, it’s hard to tell.

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

Sidebar

Related Questions

Hi I'm currently working on an iPhone game, top-down Strategy RPG (kinda like Fire
I am working on a tile based, top-down 2D game with dinamically generated terrain,
I'm currently working on a simple 2D top-down shooter in which you maneuver your
Currently working with converting SQLException error messages into messages that are more useful for
Im currently working on a game that uses multi touch to apply zoom to
I'm currently working on a XNA game prototype. I'm trying to achieve a isometric
I'm currently implementing Pull To Refresh functionality in Android. Now I have it working
At the top of a website I'm currently working on, I defined a «Skip
I am currently working in a place where they still use .net 2.0. I
Im currently working on a website for work experience and ran into a problem

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.