基本上,我剛剛深入研究了一些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標誌