Page 3 of 3
Re: I can't get my VGA driver to work
Posted: Tue Jan 25, 2022 1:03 pm
by Octocontrabass
Caffeine wrote:Here is my code - this works:
I don't think it works. You defined framebuffer as a pointer to a 32-bit integer instead of an 8-bit integer, so you should see it plotting pixels at the wrong locations.
Caffeine wrote:Sorry, but I am a little confused as to how to do this. Again, sorry for the beginner questions.
To access the second byte of the pixel, add 1 to the index. Like this:
Code: Select all
framebuffer[mbi->framebuffer_pitch * y + 4 * x + 1]
Re: I can't get my VGA driver to work
Posted: Tue Jan 25, 2022 2:16 pm
by Caffeine
Octocontrabass wrote:Caffeine wrote:Here is my code - this works:
I don't think it works. You defined framebuffer as a pointer to a 32-bit integer instead of an 8-bit integer, so you should see it plotting pixels at the wrong locations.
Caffeine wrote:Sorry, but I am a little confused as to how to do this. Again, sorry for the beginner questions.
To access the second byte of the pixel, add 1 to the index. Like this:
Code: Select all
framebuffer[mbi->framebuffer_pitch * y + 4 * x + 1]
Thanks! This worked! Sorry I didn't understand. When plotting more than 1 pixel there are these huge gaps between the pixels (See screenshot below). How do I fix this?
Re: I can't get my VGA driver to work
Posted: Tue Jan 25, 2022 2:25 pm
by Octocontrabass
I already explained why the pixels are at the wrong locations.
Octocontrabass wrote:You defined framebuffer as a pointer to a 32-bit integer instead of an 8-bit integer, so you should see it plotting pixels at the wrong locations.
Re: I can't get my VGA driver to work
Posted: Tue Jan 25, 2022 2:35 pm
by Caffeine
Octocontrabass wrote:I already explained why the pixels are at the wrong locations.
Octocontrabass wrote:You defined framebuffer as a pointer to a 32-bit integer instead of an 8-bit integer, so you should see it plotting pixels at the wrong locations.
Is this a fix?
Code: Select all
framebuffer = (unsigned char *)mbi->framebuffer_addr; // Get the framebuffer address
If so it still displays it in the wrong location. (I change it from unsigned int * to unsigned char*)
EDIT: Nevermind I understand now. It works! Thank you!
Re: I can't get my VGA driver to work
Posted: Tue Jan 25, 2022 2:41 pm
by Octocontrabass
Did you change the type of the variable, or just the cast?
Re: I can't get my VGA driver to work
Posted: Tue Jan 25, 2022 3:45 pm
by Caffeine
Octocontrabass wrote:Did you change the type of the variable, or just the cast?
Both, it works now! Thank you!