在Windows上测试时,代码按预期工作,但在Android上,glGetTexImage
API不存在,是否有其他方法从OpenGL获取所有像素而不是在创建纹理之前将它们缓存?
以下是代码:
void Texture::Bind(int unit)
{
glActiveTexture(GL_TEXTURE0 + unit);
glBindTexture(GL_TEXTURE_2D, mTextureID);
}
GLubyte* Texture::GetPixels()
{
Bind();
int data_size = mWidth * mHeight * 4;
GLubyte* pixels = new GLubyte[mWidth * mHeight * 4];
glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
return pixels;
}