Graphics Programming

From Scriptionary.com

Jump to: navigation, search
The article which you have requested is a so-called "stub" which denotes the length of the document and that it requires additional information for completion. You can help Scriptionary by adding content to this article.
Graphics Programming is the process of converting computer instructions into visual representations. This process can be abstracted into two distinct categories, namely: two-dimensional (2D) graphics and three dimensional (3D) graphics. This article discusses graphics programming as a broad term and as an introductory text for novice or aspiring graphics programmers.

Contents


Introduction

While the term Computer Graphics or CG is often associated with the three dimensional aspect of computer visualization, the term can be interpreted as any type of computer output that is visual in nature. Computer Graphics can be a visual aid in computing by the use of graphics such as:

  • Graphical User Interfaces (GUI),
  • Icons and Glyphs,
  • Data visualization,
  • Display of information such as text.

Often, computer graphics are associated with the representation of nonfunctional or recreational imagery such as photographs, film and video or interactive graphics which can be found in video games and simulations.

Two Dimensional Coordinate Representation

A visual representation of a display raster
A visual representation of a display raster

Fundamentally, all computer generated imagery is two dimensional in nature but can represent an illusion of depth (3D graphics, see next section). The output of computer graphics is usually represented on a computer monitor but can also be displayed on devices such as printers and plotters. All of these devices work with a two dimensional representational system, which in theory can be represented much like a graph with an X axis and Y axis.

This coordinate system, called a raster, consists of a constant number of coordinates set by the width and height of the coordinate system, this is called the display resolution.

A computer display device usually expresses the display of resolution in pixels which are a representational point element of this coordinate system, holding an X and Y location and a value determining its on or off state. A raster can be represented in the C programming language like so:

unsigned int Display[SCREEN_WIDTH] [SCREEN_HEIGHT]; // two-dimensional array, or matrix

Values in this raster can be accessed like so:

Display[5][5] = 0xFFFFFF; // white hexadecimal color value (on)
Display[6][5] = 0x000000; // black hexadecimal color value (off)

If implemented, this code would cause the pixel at position left: 5, top: 5 to be white or on and the pixel at position left: 6, top: 5 to be black or off. In the accompanying image, white is represented as green.

A raster showing (5, 5) and (6, 5)
A raster showing (5, 5) and (6, 5)

Most modern display devices are able to display many colors, usually up to 16 million colors. These color values are usually represented in programming languages as hexadecimal (Base 16) values, representing the Red Green and Blue, often simply called RGB, elements of the color displayed. A hexadecimal color value can be dissected as follows:

0xFF00FF = Red(FF), Green(00), Blue(FF)

Which would represent the color magenta. Each color channel can have up to 255 values ranging from 0 to 255, this accounts for a total amount of unique colors of 16,581,375.

Some programs and implementations allow the user to implement a so-called alpha value, ranging from 0 to 255, much like a color channel. An alpha channel is basically an indicator for the strength of the color when combined with the pixel's existing color. The hardware or software responsible for handling pixel events will add these two colors together to create the illusion of transparency. For example, if a pixel's color value of 0x000000 (100% black) exists and a 0xFFFFFF (100% white) color value with an alpha value of 128 (50%) is laid over the existing color, a combination of the two will result in the color value 0x808080 (50% gray).

Three Dimensional Coordinate Representation

3D X, Y and Z axes
3D X, Y and Z axes
Transformation from Coordinate System to Raster Output
Transformation from Coordinate System to Raster Output
Cube in the raster
Cube in the raster

As stated in the previous section on Coordinate Representation, all computer graphics are displayed in a two dimensional coordinate system. To display three dimensional images, another coordinate system has to be implemented which solely serves for transformation purposes.

This coordinate system contains three axes instead of two, namely the X (horizontal) axis, Y (vertical) axis and Z (depth) axis. This extra Z axis allows for depth coordination and scaling of visual elements. Without going into extreme detail, after the three dimensional positions, scales and rotation have been calculated, a specialized software or hardware converts the three dimensional coordinates into a two dimensional presentation format for display output. Common APIs that handle these transformations through hardware are OpenGL and Direct3D.

The actual rasterized version of the cube might look like the second image presented. While the process presented here is extremely simplified, it is common methodology used to rationalize converting three dimensional objects into two dimensional representations.

Conception of Computer Graphics

Ivan Sutherland
Ivan Sutherland

This section features a summarized history of Computer Graphics, mostly short abstracts derived from various sources. [1] [2] [3]

Computer Graphics started with a man called Ivan Sutherland who in 1961, for his MIT thesis, created a software called Sketchpad which allowed the user to draw vector shapes on the screen of a computer using a photoelectric light-pen.

Various projects relating to computer graphics started to take shape in the early 1960s and a growing interest in Computer Graphics was founded quickly. This prompted IBM to create the IBM 2250 a Cathode Ray Tube display in 1964 for usage with the IBM System/360 mainframe computer, which when combined effectively created the first commercially available Graphics computer.

In 1968 Ivan Sutherland and Bob Sproull created the the first primitive form of interactive three dimensional graphics, called the Sword of Damocles which was a Head Mounted Display, currently better known as a Virtual Reality set which allowed the user to move around in a wire-frame three dimensional room. Also in 1968, Ivan Sutherland and David Evans founded the Evans & Sutherland company, becoming highly influential in Computer Graphics and making headway for companies such as Silicon Graphics.

From this point on, computer graphics were getting increasingly popular. The Pong video game accelerated this interest and video games began to evolve, boosting the interest in real-time computer graphics. The late 1970s and early 1980s were monumental in advances in both computer graphics and video games. It was only in the late 1990s that fully interactive three dimensional video games were available on the consumer's desktop computer.

CG in Motion Pictures

The first major usage of two dimensional Computer Graphics in the entertainment industry was in the motion picture Westworld in 1973, its sequel Futureworld featured the first usage of three dimensional wire-frame Computer Graphics in 1976. The first motion picture making usage of solid three dimensional imagery was Tron in 1982. The first motion picture consisting of solely three dimensional computer graphics was Toy Story in 1995.

References

  1. History of Computer Graphics
  2. Biography of Ivan Sutherland
  3. A Short History of Computer Graphics
Personal tools