android gl2ext.h,opengl es - Using GL_EXT_color_buffer_half_float with Android NDK - Stack Overflow

I’m trying to use the GL_EXT_color_buffer_half_float OpenGL ES 2.0 extension with a native Android NDK application. OpenGL ES 2.0 extensions are defined in the header. The problem is that the GL_EXT_color_buffer_half_float extension isn’t defined in the header until Android API level 21**, which corresponds to Android 5.0 “Lollipop”. Previous versions of the header don’t define the GL_EXT_color_buffer_half_float extension so when I try to compile against an earlier API level (like 10 or 14) I get an undeclared identifier error:

error: use of undeclared identifier 'GL_RGBA16F_EXT'

If I go to the header from API level 21 and copy out the GL_EXT_color_buffer_half_float extension and put it in my own header:

#ifndef GL_EXT_color_buffer_half_float

#define GL_EXT_color_buffer_half_float 1

#define GL_RGBA16F_EXT 0x881A

#define GL_RGB16F_EXT 0x881B

#define GL_RG16F_EXT 0x822F

#define GL_R16F_EXT 0x822D

#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT 0x8211

#define GL_UNSIGNED_NORMALIZED_EXT 0x8C17

#endif /* GL_EXT_color_buffer_half_float */

Then everything appears to be working correctly. We do check to make sure that the GL_EXT_color_buffer_half_float is actually available on a device before using it so we shouldn’t ever run code that uses it on a device that doesn’t support the extension. However, this seems like a horrible, ugly hack.

Is there a better way to do this? What’s the “correct” way to use an OpenGL extension that isn’t included in the header but is supported by the OS/device?

**Note: I tried compiling our app using API level 21, however when I do this the app doesn’t run on older devices (Android 4.4, API level 20). It only runs on Android 5.0 devices. I’m not sure yet if this is a problem with our app or if this just isn’t even possible. Does anyone know if it’s even possible for an app compiled using the NDK API level 21 to run on older API versions?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值