我从http://heikobehrens.net/2009/08/27/obj2opengl/下载了banana.h 文件。我在 EAGLView.mm 中包含了 .h 文件。我在 EAGLView.mm 文件中替换。我按照说明用另一个 3D 模态替换茶壶。但我没有得到任何替换的输出。我不知道我在哪里做错了
namespace {
// Teapot texture filenames
const char* textureFilenames[] = {
"banana.jpg",
/*
"TextureTeapotBrass.png",
"TextureTeapotBlue.png",
"TextureTeapotRed.png"
*/
}
// Model scale factor
const float kObjectScale = 3.0f;
}
- (void) setup3dObjects
{
// build the array of objects we want drawn and their texture
// in this example we have 3 targets and require 3 models
// but using the same underlying 3D model of a teapot, differentiated
// by using a different texture for each
for (int i=0; i < [textures count]; i++)
{
Object3D *obj3D = [[Object3D alloc] init];
// obj3D.numVertices = NUM_TEAPOT_OBJECT_VERTEX;
obj3D.numVertices =bananaNumVerts;
obj3D.vertices = bananaVerts;
obj3D.normals = bananaNormals;
obj3D.texCoords = bananaTexCoords;
obj3D.numIndices = 0;
obj3D.indices = nil;
obj3D.texture = [textures objectAtIndex:i];
[objects3D addObject:obj3D];
[obj3D release];
}
}
在 renderFrame 替换:
glVertexPointer(3, GL_FLOAT, 0, bananaVerts);
glNormalPointer(GL_FLOAT, 0, bananaNormals);
glTexCoordPointer(2, GL_FLOAT, 0, bananaTexCoords);
glDrawArrays(GL_TRIANGLES, 0, bananaNumVerts);
我在哪里做错了?