Skip to content

Commit

Permalink
Merge branch 'main' of github.com:empyreanx/pico_headers
Browse files Browse the repository at this point in the history
  • Loading branch information
empyreanx committed Mar 4, 2025
2 parents 9c9f741 + 404997f commit 8b44cbb
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions pico_gfx.h
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,12 @@ void pg_destroy_pipeline(pg_pipeline_t* pipeline);
/**
* @brief Returns the shader associated with the pipeline
*/
pg_shader_t* pg_get_pipeline_shader(const pg_pipeline_t* pipeline);
pg_shader_t* pg_get_shader(const pg_pipeline_t* pipeline);

/**
* @brief Returns the blend mode associated with the pipeline
*/
const pg_blend_mode_t* pg_get_blend_mode(const pg_pipeline_t* pipeline);

/**
* @brief Texture creation options
Expand Down Expand Up @@ -928,6 +933,8 @@ struct pg_pipeline_t
sg_pipeline handle;
size_t element_size;
bool indexed;
bool blend_enabled;
pg_blend_mode_t blend_mode;
pg_shader_t* shader;
};

Expand Down Expand Up @@ -1334,8 +1341,13 @@ pg_pipeline_t* pg_create_pipeline(pg_ctx_t* ctx,

desc.primitive_type = pg_map_primitive(opts->primitive);

pipeline->blend_enabled = false;

if (opts->blend_enabled)
{
pipeline->blend_enabled = true;
pipeline->blend_mode = opts->blend;

const pg_blend_mode_t* blend_mode = &opts->blend;
desc.colors[0].blend.enabled = true;
desc.colors[0].blend.src_factor_rgb = pg_map_blend_factor(blend_mode->color_src);
Expand Down Expand Up @@ -1381,12 +1393,22 @@ void pg_destroy_pipeline(pg_pipeline_t* pipeline)
PICO_GFX_FREE(pipeline, pipeline->ctx->mem_ctx);
}

pg_shader_t* pg_get_pipeline_shader(const pg_pipeline_t* pipeline)
pg_shader_t* pg_get_shader(const pg_pipeline_t* pipeline)
{
PICO_GFX_ASSERT(pipeline);
return pipeline->shader;
}

const pg_blend_mode_t* pg_get_blend_mode(const pg_pipeline_t* pipeline)
{
PICO_GFX_ASSERT(pipeline);

if (pipeline->blend_enabled)
return &pipeline->blend_mode;
else
return NULL;
}

pg_shader_t* pg_create_shader_internal(pg_ctx_t* ctx, pg_shader_internal_t internal)
{
pg_shader_t* shader = PICO_GFX_MALLOC(sizeof(pg_shader_t), ctx->mem_ctx);
Expand Down

0 comments on commit 8b44cbb

Please sign in to comment.