Skip to content

Instantly share code, notes, and snippets.

@unitycoder
Created December 20, 2022 11:46
Show Gist options
  • Select an option

  • Save unitycoder/e1d28c19fc205ab8c32c4e5271a6abdc to your computer and use it in GitHub Desktop.

Select an option

Save unitycoder/e1d28c19fc205ab8c32c4e5271a6abdc to your computer and use it in GitHub Desktop.
Draw 2D Grid (without If's or Ternary)
int size = 10;
for (int x = 0; x < window_width; x++)
{
for (int y = 0; y < window_height; y++)
{
int i = window_width * y + x;
//color_buffer[i] = (x % size) * (y % size) ? 0x00000000 : 0xFFFFFFFF;
color_buffer[i] = ~(1 - (x % size) * (y % size)) & 0xFFFFFFFF;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment