Jump to content
  • Advertisement
Sign in to follow this  
gorgorath

[java] creating new objects out of byte buffer

This topic is 4248 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i have a bytebuffer that holds # number of this kind of class float x, y, z; byte r, g, b; 12 + 3 = 15 bytes per vertex now i want them to create so fast as possible and store them in arrays is there some sort of method to do this in java Tia Paul-

Share this post


Link to post
Share on other sites
Advertisement
No, there isn't.

To allocate objects quickly you could pre-allocate an array of type "YourVertexClass" and use that as a quick way to get new YourVertexClass objects.

Share this post


Link to post
Share on other sites
and is it possible with jni to create an array of such objects, coz right now i'm offsetting the position of the bytebuffer to get the vertices, which is pretty slow

Paul

Share this post


Link to post
Share on other sites
I must suggest a different approach to treat this problem. But instead of explaining it all here, I'll point you to this place: http://www.brackeen.com/javagamebook.

Take a look at chapter 6, and how the author deals with NIO messages using a clever interface, and a "packet-like" approach to messages. Makes it easy to deal with asynchronous content, plus allows you to encapsulate complex information quite easily. And, to top it off, adds the feature of creating complex objects to handle such data.

Worth looking.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!