Skip to content

Instantly share code, notes, and snippets.

@Lisoph
Last active April 5, 2018 08:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Lisoph/8c39aa5a78f73a124f68dbd2552ebc51 to your computer and use it in GitHub Desktop.
Save Lisoph/8c39aa5a78f73a124f68dbd2552ebc51 to your computer and use it in GitHub Desktop.
Dithering based fading in Quake 2
// https://github.com/id-Software/Quake-2/blob/372afde46e7defc9dd2d719a1732b8ace1fa096e/ref_soft/r_draw.c#L428
void Draw_FadeScreen (void)
{
int x,y;
byte *pbuf;
int t;
for (y=0 ; y<vid.height ; y++)
{
pbuf = (byte *)(vid.buffer + vid.rowbytes*y);
t = (y & 1) << 1;
for (x=0 ; x<vid.width ; x++)
{
if ((x & 3) != t)
pbuf[x] = 0;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment