add uv to vertex format and remove it from instance

This commit is contained in:
Sven Balzer
2025-09-25 08:04:16 +02:00
parent 8633cff3cb
commit dcd40b6394
2 changed files with 14 additions and 28 deletions
+11 -17
View File
@@ -109,13 +109,14 @@ enum Settings_Category {
struct Vertex {
V3 pos;
V2 uv;
};
static Vertex vertices[] = {
{{ -0.5f, 0.5f }},
{{ -0.5f, -0.5f }},
{{ 0.5f, -0.5f }},
{{ 0.5f, 0.5f }},
{{ -0.5f, 0.5f }, { 0.0f, 0.0f }},
{{ -0.5f, -0.5f }, { 0.0f, 1.0f }},
{{ 0.5f, -0.5f }, { 1.0f, 1.0f }},
{{ 0.5f, 0.5f }, { 1.0f, 0.0f }},
};
static Uint16 indices[] = {
@@ -170,11 +171,9 @@ static Uint16 grid_indices[] = {
struct Instance {
V2 pos;
V4 uv0uv1;
V4 uv2uv3;
};
static Instance player_instance = { { 0.0f, 0.0f }, { 0, 0, 1, 0 }, { 1, 1, 0, 1 }};
static Instance player_instance = {{ 0.0f, 0.0f }};
struct Map {
Sint32 width;
@@ -745,24 +744,19 @@ static bool recreate_graphics_pipelines() {
.offset = offsetof(Vertex, pos),
.shaderLocation = 0,
},
{
.format = WGPUVertexFormat_Float32x2,
.offset = offsetof(Vertex, uv),
.shaderLocation = 1,
},
};
WGPUVertexAttribute instance_buffer_attributes[] = {
{
.format = WGPUVertexFormat_Float32x2,
.offset = offsetof(Instance, pos),
.shaderLocation = 1,
},
{
.format = WGPUVertexFormat_Float32x4,
.offset = offsetof(Instance, uv0uv1),
.shaderLocation = 2,
},
{
.format = WGPUVertexFormat_Float32x4,
.offset = offsetof(Instance, uv2uv3),
.shaderLocation = 3,
},
};
WGPUVertexBufferLayout vertex_buffer_layouts[] = {