Multiple places recommend using a texture atlas for performance. Apple suggest the function gltexcoordpointer. In my example I have a row of squares each one is given a random texture. I put all the random textures into the super-texture. Now the problem is I can't seem to create a texcoordarray. I can't find any information on how gltexcoordpointer assings the selected sub-texture to the vertex coords. The vertexes would ideally be drawn using triangle_strip, but triangles will work as well.
Jesse
问问题
2410 次
2 回答
1
glTexCoordPointer
如果你想渲染纹理,你必须使用压缩或其他方式,我认为。但是,如果您想在其 UV 坐标系内移动您的纹理,您可以随时完全自由地操作纹理坐标数组中的各个条目。我使用这样的功能:
- (void) shiftTextureUVY:(float)shift {
textureVertices[1] += shift;
textureVertices[3] += shift;
textureVertices[5] += shift;
textureVertices[7] += shift;
}
- (void) shiftTextureUVX:(float)shift {
textureVertices[0] += shift;
textureVertices[2] += shift;
textureVertices[4] += shift;
textureVertices[6] += shift;
}
制作一个基本TextureAtlas
类,使用GL_TRIANGLE_STRIP
. 我想你可能会变得非常时髦,并用类似的方法进行反射和扭曲。
于 2009-11-09T04:49:30.577 回答
0
gltexcoorpointer 以 1-1 的方式分配纹理坐标。所以我不得不画成三角形并重复许多顶点。我无法共享顶点的原因是共享顶点具有相同的纹理坐标。
于 2009-03-28T17:40:04.827 回答