gpt4 book ai didi

c++ - 如何修复 stb_image 库的 alpha

转载 作者:行者123 更新时间:2023-11-30 04:17:10 25 4
gpt4 key购买 nike

我正在使用 stb_image.c 将数据字节加载到 opengl。但是,当我尝试使用 alpha channel 加载 png 文件时,我遇到了一个问题 enter image description here

现在白色区域应该是透明的,虽然它只清除了一小部分。知道是什么导致了这种行为吗?

enter image description here

Photoshop 直方图

最佳答案

您正在学习 Tom Dalling OpenGL 教程吗? ^^

我不知道您是否仍在寻找解决方案,但无论如何我都会去:实际上,我在学习该类(class)时遇到了同样的问题,但通过将 glBlendFunc 与 sfactor GL_SRC_ALPHA 和 dfactor GL_ONE_MINUS_SRC_ALPHA 一起使用,它对我有用。这些是 OpenGL 似乎至少在文档中推荐的参数:glBlendFunc

Transparency is best implemented using blend function(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) with primitives sorted from farthest to nearest. Note that this transparency calculation does not require the presence of alpha bitplanes in the frame buffer.

关于c++ - 如何修复 stb_image 库的 alpha,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17263288/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com