私はこれをやってしまった:
@property(nonatomic, assign) int *indices;
@property(nonatomic, assign) GLuint vertexBuffer; // good
@property(assign) GLKVector2 position;
@property(assign) GLKVector2 velocity;
- (id)initWithVertices: (SceneVertex [])vertices size: (uint) size; // very good
- (void)render;
そしてこれ:
- (id) initWithVertices:(SceneVertex [])vertices size:(uint)size
{
if (self = [super init])
{
glGenBuffers(1, &_vertexBuffer);
glBindBuffer(GL_ARRAY_BUFFER, _vertexBuffer);
glBufferData(GL_ARRAY_BUFFER, size * sizeof(SceneVertex), vertices, GL_STATIC_DRAW);
glEnableVertexAttribArray(GLKVertexAttribPosition);
int stride = sizeof(GLKVector3) * 2;
glVertexAttribPointer(GLKVertexAttribPosition, 3, GL_FLOAT, GL_FALSE, stride, BUFFER_OFFSET(0));
glEnableVertexAttribArray(GLKVertexAttribNormal);
glVertexAttribPointer(GLKVertexAttribNormal, 3, GL_FLOAT, GL_FALSE, stride, BUFFER_OFFSET(sizeof(GLKVector3)));
}
return self;
}
そして、それはうまくいきました。これで、すべての情報が各オブジェクトに含まれるようになりました。素晴らしい!