I can't get my VGA driver to work

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Octocontrabass
Member
Member
Posts: 5563
Joined: Mon Mar 25, 2013 7:01 pm

Re: I can't get my VGA driver to work

Post 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]
Caffeine
Member
Member
Posts: 79
Joined: Mon Nov 15, 2021 9:48 pm

Re: I can't get my VGA driver to work

Post 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?
Attachments
Closeup
Closeup
unknown (1).png (306 Bytes) Viewed 917 times
unknown.png
Octocontrabass
Member
Member
Posts: 5563
Joined: Mon Mar 25, 2013 7:01 pm

Re: I can't get my VGA driver to work

Post 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.
Caffeine
Member
Member
Posts: 79
Joined: Mon Nov 15, 2021 9:48 pm

Re: I can't get my VGA driver to work

Post 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!
Last edited by Caffeine on Tue Jan 25, 2022 2:42 pm, edited 1 time in total.
Octocontrabass
Member
Member
Posts: 5563
Joined: Mon Mar 25, 2013 7:01 pm

Re: I can't get my VGA driver to work

Post by Octocontrabass »

Did you change the type of the variable, or just the cast?
Caffeine
Member
Member
Posts: 79
Joined: Mon Nov 15, 2021 9:48 pm

Re: I can't get my VGA driver to work

Post by Caffeine »

Octocontrabass wrote:Did you change the type of the variable, or just the cast?
Both, it works now! Thank you!
Post Reply