GFX Capabilities
Dragonsoulj

I am having trouble figuring out how to properly use the flags for the gfx_capabilities. Can someone show me how? i.e. How the flags are supposed to be used.

Note: I am using C++ and the Allegro Library (I know that last on should be obvious, but I never know.)

Thanks,
Dragonsoulj

Todd Cope

This:

if((gfx_capabilities & GFX_CAN_TRIPLE_BUFFER) && (gfx_capabilities & GFX_HW_FILL))
{
    do_whatever();
}

Or:

if((gfx_capabilities & (GFX_CAN_TRIPLE_BUFFER | GFX_HW_FILL)))
{
    do_whatever();
}

Each flag is determined by whether or not a certain bit is set in gfx_capabilities. To check if a certain bit is set you use the logical and (&) operator with the righthand operand being a number that has the bits set that you want.

The logical or (|) can be used to combine the bits of 2 numbers into 1. If you have a number that has the first two bits set and another with the third and fourth bits set and or them together you will get a number with the first four bits set.

Dragonsoulj

Is there any way to set a bit yourself?

Thomas Fjellstrom
Quote:

Is there any way to set a bit yourself?

You can set it, but it won't mean anything. This variable is only there to tell you what's actually available. You should treat it as if its read only.

Dragonsoulj

Thanks. I think that clears it up. I will see if my code will work using them.

Peter Wang

Note that Todd's two examples are not equivalent though.

Todd Cope

Hmm, I can't see the difference.

Evert
Quote:

Hmm, I can't see the difference.

The second is true if either flag is set, the first if both are set.

Ron Ofir

Would it be true if you do something like (gfx_capabilities & (GFX_CAN_TRIPLE_BUFFER | GFX_HW_FILL)) > 0?

kazzmir

No it would be true if the result was equal to the combination of both flags:

if ( gfx_capabilities & (GFX_CAN_TRIPLE_BUFFER | GFX_HW_FILL) ==
 (GFX_CAN_TRIPLE_BUFFER | GFX_HW_FILL) ){
  ..
}

Todd Cope
Quote:

The second is true if either flag is set, the first if both are set.

Okay, I see now. Thanks.

Thread #587378. Printed from Allegro.cc