OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 7:03 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 36 posts ]  Go to page Previous  1, 2, 3
Author Message
 Post subject: Re: I can't get my VGA driver to work
PostPosted: Tue Jan 25, 2022 1:03 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
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:
framebuffer[mbi->framebuffer_pitch * y + 4 * x + 1]


Top
 Profile  
 
 Post subject: Re: I can't get my VGA driver to work
PostPosted: Tue Jan 25, 2022 2:16 pm 
Offline
Member
Member

Joined: Mon Nov 15, 2021 9:48 pm
Posts: 79
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:
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:
File comment: Closeup
unknown (1).png
unknown (1).png [ 306 Bytes | Viewed 555 times ]
unknown.png
unknown.png [ 15.21 KiB | Viewed 555 times ]
Top
 Profile  
 
 Post subject: Re: I can't get my VGA driver to work
PostPosted: Tue Jan 25, 2022 2:25 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
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.


Top
 Profile  
 
 Post subject: Re: I can't get my VGA driver to work
PostPosted: Tue Jan 25, 2022 2:35 pm 
Offline
Member
Member

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

Top
 Profile  
 
 Post subject: Re: I can't get my VGA driver to work
PostPosted: Tue Jan 25, 2022 2:41 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
Did you change the type of the variable, or just the cast?


Top
 Profile  
 
 Post subject: Re: I can't get my VGA driver to work
PostPosted: Tue Jan 25, 2022 3:45 pm 
Offline
Member
Member

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


Both, it works now! Thank you!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 36 posts ]  Go to page Previous  1, 2, 3

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 70 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group