Skip to content Skip to sidebar Skip to footer

Illegalargumentexception From Gluunproject

I get this error message 08-30 19:20:17.774: ERROR/AndroidRuntime(4681): FATAL EXCEPTION: GLThread 9 08-30 19:20:17.774: ERROR/AndroidRuntime(4681): java.lang.IllegalArgumentExcept

Solution 1:

I've briefly looked at the source code for this function, and it appears to expect your newcoords vector to have size 4 instead of 3. They are homogeneous coordinates, so you will also have to divide by w to get your actual coordinates.

Note that there's another error in your code as well, you're indexing newcoords out of bounds after the call to gluUnProject. The first element is newcoords[0], not newcoords[1].

I think if you use something like this, it would work better (I didn't test this though):

float[] newcoords = newfloat[4]; // Note size 4!!
GLU.gluUnProject(...);
float x = newcoords[0] / newcoords[3];
float y = newcoords[1] / newcoords[3];
float z = newcoords[2] / newcoords[3];

Post a Comment for "Illegalargumentexception From Gluunproject"