我试图找到一些代码,但发现只是过时的。我只制作了 verts & indices 数组(希望它们是正确的):
const SDL_Point blocksCount = { 4, 16 }; //I have texture with 4x16 squares 8x8 px.
f32 *verts = new f32[(blocksCount.x + 1) * (blocksCount.y + 1) * 2];
for (f32 y = 1; y >= -1; y -= 0.125f) //So I can automatize.
for (f32 x = -1; x <= 1; x += 0.5f)
{
static u32 i = 0;
verts[i] = x;
i++;
verts[i] = y;
i++;
}
u16 *indices = new u16[blocksCount.x * blocksCount.y * 4];
for (s32 y = 0; y < blocksCount.y; y++) //I've used TRIANGLE_STRIP.
for (s32 x = 0; x < blocksCount.x; x++)
{
static u32 i = 0;
indices[i] = x + y * (blocksCount.x + 1);
indices[i + 1] = x + 1 + blocksCount.x + y * (blocksCount.x + 1);
indices[i + 2] = x + 1 + y * (blocksCount.x + 1);
indices[i + 3] = x + 2 + blocksCount.x + y * (blocksCount.x + 1);
i += 4;
}
下一个是什么?我需要一些 SDL 2 和 OpenGL 4+ 的代码。也可以接受新的想法。