VGA Color not Working
Posted: Thu Feb 03, 2022 6:51 pm
Hi, I am trying to be able to plot pixels of any color using hexadecimal values as input. Any tips on how to do this?
My code so far:
Changing the color value between 0-255 changes how bright it is. Anything above 255 does not work.
My code so far:
Code: Select all
void plotPixle(int x, int y, unsigned char color) {
/*
Plot a pixle in a certain color to the screen
Parameters
----------
x : int
The x position of the pixle
y : int
The y position of the pixle
color : unsigned char
The color inputted in hexadecimal
*/
switch (mbi->framebuffer_bpp) {
case 8:
for (int i = 0; i < 4; i++) { framebuffer[mbi->framebuffer_pitch * y + 1 * x + i] = 4; }
for (int i = 0; i < 4; i++) { framebuffer[mbi->framebuffer_pitch * (y + i) + 1 * x] = 4; }
break;
case 15:
break;
case 16:
for (int i = 0; i < 4; i++) { framebuffer[mbi->framebuffer_pitch * y + 2 * x + i] = color; }
break;
case 24:
for (int i = 0; i < 4; i++) { framebuffer[mbi->framebuffer_pitch * y + 3 * x + i] = color; }
break;
case 32:
for (int i = 0; i < 4; i++) { framebuffer[mbi->framebuffer_pitch * y + 4 * x + i] = color; }
break;
default:
// error
break;
}
}