by Mwwhited
20. April 2009 23:04
I remember back in high school when I would directly program the video memory for the best speed possible for graphics rendering. Now 10 years later I have started adding similar functions to Singularity. One thing I have found out is use to the SIPs and Channels you need to effectively send packets of data to the video driver. These packets do not have to be raw byte arrays that you want to render. They could simply be a collection of points and lines with simple shapes.
Also due to limitation in the isolated nature of the SIPs you need to build generic commands that can send descriptions of what you want to do instead of simply plotting points. For an example the first graphics program I write for any new platform is a Sierpinski's triangle. Plotting random points on the screen didn’t seem too slow so I moved on to the next exercise.
Typically the next graphic rendering I code is just a random mess of lines. Simple enough you just pick two points and a color and connect the dots. I quickly found a minor problem in the graphics engine. Plotting a single point and waiting for a call back caused the lines to draw out instead of just flashing on the screen. So I moved the algorithm into the driver and it worked much faster. (With all the recompiling of the video contract I really saw a compelling reason to not static compile everything)
The functions I have added to the graphics driver so far are line, rectangle, polyline, triangle, circle, ellipses. I have also added filled versions of triangle, circle, and ellipses. I plan on adding arcs, pies, Bezier curves, and possibly even adding texture mapping. Currently these are only available for the S3 driver and have only been tested on Singularity on virtual PC.
Future programs including a simple multi-threaded GUI, simple two games (such as Tetris or Breakout), and possibly even a simple polygon 3d engine.