How to use glDrawTex*

眉间皱痕 提交于 2019-12-10 11:27:52

问题


I want to take a .png image and use it as the background for my GLView. I've heard that glDrawTex* was the best way, but I've searched the internet and haven't found a single example of how to use it (at least not one that has worked for me). Any help?


回答1:


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.



来源:https://stackoverflow.com/questions/5811035/how-to-use-gldrawtex

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