Differences
This shows you the differences between two versions of the page.
| Last revisionBoth sides next revision |
new:packing [2018/02/17 21:20] – created korshun | new:packing [2018/02/17 21:24] – korshun |
---|
All ACS integers are 32-bit. Value packing functions let you store four 8-bit integers or two 16-bit integers in one 32-bit ''int'' variable. This can be useful, for example, to store RGBA colors in a single variable. Or to store big arrays using less memory. | All ACS integers are 32-bit. Value packing functions let you store four 8-bit integers or two 16-bit integers in one 32-bit ''int'' variable. This can be useful, for example, to store RGBA colors in a single variable. Or to store big arrays using less memory. |
| |
===== Packing 8-bit integers ===== | ===== Packing 8-bit integers (bytes) ===== |
| |
''int PackBytes(int b1, int b2, int b3, int b4)'' returns a 32-bit integer containing 4 bytes. Byte values must be in [0, 255] range. | ''int PackBytes(int b1, int b2, int b3, int b4)'' returns a 32-bit integer containing 4 bytes. Byte values must be in [0, 255] range. |
</code> | </code> |
| |
| ===== Packing 16-bit integers (shorts) ===== |
| |
| ''int PackShorts(int short1, int short2)'' returns a 32-bit integer containing two 16-bit integers (shorts). Short values must be in [-32678. 32767] range. |
| |
| * ''int UnpackShort1(int packed)'' -- returns the first packed short. |
| * ''int UnpackShort2(int packed)'' -- returns the second packed short. |
| |