Primitive object size in java/scala and 'as<SomePrimitive>Buffer() methods invocation -
my objective generalize shapes creation android opengl es tutorial here: http://developer.android.com/training/graphics/opengl/shapes.html looks right now: val squarecoords = array( -0.5f, 0.5f, 0.0f, // top left -0.5f, -0.5f, 0.0f, // bottom left 0.5f, -0.5f, 0.0f, // bottom right 0.5f, 0.5f, 0.0f ) // top right val vertexbuffer = bytebuffer.allocatedirect( // (# of coordinate values * 4 bytes per float) squarecoords.length * 4) .order(byteorder.nativeorder()) .asfloatbuffer() .put(squarecoords) .position(0) so, float size hardcoded. have short arrays too: val draworder = array[short] ( 0, 1, 2, 0, 2, 3 ) val drawlistbuffer = bytebuffer.allocatedirect( // (# of coordinate values * 2 bytes per short) draworder.length * 2) .order(byteorder.nativeorder()) .asshortbuffer() drawlistbuffer.put(draworder) drawlistbuffer.position(0) code looks similar challenge part choose right method asfloatbuffer()/asshortbuffer() in case , use right primitive v...