Graphics driver
I would like to learn to design my own graphics driver, so I tried to reverse engineer the parallax driver, but it was a bit unsuccessful. I'm not that level yet!
Does some of you know where I can find a good references (book or web page) how to design simple graphics functions to interface with the buffer of a VGA driver?
What I was thinking is not a sprite/tile driver, but a more general driver for drawing primitives and maybe more advanced stuff like GUI widgets, graphs etc...
Does some of you know where I can find a good references (book or web page) how to design simple graphics functions to interface with the buffer of a VGA driver?
What I was thinking is not a sprite/tile driver, but a more general driver for drawing primitives and maybe more advanced stuff like GUI widgets, graphs etc...
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"I have not failed. I've just found 10,000 ways that won't work. "
- Thomas A. Edison
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,
One of the limitting factors for a·Propeller display driver is the amount of HUB RAM which can be dedicated to the task.· A 640x480x8bpp VGA frame buffer requires 300K and thus won't fit into 32K HUB RAM.· Display drivers therefore use tiles and sprites to reduce the amount of HUB RAM required, although at the cost of flexibility.
Now, if you have some kind of external RAM which can be used as a frame buffer, then I'd recommend some of the old VGA books.· I have Richard F. Ferraro's Programmer's Guide to the EGA, VGA, and Super VGA Cards at home somewhere, and I think it covered a lot of basic 2D graphics functions.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Composite NTSC sprite driver: Forum
NTSC & PAL driver templates: ObEx Forum
OnePinTVText driver: ObEx Forum
As inferred above, this is really a two part question...· Creating the graphics vs displaying them.
Though it is tile based, have you seen the HiRes Text VGA GUI driver?· It demonstrates the GUI aspects.· Combined with studying the VGA Bitmap driver, that kind of encapsulates much of what you may be looking for.
edit -
One thing to keep in mind is that bitmapped buffers require substantial memory resources.· Often you can 'fake' graphics on the screen using custom tiles in strategic places.
Another good resource I would suggest is Raymond Allen's website, he has some good demos which really helped me as I am writing my Prop InVGAders code.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Post Edited (Agent420) : 9/17/2009 7:31:57 PM GMT
I'll take a peek, looks like what I'm looking for [noparse]:)[/noparse]
The different standard resolutions plot each pixel using a different equation to find the byte with the pixel in it.
Standard VGA mode 13 is 320x200 with 256 colors available for 1 pixel per byte, and buffer address offset
corresponds to a one dimensional array consisting of 320 bytes representing each a pixel, followed by the
next row down and so on 200 times for each row. It is the easy one on a PC but not on a Propeller, which has
different ones that were/are/willbe carefully optimally designed for Propeller.
plot, unplot, and not essential but useful readpixelcolor x,y are the starting points.
Lines can be made generally by moving on the axis which they are longest by counting from start to end
on that coordinate, and using a fraction to find where along the other coordinate points should be plotted.
The fraction can be avoided by a different method, since division is slow.
Rectangles can be made simpler, with opposite corners x,y and a,b: while plotting count from x to a, then y to b,
then a to x, then b to y.
Filled rectangles: count from x to a within the process of counting from y to b (nested loop).
Filled circles: relative to the center, pixels whose x*x+y*y is less than or equal radius*radius are plotted.
Open circles: relative to the center, pixels whose x*x+y*y is nearly equal to radius*radius are plotted.
(how nearly determines circle thickness)
Open circles and ellipses and spirographs and other curves can be done relative to the center using
x=cos(n)*radius:y=cos(n)*radius where n counts from 0 to 2pi in steps that get smaller with larger circles,
probably radius/pi steps. Needs non-integer math.
Filling weird shapes including closed mazes is done most simply by putting all adjacent unfilled pixel coordinates on
a stack, and then pulling off all coordinates and plotting them, although this hogs memory and should be optimized
at least by making sure no pixel is put on the stack more than once.
Filled triangles, I don't know the math now but similar to making 2 or 3 lines at the same time.
Filled trapeziums can be filled by another image, useful in virtual realities as textures, also related to simultaneous
line drawing.
Making text is easy with bitmap fonts, just copy them onto the screen, use OR logic, or AND NOT logic to make
them background-transparent. They may be made of 8x8 blocks of pixels and have limited choices of size.
I do not know how non-bitmap scalable fonts usually work, especially curvy ones, but an obvious method
would be to make them with a drawing tablet and storing the directions the pen moved, which could be
multiplied by any number to get any size.
Making windows on a Propeller is best done with special characters that are re-used many times on the
sides of a window plus 4 for the corners of a window plus ones for making clickable buttons, unless you
are making a GUI for a flying saucer in Area 51 or a Federation of Planets Starship or a TARDIS.
Cursors and Mouse pointers may simply use XOR logic, or else the area covered will need to be stored and replaced
whenever they move.
OR logic: binary 1 is preferred in the result (maybe white letters over background)
AND NOT logic:binary 0 is preferred in the result (maybe black letters over background)
XOR logic: do it once, something appears, do it again and it disappears, but tends to mix with background colors.
Though 320x200 may technically be a vga resolution (probably considered more cga), I tend to think 640x480 at a minimum and 1024x768 as most common (I think many people think of xga+ displays simply as vga).
If you do a Google you will find a lot of information on graphic techniques...· I'd guess most are based on Bresenham's algorithms.
As for cursors and such, it may be of value to investigate how Chip's vga demos display them; he uses an additional cog to generate video overlay for the cursor, similar to how hardware sprites are generated.· Sprites have the advantage of not having to manipulate the main bitmap memory array; they are just superimposed on top of the existing graphics.·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Composite NTSC sprite driver: Forum
NTSC & PAL driver templates: ObEx Forum
OnePinTVText driver: ObEx Forum
To VIRAND-> I think I might start with simple routine like the ones you enumerated, there is a good tutorial on how to plot pixels in the Tile Bitmap Memory in the hydra book. I won't try to rewrite TV.spin or VGA.spin, but I'll start to do my own Graphics.spin