[java] creating new objects out of byte buffer

Started by
2 comments, last by Son of Cain 17 years, 2 months ago
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-
Cosmic Keys to my Creations & Times
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.
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
Cosmic Keys to my Creations & Times
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.
a.k.a javabeats at yahoo.ca

This topic is closed to new replies.

Advertisement