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.