我想拍摄一张 .png 图像并将其用作 GLView 的背景。我听说 glDrawTex* 是最好的方法,但我在互联网上搜索过,但没有找到一个如何使用它的示例(至少没有一个对我有用)。有什么帮助吗?
虽然OES_draw_texture 扩展 http://www.khronos.org/registry/gles/extensions/OES/OES_draw_texture.txt是一种足够好的绘制背景的方法,因为它有时可能比使用几何图形快一点,我建议不要过度使用它,因为 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);
应该是正确的。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)