小编omn*_*ore的帖子

如何在OpenGL ES中为立方体贴图?

让纹理贴图在openGL ES(iphone)中工作时遇到很多麻烦.

这就是我所做的:

  • 构建了一个顶点数组
  • 构建了一个面数组,引用每个面的顶点数组的索引
  • 建立了一个颜色数组,所以我可以肯定我知道立方体上的哪个顶点是哪个.

以下是Jeff Lamarche的教程.获取对象渲染和移动不是问题.

现在我正在尝试获得立方体(实际上是一块瓷砖,Z在X或Y中更窄)以在两个相对的面上粘贴纹理(其他面板可以稍后出现).我已经能够让一张脸上班,但我在任何其他方面都没有得到可行的结果.

在OpenGL ES中纹理映射对象的最系统方法是什么,任何人都可以看到我的代码中的错误在哪里?

#import "GLViewController.h"
#import "ConstantsAndMacros.h"
#import "OpenGLCommon.h"
#import "Cube.h"

@implementation GLViewController

@synthesize initDone;
@synthesize tileArray;
@synthesize tileRows;
@synthesize tileCols;
@synthesize cubes;
@synthesize gridOffsetX;
@synthesize gridOffsetY;
@synthesize gridOffsetZ;
@synthesize tileSpacing;

- (void)drawView:(UIView *)theView
{
    static GLfloat rot = 0.0;

    glEnableClientState(GL_VERTEX_ARRAY);
    glEnableClientState(GL_COLOR_ARRAY);
    glEnableClientState(GL_NORMAL_ARRAY);
    glEnableClientState(GL_TEXTURE_COORD_ARRAY);

    // This is the same result as using Vertex3D, just faster to type and
    // can be made const this way

    static const Vertex3D vertices[]= { …
Run Code Online (Sandbox Code Playgroud)

iphone textures opengl-es

5
推荐指数
1
解决办法
5428
查看次数

标签 统计

iphone ×1

opengl-es ×1

textures ×1