AndroidエミュレータのOpenGL ESトランスポートに見るAPI記述
Android SDKに付属するエミュレータは、ターゲットのOpenGL ES描画をシリアライズしてホストに転送し、ホスト側のOpenGLスタックで描画する機能が有る。
- https://android.googlesource.com/platform/sdk/+/android-5.0.0_r2/emulator/opengl/DESIGN
- デザインドキュメント
- https://android.googlesource.com/platform/sdk/+/android-5.0.0_r2/emulator/opengl/host/libs/GLESv2_dec/gl2.types
- 型
- https://android.googlesource.com/platform/sdk/+/android-5.0.0_r2/emulator/opengl/host/libs/GLESv2_dec/gl2.in
- API一覧
- https://android.googlesource.com/platform/sdk/+/android-5.0.0_r2/emulator/opengl/host/libs/GLESv2_dec/gl2.attrib
興味深いのはgl2.attribファイルで、シリアライズを行うために、isLargeのような(API仕様自体には関わらない)フラグを持っている。
例えば、テクスチャを転送するための関数 glTexSubImage2D のアノテーションは:
#void glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels) glTexSubImage2D len pixels pixelDataSize(self, width, height, format, type, 0) var_flag pixels isLarge
引数 pixels は isLargeであり、pixelsとして渡すバッファの長さ(len)はpixelDataSize(self, width, height, format, type, 0)と定義されている。pixelDataSizeは実際にstubを生成する(emugen)際に置き換えられる。
テクスチャのOpenGL的なハンドルを生成する関数 glGenTextures は、textures配列で出力を受けとることを記述(dir)し、更にtexturesの数が0未満である場合はエラー(param_check)としている。
#void glGenTextures(GLsizei n, GLuint *textures) glGenTextures len textures (n * sizeof(GLuint)) dir textures out param_check n if(n<0){ ctx->setError(GL_INVALID_VALUE); return; }