This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#define FRAMEBUFFER_HEIGHT 256 | |
#define FRAMEBUFFER_WIDTH 256 | |
/** 24BPP Pixel */ | |
typedef struct pixel { | |
unsigned char r; | |
unsigned char g; | |
unsigned char b; | |
} pixel; | |
int main(int argc, char **argv) { | |
pixel** framebuffer; | |
framebuffer = (pixel**) malloc (sizeof(pixel*) * FRAMEBUFFER_WIDTH); | |
for (int i = 0; i < FRAMEBUFFER_WIDTH; i++) { | |
framebuffer[i] = (pixel*) malloc (sizeof(pixel) * FRAMEBUFFER_HEIGHT); | |
} | |
for (int x = 0; x < FRAMEBUFFER_WIDTH; x++) { | |
for (int y = 0; y < FRAMEBUFFER_HEIGHT; y++) { | |
framebuffer[x][y].r = 255; | |
framebuffer[x][y].g = 0; | |
framebuffer[x][y].b = 25; | |
printf("R: %d\n", framebuffer[x][y].r); | |
printf("G: %d\n", framebuffer[x][y].g); | |
printf("B: %d\n", framebuffer[x][y].b); | |
} | |
} | |
for (int i = 0; i < FRAMEBUFFER_WIDTH; i++) { | |
free(framebuffer[i]); | |
} | |
free(framebuffer); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment