[java] creating new objects out of byte buffer
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-
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.
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
Paul
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement