public abstract put ( int arg0, short arg1 ) : global::java.nio.ShortBuffer | ||
arg0 | int | |
arg1 | short | |
return | global::java.nio.ShortBuffer |
private void initTriangle() { // float has 4 bytes ByteBuffer vbb = ByteBuffer.allocateDirect(_nrOfVertices * 3 * 4); vbb.order(ByteOrder.nativeOrder()); _vertexBuffer = vbb.asFloatBuffer(); // short has 2 bytes ByteBuffer ibb = ByteBuffer.allocateDirect(_nrOfVertices * 2); ibb.order(ByteOrder.nativeOrder()); _indexBuffer = ibb.asShortBuffer(); float[] coords = { -0.5f, -0.5f, 0f, // (x1, y1, z1) 0.5f, -0.5f, 0f, // (x2, y2, z2) 0f, 0.5f, 0f // (x3, y3, z3) }; _vertexBuffer.put(coords); _indexBuffer.put(_indicesArray); _vertexBuffer.position(0); _indexBuffer.position(0); }
private void initTriangle() { float[] coords = { -0.5f, -0.5f, 0.5f, // 0 0.5f, -0.5f, 0.5f, // 1 0f, -0.5f, -0.5f, // 2 0f, 0.5f, 0f, // 3 }; _nrOfVertices = coords.Length; float[] colors = { 1f, 0f, 0f, 1f, // point 0 red 0f, 1f, 0f, 1f, // point 1 green 0f, 0f, 1f, 1f, // point 2 blue 1f, 1f, 1f, 1f, // point 3 white }; short[] indices = new short[] { 0, 1, 3, // rwg 0, 2, 1, // rbg 0, 3, 2, // rbw 1, 2, 3, // bwg }; // float has 4 bytes, coordinate * 4 bytes ByteBuffer vbb = ByteBuffer.allocateDirect(coords.Length * 4); vbb.order(ByteOrder.nativeOrder()); _vertexBuffer = vbb.asFloatBuffer(); // short has 2 bytes, indices * 2 bytes ByteBuffer ibb = ByteBuffer.allocateDirect(indices.Length * 2); ibb.order(ByteOrder.nativeOrder()); _indexBuffer = ibb.asShortBuffer(); // float has 4 bytes, colors (RGBA) * 4 bytes ByteBuffer cbb = ByteBuffer.allocateDirect(colors.Length * 4); cbb.order(ByteOrder.nativeOrder()); _colorBuffer = cbb.asFloatBuffer(); _vertexBuffer.put(coords); _indexBuffer.put(indices); _colorBuffer.put(colors); _vertexBuffer.position(0); _indexBuffer.position(0); _colorBuffer.position(0); }
private void initTriangle() { // float has 4 bytes ByteBuffer vbb = ByteBuffer.allocateDirect(_nrOfVertices * 3 * 4); vbb.order(ByteOrder.nativeOrder()); _vertexBuffer = vbb.asFloatBuffer(); // short has 4 bytes ByteBuffer ibb = ByteBuffer.allocateDirect(_nrOfVertices * 2); ibb.order(ByteOrder.nativeOrder()); _indexBuffer = ibb.asShortBuffer(); // float has 4 bytes, 4 colors (RGBA) * number of vertices * 4 bytes ByteBuffer cbb = ByteBuffer.allocateDirect(4 * _nrOfVertices * 4); cbb.order(ByteOrder.nativeOrder()); _colorBuffer = cbb.asFloatBuffer(); float[] coords = { -0.5f, -0.5f, 0f, // (x1, y1, z1) 0.5f, -0.5f, 0f, // (x2, y2, z2) 0.5f, 0.5f, 0f // (x3, y3, z3) }; float[] colors = { 1f, 0f, 0f, 1f, // point 1 0f, 1f, 0f, 1f, // point 2 0f, 0f, 1f, 1f, // point 3 }; _vertexBuffer.put(coords); _indexBuffer.put(_indicesArray); _colorBuffer.put(colors); _vertexBuffer.position(0); _indexBuffer.position(0); _colorBuffer.position(0); }