From bab5b383b63e6e534bbb7f7125836f3d3de7b6c8 Mon Sep 17 00:00:00 2001 From: Brian Matzon Date: Mon, 9 Sep 2002 16:41:36 +0000 Subject: [PATCH] mod: changed text file to html, so that it can be included on website --- doc/openal_c-to-java.html | 87 +++++++++++++++++++++++++++++++++++++++ doc/openal_c-to-java.txt | 45 -------------------- 2 files changed, 87 insertions(+), 45 deletions(-) create mode 100644 doc/openal_c-to-java.html delete mode 100644 doc/openal_c-to-java.txt diff --git a/doc/openal_c-to-java.html b/doc/openal_c-to-java.html new file mode 100644 index 00000000..2fda3eaa --- /dev/null +++ b/doc/openal_c-to-java.html @@ -0,0 +1,87 @@ + + + + OpenAL Tutoral + + + + + +

Array Conversion
+(by Brian Matzon <brian@matzon.dk>)
+

+1.0 About this document
+This document describes the typical rules for converting arrays often used in +C/C++ OpenAL (and indeed OpenGL too)  code.
+It is not bullet proof, but should handle most cases.
+
+1.1 Array to ByteBuffer
+
When using an array of some data type in C/C++ +you will typically convert that
+to the corresponding ByteBuffer type. ie:

ALfloat +floatv[3];

+

becomes

+

+FloatBuffer floatv = createFloatBuffer(3);

+

In this example, createFloatBuffer +is this utility method:

+

+public FloatBuffer createFloatBuffer(int size) {
+  +//allocate bytebuffer, using 4 bytes per float
+  +ByteBuffer temp = ByteBuffer.allocateDirect(4*size);
+  +temp.order(ByteOrder.nativeOrder());
+  +
+  +return temp.asFloatBuffer();
+}

+

+1.2 Examples
+Using the above FloatBuffer, you would typically use it like this (examples +taken from altest.c/ALTest.java):

+

+1.2.1 Example 1

+

+alGetListenerfv(AL_POSITION, floatv);

+

+becomes

+

+al.getListenerfv(AL.POSITION, Sys.getDirectBufferAddress(floatv));

+

1.2.2 Example 2

+

+if (floatv[0] != 100.0)) {

+

becomes:

+

+if (floatv.get(0) != 100.0f) {

+

1.2.3 Example 3

+

+alGetListener3f(AL_POSITION, &floatv[0],
+                             +&floatv[1],
+                             +&floatv[2]);

+

becomes

+

+al.getListener3f(AL.POSITION, Sys.getDirectBufferAddress(floatv),
+                              +Sys.getDirectBufferAddress(floatv) + 4,
+                              +Sys.getDirectBufferAddress(floatv) + 8);

+

the last case is a bit special, since we start of by getting the base +address of the buffer, and then add the datatype size to the base address
+to get the address of that specific index. This is just how it has to +be in Java.

+ + \ No newline at end of file diff --git a/doc/openal_c-to-java.txt b/doc/openal_c-to-java.txt deleted file mode 100644 index 82582aa3..00000000 --- a/doc/openal_c-to-java.txt +++ /dev/null @@ -1,45 +0,0 @@ -Author: Brian Matzon - -When converting C/C++ OpenAL code to Java the following -conversion rules, typically apply: - -When using an array of some data type in C/C++ you will typically convert that -to the corresponding ByteBuffer type. ie: - ALfloat floatv[3]; -becomes - FloatBuffer floatv = createFloatBuffer(3); - -In this example, createFloatBuffer is this utility method: -public FloatBuffer createFloatBuffer(int size) { - //allocate bytebuffer, using 4 bytes per float - ByteBuffer temp = ByteBuffer.allocateDirect(4*size); - temp.order(ByteOrder.nativeOrder()); - - return temp.asFloatBuffer(); -} - -Using the above FloatBuffer, you would typically use it like this: -(examples taken from altest.c/ALTest.java): -example 1: - alGetListenerfv(AL_POSITION, floatv); -becomes - al.getListenerfv(AL.POSITION, Sys.getDirectBufferAddress(floatv)); - -example 2: - if (floatv[0] != 100.0)) { -becomes: - if (floatv.get(0) != 100.0f) { - -example 3: - alGetListener3f(AL_POSITION, &floatv[0], - &floatv[1], - &floatv[2]); -becomes - al.getListener3f(AL.POSITION, Sys.getDirectBufferAddress(floatv), - Sys.getDirectBufferAddress(floatv) + 4, - Sys.getDirectBufferAddress(floatv) + 8); - -the last case is a bit special, since we start of by getting the base -address of the buffer, and then add the datatype size to the base address -to get the address of that specific index. This is just how it has to -be in Java. \ No newline at end of file