gpt4 book ai didi

android - OPENGL ES 不工作 : no Current context

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:23:32 48 4
gpt4 key购买 nike

我尝试了 OpenGL ES2 for Android 书中所示的程序,但它不工作!!

我已经在 Odroid E、samsung s3、samsung y、samsung star 上测试过!!

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();
}

}

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 不工作 : no Current context,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20159821/

48 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com