Declarations ​
pascal
function WrapPow2(Value, Max: Integer): Integer; overload;
function WrapPow2(Value, Min, Max: Integer): Integer; overload;Overload Details
Overload 1 ​
pascal
function WrapPow2(Value, Max: Integer): Integer; overload;Wraps an integer value to range [0..Max] where Max+1 is a power of two.
| Parameter | Type | Description |
|---|---|---|
Value | Integer | Integer value to wrap. |
Max | Integer | Inclusive upper bound (where Max+1 is a power of 2, e.g. 3, 7, 15, 255). |
| Type | Description |
|---|---|
Integer | Wrapped integer within range [0..Max]. |
Overload 2 ​
pascal
function WrapPow2(Value, Min, Max: Integer): Integer; overload;Wraps an integer value to range [Min..Max] where Max-Min+1 is a power of two.
| Parameter | Type | Description |
|---|---|---|
Value | Integer | Integer value to wrap. |
Min | Integer | Inclusive lower bound. |
Max | Integer | Inclusive upper bound (where Max-Min+1 is a power of 2). |
| Type | Description |
|---|---|
Integer | Wrapped integer within range [Min..Max]. |
Description ​
WrapPow2 provides accelerated bitwise wrapping for power-of-two dimensions (e.g., textures of width/height 4, 8, 16, 32, 64, 128, 256, 512, 1024). It replaces division/modulo operations with fast bitwise AND masking (Value and Max).