How to use glDrawTex*

故事扮演 提交于 2019-12-06 06:29:36

Although the OES_draw_texture extension is a good enough way to draw a background because it may sometimes be a little faster than using geometry, I'd recommend against using it too heavily on the basis that iPhones don't implement it under ES 2 and you don't want to box yourself into a corner.

That being said, something like:

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);

Should be correct.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!