iphone - 如何使用 glDrawTex*

标签 iphone image opengl-es background

我想拍摄一张 .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/

相关文章:

php - 在Laravel中上传图像时获取空白页

c++ - 尝试在 C++ 代码中包含 iPhone OpenGLES header

ios - 设备 token iPhone的组合是什么?

ios - session 正在记录,但事件未记录在 Flurry for iPhone 应用程序中

iphone - AVCaptureMovieFileOutput - 如何保存视频

ios编程: Using threads to add multiple images to library

html - 在 css 中使用 % 调整图像大小

iPhone OpenGLES 2.0 文本纹理带有奇怪的边框(不是描边)问题

c++ - 将 OpenGL 基元转换为 OpenGLES

iphone - 禁用 iPhone 中 UIButton 的触摸动画