public Cube() { ByteBuffer byteBuf = ByteBuffer.AllocateDirect(vertices.Length * 4); byteBuf.Order(ByteOrder.NativeOrder()); mVertexBuffer = byteBuf.AsFloatBuffer(); mVertexBuffer.Put(vertices); mVertexBuffer.Position(0); byteBuf = ByteBuffer.AllocateDirect(colors.Length * 4); byteBuf.Order(ByteOrder.NativeOrder()); mColorBuffer = byteBuf.AsFloatBuffer(); mColorBuffer.Put(colors); mColorBuffer.Position(0); mIndexBuffer = ByteBuffer.AllocateDirect(indices.Length); mIndexBuffer.Put(indices); mIndexBuffer.Position(0); }
private void copyPALtoBGRA(ByteBuffer buffer, byte[] curLine) { if (paletteA != null) { for (int i = 1, n = curLine.Length; i < n; i += 1) { int idx = curLine[i] & 255; byte r = palette[idx * 3 + 0]; byte g = palette[idx * 3 + 1]; byte b = palette[idx * 3 + 2]; byte a = paletteA[idx]; buffer.Put(b).Put(g).Put(r).Put(a); } } else { for (int i = 1, n = curLine.Length; i < n; i += 1) { int idx = curLine[i] & 255; byte r = palette[idx * 3 + 0]; byte g = palette[idx * 3 + 1]; byte b = palette[idx * 3 + 2]; byte a = 0xFF; buffer.Put(b).Put(g).Put(r).Put(a); } } }
private void copyRGBAtoRGB(ByteBuffer buffer, byte[] curLine) { for (int i = 1, n = curLine.Length; i < n; i += 4) { buffer.Put(curLine[i]).Put(curLine[i + 1]).Put(curLine[i + 2]); } }
private void copyRGBtoBGRA(ByteBuffer buffer, byte[] curLine) { if (transPixel != null) { byte tr = transPixel[1]; byte tg = transPixel[3]; byte tb = transPixel[5]; for (int i = 1, n = curLine.Length; i < n; i += 3) { byte r = curLine[i]; byte g = curLine[i + 1]; byte b = curLine[i + 2]; byte a = (byte)0xFF; if (r == tr && g == tg && b == tb) { a = 0; } buffer.Put(b).Put(g).Put(r).Put(a); } } else { for (int i = 1, n = curLine.Length; i < n; i += 3) { buffer.Put(curLine[i + 2]).Put(curLine[i + 1]).Put(curLine[i]).Put((byte)0xFF); } } }
private void copy(ByteBuffer buffer, byte[] curLine) { buffer.Put(curLine, 1, curLine.Length - 1); }