Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (777)
Games in Android Showcase (231)
games submitted by our members
Games in WIP (856)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  arrays vs buffers for JNI  (Read 2617 times)
0 Members and 1 Guest are viewing this topic.
Offline deepthought
« Posted 2011-11-23 23:14:33 »

I've noticed that in lwjgl, the functions which would require an array in opengl require bytebuffers or floatbuffers in lwjgl. is this for speed?

i need to be able to pass an array to a function i've written, and return one.

what would be faster, using a jbytearray, or converting my array to a buffer, sending it, having the method return a buffer, and converting it to an array?

Mad Scientist
Offline princec

« JGO Spiffy Duke »

Medals: 1060
Projects: 3
Exp: 20 years

Eh? Who? What? ... Me?

« Reply #1 - Posted 2011-11-24 10:28:54 »

Yes, it's for speed. Direct ByteBuffers are the absolute fastest lowest overhead way of getting data to OpenGL. If you're actually processing that data on the CPU, do it in arrays first then send it all at once to the buffer to transmit to OpenGL.

Cas Smiley

Offline delt0r

JGO Wizard

Medals: 145
Exp: 18 years

Computers can do that?

« Reply #2 - Posted 2011-11-24 10:57:22 »

Half if not all of the reason for Direct Byte buffers is for faster marshaling of data through JNI. It really is the correct way to do things with C esp if they are passing data back. Remember a java array does not look like a C array. But a C array looks like a Direct Byte buffer. More or less.

I have no special talents. I am only passionately curious.--Albert Einstein
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline deepthought
« Reply #3 - Posted 2011-11-24 14:11:48 »

thanks for clearing that up. it had been nagging at me since i first started with lwjgl.
and of course that's useful to know if i ever write my own JNI library for anything.

Mad Scientist
Pages: [1]
  ignore  |  Print  

hadezbladez (328 views)
2018-11-16 13:46:03

hadezbladez (168 views)
2018-11-16 13:41:33

hadezbladez (327 views)
2018-11-16 13:35:35

hadezbladez (77 views)
2018-11-16 13:32:03

EgonOlsen (2159 views)
2018-06-10 19:43:48

EgonOlsen (2194 views)
2018-06-10 19:43:44

EgonOlsen (1371 views)
2018-06-10 19:43:20

DesertCoockie (1989 views)
2018-05-13 18:23:11

nelsongames (1640 views)
2018-04-24 18:15:36

nelsongames (2289 views)
2018-04-24 18:14:32
Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20

Deployment and Packaging
by philfrei
2018-08-19 23:54:46 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!