|
GFX Capabilities |
Dragonsoulj
Member #7,678
August 2006
|
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, |
Todd Cope
Member #998
November 2000
|
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
Member #7,678
August 2006
|
Is there any way to set a bit yourself? |
Thomas Fjellstrom
Member #476
June 2000
|
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
Member #7,678
August 2006
|
Thanks. I think that clears it up. I will see if my code will work using them. |
Peter Wang
Member #23
April 2000
|
Note that Todd's two examples are not equivalent though.
|
Todd Cope
Member #998
November 2000
|
Hmm, I can't see the difference. |
Evert
Member #794
November 2000
|
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
Member #2,357
May 2002
|
Would it be true if you do something like (gfx_capabilities & (GFX_CAN_TRIPLE_BUFFER | GFX_HW_FILL)) > 0? |
kazzmir
Member #1,786
December 2001
|
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
Member #998
November 2000
|
Quote: The second is true if either flag is set, the first if both are set. Okay, I see now. Thanks. |
|