Esempio n. 1
0
  // 6231529
  private static void callReset(FloatBuffer b) {
    b.position(0);
    b.mark();

    b.duplicate().reset();
    b.asReadOnlyBuffer().reset();
  }
Esempio n. 2
0
  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);
  }