Home   Info   DevZone   Wiki  
UsersWeb  |  MainWeb  |  InfoWeb  |  DevZoneWeb  |  SupportWeb
VGADriverAndGraphics ] [ not logged in ] [ Web: Imported ] goto:  options
[ get info on or edit ] login or new user ] [ list of topics, hubs & nodes, or recent changes ]

PlatformAPIPages


Article contributed by GilbertHerschberger (3 February 2000).

Introduction

After celebrating the creation of a VGA driver, the next piece required by the bit-mapped graphics is a graphics context. Any class in the virtual machine should be able to use the real graphics context.

The VGA driver is a simple bit-mapped device. It is incapable of drawing lines, rectangles, windows and decorated frames.

Graphics

If we start with an interface with methods similar to java.awt.Graphics (without images), we can build a straight forward implementation of a real graphics context.

public interface VGAGraphicsContext {
  public VGADriver getDriver();
  public void setDriver( VGADriver v );
  public byte[] readArea( Rectangle r );
  public void writeArea( Rectangle r, byte[] v );
  public void writeArea( Rectangle r, byte[] v, int style );
  public void setColor( Color v );
  public void drawLine( Point a, Point b );
  public void drawRect( Point a, Point b );
  public void fillRect( Point a, Point b );
}

Like the paintable collection for java.awt.Graphics, each class should be responsible for creating one kind of shape on top of the VGA driver. Each low-level class uses the VGA driver interface. The VGA driver interface is capable of supporting virtual bit-mapped output.

Blit

A low-level class should consistently blit its output to the VGA driver. A class constructs a private bit-mapped image of an arc, line or rectange. After the private bit-map is complete, a single call to the VGA driver with focus copies it to real VGA hardware. The classic mechanisms should be available to merge a private bit-map with the pixels already on the real VGA hardware.

A class must be written to draw a line from point A to point B. In the future, this class could be used by the drawLine() method of java.awt.Graphics.

Like some of the earlier work on graphics, the real VGA hardware can be considered a java.awt.Canvas that covers the entire output area. The mechanism of painting/repainting the real VGA hardware is similar to the mechanism of painting a small piece.

Demonstration

With a graphics context for a VGA driver, it becomes possible for us to demonstrate more of what JOS can do. Write an screen saver program with animation. Write a program that draws a VGA test pattern. Whatever is done, at least people will be able to see what can be done so far.

Since the VGA driver does not interact with the java.io packages, these programs can be written without concern for multitasking. From these humble beginnings, a complete windowing system can be written. A complete windowing system isn't far from a system-wide graphics context. Anyone who wants to build a windowing system should built it on top of a graphics context.

Not here

The low-level graphics contexts does not include support for characters, strings or fonts. It does not need to implement drawString, getFont() or setFont.

The low-level graphics context does not include interaction with a mouse. Painting a mouse runs on top of this graphics context.

The VGA driver only needs to write bytes to the real VGA hardware and read bytes from real VGA hardware. The driver needs to work with rectangles (x1, y1, x2, y2) so that the graphics context can blit an rectangular area that's smaller than the whole screen.

The low-level graphics context does not include the AWT concept of a platform independent image. The image belongs in the AWT. This graphics context is specific to a VGA driver.




Content of these pages are owned and copyrighted by the poster.
Hosted by: