Skip to content

Commit

Permalink
pico_gfx: renamed vertex attribute format enums
Browse files Browse the repository at this point in the history
  • Loading branch information
empyreanx committed Jul 6, 2024
1 parent 689aa1b commit c85296f
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 24 deletions.
8 changes: 4 additions & 4 deletions examples_pico_gfx/particles.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,17 +160,17 @@ int main(int argc, char *argv[])
},
.attrs =
{
[ATTR_vs_a_pos] = { .format = PG_VFORMAT_FLOAT2,
[ATTR_vs_a_pos] = { .format = PG_VERTEX_FORMAT_FLOAT2,
.offset = offsetof(vertex_t, pos) },

[ATTR_vs_a_uv] = { .format = PG_VFORMAT_FLOAT2,
[ATTR_vs_a_uv] = { .format = PG_VERTEX_FORMAT_FLOAT2,
.offset = offsetof(vertex_t, uv) },

[ATTR_vs_a_inst_pos] = { .format = PG_VFORMAT_FLOAT2,
[ATTR_vs_a_inst_pos] = { .format = PG_VERTEX_FORMAT_FLOAT2,
.offset = offsetof(particle_t, pos),
.buffer_index = 1 },

[ATTR_vs_a_inst_color] = { .format = PG_VFORMAT_FLOAT4,
[ATTR_vs_a_inst_color] = { .format = PG_VERTEX_FORMAT_FLOAT4,
.offset = offsetof(particle_t, color),
.buffer_index = 1 },
},
Expand Down
22 changes: 16 additions & 6 deletions examples_pico_gfx/quad.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,14 @@ int main(int argc, char *argv[])
{
.attrs =
{
[ATTR_vs_a_pos] = { .format = PG_VFORMAT_FLOAT3, .offset = offsetof(vertex_t, pos) },
[ATTR_vs_a_color] = { .format = PG_VFORMAT_FLOAT4, .offset = offsetof(vertex_t, color) },
[ATTR_vs_a_uv] = { .format = PG_VFORMAT_FLOAT2, .offset = offsetof(vertex_t, uv) },
[ATTR_vs_a_pos] = { .format = PG_VERTEX_FORMAT_FLOAT3,
.offset = offsetof(vertex_t, pos) },

[ATTR_vs_a_color] = { .format = PG_VERTEX_FORMAT_FLOAT4,
.offset = offsetof(vertex_t, color) },

[ATTR_vs_a_uv] = { .format = PG_VERTEX_FORMAT_FLOAT2,
.offset = offsetof(vertex_t, uv) },
},
},
});
Expand All @@ -145,9 +150,14 @@ int main(int argc, char *argv[])
{
.attrs =
{
[ATTR_vs_a_pos] = { .format = PG_VFORMAT_FLOAT3, .offset = offsetof(vertex_t, pos) },
[ATTR_vs_a_color] = { .format = PG_VFORMAT_FLOAT4, .offset = offsetof(vertex_t, color) },
[ATTR_vs_a_uv] = { .format = PG_VFORMAT_FLOAT2, .offset = offsetof(vertex_t, uv) },
[ATTR_vs_a_pos] = { .format = PG_VERTEX_FORMAT_FLOAT3,
.offset = offsetof(vertex_t, pos) },

[ATTR_vs_a_color] = { .format = PG_VERTEX_FORMAT_FLOAT4,
.offset = offsetof(vertex_t, color) },

[ATTR_vs_a_uv] = { .format = PG_VERTEX_FORMAT_FLOAT2,
.offset = offsetof(vertex_t, uv) },
},
},
.indexed = true,
Expand Down
6 changes: 3 additions & 3 deletions examples_pico_gfx/scenegraph.c
Original file line number Diff line number Diff line change
Expand Up @@ -415,13 +415,13 @@ int main(int argc, char *argv[])
{
.attrs =
{
[ATTR_vs_a_pos] = { .format = PG_VFORMAT_FLOAT3,
[ATTR_vs_a_pos] = { .format = PG_VERTEX_FORMAT_FLOAT3,
.offset = offsetof(vertex_t, pos) },

[ATTR_vs_a_color] = { .format = PG_VFORMAT_FLOAT4,
[ATTR_vs_a_color] = { .format = PG_VERTEX_FORMAT_FLOAT4,
.offset = offsetof(vertex_t, color) },

[ATTR_vs_a_uv] = { .format = PG_VFORMAT_FLOAT2,
[ATTR_vs_a_uv] = { .format = PG_VERTEX_FORMAT_FLOAT2,
.offset = offsetof(vertex_t, uv) },
},
},
Expand Down
22 changes: 11 additions & 11 deletions pico_gfx.h
Original file line number Diff line number Diff line change
Expand Up @@ -521,11 +521,11 @@ void pg_set_uniform_block(pg_shader_t* shader, const char* name, const void* dat
*/
typedef enum
{
PG_VFORMAT_INVALID,
PG_VFORMAT_FLOAT,
PG_VFORMAT_FLOAT2,
PG_VFORMAT_FLOAT3,
PG_VFORMAT_FLOAT4,
PG_VERTEX_FORMAT_INVALID,
PG_VERTEX_FORMAT_FLOAT,
PG_VERTEX_FORMAT_FLOAT2,
PG_VERTEX_FORMAT_FLOAT3,
PG_VERTEX_FORMAT_FLOAT4,
//FIXME: Expand this list
} pg_vertex_format_t;

Expand Down Expand Up @@ -1284,11 +1284,11 @@ static sg_vertex_format pg_map_vertex_format(pg_vertex_format_t format)
{
switch (format)
{
case PG_VFORMAT_INVALID: return SG_VERTEXFORMAT_INVALID;
case PG_VFORMAT_FLOAT: return SG_VERTEXFORMAT_FLOAT;
case PG_VFORMAT_FLOAT2: return SG_VERTEXFORMAT_FLOAT2;
case PG_VFORMAT_FLOAT3: return SG_VERTEXFORMAT_FLOAT3;
case PG_VFORMAT_FLOAT4: return SG_VERTEXFORMAT_FLOAT4;
case PG_VERTEX_FORMAT_INVALID: return SG_VERTEXFORMAT_INVALID;
case PG_VERTEX_FORMAT_FLOAT: return SG_VERTEXFORMAT_FLOAT;
case PG_VERTEX_FORMAT_FLOAT2: return SG_VERTEXFORMAT_FLOAT2;
case PG_VERTEX_FORMAT_FLOAT3: return SG_VERTEXFORMAT_FLOAT3;
case PG_VERTEX_FORMAT_FLOAT4: return SG_VERTEXFORMAT_FLOAT4;
default: PICO_GFX_ASSERT(false);
}
}
Expand All @@ -1297,7 +1297,7 @@ static void pg_set_attributes(const pg_pipeline_layout_t* layout, sg_pipeline_de
{
for (int slot = 0; slot < PG_MAX_VERTEX_ATTRIBUTES; slot++)
{
if (layout->attrs[slot].format != PG_VFORMAT_INVALID)
if (layout->attrs[slot].format != PG_VERTEX_FORMAT_INVALID)
{
desc->layout.attrs[slot] = (sg_vertex_attr_state)
{
Expand Down

0 comments on commit c85296f

Please sign in to comment.