开发者

Detect available OpenGL ES versions

I'm developing a game for Android, and I made it using OpenGL ES 2.0. Now I want to add support for devices that do not have OpenGL ES 2.0 support, and use OpenGL ES 1.0 instead.

My problem is that I can't seem to detect the right OpenGL ES version. I used the example in the SDK, but i开发者_JAVA技巧t simply returns 0 on my Legend.

This is what I've tried:

    ActivityManager am = (ActivityManager) getSystemService(getApplication().ACTIVITY_SERVICE);
    ConfigurationInfo info = am.getDeviceConfigurationInfo();

    String eglVersion = info.getGlEsVersion();
    if (eglVersion == "2.0") GameLibrary.load_gl20();
    else GameLibrary.load_gl10();

(GameLibrary is a class containing some native methods, and load_glxx are static methods calling System.loadLibrary() with the specific library for the right opengl ES version) The problem is as i said before, info.getGlEsVersion() returns "0.0"


This might be oversimplifying things, but why not just try ES 2.0 first in an error-trap, then fall back to 1.0 if it fails to load?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜