[Material] Shiniess using 4 float values ?

Hello,

i wonder about using the GL_SHININESS property. The “OpenGL Programming Guide” brings examples using only ONE float value! Using a FloatBuffer in LWJGL produce a IllegalArgumentException if only one float wrapped, 4 floats seems to work.

What i’am doing wrong or haven’t understand ? ::slight_smile:

Many thanks,
-Jens

That’s a little confusing, isn’t it? ;D

The trick is that in order to guarantee that your call won’t overwrite other memory, LWJGL needs to make sure you’ve got enough space in your buffer for the data you’re asking for. Instead of using a big-ass ugly switch statement to work out what GL_SHININESS returns, LWJGL instead knows that up to 4 floats can be returned from that function - depending on the parameter you pass - so it requires that much space in the buffer you pass it.

Using a 4-element versus a 1-element buffer has a negligable effect on memory usage and allocation time, but it avoids the almost-impossible-to-maintain parameter checking code.

So if you ever get a complaint like that, just pass the method a bigger buffer and things should work fine.