Draw Grid
Define Color buffer:
c code snippet start
uint32_t *color_buffer = (uint32_t*) malloc(sizeof(uint32_t) * window_width * window_height);c code snippet end
In my case, window size set as 800 x 600. Define an uint32t represent as 4 bytes * 800 * 600 size buffer array.
Draw 10 X 10 grid in SDL
c code snippet start
void draw_grid(void) {
for(int y = 0; y < window_height; y += 10) {
for(int x = 0; x < window_width; x ++) {
color_buffer[(window_width * y) + x ] = 0xFFFFFFFF;
}
}
for(int x = 0; x < window_width; x += 10) {
for(int y = 0; y < window_height; y ++) {
color_buffer[(window_width * y) + x ] = 0xFFFFFFFF;
}
}
}c code snippet end
