Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8070293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T13:22:11+00:00 2026-06-05T13:22:11+00:00

Well, I got problem here with opengl ES stuff (just started to learn about

  • 0

Well, I got problem here with opengl ES stuff (just started to learn about it by the way).
So here’s some code

GLExample.java

    package com.android.OpGL;

import android.app.Activity;
import android.opengl.GLSurfaceView;
import android.os.Bundle;


public class GLExample extends Activity {

    GLSurfaceView ourSurface;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        ourSurface = new GLSurfaceView(this);
        ourSurface.setRenderer(new GLRendererEx());

        setContentView(ourSurface);
    }
}

GLRendererEx.java

package com.android.OpGL;

import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;

import android.opengl.GLSurfaceView.Renderer;

public class GLRendererEx implements Renderer {

    private GLTriangleEx tri;

    public GLRendererEx(){
        tri = new GLTriangleEx();
    }


    @Override
    public void onSurfaceCreated(GL10 gl, EGLConfig eglConfig) {
        // TODO Auto-generated method stub
        gl.glDisable(GL10.GL_DITHER);
        gl.glClearColor(.8f, 0f, .2f, 1f);
        gl.glClearDepthf(1f);

    }

    @Override
    public void onDrawFrame(GL10 gl) {
        // TODO Auto-generated method stub
        gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);

        tri.draw(gl);
    }

    @Override
    public void onSurfaceChanged(GL10 gl, int width, int height) {
        // TODO Auto-generated method stub

    }



}

GLTriangleEx.java

    package com.android.OpGL;

import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import java.nio.ShortBuffer;

import javax.microedition.khronos.opengles.GL10;

public class GLTriangleEx {

    private float vertices[]= {
        0f, 1f, //(0,1) point
        1f, -1f,//(1,-1)
        -1f,-1f//(-1,-1)
    };

    private FloatBuffer vertBuff;

    private short[] pIndex = {0,1,2};

    private ShortBuffer pBuff;

    public GLTriangleEx(){

        ByteBuffer bBuff = ByteBuffer.allocate(vertices.length *4);
        bBuff.order(ByteOrder.nativeOrder());
        vertBuff = bBuff.asFloatBuffer();
        vertBuff.put(vertices);
        vertBuff.position(0);

        ByteBuffer pbBuff = ByteBuffer.allocateDirect(pIndex.length * 2);
        pbBuff.order(ByteOrder.nativeOrder());
        pBuff = pbBuff.asShortBuffer();
        pBuff.put(pIndex);
        pBuff.position(0);
    }

    public void draw(GL10 gl){
        gl.glFrontFace(GL10.GL_CW);
        gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
        gl.glVertexPointer(2, GL10.GL_FLOAT, 0, vertBuff);
        gl.glDrawElements(GL10.GL_TRIANGLES, pIndex.length, GL10.GL_UNSIGNED_SHORT, pBuff);
        gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
    }
}

And this is what was in LOGCAT

06-13 10:06:34.074: INFO/ActivityManager(71): Displayed com.android.OpGL/.GLExample: +1s391ms
06-13 10:06:34.493: ERROR/OpenGLES(727): Application com.android.OpGL (SDK target 10) called a GL11 Pointer method with an indirect Buffer.
06-13 10:06:34.523: WARN/dalvikvm(727): threadid=9: thread exiting with uncaught exception (group=0x40015560)
06-13 10:06:34.523: ERROR/AndroidRuntime(727): FATAL EXCEPTION: GLThread 10
06-13 10:06:34.523: ERROR/AndroidRuntime(727): java.lang.IllegalArgumentException: Must use a native order direct Buffer
06-13 10:06:34.523: ERROR/AndroidRuntime(727):     at com.google.android.gles_jni.GLImpl.glVertexPointerBounds(Native Method)
06-13 10:06:34.523: ERROR/AndroidRuntime(727):     at com.google.android.gles_jni.GLImpl.glVertexPointer(GLImpl.java:1121)
06-13 10:06:34.523: ERROR/AndroidRuntime(727):     at com.android.OpGL.GLTriangleEx.draw(GLTriangleEx.java:42)
06-13 10:06:34.523: ERROR/AndroidRuntime(727):     at com.android.OpGL.GLRendererEx.onDrawFrame(GLRendererEx.java:31)
06-13 10:06:34.523: ERROR/AndroidRuntime(727):     at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1363)
06-13 10:06:34.523: ERROR/AndroidRuntime(727):     at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1118)
06-13 10:06:34.553: WARN/ActivityManager(71):   Force finishing activity com.android.OpGL/.GLExample

as you see it says that error is here gl.glVertexPointer(2, GL10.GL_FLOAT, 0, vertBuff); but i don’t understan what is wrong

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T13:22:12+00:00Added an answer on June 5, 2026 at 1:22 pm

    It’s quite clear what the problem is:

    ... called a GL11 Pointer method with an indirect Buffer.
    

    The vertBuff buffer needs to be direct so that it isn’t moved around in memory.
    You need to use the allocateDirect(int) method from the ByteBuffer class.

    Then you take the ByteBuffer object returned by that method and convert it to a FloatBuffer like in this example.

    Good luck!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a problem with java's instanceof. Here's a gap of code that causes
I got this code from someone and it works very well, I just want
Well, here's my problem. I've got a php script which posts a message to
I’ve got some problem using an ODBC connection with IIS. Here is my config
I got some pretty messy urls that i got via scraping here, problem is
Well ive got this code that creates a table from JSON data. If a
Well, now that I've finally got my stupid ODBC stuff configured, I took a
I've got some 3rd party beans that have method signatures that fit quite well
I've got to develop a multi-language code generator in C#. Well actually the idea
Bit of a strange problem here... I've got an update query that isn't working,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.