xcode 立方体的 IOS GLKit 纹理

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9322832/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 23:19:38  来源:igfitidea点击:

IOS GLKit Textures for Cube

iosxcodeopengl-estextures

提问by TommyT39

new to IOS OpenGL programming. I have worked through a few tutorials that talk about the basics of OpenGL ES and been able to create a small demo program that draws cubes in a scene at positions I want. Id like to apply a texture to the faces of the cube but for some reason this seems to be a near impossible task to figure out. Im using GLKit , Ive searched all over and can't find a dead simple tutorial on how to do this without a lot of other fluff. Can anyone point me in the correct direction or have a tutorial on this? It doesn't seem like this should be hard thing to do. I must be missing something..

IOS OpenGL 编程的新手。我已经完成了一些讨论 OpenGL ES 基础知识的教程,并且能够创建一个小型演示程序,在场景中我想要的位置绘制立方体。我想将纹理应用于立方体的表面,但由于某种原因,这似乎是一项几乎不可能完成的任务。我正在使用 GLKit ,我已经搜索了所有内容,但找不到关于如何在没有很多其他绒毛的情况下执行此操作的简单教程。任何人都可以指出我正确的方向或有关于此的教程吗?这似乎不应该是一件很难做到的事情。我肯定错过了什么..

回答by Pochi

Go here for many tutorials bout this http://www.raywenderlich.com/

去这里看很多关于这个http://www.raywenderlich.com/ 的教程

or here

或在这里

http://www.raywenderlich.com/5223/beginning-opengl-es-2-0-with-glkit-part-1

http://www.raywenderlich.com/5223/beginning-opengl-es-2-0-with-glkit-part-1

this one explains about textures in detail:

这个详细解释了纹理:

http://db-in.com/blog/2011/02/all-about-opengl-es-2-x-part-23/

http://db-in.com/blog/2011/02/all-about-opengl-es-2-x-part-23/

Id recomend not to use glkit directly (maybe some helper methods) since even tho it is easier as it works like opengl 1 most of the tutorials for gl es 2.0 wont use it and you will get confused.

我建议不要直接使用 glkit(也许是一些辅助方法),因为即使它更容易,因为它像 opengl 1 一样工作,大多数 gl es 2.0 的教程都不会使用它,你会感到困惑。

Use this one for glkit to load textures

将此用于 glkit 加载纹理

https://developer.apple.com/library/ios/#documentation/GLkit/Reference/GLKTextureLoader_ClassRef/Reference/Reference.html#//apple_ref/doc/uid/TP40010922

https://developer.apple.com/library/ios/#documentation/GLkit/Reference/GLKTextureLoader_ClassRef/Reference/Reference.html#//apple_ref/doc/uid/TP40010922

Try google with something like glkit texture example

用 glkit 纹理示例之类的东西试试谷歌

this is what i got :

这就是我得到的:

https://github.com/jlamarche/iOS-OpenGLES-Stuff/blob/master/GLKit%20Stuff/GLKBaseEffect%20Drawing%20Example%20with%20Texture/blah/MCViewController.m

https://github.com/jlamarche/iOS-OpenGLES-Stuff/blob/master/GLKit%20Stuff/GLKBaseEffect%20Drawing%20Example%20with%20Texture/blah/MCViewController.m

around line 119 you can see how to use the texture, i havent checked it but it seems valid. I usually prefer to just use normal opengl since even when you have a simple program the shader file is ridiculously simple, (like less than 10 lines).

在第 119 行左右,您可以看到如何使用纹理,我还没有检查过,但它似乎有效。我通常更喜欢只使用普通的 opengl,因为即使你有一个简单的程序,着色器文件也非常简单(比如少于 10 行)。