OSDev.org

The Place to Start for Operating System Developers
It is currently Tue Apr 23, 2024 3:52 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: How can I write a RGBA color to a linear frame buffer?
PostPosted: Wed Apr 29, 2020 4:55 pm 
Offline
Member
Member
User avatar

Joined: Sun Jul 21, 2019 7:34 am
Posts: 300
Hi.
I'm trying to write a color with an alpha channel to LFB.
For example in my code I do this:
Code:
put_pixel_lfb_mem(50, 20, 0xFFFFFF);
put_pixel_lfb_mem(51, 20, 0x3FFFFFFF);


I expect the pixels to have different colors. But they are exactly the same.
How can I draw pixels with an alpha channel?
Thanks.


Top
 Profile  
 
 Post subject: Re: How can I write a RGBA color to a linear frame buffer?
PostPosted: Wed Apr 29, 2020 8:00 pm 
Offline
Member
Member

Joined: Mon Feb 02, 2015 7:11 pm
Posts: 898
mrjbom wrote:
How can I draw pixels with an alpha channel?


You just did. But putting an alpha value in the framebuffer is not going to do anything.

What do you expect to happen? Why would the colour be different? What should it be?

_________________
https://github.com/kiznit/rainbow-os


Top
 Profile  
 
 Post subject: Re: How can I write a RGBA color to a linear frame buffer?
PostPosted: Thu Apr 30, 2020 12:45 am 
Offline
Member
Member
User avatar

Joined: Fri Oct 03, 2008 4:13 am
Posts: 153
Location: Ogre, Latvia, EU
kzinti wrote:
What do you expect to happen? Why would the colour be different? What should it be?

You should be able to see what's behind the monitor, obviously :lol:

_________________
If something looks overcomplicated, most likely it is.


Top
 Profile  
 
 Post subject: Re: How can I write a RGBA color to a linear frame buffer?
PostPosted: Thu Apr 30, 2020 6:21 am 
Offline
Member
Member
User avatar

Joined: Sun Jul 21, 2019 7:34 am
Posts: 300
kzinti wrote:
You just did. But putting an alpha value in the framebuffer is not going to do anything.

Well, how can I achieve a transparency effect?


Top
 Profile  
 
 Post subject: Re: How can I write a RGBA color to a linear frame buffer?
PostPosted: Thu Apr 30, 2020 7:42 am 
Offline
Member
Member
User avatar

Joined: Sat Nov 22, 2014 6:33 pm
Posts: 934
Location: USA
mrjbom wrote:
kzinti wrote:
You just did. But putting an alpha value in the framebuffer is not going to do anything.

Well, how can I achieve a transparency effect?

You have to combine the two pixels yourself.

For example, even in 32-bit pixels, they are only 24-bits wide, eight each color. To create a transparent looking pixel, you have to read what is already there, then combine it with the new pixel and place it back.

Ben
- http://www.fysnet.net/the_graphical_user_interface.htm


Top
 Profile  
 
 Post subject: Re: How can I write a RGBA color to a linear frame buffer?
PostPosted: Thu Apr 30, 2020 1:13 pm 
Offline
Member
Member
User avatar

Joined: Fri Oct 27, 2006 9:42 am
Posts: 1925
Location: Athens, GA, USA
If helps any for you when looking into how to do this, the usual terms for this are 'alpha blending' or 'alpha compositing'. Technically speaking, alpha blending is a particular type of alpha compositing, but you'll sometimes see it used for other types of alpha compositing. It is related to the broader topic of image compositing, as well as loosely related to the issue of texturing.

As Ben said, this is something you'd have to do in software, at least for a generic video framebuffer. While the current generation of GPUs used in PCs do have hardware compositing, you would need a hardware-specific driver to use that, and you'd want to have a software method as a fallback, so it makes more sense for most hobby OS devs to stick to that.

There are a number of different algorithms for different types of alpha compositing, and each has uses in different situations.

Can you give us some idea of what you are trying to accomplish? I think is smell an XY problem in this, so more context is definitely called for.

_________________
Rev. First Speaker Schol-R-LEA;2 LCF ELF JAM POEE KoR KCO PPWMTF
Ordo OS Project
Lisp programmers tend to seem very odd to outsiders, just like anyone else who has had a religious experience they can't quite explain to others.


Last edited by Schol-R-LEA on Thu Apr 30, 2020 1:24 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: How can I write a RGBA color to a linear frame buffer?
PostPosted: Thu Apr 30, 2020 1:16 pm 
Offline
Member
Member
User avatar

Joined: Sun Jul 21, 2019 7:34 am
Posts: 300
BenLunt wrote:
mrjbom wrote:
kzinti wrote:
You just did. But putting an alpha value in the framebuffer is not going to do anything.

Well, how can I achieve a transparency effect?

You have to combine the two pixels yourself.

For example, even in 32-bit pixels, they are only 24-bits wide, eight each color. To create a transparent looking pixel, you have to read what is already there, then combine it with the new pixel and place it back.

Ben
- http://www.fysnet.net/the_graphical_user_interface.htm


Yes, that's a good idea. I solved my problem, thank you.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Majestic-12 [Bot] and 87 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