Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (524)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (592)
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 2295 times)
0 Members and 1 Guest are viewing this topic.
Offline clevengr

Senior Newbie




Java games rock!


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

Hi,
   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 (
http://developer.creative.com/articles/article.asp?cat=1&sbcat=31&top=38&aid=51&file=OpenAL_Programmers_Guide.pdf) updated December 2006 specifies (page 15)  just one form of alGenBuffers(): 

1  
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(): 

1  
alGenBuffers(int n, IntBuffer buffers) 

and
1  
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:

1  
2  
          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?

Thx.


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

toopeicgaming1999 (1 views)
2014-11-26 15:22:04

toopeicgaming1999 (4 views)
2014-11-26 15:20:36

toopeicgaming1999 (1 views)
2014-11-26 15:20:08

SHC (24 views)
2014-11-25 12:00:59

SHC (24 views)
2014-11-25 11:53:45

Norakomi (24 views)
2014-11-25 11:26:43

Gibbo3771 (22 views)
2014-11-24 19:59:16

trollwarrior1 (36 views)
2014-11-22 12:13:56

xFryIx (74 views)
2014-11-13 12:34:49

digdugdiggy (52 views)
2014-11-12 21:11:50
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
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!