public void getAttribute(Element ele, ByteBuffer values) { DataAttribut al = vb.layout.getAttribut(ele); assert al != null : "This Attribute doesn't exist in the VertexBuffer"; assert (values.remaining() >= ele.getVectorType().getByteSize()) : "not enough data in the buffer!"; int old = vb.buffer.position(); int oldl = vb.buffer.limit(); { int id = ind * al.stride + al.offset; vb.buffer.position(id * ele.getDataType().byteSize); vb.buffer.limit(vb.buffer.position() + ele.getVectorType().getByteSize()); values.put(vb.buffer); } vb.buffer.position(old); vb.buffer.limit(oldl); } }
public void setAttribute(Element ele, ByteBuffer values) { DataAttribut al = vb.layout.getAttribut(ele); assert al != null : "This Attribute doesn't exist in the VertexBuffer"; assert (values.remaining() >= ele.getVectorType().getByteSize()) : "not enough data in the buffer!"; int old = vb.buffer.position(); { int id = ind * al.stride + al.offset; vb.buffer.position(id); int oldLim = values.limit(); { int newLim = values.position() + ele.getVectorType().getByteSize(); if (newLim > oldLim) { throw new BufferOverflowException(); } values.limit(newLim); vb.buffer.put(values); } values.limit(oldLim); } vb.buffer.position(old); }
@AssistedInject @ParametersAreNonnullByDefault public StdAttributs(GraphicContext gcontext, @Assisted Shader shader, @Assisted VertexBO[] vbuffers, @Assisted @Nullable BufferObject indice) { assert shader.isInitialized() : "Shader is not initialized!"; this.indice = indice; configs = new BufferConfigs[vbuffers.length]; for (int i = 0; i < vbuffers.length; ++i) { DataLayout dl = vbuffers[i].layout; List<AttributConfig> cs = new LinkedList<>(); for (Element ele : dl.getElements()) { Optional<ShaderAttribute> sa = shader.getAttribut(ele); if (sa.isPresent()) { cs.add(new AttributConfig(sa.get(), dl.getAttribut(ele))); } } AttributConfig[] c = new AttributConfig[cs.size()]; cs.toArray(c); configs[i] = new BufferConfigs(gcontext, vbuffers[i].buffer, c); } }
public Number[] getAttribute(Element ele) { Number[] values = new Number[ele.getVectorType().getElementCount()]; DataAttribut al = vb.layout.getAttribut(ele); int id = ind * al.stride + al.offset; ele.getDataType().get(vb.buffer, id, values); return values; }
public void setAttribute(Element ele, Number... values) { DataAttribut al = vb.layout.getAttribut(ele); assert al != null : "This Attribute doesn't exist in the VertexBuffer"; assert (values.length <= ele.getVectorType().getElementCount()) : "The Attribute demands " + ele.getVectorType().getElementCount() + " values not " + values.length + "!"; int id = ind * al.stride + al.offset; ele.getDataType().put(vb.buffer, id, values); }