@Override public boolean hasData() { return data != null && data.getBuffer() != null; }
@Override public ShortBufferData makeCopy() { final ShortBufferData copy = new ShortBufferData(); copy._buffer = BufferUtils.clone(_buffer); copy._vboAccessMode = _vboAccessMode; return copy; } }
@Override public void put(final int[] array, final int offset, final int length) { for (int i = offset, max = offset + length; i < max; i++) { put(array[i]); } }
@Override public IntBuffer asIntBuffer() { final ShortBuffer source = getBuffer().duplicate(); source.rewind(); final IntBuffer buff = BufferUtils.createIntBufferOnHeap(source.limit()); for (int i = 0, max = source.limit(); i < max; i++) { buff.put(source.get() & 0xFFFF); } buff.flip(); return buff; }
@Override public void put(final int[] array) { for (int i = 0; i < array.length; i++) { put(array[i]); } }
@Override public ShortBufferData makeCopy() { final ShortBufferData copy = new ShortBufferData(); copy._buffer = BufferUtils.clone(_buffer); copy._vboAccessMode = _vboAccessMode; return copy; } }
@Override public IntBuffer asIntBuffer() { final ShortBuffer source = getBuffer().duplicate(); source.rewind(); final IntBuffer buff = BufferUtils.createIntBufferOnHeap(source.limit()); for (int i = 0, max = source.limit(); i < max; i++) { buff.put(source.get() & 0xFFFF); } buff.flip(); return buff; }
@Override public void put(final int[] array, final int offset, final int length) { for (int i = offset, max = offset + length; i < max; i++) { put(array[i]); } }
/** * Sets the index buffer. * * @param indices * the new index buffer */ public void setIndexBuffer(final ShortBuffer indices) { if (indices == null) { _indexBuffer = null; } else { _indexBuffer = new ShortBufferData(indices); } updatePrimitiveCounts(); }
private static void updateShaderAttribute(final ShaderVariablePointerShort variable, final ShaderObjectsStateRecord record, final boolean useVBO) { enableVertexAttribute(variable, record); if (useVBO) { final RenderContext context = ContextManager.getCurrentContext(); final int vboId = LwjglRenderer.setupVBO(variable.data, context); LwjglRendererUtil.setBoundVBO(context.getRendererRecord(), vboId); ARBVertexProgram .glVertexAttribPointerARB(variable.variableID, variable.size, variable.unsigned ? GL11.GL_UNSIGNED_SHORT : GL11.GL_SHORT, variable.normalized, variable.stride, 0); } else { variable.data.getBuffer().rewind(); ARBVertexProgram.glVertexAttribPointerARB(variable.variableID, variable.size, variable.unsigned, variable.normalized, variable.stride, variable.data.getBuffer()); } } }
@Override public void put(final int[] array) { for (int i = 0; i < array.length; i++) { put(array[i]); } }
/** * Sets the index buffer. * * @param indices * the new index buffer */ public void setIndexBuffer(final ShortBuffer indices) { if (indices == null) { _indexBuffer = null; } else { _indexBuffer = new ShortBufferData(indices); } updatePrimitiveCounts(); refreshInterleaved(); }
private static void updateShaderAttribute(final ShaderVariablePointerShort variable, final ShaderObjectsStateRecord record, final boolean useVBO) { enableVertexAttribute(variable, record); if (useVBO) { final RenderContext context = ContextManager.getCurrentContext(); final int vboId = JoglRenderer.setupVBO(variable.data, context); JoglRendererUtil.setBoundVBO(context.getRendererRecord(), vboId); GLContext .getCurrentGL() .getGL2ES2() .glVertexAttribPointer(variable.variableID, variable.size, variable.unsigned ? GL.GL_UNSIGNED_SHORT : GL.GL_SHORT, variable.normalized, variable.stride, 0); } else { variable.data.getBuffer().rewind(); GLContext .getCurrentGL() .getGL2ES2() .glVertexAttribPointer(variable.variableID, variable.size, variable.unsigned ? GL.GL_UNSIGNED_SHORT : GL.GL_SHORT, variable.normalized, variable.stride, variable.data.getBuffer()); } } }
@Override public void put(final IndexBufferData<?> buf) { if (buf instanceof ShortBufferData) { _buffer.put((ShortBuffer) buf.getBuffer()); } else { while (buf.getBuffer().hasRemaining()) { put(buf.get()); } } }
@Override public void read(final InputCapsule capsule) throws IOException { super.read(capsule); size = capsule.readInt("size", 0); stride = capsule.readInt("stride", 0); normalized = capsule.readBoolean("normalized", false); unsigned = capsule.readBoolean("unsigned", false); data = (ShortBufferData) capsule.readSavable("data", null); // XXX: transitional if (data == null) { final ShortBuffer buff = capsule.readShortBuffer("data", null); if (buff != null) { data = new ShortBufferData(buff); } } } }
@Override public void put(final IndexBufferData<?> buf) { if (buf instanceof ShortBufferData) { _buffer.put((ShortBuffer) buf.getBuffer()); } else { while (buf.getBuffer().hasRemaining()) { put(buf.get()); } } }