Graphics

If you are new to OS Development, plan on spending some time here first before going into the other forums.

Moderator:Moderators

Post Reply
xilvium
Posts:13
Joined:Sat Feb 14, 2009 3:13 pm
Contact:
Graphics

Post by xilvium » Thu Aug 06, 2009 10:35 am

Hello, users

Lately I made some time free so i could study some more on os development. But this time I didnt want to create a text mode os.
So I did some research on vga vesa. Well I tried to but all i could find is that if you wish to make the switch from pmode you should use v8086 mode or do it from real mode. So I thought by myself maybe I could let the bootloader do the switch for me.
But how would I let the bootloader make the switch for me? For the bootloader I use the one which is being programmed in the tutorial series. How would I let that bootloader setup an vesa or vga mode so I can plot pixels trough c++? I could not find any documentation about making the switch in the bootloader all I read is that GRUB can do it for you but as I stated I do not use grub. I highly dislike pre-programmed packages that way you cannot say that the code is 100% yours :shock:
Thank you for reading.

-Xilvium

Andyhhp
Moderator
Posts:387
Joined:Tue Oct 23, 2007 10:05 am
Location:127.0.0.1
Contact:

Re: Graphics

Post by Andyhhp » Thu Aug 06, 2009 1:37 pm

This isnt a tutorial itself but it should help you get started

http://wiki.osdev.org/How_do_I_set_a_graphics_mode

I have no experience of dealing with anything other than textmode at this level of programming

~Andrew
Image

xilvium
Posts:13
Joined:Sat Feb 14, 2009 3:13 pm
Contact:

Re: Graphics

Post by xilvium » Thu Aug 06, 2009 2:03 pm

Thank you Andrew

But I have looked at this page before and it is still vague to me.
As I am in real mode I can call the bios directly trough int 10 which is obvious.
But my assembler knowledge is not that good that I can write it myself but I do understand the basic functions.
The page you gave me contains only one link which provides usefull to me and that link is: http://www.ctyme.com/intr/int-10.htm But that website confuses the crap out of me :shock:

Thank you for reading.

Andyhhp
Moderator
Posts:387
Joined:Tue Oct 23, 2007 10:05 am
Location:127.0.0.1
Contact:

Re: Graphics

Post by Andyhhp » Thu Aug 06, 2009 6:25 pm

Hmm

I will admit that the site isnt very clear.

Unfortunatly, if your assembler isnt good enough to write by youself then trying to a GUI in real mode is paramount to insanity. (I know asm quite well but I wouldnt try making a real mode gui in a million years - you NEED higher level constructs that languages like C give you if you want a chance of succeeding).

My suggestion is that you work through the tutorials here so you get an idea of how to use assembly. Once you can do that then you can look at writing a GUI.

Sorry to be negative but it is in your best interest.

~Andrew
Image

xilvium
Posts:13
Joined:Sat Feb 14, 2009 3:13 pm
Contact:

Re: Graphics

Post by xilvium » Thu Aug 06, 2009 10:09 pm

A GUI hehe that sounds like a great idea but i am not skilled enough to code one i have to admit.
All i wanted to do is initialise VESA in real mode and then do the drawing in C like show a simple boot logo and tada thats it.
And then after alot of testing and playing around then maybe try a gui but no not now :P

User avatar
Mike
Site Admin
Posts:465
Joined:Sat Oct 20, 2007 7:58 pm
Contact:

Re: Graphics

Post by Mike » Thu Aug 06, 2009 10:28 pm

That alone is alot more complicated then what it looks like. Going into a Vesa video mode from real mode is easy; but working with that mode is not. Unless it is configured to be a linear display mode [which is not supported on all cards] you would be required to fall back into real mode for bank switching [using bios interrupts].

Of course, we can help you configure a Vesa mode for linear buffer access if you like. Please keep in mind that it may or may not work, but it would allow what you are wanting to do [set the video mode in real mode, and access it from protected mode.]

*Note: this assumes you are wanting to set a higher resolution Vesa video mode, like 800x600 or higher.

We can also help you with setting up direct VGA mode if you do not want to go with the complexities of going back into real mode, but then, of course, you would have to tend to the complexity of VGA.

...Its up to you.
Lead Programmer for BrokenThorn Entertainment, Co.
Website: http://www.brokenthorn.com
Email: webmaster@brokenthorn.com

xilvium
Posts:13
Joined:Sat Feb 14, 2009 3:13 pm
Contact:

Re: Graphics

Post by xilvium » Fri Aug 07, 2009 10:45 am

I know this is all very complicated.
But last night i have been screwing around for literally 5 hours :oops:
But i got vesa on 1024x768 working now.
I switch to vesa in real mode and then all the other stuff such as gdt etc... and now i am in pmode.
And i wrote some drawing functions such as putpixel.
Tutorial 14: Kernel: Basic CRT Setup and Code Design < i use that tutorial as a base i just stole the demo 8) and adjusted it hehe no worries it was for testing only and i used the wiki of osdev for the putpixel functions.
Anyways since i got it to work i can start on my own kernel now i suppose.
But i would really like to draw a bitmap on the screen and some text.
Do you have any idea on how i can load a bitmap file and program a font?
Or do i really need to program the letter A with the putpixel function?

Thank you for reading

EDIT:
If someone wants to see how i did it then just ask me and i will provide the code as it is just merged from severe other code's and with help of some people. So i cannot claim this and i wont claim this that would be like stealing a ferrari and say you bought it :shock:

Andyhhp
Moderator
Posts:387
Joined:Tue Oct 23, 2007 10:05 am
Location:127.0.0.1
Contact:

Re: Graphics

Post by Andyhhp » Fri Aug 07, 2009 12:06 pm

But i got vesa on 1024x768 working now.
Congratz
Anyways since i got it to work i can start on my own kernel now i suppose.
But i would really like to draw a bitmap on the screen and some text.
Do you have any idea on how i can load a bitmap file and program a font?
Or do i really need to program the letter A with the putpixel function?
You dont really want to be using putpixel - you want to develop a putrect function that (example herehttp://wiki.osdev.org/Drawing_In_Protected_Mode)

After that, you need to create small rectangular bitmaps for each character in your font, then 'print' them by copying the correct rectangle onto the correct location on the screen.

actual bitmap files are not too hard to read from.
http://www.xbdev.net/image_formats/bmp/index.php
This is a good tutorial however it assumes standard C library functions which you will have to write yourself.
If someone wants to see how i did it then just ask me
I would be quite interested to see the code if you dont mind

~Andrew
Image

xilvium
Posts:13
Joined:Sat Feb 14, 2009 3:13 pm
Contact:

Re: Graphics

Post by xilvium » Fri Aug 07, 2009 2:24 pm

Yeah i also did the fillrect code which could be found on that link :P

Osdev's fillrect code was for 800x600 so i switched to that mode.
Anyway here is the promised file ^^

[url]http:/.www.xilvium.nl/Demo6.rar[/url] < Right click save-as else you could get problems with our .htacces for hotlinking xD and it could give you a nais banner :P hehe.

Andyhhp
Moderator
Posts:387
Joined:Tue Oct 23, 2007 10:05 am
Location:127.0.0.1
Contact:

Re: Graphics

Post by Andyhhp » Fri Aug 07, 2009 3:19 pm

The osdev wiki function only needs a single line changing to make it usable with any resolution.

just change

Code: Select all

where+=3200;
to

Code: Select all

where+=pitch;
That should work for any resolution now.

Thanks for the link, I will look at it when I get off work later

~Andrew
Image

xilvium
Posts:13
Joined:Sat Feb 14, 2009 3:13 pm
Contact:

Re: Graphics

Post by xilvium » Fri Aug 07, 2009 6:22 pm

Code: Select all

where+=pitch; 
Where does pitch come from?
How do they get to the where+=3200 well i mean how do they know the 3200?
And what is pitch ? :P

Andyhhp
Moderator
Posts:387
Joined:Tue Oct 23, 2007 10:05 am
Location:127.0.0.1
Contact:

Re: Graphics

Post by Andyhhp » Fri Aug 07, 2009 8:54 pm

Pitch is a variable obtained from the VESA mode lookup function that gives you the number of bytes required to move down by 1 pixel.

3200 = 800 pixels * 4 bytes per pixel;

Thats why the code only works in 800*600 32bit mode

~Andrew
Image

User avatar
joniwalker
Posts:7
Joined:Sat Nov 21, 2009 1:09 pm

Re: Graphics

Post by joniwalker » Sat May 15, 2010 1:00 pm

You can use the x86emu it is simpler to implement than the v8086 mode.
Current developing:
  • Jupitel OS - A Win32/Linux Hybrid System
  • Line Dark The Secret of Knight a 2d/3d MMORPG game
Email: jonathan_2097@hotmail.com

Post Reply