diff --git a/android/examples/OpenGL/Shaders/LowLevelGL/LowLevelGL.pde b/android/examples/OpenGL/Shaders/LowLevelGL/LowLevelGL.pde index a8f9ef4fb..d046d6690 100644 --- a/android/examples/OpenGL/Shaders/LowLevelGL/LowLevelGL.pde +++ b/android/examples/OpenGL/Shaders/LowLevelGL/LowLevelGL.pde @@ -25,10 +25,10 @@ void setup() { flatShader = getShader(PShader.FLAT); vertices = new float[12]; - vertData = PGL.allocateDirectFloatBuffer(12); + vertData = allocateDirectFloatBuffer(12); colors = new float[12]; - colorData = PGL.allocateDirectFloatBuffer(12); + colorData = allocateDirectFloatBuffer(12); } void draw() { @@ -100,3 +100,7 @@ void updateGeometry() { colorData.put(colors); colorData.position(0); } + +FloatBuffer allocateDirectFloatBuffer(int n) { + return ByteBuffer.allocateDirect(n * Float.SIZE/8).order(ByteOrder.nativeOrder()).asFloatBuffer(); +} diff --git a/java/examples/OpenGL/Shaders/LowLevelGL/LowLevelGL.pde b/java/examples/OpenGL/Shaders/LowLevelGL/LowLevelGL.pde index b1a4327d3..4ea2b7ce4 100644 --- a/java/examples/OpenGL/Shaders/LowLevelGL/LowLevelGL.pde +++ b/java/examples/OpenGL/Shaders/LowLevelGL/LowLevelGL.pde @@ -1,5 +1,5 @@ // Draws a triangle using low-level OpenGL calls. -import java.nio.FloatBuffer; +import java.nio.*; PGraphicsOpenGL pg; PGL pgl; @@ -25,10 +25,10 @@ void setup() { flatShader = getShader(PShader.FLAT); vertices = new float[12]; - vertData = PGL.allocateDirectFloatBuffer(12); + vertData = allocateDirectFloatBuffer(12); colors = new float[12]; - colorData = PGL.allocateDirectFloatBuffer(12); + colorData = allocateDirectFloatBuffer(12); } void draw() { @@ -100,3 +100,7 @@ void updateGeometry() { colorData.put(colors); colorData.position(0); } + +FloatBuffer allocateDirectFloatBuffer(int n) { + return ByteBuffer.allocateDirect(n * Float.SIZE/8).order(ByteOrder.nativeOrder()).asFloatBuffer(); +}