public InstancedMesh(float[] positions, float[] textCoords, float[] normals, int[] indices, int numInstances) { super(positions, textCoords, normals, indices, createEmptyIntArray(MAX_WEIGHTS * positions.length / 3, 0), createEmptyFloatArray(MAX_WEIGHTS * positions.length / 3, 0)); this.numInstances = numInstances; glBindVertexArray(vaoId); // Model View Matrix modelViewVBO = glGenBuffers(); vboIdList.add(modelViewVBO); this.modelViewBuffer = MemoryUtil.memAllocFloat(numInstances * MATRIX_SIZE_FLOATS); glBindBuffer(GL_ARRAY_BUFFER, modelViewVBO); int start = 5; for (int i = 0; i < 4; i++) { glVertexAttribPointer(start, 4, GL_FLOAT, false, MATRIX_SIZE_BYTES, i * VECTOR4F_SIZE_BYTES); glVertexAttribDivisor(start, 1); start++; } // Light view matrix modelLightViewVBO = glGenBuffers(); vboIdList.add(modelLightViewVBO); this.modelLightViewBuffer = MemoryUtil.memAllocFloat(numInstances * MATRIX_SIZE_FLOATS); glBindBuffer(GL_ARRAY_BUFFER, modelLightViewVBO); for (int i = 0; i < 4; i++) { glVertexAttribPointer(start, 4, GL_FLOAT, false, MATRIX_SIZE_BYTES, i * VECTOR4F_SIZE_BYTES); glVertexAttribDivisor(start, 1); start++; } glBindBuffer(GL_ARRAY_BUFFER, 0); glBindVertexArray(0); }
posBuffer = MemoryUtil.memAllocFloat(positions.length); posBuffer.put(positions).flip(); glBindBuffer(GL_ARRAY_BUFFER, vboId); textCoordsBuffer = MemoryUtil.memAllocFloat(textCoords.length); textCoordsBuffer.put(textCoords).flip(); glBindBuffer(GL_ARRAY_BUFFER, vboId);
posBuffer = MemoryUtil.memAllocFloat(positions.length); posBuffer.put(positions).flip(); glBindBuffer(GL_ARRAY_BUFFER, posVboId); colourBuffer = MemoryUtil.memAllocFloat(colours.length); colourBuffer.put(colours).flip(); glBindBuffer(GL_ARRAY_BUFFER, colourVboId);
posBuffer = MemoryUtil.memAllocFloat(positions.length); posBuffer.put(positions).flip(); glBindBuffer(GL_ARRAY_BUFFER, posVboId); colourBuffer = MemoryUtil.memAllocFloat(colours.length); colourBuffer.put(colours).flip(); glBindBuffer(GL_ARRAY_BUFFER, colourVboId);
posBuffer = MemoryUtil.memAllocFloat(positions.length); posBuffer.put(positions).flip(); glBindBuffer(GL_ARRAY_BUFFER, posVboId); colourBuffer = MemoryUtil.memAllocFloat(colours.length); colourBuffer.put(colours).flip(); glBindBuffer(GL_ARRAY_BUFFER, colourVboId);
posBuffer = MemoryUtil.memAllocFloat(positions.length); posBuffer.put(positions).flip(); glBindBuffer(GL_ARRAY_BUFFER, posVboId); colourBuffer = MemoryUtil.memAllocFloat(colours.length); colourBuffer.put(colours).flip(); glBindBuffer(GL_ARRAY_BUFFER, colourVboId);
posBuffer = MemoryUtil.memAllocFloat(positions.length); posBuffer.put(positions).flip(); glBindBuffer(GL_ARRAY_BUFFER, posVboId);
public InstancedMesh(float[] positions, float[] textCoords, float[] normals, int[] indices, int numInstances) { super(positions, textCoords, normals, indices, createEmptyIntArray(MAX_WEIGHTS * positions.length / 3, 0), createEmptyFloatArray(MAX_WEIGHTS * positions.length / 3, 0)); this.numInstances = numInstances; glBindVertexArray(vaoId); instanceDataVBO = glGenBuffers(); vboIdList.add(instanceDataVBO); instanceDataBuffer = MemoryUtil.memAllocFloat(numInstances * INSTANCE_SIZE_FLOATS); glBindBuffer(GL_ARRAY_BUFFER, instanceDataVBO); int start = 5; int strideStart = 0; // Model matrix for (int i = 0; i < 4; i++) { glVertexAttribPointer(start, 4, GL_FLOAT, false, INSTANCE_SIZE_BYTES, strideStart); glVertexAttribDivisor(start, 1); start++; strideStart += VECTOR4F_SIZE_BYTES; } // Texture offsets glVertexAttribPointer(start, 2, GL_FLOAT, false, INSTANCE_SIZE_BYTES, strideStart); glVertexAttribDivisor(start, 1); strideStart += FLOAT_SIZE_BYTES * 2; start++; // Selected or Scaling (for particles) glVertexAttribPointer(start, 1, GL_FLOAT, false, INSTANCE_SIZE_BYTES, strideStart); glVertexAttribDivisor(start, 1); start++; glBindBuffer(GL_ARRAY_BUFFER, 0); glBindVertexArray(0); }
public InstancedMesh(float[] positions, float[] textCoords, float[] normals, int[] indices, int numInstances) { super(positions, textCoords, normals, indices, createEmptyIntArray(MAX_WEIGHTS * positions.length / 3, 0), createEmptyFloatArray(MAX_WEIGHTS * positions.length / 3, 0)); this.numInstances = numInstances; glBindVertexArray(vaoId); // Model View Matrix instanceDataVBO = glGenBuffers(); vboIdList.add(instanceDataVBO); instanceDataBuffer = MemoryUtil.memAllocFloat(numInstances * INSTANCE_SIZE_FLOATS); glBindBuffer(GL_ARRAY_BUFFER, instanceDataVBO); int start = 5; int strideStart = 0; for (int i = 0; i < 4; i++) { glVertexAttribPointer(start, 4, GL_FLOAT, false, INSTANCE_SIZE_BYTES, strideStart); glVertexAttribDivisor(start, 1); start++; strideStart += VECTOR4F_SIZE_BYTES; } // Light view matrix for (int i = 0; i < 4; i++) { glVertexAttribPointer(start, 4, GL_FLOAT, false, INSTANCE_SIZE_BYTES, strideStart); glVertexAttribDivisor(start, 1); start++; strideStart += VECTOR4F_SIZE_BYTES; } // Texture offsets glVertexAttribPointer(start, 2, GL_FLOAT, false, INSTANCE_SIZE_BYTES, strideStart); glVertexAttribDivisor(start, 1); glBindBuffer(GL_ARRAY_BUFFER, 0); glBindVertexArray(0); }
public InstancedMesh(float[] positions, float[] textCoords, float[] normals, int[] indices, int numInstances) { super(positions, textCoords, normals, indices, createEmptyIntArray(MAX_WEIGHTS * positions.length / 3, 0), createEmptyFloatArray(MAX_WEIGHTS * positions.length / 3, 0)); this.numInstances = numInstances; glBindVertexArray(vaoId); instanceDataVBO = glGenBuffers(); vboIdList.add(instanceDataVBO); instanceDataBuffer = MemoryUtil.memAllocFloat(numInstances * INSTANCE_SIZE_FLOATS); glBindBuffer(GL_ARRAY_BUFFER, instanceDataVBO); int start = 5; int strideStart = 0; // Model matrix for (int i = 0; i < 4; i++) { glVertexAttribPointer(start, 4, GL_FLOAT, false, INSTANCE_SIZE_BYTES, strideStart); glVertexAttribDivisor(start, 1); start++; strideStart += VECTOR4F_SIZE_BYTES; } // Texture offsets glVertexAttribPointer(start, 2, GL_FLOAT, false, INSTANCE_SIZE_BYTES, strideStart); glVertexAttribDivisor(start, 1); strideStart += FLOAT_SIZE_BYTES * 2; start++; // Selected or Scaling (for particles) glVertexAttribPointer(start, 1, GL_FLOAT, false, INSTANCE_SIZE_BYTES, strideStart); glVertexAttribDivisor(start, 1); start++; glBindBuffer(GL_ARRAY_BUFFER, 0); glBindVertexArray(0); }
public InstancedMesh(float[] positions, float[] textCoords, float[] normals, int[] indices, int numInstances) { super(positions, textCoords, normals, indices, createEmptyIntArray(MAX_WEIGHTS * positions.length / 3, 0), createEmptyFloatArray(MAX_WEIGHTS * positions.length / 3, 0)); this.numInstances = numInstances; glBindVertexArray(vaoId); instanceDataVBO = glGenBuffers(); vboIdList.add(instanceDataVBO); instanceDataBuffer = MemoryUtil.memAllocFloat(numInstances * INSTANCE_SIZE_FLOATS); glBindBuffer(GL_ARRAY_BUFFER, instanceDataVBO); int start = 5; int strideStart = 0; // Model matrix for (int i = 0; i < 4; i++) { glVertexAttribPointer(start, 4, GL_FLOAT, false, INSTANCE_SIZE_BYTES, strideStart); glVertexAttribDivisor(start, 1); start++; strideStart += VECTOR4F_SIZE_BYTES; } // Texture offsets glVertexAttribPointer(start, 2, GL_FLOAT, false, INSTANCE_SIZE_BYTES, strideStart); glVertexAttribDivisor(start, 1); strideStart += FLOAT_SIZE_BYTES * 2; start++; // Selected or Scaling (for particles) glVertexAttribPointer(start, 1, GL_FLOAT, false, INSTANCE_SIZE_BYTES, strideStart); glVertexAttribDivisor(start, 1); start++; glBindBuffer(GL_ARRAY_BUFFER, 0); glBindVertexArray(0); }
public InstancedMesh(float[] positions, float[] textCoords, float[] normals, int[] indices, int numInstances) { super(positions, textCoords, normals, indices, createEmptyIntArray(MAX_WEIGHTS * positions.length / 3, 0), createEmptyFloatArray(MAX_WEIGHTS * positions.length / 3, 0)); this.numInstances = numInstances; glBindVertexArray(vaoId); instanceDataVBO = glGenBuffers(); vboIdList.add(instanceDataVBO); instanceDataBuffer = MemoryUtil.memAllocFloat(numInstances * INSTANCE_SIZE_FLOATS); glBindBuffer(GL_ARRAY_BUFFER, instanceDataVBO); int start = 5; int strideStart = 0; // Model matrix for (int i = 0; i < 4; i++) { glVertexAttribPointer(start, 4, GL_FLOAT, false, INSTANCE_SIZE_BYTES, strideStart); glVertexAttribDivisor(start, 1); start++; strideStart += VECTOR4F_SIZE_BYTES; } // Texture offsets glVertexAttribPointer(start, 2, GL_FLOAT, false, INSTANCE_SIZE_BYTES, strideStart); glVertexAttribDivisor(start, 1); strideStart += FLOAT_SIZE_BYTES * 2; start++; // Selected or Scaling (for particles) glVertexAttribPointer(start, 1, GL_FLOAT, false, INSTANCE_SIZE_BYTES, strideStart); glVertexAttribDivisor(start, 1); start++; glBindBuffer(GL_ARRAY_BUFFER, 0); glBindVertexArray(0); }
public InstancedMesh(float[] positions, float[] textCoords, float[] normals, int[] indices, int numInstances) { super(positions, textCoords, normals, indices, createEmptyIntArray(MAX_WEIGHTS * positions.length / 3, 0), createEmptyFloatArray(MAX_WEIGHTS * positions.length / 3, 0)); this.numInstances = numInstances; glBindVertexArray(vaoId); // Model View Matrix instanceDataVBO = glGenBuffers(); vboIdList.add(instanceDataVBO); instanceDataBuffer = MemoryUtil.memAllocFloat(numInstances * INSTANCE_SIZE_FLOATS); glBindBuffer(GL_ARRAY_BUFFER, instanceDataVBO); int start = 5; int strideStart = 0; for (int i = 0; i < 4; i++) { glVertexAttribPointer(start, 4, GL_FLOAT, false, INSTANCE_SIZE_BYTES, strideStart); glVertexAttribDivisor(start, 1); start++; strideStart += VECTOR4F_SIZE_BYTES; } // Light view matrix for (int i = 0; i < 4; i++) { glVertexAttribPointer(start, 4, GL_FLOAT, false, INSTANCE_SIZE_BYTES, strideStart); glVertexAttribDivisor(start, 1); start++; strideStart += VECTOR4F_SIZE_BYTES; } // Texture offsets glVertexAttribPointer(start, 2, GL_FLOAT, false, INSTANCE_SIZE_BYTES, strideStart); glVertexAttribDivisor(start, 1); glBindBuffer(GL_ARRAY_BUFFER, 0); glBindVertexArray(0); }
public InstancedMesh(float[] positions, float[] textCoords, float[] normals, int[] indices, int numInstances) { super(positions, textCoords, normals, indices, createEmptyIntArray(MAX_WEIGHTS * positions.length / 3, 0), createEmptyFloatArray(MAX_WEIGHTS * positions.length / 3, 0)); this.numInstances = numInstances; glBindVertexArray(vaoId); // Model View Matrix instanceDataVBO = glGenBuffers(); vboIdList.add(instanceDataVBO); instanceDataBuffer = MemoryUtil.memAllocFloat(numInstances * INSTANCE_SIZE_FLOATS); glBindBuffer(GL_ARRAY_BUFFER, instanceDataVBO); int start = 5; int strideStart = 0; for (int i = 0; i < 4; i++) { glVertexAttribPointer(start, 4, GL_FLOAT, false, INSTANCE_SIZE_BYTES, strideStart); glVertexAttribDivisor(start, 1); start++; strideStart += VECTOR4F_SIZE_BYTES; } // Light view matrix for (int i = 0; i < 4; i++) { glVertexAttribPointer(start, 4, GL_FLOAT, false, INSTANCE_SIZE_BYTES, strideStart); glVertexAttribDivisor(start, 1); start++; strideStart += VECTOR4F_SIZE_BYTES; } // Texture offsets glVertexAttribPointer(start, 2, GL_FLOAT, false, INSTANCE_SIZE_BYTES, strideStart); glVertexAttribDivisor(start, 1); glBindBuffer(GL_ARRAY_BUFFER, 0); glBindVertexArray(0); }
instanceDataBuffer = MemoryUtil.memAllocFloat(numInstances * INSTANCE_SIZE_FLOATS); glBindBuffer(GL_ARRAY_BUFFER, instanceDataVBO); int start = 5;
instanceDataBuffer = MemoryUtil.memAllocFloat(numInstances * INSTANCE_SIZE_FLOATS); glBindBuffer(GL_ARRAY_BUFFER, instanceDataVBO); int start = 5;
instanceDataBuffer = MemoryUtil.memAllocFloat(numInstances * INSTANCE_SIZE_FLOATS); glBindBuffer(GL_ARRAY_BUFFER, instanceDataVBO); int start = 5;
instanceDataBuffer = MemoryUtil.memAllocFloat(numInstances * INSTANCE_SIZE_FLOATS); glBindBuffer(GL_ARRAY_BUFFER, instanceDataVBO); int start = 5;
instanceDataBuffer = MemoryUtil.memAllocFloat(numInstances * INSTANCE_SIZE_FLOATS); glBindBuffer(GL_ARRAY_BUFFER, instanceDataVBO); int start = 5;
verticesBuffer = MemoryUtil.memAllocFloat(vertices.length); verticesBuffer.put(vertices).flip();