Hi !
Featured games (85)
games approved by the League of Dukes
Games in Showcase (636)
Games in Android Showcase (178)
games submitted by our members
Games in WIP (688)
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  
  Buffer offsets from Sys.getDirectBufferAddress();  (Read 2442 times)
0 Members and 1 Guest are viewing this topic.
Offline Spasi
« Posted 2002-12-11 11:57:27 »

Say I want to use the following method:

unProject(double winx, double winy, double winz, int modelMatrix, int projMatrix, int viewport, int objx, int objy, int objz);

The last 3 parameters and pointers to doubles. One way to use this method is to create 3 different one double long buffers, get their addresses and give them to unProject. Is there a way to use just one? For example, do something like this:

DoubleBuffer xyz = ByteBuffer.allocateDirect(3 * 8).order(ByteOrder.nativeOrder()).asDoubleBuffer();
int xyzP = Sys.getDirectBufferAddress(xyz);

and then:

unProject(winx, winy, winz, modelMatrix, projMatrix, viewport, xyzP, xyzP + 2, xyzP + 4);

where xyzP, the address of the first double
where xyzP + 2, the address of the second double
where xyzP + 4, the address of the third double

I have tested this and of course it didn't work. Actually, it run, but it didn't work correctly. Could something like this work, use one buffer's starting address to get offsets on the same buffer? Am I correct to assume that the second double is 2 addresses (2 * 32 bits = 64 bits) away from the first one? I'm asking this because I'm afraid of the overhead of many Buffers (should I?) and besides my code gets really ugly. It would be a lot easier and cleaner to use xyz.get(double_array[3]) than have three different buffers and use buffer.get() three times. It would be faster too. Any suggestions?
Offline Orangy Tang

JGO Kernel

Medals: 57
Projects: 11

Monkey for a head

« Reply #1 - Posted 2002-12-11 12:23:55 »

Am I correct to assume that the second double is 2 addresses (2 * 32 bits = 64 bits)

Odds are I think that the addresses are going to be either byte or 16-bit word addressable, so your offsets of +2 and +4 should be doubled at least. I was using something similar for gluProject a little while ago, but i can't remember whether I got it working or not (or even if its cross-platform friendly..).

[ - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline princec

« JGO Spiffy Duke »

Medals: 625
Projects: 3
Exp: 16 years

Eh? Who? What? ... Me?

« Reply #2 - Posted 2002-12-11 12:38:19 »

Yes, and it's a necessary evil to be sure. Offsets are in bytes so a double would need +8, +16 etc.

Cas Smiley

Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

Dwinin (77 views)
2015-11-07 13:29:08

Rems19 (83 views)
2015-10-31 01:36:56

Rems19 (82 views)
2015-10-31 01:32:37

williamwoles (108 views)
2015-10-23 10:42:59

williamwoles (95 views)
2015-10-23 10:42:45

Jervac_ (113 views)
2015-10-18 23:29:12

DarkCart (139 views)
2015-10-16 00:58:11

KaiHH (120 views)
2015-10-11 14:10:14

KaiHH (161 views)
2015-10-11 13:26:18

BurntPizza (174 views)
2015-10-08 03:11:46
Rendering resources
by Roquen
2015-11-13 14:37:59

Rendering resources
by Roquen
2015-11-13 14:36:58

Math: Resources
by Roquen
2015-10-22 07:46:10

Networking Resources
by Roquen
2015-10-16 07:12:30

Rendering resources
by Roquen
2015-10-15 07:40:48

Math: Inequality properties
by Roquen
2015-10-01 13:30:46

Math: Inequality properties
by Roquen
2015-09-30 16:06:05

HotSpot Options
by Roquen
2015-08-29 11:33:11 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!