Call unimplemented OpenGL API on Android

Discussion of issues specific to mobile platforms such as iOS, Android, Symbian and Meego.
jsding
Greenskin
Posts: 105
Joined: Tue Dec 14, 2010 9:46 am
x 1

Call unimplemented OpenGL API on Android

Post by jsding »

Hi

I run my OGRE +GLES app on android 2.3, but the logcat flooded with the "Call unimplemented OpenGL API", How can i track the issure?

Thanks for your help.
ironsteel
Gnoblar
Posts: 5
Joined: Mon Feb 20, 2012 9:27 am

Re: Call unimplemented OpenGL API on Android

Post by ironsteel »

Are you using the code from the ogre repository ?
And are you trying it with GLES 1.1 or with GLES 2.0 render system ?
jsding
Greenskin
Posts: 105
Joined: Tue Dec 14, 2010 9:46 am
x 1

Re: Call unimplemented OpenGL API on Android

Post by jsding »

Hi, Thanks for your reponse.

I am using the trunk version and GLES Rendersystem.
ironsteel
Gnoblar
Posts: 5
Joined: Mon Feb 20, 2012 9:27 am

Re: Call unimplemented OpenGL API on Android

Post by ironsteel »

Make sure that the java side is initializing the gl context properly.

I got the same warnings, as my mistake was extending the NVGLESActivity class not the NVGLES2Activity class.

Can you post the output before you get the warnings, so we can see which version of the GLES context is initialized ?
jsding
Greenskin
Posts: 105
Joined: Tue Dec 14, 2010 9:46 am
x 1

Re: Call unimplemented OpenGL API on Android

Post by jsding »

Hi,
Finally, I solved the problem, it's really the EGL configuration problem. for whom encounter the same problem:
Step1. add following code to NvGLESActivity

Code: Select all

  private EGLConfigChooser mEGLConfigChooser;


  /**
   * An interface for choosing an EGLConfig configuration from a list of
   * potential configurations.
   * <p>
   * This interface must be implemented by clients wishing to call
   * {@link GLSurfaceView#setEGLConfigChooser(EGLConfigChooser)}
   */
  public interface EGLConfigChooser {
    /**
     * Choose a configuration from the list. Implementors typically implement
     * this method by calling {@link EGL10#eglChooseConfig} and iterating
     * through the results. Please consult the EGL specification available from
     * The Khronos Group to learn how to call eglChooseConfig.
     * 
     * @param egl
     *          the EGL10 for the current display.
     * @param display
     *          the current display.
     * @return the chosen configuration.
     */
    EGLConfig chooseConfig(EGL10 egl, EGLDisplay display);
  }
  
  

  private static abstract class BaseConfigChooser implements EGLConfigChooser {
    public BaseConfigChooser(int[] configSpec) {
      mConfigSpec = configSpec;
    }

    public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) {
      int[] num_config = new int[1];
      egl.eglChooseConfig(display, mConfigSpec, null, 0, num_config);

      int numConfigs = num_config[0];

      if (numConfigs <= 0) {
        throw new IllegalArgumentException("No configs match configSpec");
      }

      EGLConfig[] configs = new EGLConfig[numConfigs];
      egl.eglChooseConfig(display, mConfigSpec, configs, numConfigs, num_config);
      EGLConfig config = chooseConfig(egl, display, configs);
      if (config == null) {
        throw new IllegalArgumentException("No config chosen");
      }
      return config;
    }

    abstract EGLConfig chooseConfig(EGL10 egl, EGLDisplay display, EGLConfig[] configs);

    protected int[] mConfigSpec;
  }

  private static class ComponentSizeChooser extends BaseConfigChooser {
    public ComponentSizeChooser(int redSize, int greenSize, int blueSize, int alphaSize, int depthSize, int stencilSize) {
      super(new int[] { EGL10.EGL_RED_SIZE, redSize, EGL10.EGL_GREEN_SIZE, greenSize, EGL10.EGL_BLUE_SIZE, blueSize, EGL10.EGL_ALPHA_SIZE, alphaSize, EGL10.EGL_DEPTH_SIZE, depthSize, EGL10.EGL_STENCIL_SIZE, stencilSize, EGL10.EGL_NONE });
      mValue = new int[1];
      mRedSize = redSize;
      mGreenSize = greenSize;
      mBlueSize = blueSize;
      mAlphaSize = alphaSize;
      mDepthSize = depthSize;
      mStencilSize = stencilSize;
    }

    @Override
    public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display, EGLConfig[] configs) {
      EGLConfig closestConfig = null;
      int closestDistance = 1000;
      for (EGLConfig config : configs) {
        int r = findConfigAttrib(egl, display, config, EGL10.EGL_RED_SIZE, 0);
        int g = findConfigAttrib(egl, display, config, EGL10.EGL_GREEN_SIZE, 0);
        int b = findConfigAttrib(egl, display, config, EGL10.EGL_BLUE_SIZE, 0);
        int a = findConfigAttrib(egl, display, config, EGL10.EGL_ALPHA_SIZE, 0);
        int d = findConfigAttrib(egl, display, config, EGL10.EGL_DEPTH_SIZE, 0);
        int s = findConfigAttrib(egl, display, config, EGL10.EGL_STENCIL_SIZE, 0);
        int distance = Math.abs(r - mRedSize) + Math.abs(g - mGreenSize) + Math.abs(b - mBlueSize) + Math.abs(a - mAlphaSize) + Math.abs(d - mDepthSize) + Math.abs(s - mStencilSize);
        if (distance < closestDistance) {
          closestDistance = distance;
          closestConfig = config;
        }
      }
      return closestConfig;
    }

    private int findConfigAttrib(EGL10 egl, EGLDisplay display, EGLConfig config, int attribute, int defaultValue) {

      if (egl.eglGetConfigAttrib(display, config, attribute, mValue)) {
        return mValue[0];
      }
      return defaultValue;
    }

    private int[] mValue;
    // Subclasses can adjust these values:
    protected int mRedSize;
    protected int mGreenSize;
    protected int mBlueSize;
    protected int mAlphaSize;
    protected int mDepthSize;
    protected int mStencilSize;
  }

  /**
   * This class will choose a supported surface as close to RGB565 as possible,
   * with or without a depth buffer.
   * 
   */
  private static class SimpleEGLConfigChooser extends ComponentSizeChooser {
    public SimpleEGLConfigChooser(boolean withDepthBuffer) {
      super(4, 4, 4, 0, withDepthBuffer ? 16 : 0, 0);
      // Adjust target values. This way we'll accept a 4444 or
      // 555 buffer if there's no 565 buffer available.
      mRedSize = 5;
      mGreenSize = 6;
      mBlueSize = 5;
    }
  }
Step2. modify the initELG method to

Code: Select all

    /*
     * Get an EGL instance
     */
    egl = (EGL10) EGLContext.getEGL();

    /*
     * Get to the default display.
     */
    eglDisplay = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);

    /*
     * We can now initialize EGL for that display
     */
    int[] version = new int[2];
    egl.eglInitialize(eglDisplay, version);
    eglConfig = mEGLConfigChooser.chooseConfig(egl, eglDisplay);

    /*
     * Create an OpenGL ES context. This must be done only once, an OpenGL
     * context is a somewhat heavy object.
     */
    eglContext = egl.eglCreateContext(eglDisplay, eglConfig, EGL10.EGL_NO_CONTEXT, null);

    eglSurface = null;
    return true;
}
User avatar
masterfalcon
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
x 126

Re: Call unimplemented OpenGL API on Android

Post by masterfalcon »

Could you submit a patch for this so it doesn't get lost? Thanks
jsding
Greenskin
Posts: 105
Joined: Tue Dec 14, 2010 9:46 am
x 1

Re: Call unimplemented OpenGL API on Android

Post by jsding »

found still not solved..... :cry: