从其他库获取了一个 OpenGL ES 纹理,想要指定其目标。
// got from other lib, no more information about it's target, format..
void *a = foo();
// glBindTexture(GL_TEXTURE_2D, (uintptr_t)a);
// or
// glBindTexture(GL_TEXTURE_2D_ARRAY, (uintptr_t)a);
有没有方便的方法来指定该纹理的目标?
可能会找到一个临时的办法:
glBindTexture(GL_TEXTURE_2D, (uintptr_t)texptr);
if (glGetError() == GL_NO_ERROR) {
LOGI("texture target == GL_TEXTURE_2D");
} else {
LOGI("texture target != GL_TEXTURE_2D");
}
glBindTexture(GL_TEXTURE_2D, 0);
glBindTexture(GL_TEXTURE_2D_ARRAY, (uintptr_t)texptr);
if (glGetError() == GL_NO_ERROR) {
LOGI("texture target == GL_TEXTURE_2D_ARRAY");
} else {
LOGI("texture target != GL_TEXTURE_2D_ARRAY");
}
glBindTexture(GL_TEXTURE_2D_ARRAY, 0);
glBindTexture(GL_TEXTURE_3D, (uintptr_t)texptr);
if (glGetError() == GL_NO_ERROR) {
LOGI("texture target == GL_TEXTURE_3D");
} else {
LOGI("texture target != GL_TEXTURE_3D");
}
glBindTexture(GL_TEXTURE_3D, 0);
// ... and so on