First off, are you using grub and multiboot to load your kernel? If so, then the VESA information(along with the video memory address(also known as the linear framebuffer address), will be copied into the multiboot header struct which you can access in your "kernel.c" file. The framebuffer address is stored inside the struct at index 22. If you want the full spec on multiboot and its structs, you can view them here: https://www.gnu.org/software/grub/manual/multiboot/multiboot.html
otherwise, you can do this inside your "kernel.c" file:
void kmain(unsigned int* MultiBootHeaderStruct)
{
//color code macros:
#define red 0xFF0000
#define green 0x00FF00
#define blue 0x0000FF
/*store the framebuffer address inside a new pointer
the framebuffer is located at MultiBootHeaderStruct[22]*/
unsigned int* framebuffer = (unsigned int*)MultiBootHeaderStruct[22];
/*now to place a pixel at a specific screen position(screen index starts at
the top left of the screen which is at index 0), write a color value
to the framebuffer pointer with a specified index*/
//Sample Code:
framebuffer[0] = red; //writes a red pixel(0xFF0000) at screen index 0
framebuffer[1] = green; //writes a green pixel(0x00FF00) at screen index 1
framebuffer[2] = blue; //writes a blue pixel(0x0000FF) at screen index 2
/*this code should plot 3 pixels at the very top left of the screen
one red, one green and one blue. If you want a specific color you can
use the link I will provide at the bottom.*/
//Sample code to fil the entire screen blue:
int totalPixels = 480000; //800x600 = 480000 pixels total
//loop through each pixel and write a blue color value to it
for (int i = 0; i < totalPixels; i++)
{
framebuffer[i] = blue; //0x0000FF is the blue color value
}
}
A useful color code generator: https://html-color-codes.info/
Note. Do not use the "#" hashtag that is placed in front of the color that you generate, only use the values after it and place the color values in your code after a "0x", meaning #FF0000 should be placed in your code as: 0xFF0000
I hope this helped. I also struggled with VESA and I want to help anyone that is also struggling with it. if you want to contact me directly for help you can add me on discord and I can try to help as best as I can. My username and tag is: Yeon#7984