public void updateModelMatrix(GL2GL3 gl, Shader shader, PMVMatrix model) { model.update(); // if(gl.glGetUniformLocation(shader.getID(), "model") == -1) // System.out.println("uniform model error"); gl.glUniformMatrix4fv( gl.glGetUniformLocation(shader.getID(), "model"), 1, false, model.glGetMatrixf(GL2.GL_MODELVIEW)); }
public void updatelights( GL2GL3 gl, int uniformlightsview, int uniformlightsproj, int uniformlightscolor, int uniformlightsattr, int uniformlightcount) { FloatBuffer lightspos = FloatBuffer.allocate(16 * realLightcount); FloatBuffer lightsproj = FloatBuffer.allocate(16 * realLightcount); FloatBuffer lightscolor = FloatBuffer.allocate(4 * realLightcount); IntBuffer lightsattr = IntBuffer.allocate(4 * realLightcount); for (int i = 0; i < realLightcount; i++) { FloatBuffer tmp = lights.get(i).getMatrixf(GL2.GL_MODELVIEW); // putするときにFloatBufferの位置が動いていけないのでmark()とreset()を行う。 tmp.mark(); lightspos.put(tmp); tmp.reset(); tmp = lights.get(i).getMatrixf(GL2.GL_PROJECTION); tmp.mark(); lightsproj.put(tmp); tmp.reset(); lightscolor.put(lights.get(i).color()); lightscolor.put((float) lights.get(i).intensity); lightsattr.put(lights.get(i).attr()); } lightspos.rewind(); lightsproj.rewind(); lightscolor.rewind(); lightsattr.rewind(); gl.glUniformMatrix4fv(uniformlightsview, realLightcount, false, lightspos); gl.glUniformMatrix4fv(uniformlightsproj, realLightcount, false, lightsproj); gl.glUniform2i(uniformlightcount, realLightcount, virtualLightcount); gl.glUniform4fv(uniformlightscolor, realLightcount, lightscolor); gl.glUniform4iv(uniformlightsattr, realLightcount, lightsattr); }
public void updatePVMatrixtess(GL2GL3 gl) { shadertess.use(gl); gl.glUniformMatrix4fv(uniformviewtess, 1, false, pvmat.glGetMatrixf(GL2.GL_MODELVIEW)); gl.glUniformMatrix4fv(uniformprojtess, 1, false, pvmat.glGetMatrixf(GL2.GL_PROJECTION)); Shader.unuse(gl); }