2013年8月23日星期五

Android opengl es problem (fast solution) seeking help

 This post last edited by the hbm717 on 2013-08-11 10:15:37
I use eclipse opengl es2.0 real machine running, but withdrew just opened

open debugging automatic hyphenation in GLSurfaceView $ GLThread.run, the code can not be displayed GLSurfaceView.class

seek expert help ............

main issues :: 0: buffer_sunxi_init: Generic buffer formats must be registered first. Re-order your gralloc constructors.

Source:

main activity
public class MainActivity extends Activity
{
GameView mGame;
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
mGame=new GameView(getApplication());
setContentView(mGame);
}

    protected void onPause()
    {
        super.onPause();
        mGame.onPause();
    }

    protected void onResume()
    {
        super.onResume();
        mGame.onResume();
    }
}



GLSurfaceView class inheritance
public class GameView extends GLSurfaceView
{
Renderer mRenderer;
public GameView(Context context)
{
super(context);
setEGLConfigChooser(8,8,8,8,16,0);
setEGLContextClientVersion(2);
mRenderer=new Renderer();
setRenderer(mRenderer);
}

private static class Renderer implements GLSurfaceView.Renderer
{
    private float red = 0f;  
    private float green = 0f;  
    private float blue = 0f;  
 
    private ShortBuffer indexBuffer;  
    private FloatBuffer vertexBuffer;  
    private short[] indicesArray = { 0, 1, 2 };  
    private int numberOfVertices = 3;  
      
    private float angle;  
      
    private void initTriangle() {  
        ByteBuffer vbb = ByteBuffer.allocateDirect(numberOfVertices * 3 * 4);  
        vbb.order(ByteOrder.nativeOrder());  
        vertexBuffer = vbb.asFloatBuffer();  
 
        ByteBuffer ibb = ByteBuffer.allocateDirect(numberOfVertices * 2);  
        ibb.order(ByteOrder.nativeOrder());  
        indexBuffer = ibb.asShortBuffer();  
 
        float[] coords = { -0.5f, -0.5f, 0f, 0.5f, -0.5f, 0f, 0f, 0.5f, 0f };  
 
        vertexBuffer.put(coords);  
        indexBuffer.put(indicesArray);  
 
        vertexBuffer.position(0);  
        indexBuffer.position(0);  
    }  
   
    public void onSurfaceCreated(GL10 gl, EGLConfig config) {  
        gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);  
        initTriangle();  
    }
   
    public void onSurfaceChanged(GL10 gl, int width, int height) {  
        gl.glViewport(0, 0, width, height);  
    }
   
    public void onDrawFrame(GL10 gl) {  
        gl.glClearColor(red, green, blue, 1.0f);  
        gl.glClear(GL10.GL_COLOR_BUFFER_BIT);  
        gl.glRotatef(angle, 0f, 1f, 0f);  
        gl.glColor4f(0.5f, 0f, 0f, 0.5f);  
        gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer);  
        gl.glDrawElements(GL10.GL_TRIANGLES, numberOfVertices, GL10.GL_UNSIGNED_SHORT, indexBuffer);  
    }  
}
}



error message is as follows
08-10 13:34:43.683: D / OpenGLRenderer (28904): Enabling debug mode 0
08-10 13:34:43.693: W / dalvikvm (28904): threadid = 11: thread exiting with uncaught exception (group = 0x41781300)
08-10 13:34:43.703: E / AndroidRuntime (28904): FATAL EXCEPTION: GLThread 1278
08-10 13:34:43.703: E / AndroidRuntime (28904): java.lang.RuntimeException: createContext failed: EGL_BAD_CONFIG
08-10 13:34:43.703: E / AndroidRuntime (28904): at android.opengl.GLSurfaceView $ EglHelper.throwEglException (GLSurfaceView.java: 1193)
08-10 13:34:43.703: E / AndroidRuntime (28904): at android.opengl.GLSurfaceView $ EglHelper.throwEglException (GLSurfaceView.java: 1184)
08-10 13:34:43.703: E / AndroidRuntime (28904): at android.opengl.GLSurfaceView $ EglHelper.start (GLSurfaceView.java: 1034)
08-10 13:34:43.703: E / AndroidRuntime (28904): at android.opengl.GLSurfaceView $ GLThread.guardedRun (GLSurfaceView.java: 1401)
08-10 13:34:43.703: E / AndroidRuntime (28904): at android.opengl.GLSurfaceView $ GLThread.run (GLSurfaceView.java: 1240)
---- - Solution --------------------------------------------

Masters ...... tell me I did not configure the context, and then give you a minute ......  

no configuration context
------ reference - --------------------------------------
my virgin stickers so heavy. . Reconciled ah. . . .
------ reference --------------------------------------- < br> ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah

I would get points virgin stickers affixed ah ah ah ah
------ reference ------------------------ ---------------
first come first served ......
------ reference ---------------- -----------------------

------ reference ------------------------- --------------

Masters ...... tell me I did not configure the context, and then give you a minute ......

没有评论:

发表评论