Hello all, I'm getting illegal argument exception in my Renderer class, here is the code, see if some one can help me out, i have attached the code and the exception log:
code: public class VortexRenderer implements GLSurfaceView.Renderer{ @SuppressWarnings("unused") private static final String LOG_TAG = VortexRenderer.class.getSimpleName(); private ShortBuffer _indexBuffer; private FloatBuffer _vertexBuffer; private FloatBuffer _colorBuffer; private short[] _indicessArray = {0,1,2}; private int _nr0fvertices = 3; private float _red = 0f; private float _green = 0f; private float _blue = 0f; private float _angle; @SuppressWarnings("static-access") @Override public void onSurfaceCreated(GL10 gl, EGLConfig config){ gl.glEnableClientState(gl.GL_VERTEX_ARRAY); gl.glEnableClientState(gl.GL_COLOR_ARRAY); initTriangle(); } @Override public void onSurfaceChanged(GL10 gl, int w, int h) { gl.glViewport(0, 0, w, h); } public void setColor(float r, float g, float b){ _red = r; _green = g; _blue = b; } public void setAngle(float angle){ _angle = angle; } @Override public void onDrawFrame(GL10 gl) { // define the color we want to be displayed as the "clipping wall" gl.glClearColor(_red, _green, _blue, 1.0f); //reset the matrix - good to fix the rotation to a specific angle gl.glLoadIdentity(); // clear the color buffer to show the ClearColor we called above... gl.glClear(GL10.GL_COLOR_BUFFER_BIT); //set rotation gl.glRotatef(_angle, 0f, 1f, 0f); //Drawing the Triangle //define the vertices we wanth to draw gl.glVertexPointer(3, GL10.GL_FLOAT, 0, _vertexBuffer); //Setting the color pointer gl.glColorPointer(4, GL10.GL_FLOAT, 0, _colorBuffer); //finally draw the vertices gl.glDrawElements(GL10.GL_TRIANGLES, _nr0fvertices, GL10.GL_UNSIGNED_SHORT, _indexBuffer); } private void initTriangle(){ //Float has 4 Bytes ByteBuffer vbb = ByteBuffer.allocateDirect(_nr0fvertices *3 *4); vbb.order(ByteOrder.nativeOrder()); _vertexBuffer = vbb.asFloatBuffer(); //Short has 4 Bytes ByteBuffer ibb = ByteBuffer.allocateDirect(_nr0fvertices * 2); ibb.order(ByteOrder.nativeOrder()); _indexBuffer = ibb.asShortBuffer(); //Float has 4 Bytes, 4 Colors (RGBA)*no of vertices*4 Bytes ByteBuffer cbb = ByteBuffer.allocate(4*_nr0fvertices*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) 0f, 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(_indicessArray); _colorBuffer.put(colors); _vertexBuffer.position(0); _indexBuffer.position(0); _colorBuffer.position(0); } } exception log: 12-19 08:11:44.691: ERROR/AndroidRuntime(3769): java.lang.IllegalArgumentException: Must use a native order direct Buffer 12-19 08:11:44.691: ERROR/AndroidRuntime(3769): at com.google.android.gles_jni.GLImpl.glColorPointerBounds(Native Method) 12-19 08:11:44.691: ERROR/AndroidRuntime(3769): at com.google.android.gles_jni.GLImpl.glColorPointer(GLImpl.java:211) 12-19 08:11:44.691: ERROR/AndroidRuntime(3769): at example.Vortex.VortexRenderer.onDrawFrame(VortexRenderer.java:86) 12-19 08:11:44.691: ERROR/AndroidRuntime(3769): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1332) 12-19 08:11:44.691: ERROR/AndroidRuntime(3769): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1116) -- Thanks & Regards Raghav Dwivedi http://about.me/raghavdwivedi -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en