LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: Itun on April 06, 2011, 17:23:54

Title: glLight is glLightfv, isn t it?
Post by: Itun on April 06, 2011, 17:23:54
If it is, why have you change the name?
Title: Re: glLight is glLightfv, isn t it?
Post by: WiESi on April 19, 2011, 12:52:08
See here: http://www.lwjgl.org/wiki/index.php?title=About_LWJGL#Speed
Title: Re: glLight is glLightfv, isn t it?
Post by: spasi on April 19, 2011, 14:27:49
Quote from: Itun on April 06, 2011, 17:23:54If it is, why have you change the name?

We have done this for all *v methods that work with pointers at the C level. The C function that will be called depends on the NIO buffer argument's type of the corresponding Java method. For example:

glLight(int light, int pname, FloatBuffer params) will call glLightfv
glLight(int light, int pname, IntBuffer params) will call glLightiv

As for the why, I guess because it looks better, it's less typing and the {fi}v postfix doesn't really offer anything. Method overloading is nice.

We could have done the same for scalar arguments (e.g. glLightf(int light, int pname, float param)), but that would be error-prone because of the implicit type conversions that Java allows.