我想拍摄一张 .png 图像并将其用作 GLView 的背景。我听说 glDrawTex* 是最好的方法,但我在互联网上搜索过,但没有找到一个如何使用它的示例(至少没有一个对我有用)。有什么帮助吗?
最佳答案
尽管OES_draw_texture extension是一种足够好的绘制背景的方法,因为它有时可能比使用几何图形快一点,我建议不要过度使用它,因为 iPhone 没有在 ES 2 下实现它,而且你也不想把自己逼到墙角。
话虽如此,类似于:
int sourceRect[4] = {0, 24, 8, 16}; // we'll use the rectangle from (0, 24) of
// size (8, 16) in the texture or textures
// that are currently active as the
// source graphic...
// ... by saying as much to OpenGL
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, sourceRect);
// we'll then draw that at (x, y), with nominal depth z, so as
// to cover the screen area (width, height)
glDrawTexiOES(x, y, z, width, height);
应该是正确的。
关于iphone - 如何使用 glDrawTex*,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5811035/