Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (475)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (530)
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 2093 times)
0 Members and 1 Guest are viewing this topic.
Offline Spasi
« Posted 2002-12-11 12: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: 56
Projects: 11


Monkey for a head


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

Quote
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..).

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

JGO Kernel


Medals: 339
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #2 - Posted 2002-12-11 13: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.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Riven (4 views)
2014-07-23 20:17:25

ctomni231 (39 views)
2014-07-18 06:55:21

Zero Volt (36 views)
2014-07-17 23:47:54

danieldean (29 views)
2014-07-17 23:41:23

MustardPeter (32 views)
2014-07-16 23:30:00

Cero (47 views)
2014-07-16 00:42:17

Riven (48 views)
2014-07-14 18:02:53

OpenGLShaders (38 views)
2014-07-14 16:23:47

Riven (37 views)
2014-07-14 11:51:35

quew8 (33 views)
2014-07-13 13:57:52
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org 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‑gaming.org
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!