Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (844)
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  
  JOAL API inconsistent with OpenAL?  (Read 3559 times)
0 Members and 1 Guest are viewing this topic.
Offline clevengr

Senior Newbie

Java games rock!

« Posted 2006-12-20 23:13:10 »

   I'm trying to understand why it appears that the JOAL API does not seem to match the OpenAL API (in the same way, for example, that one expects the JOGL API to match the OpenGL API).  I freely admit this could be due to my misunderstanding something, or looking at the wrong version, or something else (in which case I'd appreciate a gentle correction), but here's an example of what I'm talking about.

  The OpenAL 1.1 Programmers Giude ( updated December 2006 specifies (page 15)  just one form of alGenBuffers(): 

void alGenBuffers(ALsizei n,ALuint *buffers);

  The JOAL 1.1b03  API (Sep 5, 2006; the latest, as far as I know) specifies two forms of method alGenBuffers(): 

alGenBuffers(int n, IntBuffer buffers) 

alGenBuffers(int n, int[] buffers, int buffers_offset)

On it's face, this would seem to at least indicate that JOAL is not precisely just an interface directly into OpenAL, but rather that someone has decided to "do it better" (?).

Further, there is no documentation in the JOAL API JavaDoc explaining what the second form of alGenBuffers() does (i.e., what that third parameter represents (yes, I could guess a bit from the parameter name, but that's pretty weak documentation if that's the intent, and anyway every guess I make leaves me with at least a couple of questions).

Worse, both methods contain the same comment as to what they do:

          Entry point (through function pointer) to C language function: 
void alGenBuffers(ALsizei n, ALuint * buffers);

leaving even more confusion (and fewer clues) as to how the JOAL API actually works.

I've used alGenBuffers() as an example; there are many other routines with the same ambiguities. 

I am teaching classes in game design and am trying to make the argument that JOAL is a solid alternative to other choices.  However, things like this, which make it difficult for me to figure things out and therefore darn near impossible for my students, make it difficult to continue considering JOAL as a viable alternative.  Can someone help -- either in pointing out my error(s),  providing the missing explanation of what the API really intends to say/do, or (best case) improve the API so that it is either consistent with OpenAL or else has JavaDoc that clearly explains the differences?


Offline Ken Russell

JGO Coder

Java games rock!

« Reply #1 - Posted 2006-12-21 03:01:36 »

Sorry for the confusion and for the lack of javadoc. It is rooted in the fact that the Java programming language does not have pointers, so stylistic constructs have to be adopted.

We documented the mappings from C to Java in the JSR-231 overview documentation which you can find here. I've just filed JOAL Issue 14 to track improving the javadoc.

We're on the verge of releasing new versions of JOAL and JOGL which allow both to be used in applets as well as via Java Web Start. This massively simplifies deployment of Java applications using OpenGL and OpenAL and I think is an exciting development. I hope you'll agree and will consider using JOAL in your course.

Please also take a look at the joal-demos source code which shows how to use the APIs, and post if you have more questions or comments.
Offline Ultraq

Junior Devvie

That's what she said

« Reply #2 - Posted 2006-12-21 20:08:39 »

As Ken pointed-out, Java lacks pointers like C/C++, so when you use the array method instead of the buffer one, you have to specify from where in the array you begin (whereas a Buffer object has a variable to where it begins).  So if you wanted to start from the beginning of the array, you just have 0 as the 3rd parameter.  And as for buffers, remember to rewind() them beforehand.

In essence, both alGenBuffers(..) methods are exactly the same, both as interfaces to the C function alGenBuffers(ALsizei n,ALuint *buffers):

IntBuffer buffer = IntBuffer.allocate(1);
al.alGenBuffers(1, buffer);
int bufferID = buffer.get();

is the same as

int[] buffer = new int[1];
al.alGenBuffers(1, buffer, 0);
int bufferID = buffer[0];

The JOGL API does the same thing where there are methods that can accept either a Buffer, or an array & offset.

Ultraq's Final MooCow
Bits and Pieces by Emanuel Rabina
Pages: [1]
  ignore  |  Print  

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

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

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

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

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

nelsongames (141 views)
2018-04-24 18:14:32

ivj94 (883 views)
2018-03-24 14:47:39

ivj94 (144 views)
2018-03-24 14:46:31

ivj94 (795 views)
2018-03-24 14:43:53

Solater (159 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 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!