private static void setPosition(final int index, final LightStateRecord record, final float positionX, final float positionY, final float positionZ, final float positionW, final LightRecord lr) { // From OpenGL Docs: // The light position is transformed by the contents of the current top // of the ModelView matrix stack when you specify the light position // with a call to glLightfv(GL_LIGHT_POSITION,...). If you later change // the ModelView matrix, such as when the view changes for the next // frame, the light position isn't automatically retransformed by the // new contents of the ModelView matrix. If you want to update the // light's position, you must again specify the light position with a // call to glLightfv(GL_LIGHT_POSITION,...). // XXX: This is a hack until we get a better lighting model up final ReadOnlyMatrix4 modelViewMatrix = Camera.getCurrentCamera().getModelViewMatrix(); if (!record.isValid() || lr.position.getXf() != positionX || lr.position.getYf() != positionY || lr.position.getZf() != positionZ || lr.position.getWf() != positionW || !lr.modelViewMatrix.equals(modelViewMatrix)) { record.lightBuffer.clear(); record.lightBuffer.put(positionX); record.lightBuffer.put(positionY); record.lightBuffer.put(positionZ); record.lightBuffer.put(positionW); record.lightBuffer.flip(); GL11.glLight(GL11.GL_LIGHT0 + index, GL11.GL_POSITION, record.lightBuffer); lr.position.set(positionX, positionY, positionZ, positionW); if (!Camera.getCurrentCamera().isFrameDirty()) { lr.modelViewMatrix.set(modelViewMatrix); } } }
private static void setPosition(final int index, final LightStateRecord record, final float positionX, final float positionY, final float positionZ, final float positionW, final LightRecord lr) { final GL gl = GLContext.getCurrentGL(); // From OpenGL Docs: // The light position is transformed by the contents of the current top // of the ModelView matrix stack when you specify the light position // with a call to glLightfv(GL_LIGHT_POSITION,...). If you later change // the ModelView matrix, such as when the view changes for the next // frame, the light position isn't automatically retransformed by the // new contents of the ModelView matrix. If you want to update the // light's position, you must again specify the light position with a // call to glLightfv(GL_LIGHT_POSITION,...). // XXX: This is a hack until we get a better lighting model up final ReadOnlyMatrix4 modelViewMatrix = Camera.getCurrentCamera().getModelViewMatrix(); if (!record.isValid() || lr.position.getXf() != positionX || lr.position.getYf() != positionY || lr.position.getZf() != positionZ || lr.position.getWf() != positionW || !lr.modelViewMatrix.equals(modelViewMatrix)) { record.lightBuffer.clear(); record.lightBuffer.put(positionX); record.lightBuffer.put(positionY); record.lightBuffer.put(positionZ); record.lightBuffer.put(positionW); record.lightBuffer.flip(); gl.getGL2().glLightfv(GLLightingFunc.GL_LIGHT0 + index, GLLightingFunc.GL_POSITION, record.lightBuffer); lr.position.set(positionX, positionY, positionZ, positionW); if (!Camera.getCurrentCamera().isFrameDirty()) { lr.modelViewMatrix.set(modelViewMatrix); } } }
assertFalse(mat4.equals(null)); assertFalse(mat4.strictEquals(null)); assertFalse(mat4.equals(new Vector2())); assertFalse(mat4.strictEquals(new Vector2())); assertFalse(mat4.equals(comp)); assertFalse(mat4.strictEquals(comp)); for (int i = 0; i < 15; i++) { comp.setValue(i / 4, i % 4, i); assertFalse(mat4.equals(comp)); assertFalse(mat4.strictEquals(comp));