Skip to content

Instantly share code, notes, and snippets.

@mlabbe
Last active August 29, 2015 14:06
Show Gist options
  • Save mlabbe/c0957e39c5af5fa7ed2c to your computer and use it in GitHub Desktop.
Save mlabbe/c0957e39c5af5fa7ed2c to your computer and use it in GitHub Desktop.
Uint32 mask = 0;
switch ( numChannels )
{
case 1:
mask = 0xFF000000;
break;
case 2:
mask = 0xFFFF0000;
break;
case 3:
mask = 0xFFFFFF00;
break;
case 4:
mask = 0xFFFFFFFF;
break;
default:
Assert(0);
}
const Uint32 WRITEVAL = inVal & mask;
// sample inner loop random access pixel wmrite
Uint32 *px = (Uint32*)(channels + (j * numChannels) + (pt.y * pitch));
*px |= WRITEVAL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment