LWJGL
May 22, 2012, 14:32:47 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: LWJGL 2.8.3 released!
 
   Home   Help Search Login Register  



Pages: [1] 2
  Print  
Author Topic: String and primitive parameters/return values - Feedback request  (Read 3347 times)
spasi
Nerdus Imperius
*****
Posts: 643



WWW
« on: March 12, 2010, 16:45:44 »

Support for String arguments and return values has been added to LWJGL:

- Existing methods have been overloaded, your current code will run unmodified.
- Return values are Strings, input values are CharSequences, so you can also use String, StringBuilder or any other implementation.
- Support for CharSequence[] arguments is also included.
- The implementation uses ThreadLocal buffers internally, so it's multi-context ready.

Some examples:

glShaderSource(int shader, ByteBuffer string); // Original
glShaderSource(int shader, CharSequence string); // New - single source
glShaderSource(int shader, CharSequence[] strings); // New - multiple sources

void glGetShaderInfoLog(int shader, IntBuffer length, ByteBuffer infoLog); // Original
String glGetShaderInfoLog(int shader, int maxLength); // New

----------------------

EDIT: I have extended this API feature to primitive types. Functions with Buffer arguments that often read or write a single value in those Buffers have been overloaded to accept or return that single primitive value. Examples:

int texID = glGenTextures();
glDeleteTextures(texID);

int maxTexUnits = glGetInteger(GL_MAX_TEXTURE_UNITS);
float aniso = glGetFloat(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT);

if ( glGetShader(shaderID, GL_COMPILE_STATUS) == GL11.GL_FALSE ) throw new RuntimeException();

----------------------

EDIT2: Added a javadoc comment to all the new methods that says which GL call is being overloaded.

----------------------

I would very much appreciate it if you could download a nightly build and try it out in your projects. Let me know if something doesn't work or if I have missed any functions that could be overloaded.
Logged

princec
Nerdus Imperius
*****
Posts: 1782



WWW
« Reply #1 on: March 14, 2010, 06:28:18 »

Fancy adding conveniences for glGetInteger etc. too?

Cas Smiley
Logged

spasi
Nerdus Imperius
*****
Posts: 643



WWW
« Reply #2 on: March 14, 2010, 08:15:53 »

It's what I'm doing the past two days. Wink
Logged

spasi
Nerdus Imperius
*****
Posts: 643



WWW
« Reply #3 on: March 14, 2010, 17:01:11 »

Support for primitive parameters and return values has been added, I've updated the first post with examples.
Logged

Rene
Regular nerd
**
Posts: 78


« Reply #4 on: March 15, 2010, 06:49:01 »

Wow, that's all looking great. I'll check the nightly when I have a moment
Logged

When I am king, they shall not have bread and shelter only, but also teachings out of books, for a full belly is little worth where the mind is starved - Mark Twain
Rene
Regular nerd
**
Posts: 78


« Reply #5 on: March 16, 2010, 03:41:27 »

Wow, that's all looking great. I'll check the nightly when I have a moment

Right, I just checked some of the new functions, and it all works like a charm. This cleans up my code quite a bit! Thanks!
Logged

When I am king, they shall not have bread and shelter only, but also teachings out of books, for a full belly is little worth where the mind is starved - Mark Twain
Fool Running
Nerdus Imperius
*****
Posts: 648


« Reply #6 on: March 16, 2010, 05:50:20 »

I agree, this looks like a welcome change. Smiley
Logged

Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option Grin
ryanm
Newbie
*
Posts: 44


« Reply #7 on: March 16, 2010, 06:35:35 »

Lovely stuff. Any chance of this rolling across to the OpenAL side too?
Logged
spasi
Nerdus Imperius
*****
Posts: 643



WWW
« Reply #8 on: March 16, 2010, 11:03:40 »

I've added some AL functions, should be available on the next nightly. They are only 6 though, 4 Gen/Delete ones and the two alSource(Un)QueueBuffers. The rest of the API already has alternate function versions for single values, unless I missed something.
Logged

ryanm
Newbie
*
Posts: 44


« Reply #9 on: March 17, 2010, 06:29:52 »

Even lovelier stuff! GLUtil.scratch buffer begone!
Logged
delt0r
Newbie
*
Posts: 25


« Reply #10 on: March 18, 2010, 02:15:56 »

Great change. Hope this doesn't complicated the auto JNI stuff for you devs however. We don't want to give you too much work and put you all off the project.
Logged
EvilOne
Newbie
*
Posts: 22


« Reply #11 on: March 23, 2010, 00:59:27 »

This is damn great.

Would be nice to have some additional stuff for getActiveAttrib/Uniform to get rid of those pesky IntBuffers... glGetActiveAttribType and glGetActiveAttribSize maybe?

Cheers,
E1.
Logged

If you got a shiny new hammer, every problem looks like a nail!
spasi
Nerdus Imperius
*****
Posts: 643



WWW
« Reply #12 on: March 23, 2010, 05:44:42 »

Would be nice to have some additional stuff for getActiveAttrib/Uniform to get rid of those pesky IntBuffers... glGetActiveAttribType and glGetActiveAttribSize maybe?

Done, added glGetActiveUniformSize, glGetActiveUniformType, glGetActiveAttribSize, glGetActiveAttribType. Could you please test it when the next build is up? I'm not sure how it's going to behave with a 0 maxlength passed to the native call. Btw, for uniforms a better choice would be glGetActiveUniforms(int program, int uniformIndex, int pname) in GL31 and ARB_uniform_buffer_object.

I've also added a javadoc comment to all the new methods, so that it's easy to tell which GL method it overloads. It can be quite messy without it in some cases.
Logged

elFarto
Newbie
*
Posts: 6


« Reply #13 on: March 26, 2010, 12:54:01 »

Hi

Thanks for the new methods, they clean up the code nicely. Any chance of getting glGetActiveUniformBlock added aswell?

Thanks & Regards
elFarto
Logged
spasi
Nerdus Imperius
*****
Posts: 643



WWW
« Reply #14 on: March 26, 2010, 13:25:15 »

Thanks, glGetActiveUniformBlock was ok in ARB_uniform_buffer_object but missed it in GL31. Gonna add it when I commit the APPLE extensions.
Logged

Pages: [1] 2
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines
SMFAds for Free Forums
Valid XHTML 1.0! Valid CSS!