Ok, I figured it out myself through trial and error! Still got a lot of tidying up to do though in my code, I’ve pasted it below in case it helps anyone else. For some reason the shadow map has absolutely killed my framerate. I was getting >300fps with one light source and 350,000 polygons, now with shadows it’s dropped to 70fps 1/5th!!
Is this normal??? Anyway the code snippet is below…
{ int j=0,k=0;
for(int i = 0; i < 16; i++) {
bm.set(j,k,biasMatrix[i]);
lpm.set(j,k,lightProjectionMatrix[i]);
lvm.set(j,k,lightViewMatrix[i]);
j++; if(j>3) j=0;
if(j==0) k++;
} }
tm = bm.mul(lpm.mul(lvm));
//tm.getColumnMajorData(textureMatrix);
{ int j=0,k=0;
for(int i = 0; i < 16; i++) {
textureMatrix[i] = tm.get(k,j);
j++; if(j>3) j=0;
if(j==0) k++;
} }
//Set up texture coordinate generation.
gl.glTexGeni(GL.GL_S, GL.GL_TEXTURE_GEN_MODE, GL.GL_EYE_LINEAR);
gl.glTexGenfv(GL.GL_S, GL.GL_EYE_PLANE, textureMatrix, 0);
gl.glEnable(GL.GL_TEXTURE_GEN_S);
gl.glTexGeni(GL.GL_T, GL.GL_TEXTURE_GEN_MODE, GL.GL_EYE_LINEAR);
gl.glTexGenfv(GL.GL_T, GL.GL_EYE_PLANE, textureMatrix, 4);
gl.glEnable(GL.GL_TEXTURE_GEN_T);
gl.glTexGeni(GL.GL_R, GL.GL_TEXTURE_GEN_MODE, GL.GL_EYE_LINEAR);
gl.glTexGenfv(GL.GL_R, GL.GL_EYE_PLANE, textureMatrix, 8);
gl.glEnable(GL.GL_TEXTURE_GEN_R);
gl.glTexGeni(GL.GL_Q, GL.GL_TEXTURE_GEN_MODE, GL.GL_EYE_LINEAR);
gl.glTexGenfv(GL.GL_Q, GL.GL_EYE_PLANE, textureMatrix, 12);
gl.glEnable(GL.GL_TEXTURE_GEN_Q);