How do I set a graphics mode: Difference between revisions

Jump to navigation Jump to search
no edit summary
[unchecked revision][unchecked revision]
(Created faq entry)
 
No edit summary
Line 1:
=Setting Graphics Modes=
When a PC first boots up, it is set to a standard, known VGA text mode. But at some point you will want to start drawing pixels to the screen instead of text. This requires you to switch from text mode to a ''graphics'' mode. In 16-bit mode, you can easily use the BIOS to switch between different graphics modes by calling different functions of interrupt 0x10. Once you enter protected mode, however, things get a bit more difficult.
=Methods=
== Using the BIOS ==
Each video card you find in a PC comes with a piece of code that allows it to be initialized, the video BIOS. This bios is expected to
run in [[Real Mode]], and as long as you are, you can access all the functions directly by calling int [http://www.ctyme.com/intr/int-10.htm 0x10] with the right values in the registers. '''If your kernel is based on a tutorial, you can not do this''', because for practically all tutorials, you are in protected mode, and not in real mode.
 
Almost allMany video cards have two interfaces, one [[:Category:VGA|VGA interface]] for low resolutions, and the [[Getting VBE Mode Info|VESA VBE]] interface for higher resolutions. Alternatively, you can write your own code to directly deal with the graphics hardware.
 
 
In [[Protected Mode]] or [[Long Mode]], the BIOS interface is not directly accessible. A number of approaches can be used to still use it. They all work by setting or simulating real mode and calling the interrupt that way.
===Methods for drawing via the BIOS===
* Drop back to real mode, then call the BIOS. The easiest solution, but also the most ugly. Be careful to restore everything to real-mode values when you do.
* Use [[Virtual 8086 Mode]]. The most common good solution for protected mode. This way you can run the BIOS from a virtual machine style environment, thus maintaining control over the process. Virtual 8086 mode is however not available from Long Mode.
* Write/use an emulator. The slowest and most intensive approach, but has the advantage that it will work under any condition, including long mode and other platforms.
== Writing your own Driver ==
 
The alternative approach is to not use the BIOS at all:. In this case, you must write your own drivers to interact with the hardware.
 
===VESA===
The alternative approach is to not use the BIOS at all:
*The simplest way to get graphics modes without using BIOS would be to [[VGA Hardware|Writedevelop]] or [[VGA Resources|reuse an existing]] a VGA driver. This gives you all low resolution modes on practically all hardware, and is easier to do than setting up a virtual machine of any sort.
===Proprietary Drivers===
* Write a driver for [[Accelerated Graphic Cards|each graphics card]]. Only recommended if you have more than one life to waste.
However, if you want to support the highest resolutions, and the most features, you must write a driver for [[Accelerated Graphic Cards|each graphics card]] that you want your OS to support. Keep in mind that not all video cards are well documented. In fact, a lot of the newer cards have absolutely no documentation at all.
=Final Thoughts=
The easiest solution is to simply let the BIOS do the work for you. Although it is the slowest option (speed wise), it is the most compatible. If you insist on writing your own video drivers, you should at the very least fall back on VESA, if not VGA when a driver fails to load (or simply does not exist).
 
 
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu