Skip to content

Support Alpha blending in sokol_gl.h#1266

Open
danielchasehooper wants to merge 1 commit into
floooh:masterfrom
danielchasehooper:patch-3
Open

Support Alpha blending in sokol_gl.h#1266
danielchasehooper wants to merge 1 commit into
floooh:masterfrom
danielchasehooper:patch-3

Conversation

@danielchasehooper

Copy link
Copy Markdown
Contributor

sokol_gl's api accepts colors with alpha, so blending should probably be enabled

Comment thread util/sokol_gl.h
@@ -3331,6 +3331,9 @@ static void _sgl_init_context(sgl_context ctx_id, const sgl_context_desc_t* in_d
sg_pipeline_desc def_pip_desc;
_sgl_clear(&def_pip_desc, sizeof(def_pip_desc));
def_pip_desc.depth.write_enabled = true;

@floooh floooh May 20, 2025

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It probably makes sense to remove this depth.write_enabled = true line when alpha-blending is enabled by default, and also remove this code in _sgl_init_pipeline() since it wouldn't have any purpose then:

sokol/util/sokol_gl.h

Lines 3146 to 3148 in 202f41b

if (ctx_desc->depth_format == SG_PIXELFORMAT_NONE) {
desc.depth.write_enabled = false;
}

The rest of the default pipeline state is configured for 2D rendering anyway, which IMHO makes it ok to switch the default pipeline state to alpha blended (e.g. the common setup for rendering alpha-blended 2D sprites - which seems to be what sokol_gl.h is commonly used for)

@floooh floooh self-assigned this May 20, 2025
@floooh floooh moved this to Review in sokol todo May 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Review

Development

Successfully merging this pull request may close these issues.

2 participants