Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了android – OPENGL ES不工作:否当前上下文大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我试过这个程序,如OpenGL ES2 for Android所示,但它不工作!

我已经在Odroid E测试了,三星s3,三星y,三星星!

the gl version suported returns 2,but i get
11-22 15:09:45.804: E/oGl-es v(9047): 2.0:131072
11-22 15:09:45.804: E/libEGL(9047): call to OpenGL ES API with no current context     (logged once per thread)
11-22 15:09:45.804: E/unable to(9047): createShader
11-22 15:09:45.804: E/libEGL(9047): call to OpenGL ES API with no current context (logged once per thread)
11-22 15:09:45.804: E/unable to(9047): createShader
11-22 15:09:45.804: E/libEGL(9047): call to OpenGL ES API with no current context (logged once per thread)
11-22 15:09:45.804: E/Error creaTing(9047): GL programObject
11-22 15:09:45.812: E/render(9047): set
11-22 15:09:46.062: E/Results of validaTing program:(9047): 0
11-22 15:09:46.062: E/Results of validaTing program:(9047): Log:

以下是我的代码

public class Main_OGLT1 extends Activity {

    MySurface mGLSurfaceView;
private Boolean renderSet;
    @Override
    protected void onCreate(Bundle savedInstanceStatE) {
        super.onCreate(savedInstanceStatE);

        mGLSurfaceView = new MySurface(this);//(this); //instantiation

        Activitymanager actMan = (Activitymanager) getSystemservice(Context.ACTIVITY_serviCE);
        ConfigurationInfo mConfigInfo = actMan.getDeviceConfigurationInfo();
        Boolean isES2Compat = (mConfigInfo.reqGlEsVersion >= 0x20000);
        Log.e("oGl-es v",mConfigInfo.getGlEsVersion()+":"+ mConfigInfo.reqGlEsVersion);
        if(isES2Compat){


            renderSet = true;
            Log.e("render","set");

        }


    }

    @Override
    public Boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.activity_main__oglt1,menu);
        return true;
    }

    @Override
    protected void onResume()
    {
        // The activity must call the GL surface view's onResume() on activity onResume().
        super.onResume();
        mGLSurfaceView.onResume();
    }

    @Override
    protected void onPause()
    {
        // The activity must call the GL surface view's onPause() on activity onPause().
        super.onPause();
        mGLSurfaceView.onPause();
    }

}
@H_200_2@mySurface类:

public class MySurface extends GLSurfaceView{

    public MySurface(Context context) {
        super(context);
        // TODO Auto-generated constructor stub
        setEGLContextClientVersion(2);
        setRenderer(new myTestRenderer(getContext()));
    }

 }

解决方法

问题在于glSurfaceView,因为它不会在OpenGL线程上运行. glSurfaceView应该在主要的android线程上.

在这里你可以找到关于它的更多信息

opengl es api with no current context

OpenGL ES 2.0 Context in Android

希望这个帮助.

大佬总结

以上是大佬教程为你收集整理的android – OPENGL ES不工作:否当前上下文全部内容,希望文章能够帮你解决android – OPENGL ES不工作:否当前上下文所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。