使用 Allegro 更改位图传输的亮度

发布于 2024-08-15 01:13:41 字数 195 浏览 3 评论 0原文

我正在使用 Allegro 游戏库制作瓷砖游戏。我希望瓷砖变得更加明亮。不幸的是 Allegro 没有“增亮”功能。然后我决定做的是将一个图块传输到缓冲区,然后对于它刚刚为该图块传输的每个像素,我增加了它们的 RGB 值并放置像素。最大的问题是它严重降低了我的帧速率,因为它做了两倍的工作。有什么方法可以实现这一点,而无需为每个图块提供稍微更亮的图块位图(这将是荒谬的)。谢谢

I'm using the Allegro game library to make a tile game. I want the tiles to get exponentially brighter. Unfortunately Allegro does not have a "Brighten" feature. What I then decided to do, was blit a tile to the buffer, then for each pixel that it just blited for that tile, I increased their rgb values and putpixel. The big problem with this is it severely decreased my framerate since it does twice as much work. Is there any way I can achieve this without having a tile bitmap for each tile that is slightly brighter (which would be ridiculous). Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

留蓝 2024-08-22 01:13:41

您可以使用:

draw_lit_sprite

它的作用是获取 BITMAP并使用之前必须使用此函数设置的“光”进行绘制:

set_trans_blender

所以基本上,你要做的是:

    //Init allegro code here
    init_allegro_stuff();

    //It takes as arguments red, green, blue, alpha
    //so in this case it's a white light
    set_trans_blender(255, 255, 255, 255);

    //Draws the sprite like draw_sprite but with intensity
    draw_lit_sprite(buffer, yourSprite, x, y, intensity); 

希望它有帮助:)

You can use:

draw_lit_sprite

what it does is take a BITMAP and draw it using a "light" that you have to set before by using this function:

set_trans_blender

so basically, what you have to do is:

    //Init allegro code here
    init_allegro_stuff();

    //It takes as arguments red, green, blue, alpha
    //so in this case it's a white light
    set_trans_blender(255, 255, 255, 255);

    //Draws the sprite like draw_sprite but with intensity
    draw_lit_sprite(buffer, yourSprite, x, y, intensity); 

hope it helps :)

暗喜 2024-08-22 01:13:41

调色板可能是这样的: http://alleg.sourceforge.net/stabledocs/en /alleg011.html

我对 Allegro 不太了解,但我知道在旧的 8 位游戏中,淡入淡出通常是通过更改渲染时显卡读取的颜色表来完成的,因此给出一种同时更新屏幕上许多像素的恒定时间方式。

希望有帮助:)

It might be possible with palettes: http://alleg.sourceforge.net/stabledocs/en/alleg011.html

I don't know much about Allegro, but I know that in the 8-bit games of old, fading is usually accomplished by altering the color table that the video card reads from when rendering, hence giving a constant-time way to update many pixels on the screen simultaneously.

Hope that helps :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文