Anyone have ideas on implementing a GUI?

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.
DavidBG
Member
Member
Posts: 62
Joined: Thu Jan 14, 2010 1:02 pm
Location: At the computer
Contact:

Anyone have ideas on implementing a GUI?

Post by DavidBG »

Hello again:

I was wondering how some of you went about making a GUI. Did you create your own graphical primitives, or get a VESA standard library working on your OS? I have initialized a VESA window, and would like to know what some of you all did.

Also, like for the graphics, like an X for close, did you make up your own format, or use something like .BMP or .PCX?

Thanks,
David
President of the Useless OS project
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Re: Anyone have ideas on implementing a GUI?

Post by neon »

Hello,

In my system the GUI will run in userspace and will render graphics using a video-independent API [which contains primitive routines] which in turn calls the current video driver. This allows multiple video drivers and graphics mode independent from the GUI, managed by the software Subsystem API called from a userspace program.

ie, like: program->SubSystem API->Video-independent API-> [...] ->Video driver

While it is planned to provide support for both VBE and generic video drivers, we currently only have a protected mode VGA driver.

Please keep in mind that this setup is just design.

--

At the moment, I do support BMPs but as image resources in the program. In other systems, id go with TGAs instead. This is only one method of going for it; others will probably have different ideas but perhaps this might give you some ideas as well :)
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
neato
Member
Member
Posts: 75
Joined: Fri Jan 15, 2010 2:46 am

Re: Anyone have ideas on implementing a GUI?

Post by neato »

Hi, I wrote everything myself, as I seen it was needed. All you need is a little know how (code wise) and a lot of creativity. I found that it helped me to first create a draft of it in MSPaint first, then use PsShop to get the RGB values, and dimensions, then I just wrote code to draw it out.
User avatar
Creature
Member
Member
Posts: 548
Joined: Sat Dec 27, 2008 2:34 pm
Location: Belgium

Re: Anyone have ideas on implementing a GUI?

Post by Creature »

Well, last time I got graphics working, I first started out with some basic VESA stuff (higher resolutions and such). Then I wrote an invalidation-rectangle system (DAMN, that increases speed a lot) and wrote some convenience code (like alpha blending, mapping an RGBA value to an appropriate integral value based on the colour depth, etc.).
When the chance of succeeding is 99%, there is still a 50% chance of that success happening.
neato
Member
Member
Posts: 75
Joined: Fri Jan 15, 2010 2:46 am

Re: Anyone have ideas on implementing a GUI?

Post by neato »

Definitely mapping each control precisely does certainly increase redraw speed and helps to limit flickering. Just think how dumb it would be to refresh the entire screen every time you went to update a status bar... :shock:

Yeah, you have to have alpha blending if you want to create an illusion that something like an icon was selected in a browser window. Otherwise you'd have to waste major time toggling images. I just integrated mine into my main draw function and I toggle that on and off instead. lol... much faster.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Anyone have ideas on implementing a GUI?

Post by Combuster »

neato wrote:Yeah, you have to have alpha blending if you want to create an illusion that something like an icon was selected in a browser window.
Never heard of insets/outsets/dashed lines? You'll get up, down and selected states without having to replot the image, only the borders.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
DavidBG
Member
Member
Posts: 62
Joined: Thu Jan 14, 2010 1:02 pm
Location: At the computer
Contact:

Re: Anyone have ideas on implementing a GUI?

Post by DavidBG »

Hello:

Would redrawing the screen every time the user moves the mouse be too slow? It seems though, that I should make my own primitives. (I've done it before, in VGA, I assume is is the same in SVGA)

David
President of the Useless OS project
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Anyone have ideas on implementing a GUI?

Post by Combuster »

DavidBG wrote:Would redrawing the screen every time the user moves the mouse be too slow?
Ususally, yes.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
giszo
Member
Member
Posts: 124
Joined: Tue Nov 06, 2007 2:37 pm
Location: Hungary

Re: Anyone have ideas on implementing a GUI?

Post by giszo »

You should redraw the old and the new rectangle of the mouse pointer only.
DavidBG
Member
Member
Posts: 62
Joined: Thu Jan 14, 2010 1:02 pm
Location: At the computer
Contact:

Re: Anyone have ideas on implementing a GUI?

Post by DavidBG »

Hello again:

Here is a silly question but I have searched and searched for an answer:

How do I plot a pixel in SVGA?

I already have a VESA Standard window initialized.

But I can only plot a pixel in VGA with int 0x10 if I move 0x0C into AH and the color into AL. Then I put the X and Y in CX and DX and call int 0x10. But this does not work in SVGA. I can't figure out how to do it directly either like with 0xA000. Any of you know how to do it in ASM?

Thanks!

P.S. Is double buffering slow? Or would that be a solution?
President of the Useless OS project
DavidBG
Member
Member
Posts: 62
Joined: Thu Jan 14, 2010 1:02 pm
Location: At the computer
Contact:

Re: Anyone have ideas on implementing a GUI?

Post by DavidBG »

On second thought, Maybe I should start with a VGA GUI anyway, because I am in real-mode. I do not know how to use a GDT so I cannot go into protected-mode yet. This means I can't use more than the first 64k of the screen anyway.

I'll keep working at it, thanks for the ideas on how to go about it.
President of the Useless OS project
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Anyone have ideas on implementing a GUI?

Post by Combuster »

DavidBG wrote:Here is a silly question but I have searched and searched for an answer:
Hmm, first hit on google for me: The manual. Includes fairly detailed instructions for a reference document.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
Creature
Member
Member
Posts: 548
Joined: Sat Dec 27, 2008 2:34 pm
Location: Belgium

Re: Anyone have ideas on implementing a GUI?

Post by Creature »

DavidBG wrote:Hello:

Would redrawing the screen every time the user moves the mouse be too slow? It seems though, that I should make my own primitives. (I've done it before, in VGA, I assume is is the same in SVGA)

David
AFAIK, GFX cards usually have a feature called "hardware cursors" (or something like that) allowing better performance.
DavidBG wrote: P.S. Is double buffering slow? Or would that be a solution?
Well, it does require you to (typically) add a buffer the size of the screen, to which you draw everything. Then, when you are finished drawing (or when the monitor refreshes), you swap the buffers. There is an article on the wiki called Double Buffering that you might want to check out.
When the chance of succeeding is 99%, there is still a 50% chance of that success happening.
neato
Member
Member
Posts: 75
Joined: Fri Jan 15, 2010 2:46 am

Re: Anyone have ideas on implementing a GUI?

Post by neato »

Combuster wrote:
neato wrote:Yeah, you have to have alpha blending if you want to create an illusion that something like an icon was selected in a browser window.
Never heard of insets/outsets/dashed lines? You'll get up, down and selected states without having to replot the image, only the borders.
When one icon is selected within an ocean of unselected icons, which is easier to see: A) A big blue rectangle. B) A tiny little dash line. It's all about trying to be friendly to as many users as possible and you're not going to get there by being lazy.
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Re: Anyone have ideas on implementing a GUI?

Post by neon »

DavidBG wrote:On second thought, Maybe I should start with a VGA GUI anyway, because I am in real-mode. I do not know how to use a GDT so I cannot go into protected-mode yet. This means I can't use more than the first 64k of the screen anyway,
VBE (and thus Super VGA) supports a way to switch between banks of the full video memory allowing you to be able to access the full video memory through that 64k "window". Look into "Bank Switching" with VBE; im sure there is plenty of tutorials on it ;)

On the use of double buffering, if it was possible, id go with page flipping over double buffering for a general graphics OS. Requires hardware support though, but does fix the issues involved with double buffering.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
Post Reply