基本上,我刚刚深入研究了一些Android和OpenGL ES 2.0编程,并遇到了一些问题。GL ES 2.0无法创建opengl对象
我的代码编译得很好,它运行但opengl函数似乎没有工作。
GLES20.createShader(GLES20.GL_VERTEX_SHADER);
GLES20.glCreateProgram();
都将返回0
同样这样的:
int posHandle = GLES20.glGetAttribLocation(mShader.getProgramId(), "vPosition");
将返回-1等。
我如何创建我的活动:
// Activity
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
mSurfaceView = new GLESSurfaceView(this);
final ActivityManager activityManager = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
final ConfigurationInfo configInfo = activityManager.getDeviceConfigurationInfo();
final boolean supports_gles2 = configInfo.reqGlEsVersion >= 0x20000;
if (supports_gles2)
{
mSurfaceView.setEGLContextClientVersion(2);
mSurfaceView.setRenderer(new GLESRenderer());
}
else
{
//Log.e("", "Doesn't support GLES 2.0");
}
setContentView(mSurfaceView);
}
我有这个在AndroidManifest.xml
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" />
我想这应该是它允许GLES 2.0功能工作的权利?如果需要,我可以提供更多代码,但它基本上只是着色器设置,创建顶点缓冲区,然后渲染基本形状。
干杯家伙
编辑:我要补充一点,GLES20.glGetError()返回GL_NO_ERROR标志