Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Draw bitmap brighter without shaders?

This thread is locked; no one can reply to it. rss feed Print
Draw bitmap brighter without shaders?
jmasterx
Member #11,410
October 2009

I basically want to do the opposite of draw tinted bitmap. With that, I can make things darker which looks great, but I have some 512x512 bitmaps that I hover over and I'd like a bright hover state without wasting vram.

I'll use shaders if I have to, but it would be nice if there was a way to do it without it. I am using 5.1.7

I tried additive blending, but it didnt do much:

    al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ONE);
      g->drawTintedScaledRotatedSprite(img,Color(darkness * c.getR(),
        darkness * c.getG(),darkness * c.getB()),img->getWidth() / 2, img->getHeight() / 2,
        r.getX() + (r.getWidth() / 2),r.getY() + (r.getHeight() / 2),
        (float)scale,
        (float)scale,ang,0);
      al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_INVERSE_ALPHA);

Elias
Member #358
May 2000

Draw it normal first, then another one on top with additive.

--
"Either help out or stop whining" - Evert

Kris Asick
Member #1,424
July 2001

Performance-wise, a gamma correction or simple linear brightening shader would probably be faster than drawing the same bitmap twice, though it is obviously the more complicated solution and not worth the effort if you're only drawing a few things this way.

--- Kris Asick (Gemini)
--- http://www.pixelships.com

Winfield
Member #15,244
July 2013
avatar

FWIW, shaders aren't really that much of a pain - there are several excellent examples that come with Allegro 5.1, though the docs aren't really up to scratch yet. I'd look into using shaders unless your needs are very basic, as it's both more performant and more flexible - you'll be able to vary the level of brightness with arbitrary steps, which wouldn't be the case with doubling up additive blends.

pkrcel
Member #14,001
February 2012

FWIW, the main problem I found with shaders (in GLSL) is that they are quite poorly documented.

I've followed the first parts of http://www.arcsynthesis.org/gltut/ but haven't yet got into it.

It is unlikely that Google shares your distaste for capitalism. - Derezo
If one had the eternity of time, one would do things later. - Johan Halmén

OICW
Member #4,069
November 2003
avatar

There's a book dedicated to GLSL and brief overview is written as an appendix of the OpenGL redbook (or at least was in the 4th edition or whichever I have in possesion). That's hardly poor documentation.

[My website][CppReference][Pixelate][Allegators worldwide][Who's online]
"Final Fantasy XIV, I feel that anything I could say will be repeating myself, so I'm just gonna express my feelings with a strangled noise from the back of my throat. Graaarghhhh..." - Yahtzee
"Uhm... this is a.cc. Did you honestly think this thread WOULDN'T be derailed and ruined?" - BAF
"You can discuss it, you can dislike it, you can disagree with it, but that's all what you can do with it"

Elias
Member #358
May 2000

I found the GLSL specification to be most excellent documentation. Basically covers... everything.

--
"Either help out or stop whining" - Evert

pkrcel
Member #14,001
February 2012

Well, unfortunately I haven't dug into it nearly enuff, but I remember definitely not being overwhelmed.

The REAL problem is time, as usual.

It is unlikely that Google shares your distaste for capitalism. - Derezo
If one had the eternity of time, one would do things later. - Johan Halmén

Go to: