SDL Standard Drawing Library: C Library Reference Manual
SDL Standard Drawing Library: C Library Reference Manual
SDL Standard Drawing Library: C Library Reference Manual
Standard Drawing
Library
C Library Reference Manual
Rastergraf, Inc.
1810-J SE First St.
Redmond, OR 97756
(541) 923-5530
web: https://www.rastergraf.com
email: support@rastergraf.com
Release 3.6.2
November 15, 2006
SDL C Library Reference Manual 1
Notices
Trademarks mentioned in this manual are the property of their respective owners.
This manual is based in part on Xlib - C Language X Interface, Version 11, Release 6 which is
copyrighted material. This documentation is used under the terms of its copyright which grants
free use as noted below.
Copyright © 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994 X Consortium
Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in the Software
without restriction, including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to
whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
Except as contained in this notice, the name of the X Consortium shall not be used in
advertising or otherwise to promote the sale, use or other dealings in this Software without
prior written authorization from the X Consortium.
Copyright © 1985, 1986, 1987, 1988, 1989, 1990, 1991 by Digital Equipment Corporation.
Portions Copyright © 1990, 1991 by Tektronix, Inc.
Permission to use, copy, modify and distribute this documentation for any purpose and
without fee is hereby granted, provided that the above copyright notice appears in all
copies and that both that copyright notice and this permission notice appear in all copies,
and that the names of Digital and Tektronix not be used in advertising or publicity
pertaining to this documentation without specific, written prior permission. Digital and
Tektronix makes no representations about the suitability of this documentation for any
purpose. It is provided "as is" without express or implied warranty.
Permission is granted to licensed users of SDL to duplicate this manual for non-commercial uses
2 SDL C Library Reference Manual
Preface
This manual is a reference document for programmers using the Standard Drawing Library, SDL.
This manual provides a brief overview of SDL features and describes each function in the library.
SDL is licensed in object and source format for use with embedded systems and in other industrial
graphics hardware products. Although designed primarily for use with graphics boards from
Rastergraf, the source code format allows SDL to be easily ported to the many different products
in the marketplace.
The functions described in this manual represent the complete list of SDL library functions. Not all
functions may be implemented in all graphics board drivers.
SDL requires a system with an ANSI C compiler and operating system and processor with a linear
address space.
Permission is granted to licensed users to reproduce this manual for non-commercial uses. This
means that this manual may not be resold to third parties. It does mean that licensed users of
SDL may reproduce this manual for use in developing SDL programs, which may be included in a
product and subsequently sold.
SDL is the product of over 20 years of experience developing graphics products for industry and
we hope you will find it useful.
Please visit our web page at http://www.rastergraf.com for the latest information on our current
graphics products.
SDL C Library Reference Manual 3
Contents
Notices ............................................................................................................ 1
Preface ............................................................................................................ 2
Contents .......................................................................................................... 3
Index............................................................................................................181
4 SDL C Library Reference Manual
System Overview
The Standard Drawing Library, SDL, is a scaleable C graphics library designed for use with real-
time and non-real-time operating systems. SDL is small, compact, ROMable, and offers device
independent graphics functions for board level and embedded systems applications.
SDL is easy to use and provides a complete set of graphics primitives. These graphics primitives
can be extended by adding utility functions for specialized graphics tasks.
SDL is written in ANSI C and is supplied in library format, which means that its target code size
can be controlled by limiting the number of functions used in a given application. SDL has been
designed to run on any CPU and operating system that uses linear addressing and that is
supported by an ANSI C compiler and linker.
SDL includes a generic graphics driver module that provides the hardware specific routines
needed to interface to the graphics hardware in a user’s system. A graphics driver specification
is provided to customers licensing SDL in source format, allowing the customer to port SDL to the
specific graphics hardware in the customer’s system. SDL can be readily ported to a new system
by changing this one module. SDL, therefore, does not depend on any specific graphics
hardware, and versions of SDL can be used with VGA chips, EL panels, LCD displays, and most
other graphics devices.
• All graphics primitives are drawn as single pixel lines. Rectangles, polygons, circles, ellipses,
and chords can be filled with a solid color or stipple patterns
• Use with Motorola PowerPC Products: MVME160x, MVME260x,and MVME360x
• Use with Rastergraf Graphics Boards under Linux, VxWorks, OS9, and other real-time OSs
• Full Featured and Easy to Use
• Written in ANSI C and supplied in Library or Source format
• Scaleable, ROMable, and Minimal RAM usage
• Circles, Ellipses, and Arcs
• Filled Circles, Chords, Sectors, and Polygons
• Solid, wide solid, and dashed lines, polylines, and rectangles
• filled rectangles, polygons, ellipses, circles, sectors, and chords
• pixel blits to/from the display and host memory
• Solid and Pattern Fills – Pixel Processing
• Proportional and Fixed Width Fonts
• Clipping Rectangle and Logical Origin
• Screen to Screen and Host to Screen Image Copy
• Mouse and Keyboard Support
• Video Capture Extensions
SDL C Library Reference Manual 5
Colors
SDL can support most of the popular color configurations, including 16 color, 256 color, and true
color systems. The color configuration is determined by the graphics driver, which is configured to
match the graphics hardware used in the system. SDL maintains two colors, a foreground color
and background color, stored in variables. The colors are specified with the setForeground() and
setBackground() functions, which load the specified unsigned 32 bit pattern (representing the
color) into the corresponding variable.
Rectangles, circles, chords, sectors, ellipses, and polygons can be filled with a solid color,
stipple pattern, or opaque stipple pattern.
• Solid color fills use the current foreground color to fill the object.
• A binary pattern is used to specify a stipple pattern. Each bit in the binary pattern
corresponds to a pixel. When an object is filled with a stipple pattern, the ones in the pattern
are drawn in the current foreground color. The zeros in the pattern are not used and the
corresponding screen (or memory) locations are not modified.
• An opaque stipple fill uses the same binary pattern used by the stipple fill, except that both
the ones and zeros of the pattern are drawn in the corresponding foreground and background
colors.
• An offset is provided to allow a stipple pattern to start at any point in the pattern as opposed to
always starting at the beginning of the pattern. See setPatternOrigin().
Coordinate System
The coordinate system for SDL has the Screen Origin
origin in the upper left corner of the 0,0
screen. x increases to the right and y +x
increases downwards on the screen. A
clipping rectangle can be definedon the
display screen to limit where text and Display Screen
graphics are drawn, and a logical origin,
which defaults to the screen origin can
be moved about the screen to make it
easy to position complex objects.
+y
Clipping Rectangle
A clipping rectangle is used to limit all graphics to a rectangular area of the display screen
(memory). The default is for the clipping rectangle to be the same size as the entire screen,
thereby limiting memory writes to the range of memory allocated for the display. The clipping
rectangle is programmable in size and location. See setClipRect() for more information.
Pixel Processing
SDL supports replace, or, and, and xor pixel processing. For pixel processing to work, the
graphics driver must be able to generate read/modify/write memory cycles to and from the
graphics hardware memory.
SDL C Library Reference Manual 7
Fonts
SDL provides 18 fonts, including both proportional and fixed width fonts. See Appendix B for a
description of the fonts included with SDL. Fonts can increase the code size significantly, as
some of the larger fonts can be 10k bytes or larger in size. For applications with limited memory
or ROM, fonts types should be used sparingly to limit SDL code size. Additional fonts are
available in separate font utility.
The user must specify the fonts to be included in the run time code at compile time. The selected
fonts must be included in the file, userinit.c. See initGraphics() for more information.
Text may be rotated as it is drawn on the display (see setTextDirection()).
Graphics Driver
SDL is portable and can be used on a wide range of systems. To be portable, SDL uses a simple
graphics driver to interface SDL to the user’s graphics hardware, such as VGA display, Flat Panel,
etc. The Graphics Driver is a module in SDL and is the only part of SDL that is modified when
porting SDL to a new platform.
Performance
SDL runs on the host processor and its performance will vary depending on the processor used.
A 68040 class processor gives good graphics performance for industrial control applications.
Faster processors such as the 603 PowerPC give outstanding performance.
This example first draws a white bounding rectangle to simulate the edge of the video screen.
Next, it shows how to redefine the size and location of the clipping rectangle. It then draws a filled
rectangle within the clipping area and draws the text string Big Box under the red filled rectangle.
The filled rectangle is positioned so that part of it extends outside the clipping rectangle and is
therefore clipped as shown below in Figure 1.
Clipping Rectangle
located at x=100, y=100,
Width=300, Height=300
Bounding Rectangle
simulating the edge of
the video screen
setDashPattern() if a different dashed line pattern was desired. The upper left corner of
the green dashed rectangle is located at x=100, y=100 and its width = height = 300. The
green dashed rectangle is drawn with dashedRectangle().
Next, a dashed red rectangle is drawn that extends to the right of the clipping area to
show the part of the filled rectangle (not drawn yet) that is clipped (not drawn) because it
falls outside the clipping rectangle. The foreground color is changed to red, and the red
dashed rectangle is drawn with dashedRectangle().
(3) Set the clipping rectangle.
The clipping rectangle defaults to the entire screen size, but can be resized and
positioned anywhere within the screen area. In this example, the clipping rectangle is
represented by the green dashed rectangle described above. The actual clipping
rectangle is defined with the setClipRec() function and takes the same parameters as the
dashedRectangle() function used above to outline the clipping rectangle. After the
clipping rectangle has been resized and positioned to coincide with the green dashed
rectangle, graphics can only be drawn within the clipping rectangle. Note that the smaller
red dashed rectangle could not be drawn at its current location once the clipping rectangle
has been defined. From this point on, the only drawing routine which can alter pixels
outside the clipping rectangle, without redefining the clipping rectangle, is the
clearScreen() routine.
(4) How to draw a filled rectangle.
The filled red rectangle is drawn using filledRectangle() and works much the same as the
dashedRectangle() function. The fill style is set to solid fill, which fills the rectangle with
the current foreground color, red. The filled rectangle is located at x=200, y=200 and is
300 pixels wide and 100 pixels high. This filled red rectangle overwrites the portion of the
dashed red rectangle within the clipping rectangle, leaving the right 100 pixels of the
dashed red rectangle unmodified. This unmodified portion of the dashed red rectangle
shows the part of the filled red rectangle that was clipped and did not get written.
(5) How to draw a text string.
The text string ‘Big Box’ is drawn below the filled rectangle. The text string is located at
x=300, y=325 and is drawn using the drawText() function. The color of the text is
determined by the current foreground color, which can be set with setForeground().
The text is drawn at a fixed location in this example, but other options are available. For
example, the width of the text string can be calculated by the getTextWidth() function,
allowing the text to be centered relative to a screen location. Sixteen font types are
available with SDL. This example uses the current font. See Appendix B for a description
of the SDL fonts.
SDL C Library Reference Manual 11
Listing of clip.c
/**************************************************************************/
/* STANDARD DRAWING LIBRARY */
/* */
/* Rastergraf, Inc. */
/* Used under license from CURTISS-WRIGHT CONTROLS, INC. */
/* COPYRIGHT (C) 2001 CURTISS-WRIGHT CONTROLS, INC. */
/* */
/* This software is licensed software subject to the terms of the */
/* Source Code License Agreement. Refer to the file LICENSE for details. */
/**************************************************************************/
/* FILE NAME : clip.c */
/* DESCRIPTION : Example program for setting clip rectangle */
/* AUTHOR : P. K. */
/* DATE CREATED : 8/3/95 */
/**************************************************************************/
/* This program is designed to show how clipping works in SDL. ...........*/
/**************************************************************************/
#include <sdl.h> /* SDL root header file */
#include <extern.h> /* SDL header file containing global vars */
#include <colors.h> /* SDL color names equated to index values */
/* now that clipping rectangle has been redefined, draw the filled */
/* red rectangle and observe that the 100 pixels on the right side, */
/* represented by the dashed red rectangle, does not get drawn. */
filledRectangle(RED_FREC_X, RED_FREC_Y, RED_FREC_WIDTH,
RED_FREC_HEIGHT);
} /* end of main */
SDL C Library Reference Manual 13
C FUNCTIONS
14 SDL C Library Reference Manual
arc
NAME
arc - draws an elliptical arc
SYNOPSIS
void arc
(
int x, /*x-coord of bounding rectangle origin */
int y, /*y-coord of bounding rectangle origin */
int width, /*width of bounding rectangle */
int height, /*height of bounding rectangle */
int start_angle, /*start angle (in 32nds of a degree) */
int end_angle /*end angle (in 32nds of a degree) */
)
DESCRIPTION
This routine draws an elliptical arc (or circular if width=height). Each arc is specified by a
rectangle and two angles. The center of the circle or ellipse is the center of the rectangle,
and the major and minor axes are specified by the width and height of the rectangle.
Positive angles indicate counterclockwise direction, and negative angles indicate
clockwise motion. If the magnitude of either angle is greater than 360 degrees, it is set to
the angle modulo 360 degrees. The arc is drawn relative to the logical origin.
All drawing primitives are affected by the current fill style which is specified with
setFillStyle(). Use SOLID_FILL for drawing solid lines.
INCLUDE FILES
sdl.h, extern.h
SEE ALSO
arc2(), filledArc()
End Angle
x,y
Start Angle
Height
Width
Elliptical Arc
SDL C Library Reference Manual 19
arc2
NAME
arc2 - draws an elliptical arc
SYNOPSIS
void arc2
(
int x, /*x-coord of bounding rectangle origin */
int y, /*y-coord of bounding rectangle origin */
int width, /*width of bounding rectangle */
int height, /*height of bounding rectangle */
int start_angle, /*start angle (in 32nds of a degree) */
int angle_extent /*angle extent (in 32nds of a degree) */
)
DESCRIPTION
This routine draws an elliptical arc (or circular if width=height). Each arc is specified by a
rectangle and two angles. The center of the circle or ellipse is the center of the rectangle,
and the major and minor axes are specified by the width and height of the rectangle.
Positive angles indicate counterclockwise direction, and negative angles indicate
clockwise motion. If the magnitude of start_angle is greater than 360 degrees, it is set to
the angle modulo 360 degrees. If the magnitude of angle_extent is greater than 360
degrees, it is truncated to 360 degrees. The arc is drawn relative to the logical origin.
All drawing primitives are affected by the current fill style which is specified with
setFillStyle(). Use SOLID_FILL for drawing solid lines.
INCLUDE FILES
sdl.h, extern.h
SEE ALSO
arc(), filledArc2()
Angle Extent
Height
Width
Elliptical Arc
20 SDL C Library Reference Manual
boardOK
NAME
boardOK – perform a simple board test
SYNOPSIS
int boardOK(void)
DESCRIPTION
This function performs a few simple board tests to verify the graphics board can be
accessed and the framebuffer memory can be read and written to.
RETURNS
int /* 1 on success, 0 on failure */
INCLUDE FILES
sdl.h
SEE ALSO
SDL C Library Reference Manual 21
boardTemp
NAME
boardTemp – report the board temperature
SYNOPSIS
int boardTemp(void)
DESCRIPTION
This function reports the temperature measured by the onboard LM75 temperature
sensor. This function is not available on all graphics boards.
RETURNS
int /* temperature in degrees C */
INCLUDE FILES
sdl.h
SEE ALSO
22 SDL C Library Reference Manual
circle
NAME
circle - draws a circle
SYNOPSIS
void circle(int x, int y, int radius)
DESCRIPTION
This function draws a single line circle centered about x,y and of the radius specified. x,y
is relative to the logical origin.
All drawing primitives are affected by the current fill style which is specified with
setFillStyle(). Use SOLID_FILL for drawing solid lines.
INCLUDE FILES
sdl.h, extern.h
SEE ALSO
filledCircle()
Radius
Circle
SDL C Library Reference Manual 23
clearScreen
NAME
clearScreen - clears the screen
SYNOPSIS
void clearScreen(void)
DESCRIPTION
This function clears the entire screen to black. The color for black must be specified in the
userinit.c file which is executed by initGraphics().
INCLUDE FILES
sdl.h, extern.h
24 SDL C Library Reference Manual
closeGraphics
NAME
closeGraphics - closes the graphics task
SYNOPSIS
void closeGraphics(void)
DESCRIPTION
This routine is used to terminate graphics processing, and should be the last SDL function
used before any calls are made to the operating system to terminate the graphics task.
This routine is specific to the output graphics hardware and to the operating system being
used.
Failure to call closeGraphics() when exiting a graphics application may lead to
upredictable system operation.
INCLUDE FILES
sdl.h, extern.h
SEE ALSO
initGraphics()
SDL C Library Reference Manual 25
copyImage
NAME
copyImage - copy area of display from one location to another
SYNOPSIS
void copyImage
(
int x, /* source upper left x-coord */
int y, /* source upper left y-coord */
int width, /* source width */
int height, /* source height */
int destx, /* destination upper left x-coord */
int desty /* destination upper left y-coord */
)
DESCRIPTION
CopyImage() copies a rectangular area of the display to another place on the display.
The image data is copied from and to the current write page (which may be different than
the current display page). The image is also clipped to the current clipping rectangle for
the source and destination rectangles.
INCLUDE FILES
sdl.h
SEE ALSO
copyPage(), copyPageImage(), getImage(), putImage()
left,top
right,bottom
(destx, desty)
26 SDL C Library Reference Manual
copyPage
NAME
copyPage - copy one page of graphics memory to another page
SYNOPSIS
void copyPage
(
int src_page, /* source page number */
int dst_page /* destination page number */
)
DESCRIPTION
CopyPage() copies the contents of video RAM page src_page to video RAM page
dst_page. This function is only available for drivers that support mutliple video pages and
graphics hardware that physically has multiple pages of video memory.
The entire page is always copied, regardles of the current clipping rectangle.
INCLUDE FILES
sdl.h
SEE ALSO
copyImage(), copyPageImage(), getImage(), putImage()
SDL C Library Reference Manual 27
copyPageImage
NAME
copyPageImage - copy area of display from one page to another page
SYNOPSIS
void copyPageImage
(
int src, /* source video page */
int x, /* source upper left x-coord */
int y, /* source upper left y-coord */
int width, /* source width */
int height, /* source height */
int dst, /* destination video page */
int destx, /* destination upper left x-coord */
int desty /* destination upper left y-coord */
)
DESCRIPTION
CopyPageImage() copies a rectangular area of the source video page to location (destx,
desty) in a destination video page. Src and dst can refer to the same or different pages in
video memory.For Rastergraf VME graphics boards, both pages must be in the same
graphics channel.This function is only available for drivers that support mutliple video
pages and graphics hardware that physically has multiple pages of video memory.
The image is also clipped to the current clipping rectangle for the source and destination
rectangles.
INCLUDE FILES
sdl.h
SEE ALSO
copyImage(), copyPage(), getImage(), putImage()
28 SDL C Library Reference Manual
dashedLine
NAME
dashedLine - draws a dashed line
SYNOPSIS
void dashedLine
(
int x0, /* x-coord of first endpoint */
int y0, /* y-coord of first endpoint */
int x1, /* x-coord of second endpoint */
int y1 /* y-coord of second endpoint */
)
DESCRIPTION
This routine draws a dashed line from (x0,y0) to (x1,y1). The coordinates are relative to
the logical origin. It uses the current dashed line pattern. The dashed line pattern is set
with the setDashPattern() function, which initializes an array of unsigned chars with the
pixel lengths of the two sections of the dashed line. Two styles of dashed lines are
possible, on/off and double dash, selected with the setDashStyle() function.
On/off dashed lines write the even array index values ( [0], [2], [4], etc. that define the
dashed line pattern) in the current foreground color. The odd array index values ( [1], [3],
[5], etc.) represent the number of pixels to skip. The result is that on/off dashed lines are
drawn in the foreground color and the gap part of the dashed line is not drawn (it is
skipped).
Double dashed lines draw both parts of the dashed line using the current foreground and
background colors. The odd array values [1], [3], [5] are drawn in the background color.
The result is a two color dashed line.
All drawing primitives are affected by the current fill style which is specified with
setFillStyle(). Use SOLID_FILL for drawing solid lines.
INCLUDE FILES
sdl.h, extern.h
SEE ALSO
dashedPolyline(),setDashPattern(), setDashStyle(), setLineWIdth()
x1,y1 x1,y1
x0,y0 x0,y0
dashedPolyline
NAME
dashedPolyline - draws a dashed polyline
SYNOPSIS
void dashedPolyline
(
int num_pts, /*number of points in the array */
sPoint *ptr_to_coord_list /*pointer to array of points */
)
DESCRIPTION
This routine draws dashed lines between each pair of points in the array of sPoint
structures. It draws the lines in the order listed in the array. All coordinates are relative to
the logical origin. It uses the current dashed line pattern. The dashed line pattern is set
with the setDashPattern() function. Two styles of dashed lines are possible: on/off and
double dash. On/off dashed lines write the even array index values ( [0], [2], [4], etc. that
define the dashed line pattern) in the current foreground color. The odd array index
values ( [1], [3], [5], etc.) represent the number of pixels to skip. The result is that on/off
dashed lines are drawn in the foreground color and the gap part of the dashed line is not
drawn (it is skipped). Double dashed lines draw both parts of the dashed line using the
current foreground and background colors. The odd array values [1], [3], [5] are drawn in
the background color. The result is a two color dashed line.
All drawing primitives are affected by the current fill style which is specified with
setFillStyle(). Use SOLID_FILL for drawing solid lines.
The sPoint structure is defined as follows:
x3,y3
x1,y1 x3,y3 x1,y1
dashedRectangle
NAME
dashedRectangle - draws a dashed rectangle
SYNOPSIS
void dashedRectangle
(
int x, /* x-coord of upper left corner */
int y, /* y-coord of upper left corner */
int width, /* width */
int height /* height */
)
DESCRIPTION
This routine draws a dashed rectangle. The x and y coordinates are relative to the logical
origin. Depending on the current dash style, rectangles can be drawn with on/off or
double dashed lines. The dashed line pattern is set with the setDashPattern() function,
which initializes an array of unsigned chars with the pixel lengths of the two sections of the
dashed line. Two styles of dashed lines are possible, on/off and double dashed, selected
with the setDashStyle() function.
On/off dashed lines write the even array index values ( [0], [2], [4], etc. that defines the
dashed line pattern) in the current foreground color. The odd array index values ( [1], [3],
[5], etc.) represent the number of pixels to skip. The result is that on/off dashed lines are
drawn in the foreground color and the gap part of the dashed line is not drawn (it is
skipped). Double dashed lines draw both parts of the dashed line using the current
foreground and background colors. The odd array values [1], [3], [5] are drawn in the
background color. The result is a two color dashed line.
Double dashed lines draw both parts of the dashed line using the current foreground and
background colors. The result is a two color dashed line.
All drawing primitives are affected by the current fill style which is specified with
setFillStyle(). Use SOLID_FILL for drawing solid lines.
INCLUDE FILES
sdl.h, extern.h
SEE ALSO
rectangle(), filledRectangle(), setDashOffset(), setDashPattern(), setDashStyle()
Height Height
drawPixel
NAME
drawPixel - draws a pixel at x,y
SYNOPSIS
void drawPixel
(
int x, /* x-coord of pixel */
int y /* y-coord of pixel */
)
DESCRIPTION
This routine draws a pixel at the display coordinates x,y, relative to the logical origin.
This routine draws a single pixel using the current fill style (set by setFillStyle()) and uses
the foreground color when the fill style is solid color or stipple, and both the foreground
and background colors when the fill style is opaque stipple.
All drawing primitives are affected by the current fill style which is specified with
setFillStyle(). Use SOLID_FILL for drawing solid lines.
INCLUDE FILES
sdl.h, extern.h
SEE ALSO
getPixel()
32 SDL C Library Reference Manual
drawText
NAME
drawText - draws a text string
SYNOPSIS
void drawText
(
int x, /* x-coord of text origin */
int y, /* y-coord of text origin */
char *string /* string to draw */
)
DESCRIPTION
This routine draws a string of ASCII coded characters starting at the specified location,
x,y. x,y is located relative to the logical origin and defines the location of the first
character. The character is positioned so that the left side of its bounding box is located
at x, and the character is positioned vertically so that its baseline sits on a horizontal line
located at y. string contains the ASCII string of text to be printed to the screen or graphics
output device.
Font glyphs are defined with a binary pattern. Ones in the character glyph are drawn in
the current foreground color. If transparency is on, only the ones are drawn and the zeros
in the glyph pattern are not drawn. If transparency is off, the ones are drawn in the
foreground color and the zeros in the glyph pattern are drawn in the background color.
The default is transparency on.
In adition to normal left to right text drawing, a text string may be drawn right to left, top to
bottom, or bottom to top. If text rotated by an arbitrary angle is required, use the optional
vector font or polygon font library.
All drawing primitives are affected by the current fill style which is specified with
setFillStyle(). Use SOLID_FILL for drawing solid lines.
INCLUDE FILES
sdl.h, extern.h
SEE ALSO
setFont(), getTextWidth(), getFontStruct(), setTextDirection()
Descent
ellipse
NAME
ellipse - draws an ellipse
SYNOPSIS
void ellipse
(
int x, /*x-coord of bounding rectangle origin */
int y, /*y-coord of bounding rectangle origin */
int width, /*width of bounding rectangle */
int height /*height of bounding rectangle */
)
DESCRIPTION
This routine draws a single line ellipse. The ellipse is located relative to the logical origin.
All drawing primitives are affected by the current fill style which is specified with
setFillStyle(). Use SOLID_FILL for drawing solid lines.
INCLUDE FILES
sdl.h, extern.h
SEE ALSO
filledEllipse()
x,y
Height
Width
Ellipse
34 SDL C Library Reference Manual
enableStereo
NAME
enableStereo – enable or disable stereo output
SYNOPSIS
void enableStereo
(
int state /* 1 = on, 0 = off */
)
DESCRIPTION
EnableStereo() enables or disables the special stereo output mode of the Borealis 3
graphics chip. The output format is alternating line. A control line toggles to indicate the
active line (left or right). The stereo image is comprised of a left image in the normal frame
buffer (page 0) and a right image in page 1. The graphics controller alternates outputting a
line from page 0, then a line from page 1, then the second line from page 0, and the
second line from page 1, etc.
Typically, this stereo format is usable only on head mounted displays (HMDs) with two
LCDs, or with an external line blanking device.
INCLUDE FILES
sdl.h
SEE ALSO
setWritePage ()
SDL C Library Reference Manual 35
filledArc
NAME
filledArc - draws a filled sector or chord
SYNOPSIS
void filledArc
(
int x, /* x-coord of bounding rectangle origin */
int y, /* y-coord of bounding rectangle origin */
int width, /* width of bounding rectangle */
int height, /* height of bounding rectangle */
int start_angle, /* start angle (in 32nds of a degree) */
int end_angle /* end angle (in 32nds of a degree) */
)
DESCRIPTION
This routine draws a filled sector or filled chord depending on the current filled arc mode,
set by setArcMode(). The arc portion is specified by a rectangle and two angles. The
center of the circle or ellipse is the center of the rectangle, and the major and minor axes
are specified by the width and height. Positive angles indicate counterclockwise motion,
and negative angles indicate clockwise motion. If the magnitude of either angle is greater
than 360 degrees, it is set to the angle modulo 360 degrees.
All drawing primitives are affected by the current fill style which is specified with
setFillStyle(). Use SOLID_FILL for drawing solid lines.
INCLUDE FILES
sdl.h, extern.h
SEE ALSO
arc(), filledArc2(), setArcMode(), setFillStyle()
x,y
Filled Sector
Width
filledArc2
NAME
filledArc2 - draws a filled sector or chord
SYNOPSIS
void filledArc2
(
int x, /* x-coord of bounding rectangle origin */
int y, /* y-coord of bounding rectangle origin */
int width, /* width of bounding rectangle */
int height, /* height of bounding rectangle */
int start_angle, /* start angle (in 32nds of a degree) */
int angle_extent /* angle extent (in 32nds of a degree) */
)
DESCRIPTION
This routine draws a filled sector or filled chord depending on the current filled arc mode,
set by setArcMode(). The arc portion is specified by a rectangle and two angles. The
center of the circle or ellipse is the center of the rectangle, and the major and minor axes
are specified by the width and height. Positive angles indicate counterclockwise motion,
and negative angles indicate clockwise motion. If the magnitude of start_angle is greater
than 360 degrees, it is set to the angle modulo 360 degrees. If the magnitude of
angle_extent is greater than 360 degrees, it is truncated to 360 degrees.
All drawing primitives are affected by the current fill style which is specified with
setFillStyle(). Use SOLID_FILL for drawing solid lines.
INCLUDE FILES
sdl.h, extern.h
SEE ALSO
arc2(), filledArc(), setArcMode(), setFillStyle()
Angle Extent
Filled Chord
x,y
Filled Sector
Width
filledCircle
NAME
filledCircle - draws a filled circle
SYNOPSIS
void filledCircle(int x, int y, int radius)
DESCRIPTION
This function draws a filled circle centered about x,y, and of the radius value specified. x,y
is relative to the logical origin. The circle can be filled with a solid color, a stipple fill, or an
opaque stipple fill. See setFillStyle().
INCLUDE FILES
sdl.h, extern.h
SEE ALSO
circle(), setFillStyle()
Radius
Filled Circle
38 SDL C Library Reference Manual
filledEllipse
NAME
filledEllipse - draws a filled ellipse
SYNOPSIS
void filledEllipse
(
int x, /* x-coord of bounding rectangle origin */
int y, /* y-coord of bounding rectangle origin */
int width, /* width of bounding rectangle */
int height /* height of bounding rectangle */
)
DESCRIPTION
This routine draws a filled ellipse. The ellipse is specified by a bounding rectangle with an
origin at x,y, relative to the logical origin. The center of the circle or ellipse is the center of
the rectangle, and the major and minor axes are specified by the width and height. The
ellipse is filled using the current fill style: solid, stipple, or opaque stipple.
INCLUDE FILES
sdl.h, extern.h
SEE ALSO
filledArc(), setFillStyle()
x,y
Height
Width
Filled Ellipse
SDL C Library Reference Manual 39
filledPolygon
NAME
filledPolygon - draws a filled polygon
SYNOPSIS
void filledPolygon
(
int ptscount, /* number of points in the array */
sPoint *points /* pointer to array of points in the path */
)
DESCRIPTION
This routine fills the polygon formed by the connected lines forming a closed path. If the
path is not closed, (ie the last line does not end where the first line started) the path is
closed automatically. All coordinates are relative to the logical origin.
The polygon is filled using the current fill style (set by setFillStyle()) and according to the
rule specified by the setFillRule() function. The foreground color is used for solid color
and stipple fills, and both the foreground and background colors are used for opaque
stipple fills.
INCLUDE FILES
sdl.h, extern.h
SEE ALSO
polyline(), setFillRule(), setFillstyle(), setPattern()
x0,y0
x2,y2
x1,y1
x4,y4 x3,y3
Filled Polygon
40 SDL C Library Reference Manual
filledRectangle
NAME
filledRectangle - draws a filled rectangle
SYNOPSIS
void filledRectangle
(
int x, /* x-coord of upper left corner */
int y, /* y-coord of upper left corner */
int width, /* width */
int height /* height */
)
DESCRIPTION
This routine draws a filled rectangle. The x and y coordinates are relative to the logical
origin, and specify the coordinates for the upper left corner of the rectangle.
The rectangle is filled using the current fill style (set by setFillStyle()) and uses the
foreground color for solid color and stipple fills, and both the foreground and background
colors for opaque stipple fills.
INCLUDE FILES
sdl.h, extern.h
SEE ALSO
rectangle(), setFillStyle()
x,y Width
Height
Filled Rectangle
SDL C Library Reference Manual 41
flushKeyboard
NAME
flushKeyboard - flush the keyboard queue
SYNOPSIS
void flushKeyboard(void)
DESCRIPTION
FlushKeyboard() clears the keyboard queue on the graphics board of any key pushes.
INCLUDE FILES
drv/rgkeybd.h
SEE ALSO
keyboardRead(), keyboardReady()
42 SDL C Library Reference Manual
flushMouse
NAME
flushMouse - flush the mouse queue
SYNOPSIS
void flushMouse(void)
DESCRIPTION
FlushMouse() clears the mouse queue on the graphics board of any mouse events.
INCLUDE FILES
drv/rgmouse.h
SEE ALSO
mouseRead(), mouseReady()
SDL C Library Reference Manual 43
getColor
NAME
getColor - reads an rgb color from color palette
SYNOPSIS
void getColor
(
int index, /* palette index */
int *red, /* points to save location for red */
int *green, /* points to save location for green */
int *blue /* points to save location for blue */
)
DESCRIPTION
This routine reads the rgb color values from the specified index value of the systems color
palette and stores the values at the addresses, red, green, and blue.
INCLUDE FILES
sdl.h, extern.h, colors.h
SEE ALSO
storeColor()
44 SDL C Library Reference Manual
getFontStruct
NAME
getFontStruct - gets font parameters
SYNOPSIS
void getFontStruct
(
sFontStruct *fs /* pointer to structure with */
/* font parameters */
)
DESCRIPTION
This routine fills in the structure, fs, with the parameters for the current font.
Proportionally spaced fonts typically fill in the fontAscent and fontDescent structure
members, while constant space fonts typically use minbounds.ascent and
minbounds.descent for the overall font ascent and descent values.
The FontStruct structure is defined as follows:
typedef struct tagFontInfo
{
short width, /* width of character in pixels */
ascent, /* number of pixels above baseline */
descent; /* number of pixels below baseline */
}sFontInfo, *spFontInfo;
INCLUDE FILES
sdl.h, extern.h
SEE ALSO
drawText(), getTextWidth(), setFont()
SDL C Library Reference Manual 45
getFramebufPtr
NAME
getFramebufPtr – gets current value of the framebuffer pointer
SYNOPSIS
unsigned char *getFramebufPtr(void)
DESCRIPTION
This routine looks up the current value of the framebuffer pointer. This pointer is only valid
for the current device context. If the active graphics device is changed, or a different write
page is selected, the pointer may become invalid, so this function should be called again
to obtain the updated value.
RETURNS
unsigned char * /* pointer to framebuffer memory */
INCLUDE FILES
sdl.h
SEE ALSO
setGraphicsDevice(), setWritePage()
46 SDL C Library Reference Manual
getImage
NAME
getImage - copy area of display to host memory
SYNOPSIS
void getImage
(
int x, /* source upper left x-coord */
int y, /* source upper left y-coord */
int width, /* source width */
int height, /* source height */
unsigned char *buff /* host memory buffer */
)
DESCRIPTION
GetImage() copies a rectangular area of the display to a host memory buffer pointed to by
buff. The user must allocate enough memory to contain the image. The amount of
memory, in bytes, can be calculated as:
size = width * height;
In 256 color video modes, each pixel is stored as a single byte with a value from 0 to 255.
In 16 color video modes, each pixel is stored as a single byte with a value from 0 to 15.
The image source data is taken from the current write page and is clipped to the current
clipping rectangle.
INCLUDE FILES
sdl.h
SEE ALSO
copyImage(), copyPageImage(), putImage()
x,y HOST
MEMORY
height
width
Video Screen
(VRAM)
SDL C Library Reference Manual 47
getMouseXY
NAME
getMouseXY - get the current mouse location
SYNOPSIS
void getMouseXY
(
int *mx, /* pointer to returned mouse X position */
int *my /* pointer to returned mouse Y position */
)
DESCRIPTION
GetMouseXY() gets the current location of the mouse cursor.
The returned position is the location of the cursor “hot-spot” on the screen, based on
absolute screen coordinates.
INCLUDE FILES
drv/rgmouse.h
SEE ALSO
mouseRead(), mouseReady(), mouseCursorXY(), mouseRect(), mouseScale(),
setMouseParam()
48 SDL C Library Reference Manual
getPixel
NAME
getPixel - gets pixel at x,y
SYNOPSIS
unsigned long getPixel
(
int x, /* pixel’s x coordinate*/
int y /* pixel’s y coordinate */
)
DESCRIPTION
This routine returns the value of the pixel at x,y. The x,y coordinates are relative to the
logical origin.
INCLUDE FILES
sdl.h, extern.h
RETURNS
unsigned long /* 32 bit value of pixel at x,y */
SEE ALSO
drawPixel()
SDL C Library Reference Manual 49
getTextWidth
NAME
getTextWidth - gets width of text string
SYNOPSIS
int getTextWidth
(
char *string /* string to measure */
)
DESCRIPTION
This routine returns the width in pixels of the null terminated text string pointed to by
string. Regardless of the current text drawing direction, getTextWidth() always returns the
width as if the string is drawn horizontally left to right. If passed a null string, it returns zero
for the length.
INCLUDE FILES
sdl.h, extern.h
RETURNS
int /* string_width, -1 on error */
SEE ALSO
drawText(), getFontStruct()
50 SDL C Library Reference Manual
initGraphics
NAME
initGraphics - initializes SDL and the graphics hardware
SYNOPSIS
int initGraphics(int argc, char **argv)
DESCRIPTION
This routine initializes SDL and the graphics hardware by executing the code contained in
userinit.c. This file must be modified by the user to initialize the user’s system before
graphics processing can occur. Typically, userinit.c installs the selected fonts, initializes
the graphics hardware, and performs power up initialization required by the user’s system
to be able to run SDL. The argv parameters may be used to pass command line
arguments to initGraphics().
To modify the default parameters, the user must edit the file userinit.c, recompile it, and
link it.
Arguments passed to initGraphics() are driver specific. Currently, the only argument used
by all drivers is -v, which overides the video mode selection made in userinit.c. See the
include file sdl.h for a list of video modes. Using a value of -1, with the -v switch will print a
list of supported video modes. Using a flag of -h will print a help message showing
available options.
Since VxWorks does not generally support argc/argv style arguments, all options must be
passed as a single string as the first argument to initGraphics(). For example:
keyboardRead
NAME
keyboardRead - read keyboard character
SYNOPSIS
void keyboardRead(unsigned short *kdata)
DESCRIPTION
KeyboardRead() is a blocking call to read a character from the keyboard buffer. The
keycode is returned in the least significant byte of the short word pointed to by kdata. For
Rastergraf VME graphics boards, extended keycodes have the most significant byte of the
short word set to 0xff; standard keycodes have the most significant byte set to zero.
INCLUDE FILES
drv/rgkeybd.h
SEE ALSO
flushKeyboard(), keyboardReady()
52 SDL C Library Reference Manual
keyboardReady
NAME
keyboardReady - check for keycodes in the keyboard queue
SYNOPSIS
int keyboardReady(void)
DESCRIPTION
KeyboardReady() is a non-blocking call to check if any characters are available in the
keyboard buffer.
INCLUDE FILES
drv/rgkeybd.h
SEE ALSO
flushKeyboard(), keyboardRead()
SDL C Library Reference Manual 53
line
NAME
line - draws a line
SYNOPSIS
void line
(
int x0, /* x-coord of first endpoint */
int y0, /* y-coord of first endpoint */
int x1, /* x-coord of second endpoint */
int y1 /* y-coord of second endpoint */
)
DESCRIPTION
This routine draws a single pixel line from (x0,y0) to (x1,y1). The coordinates are relative
to the logical origin. The line is drawn using the current fill style (set by setFillStyle()) and
and line width (set by setLineWidth()) uses the foreground color when the fill style is solid
color or stipple, and both the foreground and background colors when the fill style is
opaque stipple.
Wide lines are only available when the fill style is SOLID. A line width of 1 forces use of
the wide line function, while a line width of zero uses the optimized zero-width line drawing
functions.
INCLUDE FILES
sdl.h, extern.h
SEE ALSO
polyline(), dashedLine(), setLineWidth()
x1,y1
x0,y0
Line
54 SDL C Library Reference Manual
mouseCursorOn
NAME
mouseCursorOn - turn the mouse cursor on or off
SYNOPSIS
void mouseCursorOn
(
int state /* 1 = on, 0 = off */
)
DESCRIPTION
MouseCursorOn() turns the mouse cursor on and off. The cursor type can be changed by
using setMouseCursor(). The cursor position can be moved by using mouseCursorXY().
The screen contents under the cursor are automatically saved when the cursor is enabled
(state = 1) and restored when the cursor is disabled (state = 0).
When the mouse is enabled in the driver, the default mouse cursor is automatically
displayed. This function can be used to turn it off, then on again as required when
changing the mouse setup.
INCLUDE FILES
drv/rgmouse.h
SEE ALSO
getMouseXY(), mouseCursorXY(), mouseRead(), mouseReady(), mouseRect(),
mouseScale(), setMouseCursor(), setMouseParam()
SDL C Library Reference Manual 55
mouseCursorXY
NAME
mouseCursorXY - move the mouse cursor to a new position
SYNOPSIS
void mouseCursorXY
(
int x, /* new x-coord of position */
int y /* new y-coord of position */
)
DESCRIPTION
MouseCursorXY() changes the current x-y mouse address and specifies the starting point
for the mouse cursor on the screen. If the mouse cursor already being displayed, it is
repositioned to the x-y location specified.
The position is the location of the cursor “hot-spot” on the screen, based on absolute
screen coordinates.
INCLUDE FILES
drv/rgmouse.h
SEE ALSO
mouseCursorOn(), mouseRect(), mouseScale(),setMouseCursor(),
setMouseParam()
56 SDL C Library Reference Manual
mouseRead
NAME
mouseRead - read a mouse event
SYNOPSIS
void mouseRead
(
sMouseEvent *mse /* pointer to returned mouse event */
)
DESCRIPTION
MouseRead() reads a single mouse event from the mouse queue into the event structure
mse. This is a blocking call that does not return until a mouse event has been read. Use
the non-blocking mouseReady() call to query if any events are in the queue. The
sMouseEvent structure is defined as:
mouseReady
NAME
mouseReady - check for mouse events in the mouse queue
SYNOPSIS
int mouseReady(void)
DESCRIPTION
MouseReady() is a non-blocking call to check if any events available in the mouse queue.
It is used to check if an event is available before calling the blocking mouseRead()
function.
INCLUDE FILES
drv/rgmouse.h
RETURNS
Zero on success, non-zero on failure or when the mouse is not enabled in the driver.
SEE ALSO
flushMouse(), mouseRead()
58 SDL C Library Reference Manual
mouseRect
NAME
mouseRect - set window limits for the mouse cursor
SYNOPSIS
void mouseRect
(
int x, /* upper left x-coord */
int y, /* upper left y-coord */
int width, /* width of bounding area */
int height /* height of bounding area */
)
DESCRIPTION
MouseRect() sets a boundary window for the mouse cursor. The mouse cursor movement
is pinned at the new window edges. The bounding rectangle is based on absolute screen
coordinates.
MouseRect() does not automatically set the MSECSR_WINDOW bit in mouse parameter zero.
This must be done using the setMouseParam() function when the boundary window is
smaller than the screen size.
INCLUDE FILES
drv/rgmouse.h
SEE ALSO
getMouseXY(), mouseCursorOn(), mouseCursorXY(), mouseScale(),
setMouseCursor(), setMouseParam()
SDL C Library Reference Manual 59
mouseScale
NAME
mouseScale - set scale factors for the mouse cursor
SYNOPSIS
void mouseScale
(
int xscale, /* scaling in x direction */
int yscale /* scaling in y direction */
)
DESCRIPTION
MouseScale() sets the scale factors used for the mouse cursor. Incoming mouse
movement is multiplied by the scale factors factors in calculating the updated mouse
cursor position. The scale factors are in a 16-bit fixed point format with 8-bit integer and 8-
bit fraction. The default scaling is +1.000 (0x0100).
INCLUDE FILES
drv/rgmouse.h
SEE ALSO
getMouseXY(), mouseCursorOn(), mouseCursorXY(), mouseRect(),
setMouseCursor(), setMouseParam()
60 SDL C Library Reference Manual
panelType
NAME
panelType – report hardware configured display panel type
SYNOPSIS
int panelType (void)
DESCRIPTION
This function returns the display panel type as reported by the graphics hardware
configuration bits. The return value is driver specific.
INCLUDE FILES
sdl.h
RETURNS
int /* up to 32-bits of driver/hardware specific info */
SDL C Library Reference Manual 61
polyline
NAME
polyline - draws a polyline
SYNOPSIS
void polyline
(
int num_pts, /*number of points in the array */
sPoint *ptr_to_coord_list /*pointer to array of points */
)
DESCRIPTION
This routine draws lines connecting each pair of points in the array of sPoint structures. It
draws the lines, connecting the points in the order listed in the array. If the lines intersect,
the intersecting pixels are drawn again and pixel processing will behave accordingly. All
coordinates are relative to the logical origin.
The lines are drawn using the current fill style (set by setFillStyle())and line width (set by
setLineWidth()) and use the foreground color when the fill style is solid color or stipple,
and both the foreground and background colors when the fill style is opaque stipple.
Wide lines are only available when the fill style is SOLID. A line width of 1 forces use of
the wide line function, while a line width of zero uses the optimized zero-width line drawing
functions.
The sPoint structure is defined as follows:
x1,y1 x3,y3
x0,y0
x2,y2
Polyline
62 SDL C Library Reference Manual
putImage
NAME
putImage - copy image in host memory to the display
SYNOPSIS
void putImage
(
unsigned char *buff, /* host memory buffer */
int width, /* source width */
int height, /* source height */
int x, /* destination upper left x-coord */
int y /* destination upper left y-coord */
)
DESCRIPTION
PutImage() copies an image in host memory to a rectangular area of the display. The host
memory buffer is a raw pixmap with one byte per pixel and pitch equal to the width of the
image.
Each byte in the source image represents a pixel color in the current color palette. In 256
color video modes, each pixel is a single byte with a value from 0 to 255. In 16 color video
modes, each pixel is a single byte with a value from 0 to 15.
The image data is drawn to the current write page and is clipped to the current clipping
rectangle.
INCLUDE FILES
sdl.h
SEE ALSO
copyImage(), copyPageImage(), getImage()
HOST
MEMORY x,y
height
width
Video Screen
(VRAM)
SDL C Library Reference Manual 63
rectangle
NAME
rectangle - draws a rectangle
SYNOPSIS
void rectangle
(
int x, /* x-coord of upper left corner */
int y, /* y-coord of upper left corner */
int width, /* width */
int height /* height */
)
DESCRIPTION
This routine draws a rectangle. The x and y coordinates are relative to the logical origin of
the screen.
The rectangle edges are drawn using the current fill style (set by setFillStyle())and line
width (set by setLineWidth()).
Wide lines for edges are only available when the fill style is SOLID. A line width of 1 forces
use of the wide line function, while a line width of zero uses the optimized zero-width line
drawing functions.
INCLUDE FILES
sdl.h, extern.h
SEE ALSO
filledRectangle(), dashedRectangle()
x,y Width
Height
Rectangle
64 SDL C Library Reference Manual
setArcMode
NAME
setArcMode - specifies a filled arc to be a filled sector or filled chord
SYNOPSIS
void setArcMode
(
int fillMode /* 0==filled sector; 1==filled chord */
)
DESCRIPTION
This routine specifies what the filledArc() function will draw: a filled sector or filled chord.
The sector or chord can be filled with a solid color, stipple pattern, or an opaque stipple
pattern.
The arc modes are defined in sdl.h as follows:
# define SECTOR_MODE 0
# define CHORD_MODE 1
INCLUDE FILES
sdl.h, extern.h
SEE ALSO
filledArc(), setFillStyle()
x,y
Filled Sector
Width
setBackground
NAME
setBackground - sets the background color
SYNOPSIS
void setBackground
(
unsigned long color /* new background color */
)
DESCRIPTION
This routine sets the current background color by loading the global variable _bcolor with
the unsigned 32 bit value passed to it. The background color is used for the character cell
background color when transparency is off, for a stipple pattern background color, and for
dashed lines when double dash is specified. The value loaded into the global variable is
device dependent, and will be converted as necessary by the graphics driver to be
compatible with the graphics hardware.
Most graphics drivers support 8, 16, and 24 or 32 bit color values.
INCLUDE FILES
sdl.h, extern.h
SEE ALSO
setForeground()
66 SDL C Library Reference Manual
setClipRect
NAME
setClipRect - sets the clipping rectangle.
SYNOPSIS
void setClipRect
(
int x, /* x coordinate of clip origin */
int y, /* y coordinate of clip origin */
int width, /* width of clipping rectangle */
int height /* height of clipping rectangle */
)
DESCRIPTION
This routine sets the parameters of the clipping rectangle on the screen. All primitives are
clipped to this area. Height and width must be positive or zero. A width or height of zero
will prevent any graphics from appearing on the screen. The default clip rectangle is the
entire visible screen. The clipping rectangle is positioned relative to the screen
coordinates.
INCLUDE FILES
sdl.h, extern.h
Screen
0,0 X
Clip Rectangle
Height
Width
Clip Rectangle
SDL C Library Reference Manual 67
setDashOffset
NAME
setDashOffset – sets a new pattern offset for dashed lines
SYNOPSIS
void setDashOffset
(
int dashOffset /* pixel offset for pattern start*/
)
DESCRIPTION
The dashOffset specifies the starting point from the beginning of the pattern in pixels.
This feature allows the user to specify where to start in the pattern. The dashed line
pattern does not restart each time it is used, allowing dashed lines to continue around the
corner of a rectangle, or polyline. The user has the option of restarting the pattern by
specifying a dashOffset value of zero.
INCLUDE FILES
sdl.h, extern.h
SEE ALSO
setDashPattern(), setDashStyle()
68 SDL C Library Reference Manual
setDashPattern
NAME
setDashPattern - specifies the dash line pattern for dashed lines
SYNOPSIS
void setDashPattern
(
int numDashes, /* number of entries in the dash list */
unsigned char *dashList, /* dash pattern list */
int dashOffset /* pixel offset for pattern start*/
)
DESCRIPTION
This routine specifies the pattern to be used for dashed lines. The first parameter,
numDashes, specifies the number of entries in the dashList. The dashList tells the line-
drawing routine the sequence of pixels to write and skip. If, for example, the dashList
contained [2,3,1,4], the line drawing routine would draw two pixels in the foreground color,
skip three, draw one, skip four, and then repeat the pattern until the line was completed,
assuming on/off was the active dashed line style. If double dashed was the active dashed
line style, the values in the even index locations ([0], [2], etc.) would be written in the
foreground color as before, and the values in the odd index locations ([1], [3], etc.) would
be written in the background color.
There must be at least one element in the specified dash list. All of the elements must be
nonzero.
The dashOffset specifies the starting point from the beginning of the pattern in pixels.
This feature allows the user to specify where to start in the pattern. The dashed line
pattern does not restart each time it is used, allowing dashed lines to continue around the
corner of a rectangle, or polyline. The user has the option of restarting the pattern by
specifying a dashOffset value of zero.
The number of entries in the list is limited to 255.
INCLUDE FILES
sdl.h, extern.h
SEE ALSO
setDashOffset(), setDashStyle()
setDashStyle
NAME
setDashStyle - specifies the dash line style, On/Off or Double Dash
SYNOPSIS
void setDashStyle
(
int dashStyle /* 0 == on/off; 1 == double dash */
)
DESCRIPTION
This routine specifies the dashed line style to be used for dashed lines.
On/Off dashed lines draw one color dashed lines. The foreground color is used.
Double Dashed lines are two color dashed lines. Both the foreground and background
colors are used.
#define ONOFF_DASH 0
#define DOUBLE_DASH 1
INCLUDE FILES
sdl.h, extern.h
SEE ALSO
setDashOffset(), setDashPattern()
setDisplayPage
NAME
setDisplayPage - set the current display page
SYNOPSIS
void setDisplayPage
(
int pagenum /* graphics memory page number */
)
DESCRIPTION
SetDisplayPage() selects the page number (for graphics hardware with more than one
page of video memory) that is to be displayed. Page numbering starts at zero.
INCLUDE FILES
sdl.h
SEE ALSO
setWritePage()
SDL C Library Reference Manual 71
setFillRule
NAME
setFillRule - specifies the fill rule for polygon fills
SYNOPSIS
void setFillRule
(
int fillrule /* rule for filledPolygon */
)
DESCRIPTION
This routine specifies the fill rule to be used for filling polygons.
Specify 0 for EVENODD or 1 for WINDING. The default is EVENODD.
The fill-rule determines how self-intersecting polygons are filled, by defining which pixels
are inside (drawn). For EVENODD, a point is inside if an infinite ray originating at that point
as crosses the path an odd number of times. For WINDING, a point is inside if an infinite
ray originating at that point crosses an unequal number of clockwise and counterclockwise
directed path segments. A clockwise directed path segment is one that crosses the ray
from left to right as observed from the point. A counterclockwise segment is one that
crosses the ray from right to left as observed from the point. The case where a directed
line segment is coincident with the ray is uninteresting because you can simply choose a
different ray that is not coincident with a segment.
For both EVENODD and WINDING, a point is infinitely small, and the path is an infinitely
thin line. A pixel is inside if the center point of the pixel is inside and the center point is not
on the boundary. If the center point is on the boundary, the pixel is inside if and only if the
polygon interior is immediately to its right (x increasing direction). Pixels with centers on a
horizontal edge are a special case and are inside if and only if the polygon interior is
immediately below (y increasing direction).
The fill rule is defined in sdl.h, as:
#define EVENODD 0
#define WINDING 1
INCLUDE FILES
sdl.h, extern.h
SEE ALSO
filledPolygon()
72 SDL C Library Reference Manual
setFillStyle
NAME
setFillStyle - specifies a fill style of solid, stipple, or opaque stipple
SYNOPSIS
void setFillStyle
(
int fillStyle /* 0== solid, 1== stipple */
/* 2==opaque stipple */
)
DESCRIPTION
This routine specifies the fill style for circles, ellipses, arcs (sectors and chords) polygons,
and rectangles. The fill style affects all other drawing primitives. For example, a line
will be drawn with the stipple pattern if the fill style is set to stipple.
Only the foreground color is used for solid or stipple fills. Both the foreground and
background colors are used for opaque stipple fills.
The fill style is defined in sdl.h as:
#define SOLID_FILL 0
#define STIPPLE_FILL 1
#define OPAQUE_FILL 2
INCLUDE FILES
sdl.h, extern.h
SEE ALSO
filledPolygon(), filledRectangle(), filledArc()
SDL C Library Reference Manual 73
setFont
NAME
setFont - sets the current font
SYNOPSIS
void setFont
(
int fontIndex /* selects the current font */
)
DESCRIPTION
This routine selects the current font. This function takes as a parameter, the font name as
defined in fonts.h, or the corresponding index value for the font.
The user installs fonts by adding the font names to the global array _fontTable specified
in the file fonts.c.
The default fonts for SDL are shown below. Also see Appendix B.
#define HELVR12 0 /* Helvetica 12pt Normal Prop. Spaced */
#define HELVR08 1 /* Helvetica 8pt Normal Prop. Spaced */
#define HELVR10 2 /* Helvetica 10pt Normal Prop. Spaced */
#define HELVR14 3 /* Helvetica 14pt Normal Prop. Spaced */
#define HELVR18 4 /* Helvetica 18pt Normal Prop. Spaced */
#define HELVR24 5 /* Helvetica 24pt Normal Prop. Spaced */
#define CLR6X6 6 /* Clear 6x6 Normal Fixed Width */
#define CLR8X8 7 /* Clear 8x8 Normal Fixed Width */
#define CLR8X16 8 /* Clear 8x16 Normal Fixed Width */
#define FIX12X24RK 9 /* 12x24 Normal Fixed Width Roman-Kana */
#define HELVB14 10 /* Helvetica 14pt Bold Prop. Spaced */
#define HELVB18 11 /* Helvetica 18pt Bold Prop. Spaced */
#define HELVB24 12 /* Helvetica 24pt Bold Prop. Spaced */
#define HELVBO14 13 /* Helvetica 14pt BoldOblique Prop. Spaced */
#define HELVBO18 14 /* Helvetica 18pt BoldOblique Prop. Spaced */
#define HELVBO24 15 /* Helvetica 24pt BoldOblique Prop. Spaced */
#define RGBOLD36 16 /* Peritek Bold Fixed 36x78 */
#define RGSWISS44 17 /* Peritek Swiss Fixed 44x70 */
INCLUDE FILES
sdl.h, extern.h, fonts.h
SEE ALSO
drawText()
74 SDL C Library Reference Manual
setForeground
NAME
setForeground - sets the current foreground color
SYNOPSIS
void setForeground
(
unsigned long color /* new foreground color */
)
DESCRIPTION
This routine sets the current foreground color. All primitives are drawn using the
foreground color. The actual value used for the color is hardware dependent. This
functions loads the 32 bit color parameter passed to it into the global variable _fcolor.
The graphics driver must convert the 32 bit color parameter to the appropriate value for
the display hardware. Most graphics drivers support 8, 16, and 24 or 32 bit color values.
INCLUDE FILES
sdl.h, extern.h
SEE ALSO
setBackground()
SDL C Library Reference Manual 75
setGraphicsDevice
NAME
setGraphicsDevice - set the current graphics display device
SYNOPSIS
void setGraphicsDevice
(
int devnum /* graphics device number */
)
DESCRIPTION
SetGraphicsDevice() selects the graphics device for graphics hardware with more than
one channel, for systems with more than one graphics device installed or for graphics
hardware with multiple outputs formats, such as SVGA chips with CRT, LCD and/or video
outputs. Device numbering starts at zero and is driver specific.
All drawing primitives, keyboard operations and mouse operations apply to the currently
selected graphics device. When used to switch between multiple graphics devices, the
current display page, write page, clipping rectangle and mouse status is saved for each
graphics device to make the switching between multiple graphics devices as transparent
as possible.
Depending on the particular driver and graphics hardware used, the userinit.c file may
need to be edited to set the device addresses and other features that are unique for each
device.
The device ids used with typical PMC graphics boards defined in sdl.h as:
#define CRT_DEVICE 0x000001 /* default */
#define LCD_DEVICE 0x000002
#define NTSC_TV_DEVICE 0x000004
#define PAL_TV_DEVICE 0x000008
As of SDL version 3.1, additional support was added to support multiple graphics
controllers on a single graphics board, and multiple graphics boards in a system. The
following defines can be or’d together to select a specific board and controller
combination:
#define GDEV_0 0x000000 /* first (or only) graphics controller */
#define GDEV_1 0x000100 /* second graphics controller */
#define GDEV_2 0x000200 /* third graphics controller */
#define GDEV_3 0x000300 /* fourth graphics controller */
#define GBRD_0 0x000000 /* first (or only) graphics board */
#define GBRD_1 0x010000 /* second graphics board */
#define GBRD_2 0x020000 /* third graphics board */
#define GBRD_3 0x030000 /* fourth graphics board */
76 SDL C Library Reference Manual
As of SDL version 3.2, additional flags were added to support the dual channel display
engines in the SM731 and M9-based graphics boards. These flags are:
#define VP2CRTDAC 0x000010 /* VP engine feeds CRT DAC */
#define VP2DIGOUT 0x000020 /* VP engine feeds flat panel output */
#define VP2LVDS2 0x000040 /* VP engine feeds LVDS2 output */
#define NULL_DEVICE 0x000080 /* keep previous output settings */
INCLUDE FILES
sdl.h
SEE ALSO
setMode()
SDL C Library Reference Manual 77
setLineWidth
NAME
setLineWidth - sets the current line width
SYNOPSIS
void setLineWidth
(
int width /* new line width */
)
DESCRIPTION
This routine sets the current line width. All dashed and solid line primitives (line, polyline,
rectangle) use the line width when drawing lines. A line width of 1 may not be the same
as a line width of zero for diagonal lines as they use different low level functions to draw
the lines.
INCLUDE FILES
sdl.h, extern.h
SEE ALSO
dashedLine(), dashedPolyline(), line(), polyline()
78 SDL C Library Reference Manual
setMode
NAME
setMode - set displayed video mode and attributes
SYNOPSIS
int setMode
(
char *mode_args /* init args in string form */
)
DESCRIPTION
SetMode() is used to change the video mode (resolution and bits per pixel) of the currently
active graphics device. Other attributes, such as virtual width and height, refresh clock
frequency, etc., can also be set, depending on the specific graphics board and driver. This
function can be used (where supported) in place of calling closeGraphics() followed by
initGraphics() to reinitialize the board. The mode_args string is the list of initialization
arguments in string form.
SetMode() is usually used with the sm731 driver (Colos/Duros/Stratus/Tropos boards) to
set a different resolution on the second display channel. When the second channel is
initialized (via setGraphicsDevice()), it acquires the same video mode (resolution, bits per
pixel, etc.) as the primary channel, so by using setMode() the primary (flat panel) channel
can remain at its original resolution (say 1024x768) and the secondary CRT channel could
be configured to display a different image at say 640x480 resolution.
EXAMPLE
int myprog(int argc, char **argv)
{
/* initialize main (FP) channel */
if (initGraphics(argc, argv)) {
printf(“initialization failed!\n”);
return –1;
}
/* initialize VP channel */
setWritePage(4); /* different memory region for channel 2 */
setGraphicsDevice(GDEV_1|VP2CRTDAC);
/* change VP video mode to 640x480x8 at 60 Hz */
if (setMode(“-v 1 –c 60”))
return –1; /* failed to change video mode */
/* select FP channel again */
setGraphicsDevice(GDEV_0|NULL_DEVICE);
setWritePage(0); /* original memory region for channel 1 */
:
}
INCLUDE FILES
sdl.h
RETURNS
int /* 0 on success, -1 on error */
SEE ALSO
closeGraphics(), initGraphics(), setGraphicsDevice()
SDL C Library Reference Manual 79
setMouseCursor
NAME
setMouseCursor - set mouse cursor type and colors
SYNOPSIS
void setMouseCursor
(
unsigned long csr_id, /* predefined cursor num. or addr */
unsigned long color1, /* bottom color of the cursor */
unsigned long color2 /* top color of the cursor */
)
DESCRIPTION
SetMouseCursor() selects one of the predefined mouse cursors, or a user defined cursor
symbol. If the value of csr_id is less than 128, it is assumed to be an index into the table of
default cursors; otherwise csr_id is assumed to be a pointer to a user defined cursor
structure which has been previously downloaded to the graphics board. A list of
predefined cursors is listed in Appendix D. The default cursor is a left arrow.
Only one mouse cursor is available per graphics device. If a mouse cursor is already on, it
must be turned off (using mouseCursorOn()) before calling this function, then turned on
again.
INCLUDE FILES
drv/rgmouse.h
SEE ALSO
getMouseXY(), mouseCursorOn(), mouseCursorXY()
80 SDL C Library Reference Manual
setMousePage
NAME
setMousePage - set the mouse display page
SYNOPSIS
int setMousePage
(
int page /* graphics memory page */
)
DESCRIPTION
SetMousePage() sets graphics memory page that is used for displaying the mouse cursor.
The page always refers to the currently selected graphics device (if there is more than one
device in the system) and currently selected channel (underlay or overlay, if supported).
If the mouse cursor is already on, it must be turned off (using mouseCursorOn()) before
calling this function, then turned on again.
INCLUDE FILES
drv/rgmouse.h
SEE ALSO
mouseCursorOn(), mouseCursorXY(), mouseRead(), mouseReady(), mouseRect(),
mouseScale(), setGraphicsDevice(), setMouseCursor()
SDL C Library Reference Manual 81
setMouseParam
NAME
setMouseParam - set the mouse configuration parameters
SYNOPSIS
void setMouseParam
(
int pid, /* parameter id */
int value /* parameter value */
)
DESCRIPTION
SetMouseParam() sets mouse parameter pid to value value. The mouse parameters and
special defines for the bits in certain parameters are listed below. Use mouseScale() to
set the scale parameters and mouseRect() to set the window parameters.
If the mouse cursor is already on, it must be turned off (using mouseCursorOn()) before
calling this function, then turned on again.
/*******************************************************/
/* MOUSE MODE PARAMETERS */
/*******************************************************/
#define MSE_TRACKMODE 0 /* mouse position tracking mode */
#define MSE_REPORTMODE 1 /* mouse reporting mode */
/************************************************/
/* bit fields and values of selected parameters */
/************************************************/
INCLUDE FILES
drv/rgmouse.h
SEE ALSO
mouseCursorOn(), mouseCursorXY(), mouseRead(), mouseReady(), mouseRect(),
mouseScale(), setMouseCursor(), setMousePage()
82 SDL C Library Reference Manual
setOrigin
NAME
setOrigin() - sets the logical origin
SYNOPSIS
void setOrigin
(
int x, /* x coordinate */
int y /* y coordinate */
)
DESCRIPTION
This routine sets the logical origin. All graphics primitives are drawn relative to the logical
origin.
The default value is for the logical origin to be located at the screen origin.
A graphics object, such as a gauge, can be drawn relative to 0,0 and can subsequently be
redrawn at a different screen location by simply changing the logical origin to the new
location before redrawing the gauge.
INCLUDE FILES
sdl.h, extern.h
Y=80 0,0
setPanStart
NAME
setPanStart() - sets the display origin within the virtual window
SYNOPSIS
void setPanStart
(
int x, /* x coordinate */
int y /* y coordinate */
)
DESCRIPTION
This routine sets the origin of the displayed window, within a larger virtual window. The
default value is for the display origin to be located at the upper left corner of the virtual
window.
A large graphics object, or multiple graphics objects, can be drawn beyond the physical
display size with setPanStart() called to pan the display to make different portions of the
virtual window visible.
INCLUDE FILES
sdl.h, extern.h
SEE ALSO
setVirtualSize()
Y=436
1023,915
1023,1023
setPattern
NAME
setPattern() - specifies the current stipple fill pattern
SYNOPSIS
void setPattern
(
sPattern *newpattern /* Pointer to stipple pattern */
)
DESCRIPTION
Use this function to specify the current stipple pattern for use with both stipple and opaque
stipple fills. The stipple pattern must be created and placed at the corresponding memory
location by the user.
The following can be filled with a stipple pattern: filled polygons, filled circles, filled
ellipses, filled arcs, and filled rectangles.
Text and lines are also drawn with the stipple pattern if stipple or opaque stipple is
selected as the current fill style.
The stipple fill pattern is limited to 16 pixels wide maximum, but the width can be any
value from 1 to 16. The height of the pattern can be any value from 1 to 255. The stipple
pattern is a binary pattern. The ones in the pattern are expanded to the foreground color.
For opaque stipple fills, the zeros in the pattern are expanded to the background color.
All drawing primitives are affected by the current fill style which is specified with
setFillStyle(). Use SOLID_FILL for drawing solid lines.
The sPattern structure is defined as follows:
setPatternOrigin
NAME
setPatternOrigin - sets stipple fill pattern origin
SYNOPSIS
void setPatternOrigin
(
int x, /* start location in x from pattern edge */
int y /* start location in y from pattern edge */
)
DESCRIPTION
Use this function to set the pattern origin in x and y from the pattern edge.
The default coordinates for the pattern origin is x=0, y=0. As a pattern is drawn the
coordinates of the pattern continue to increment, modulo whatever the pattern dimensions
(in pixels) are.
Use the setPatternOrigin() to reset the pattern coordinates to zero, thereby causing the
stipple pattern to be drawn starting at the beginning of the pattern. A stipple pattern is
shown twice below, each with a different origin, indicating the starting point of the pattern.
INCLUDE FILES
sdl.h, extern.h
SEE ALSO
setPattern()
y=0
y=2
setPixelProcessing
NAME
setPixelProcessing - sets pixel processing, replace, and, or, xor
SYNOPSIS
void setPixelProcessing
(
int operation /* 0 == replace*/
) /* 1 == and */
/* 2 == or */
/* 3 == xor */
DESCRIPTION
This function specifies the boolean operation for pixel processing. Pixel processing
operates on the color index values, not on the color data stored in the color lookup table.
If the color mode is true color, then pixel processing operates on the actual pixel values,
because they are not index values. For a palette based system, the pixel color value is an
index into a color lookup table.
The pixel processing types are defined in sdl.h as follows:
#define REPLACE 0
#define AND 1
#define OR 2
#define XOR 3
Invalid processing values are set to REPLACE.
INCLUDE FILES
sdl.h, extern.h
SDL C Library Reference Manual 87
setTextDirection
NAME
setTextDirection - sets the current drawing direction for text
SYNOPSIS
void setTextDirection
(
int dir /* new direction */
)
DESCRIPTION
This routine sets the current direction for drawing text on the display. Text may be drawn
left to right, right to left, top to bottom, or bottom to top on a character basis. The default is
left to right.
Proportionally spaced text is left justified on the bounding rectangle of the glyph even
when drawing vertically. This may cause the text to be non-centered. A fixed width font is
generally better for this application.
The text direction is defined in sdl.h as:
#define TXT_DIR_NORM 0
#define TXT_DIR_UP 1
#define TXT_DIR_RL 2
#define TXT_DIR_DWN 3
INCLUDE FILES
sdl.h, extern.h
SEE ALSO
drawText()
I
U
Up (bottom Q
to top)
E
H Left to Right
T
XOF NWORB KCIUQ EHT T THE QUICK BROWN FOX
H
Right to Left
E
Q Down (top to
U bottom)
I
C
K
88 SDL C Library Reference Manual
setTiming
NAME
setTiming - sets custom video timing
SYNOPSIS
int setTiming
(
float vfreq, /* vertical frequency (in Hz) */
float vblank, /* vertical blanking width */
float vfporch, /* vertical front porch width */
float vsync, /* vertical sync width */
float hblank, /* horizontal blanking width */
float hfporch, /* horizontal front porch width */
float hsync /* horizontal sync width */
)
DESCRIPTION
This function provides means to adjust the video timing to match a particular display
monitor. This function may be called at any time after a successful initGraphics() call.
The vertical timing values, other than the vertical frequency, are specified in milliseconds.
Horizontal timing values are specified in microseconds. This function is not available with
the RG-101 driver.
INCLUDE FILES
sdl.h, extern.h
RETURNS
int /* 0 on success, -1 on error */
SEE ALSO
initGraphics()
SDL C Library Reference Manual 89
setTransparency
NAME
setTransparency - sets the text transparency mode
SYNOPSIS
void setTransparency
(
int transparency /* 0 == transparency off */
) /* 1 == transparency on */
DESCRIPTION
This function turns transparency on or off.
Transparency applies only to text. If on, only the ones of the character glyph are drawn.
They are drawn in the foreground color. If transparency is off, both the ones and zeros of
the character glyph are drawn. The ones are drawn in the foreground color, and the zeros
are drawn in the background color.
Transparency should be used for proportionally spaced fonts, because the background
cell varies from character to character. To place a background behind proportionally
spaced fonts, first draw a filled rectangle with the desired color and then write the text into
the rectangular area. Transparency enabled is the default mode.
The transparency modes are defined in sdl.h as:
#define OPAQUE 0 /* Transparency off */
#define TRANSPARENT 1 /* Transparency on */
INCLUDE FILES
sdl.h, extern.h
Transparency off
Transparency on
90 SDL C Library Reference Manual
setVirtualSize
NAME
setVirtualSize() - sets the display origin within the virtual window
SYNOPSIS
void setVirtualSize
(
int width, /* window width */
int height /* window height */
)
DESCRIPTION
SetVirtualSize() provides a means to specify a virtual window larger then the physcial
display or screen size. For instance, a 1024x1024 virtual window can be created in the
framebuffer memory using a 640x480 physical display size. The entire virtual window is
available for rendering graphics objects, with the physical display providing a smaller
visible window into the virtual window. SetPanStart() is used to move the origin of the
visible displayed window.
Note: if a virtual window is desired, this function must be called prior to the call to
initGraphics(). Once set, the size of the virtual window can not be changed during the
graphics session.
INCLUDE FILES
sdl.h
SEE ALSO
setPanStart()
SDL C Library Reference Manual 91
setWritePage
NAME
setWritePage - set the current write page
SYNOPSIS
void setWritePage
(
int pagenum /* graphics memory page number */
)
DESCRIPTION
SetWritePage() selects the page number (for graphics hardware with more than one page
of video memory) that is to be written to. Page numbering starts at zero.
INCLUDE FILES
sdl.h
SEE ALSO
setDisplayPage()
92 SDL C Library Reference Manual
storeColor
NAME
storeColor - writes an rgb value to the color palette
SYNOPSIS
void storeColor
(
int index,
int red,
int green,
int blue
)
DESCRIPTION
This function writes the three rgb values specified to the system’s color palette at the
index specified. Use this function to update a single color entry in the palette, or to update
the entire palette with repeated calls to this function.
INCLUDE FILES
sdl.h
SEE ALSO
getColor()
SDL C Library Reference Manual 93
syncControl
NAME
syncControl – overrides the default horizontal and vertical sync state
SYNOPSIS
void syncControl
(
int hsync, /* horiz sync state */
int vsync /* vert sync state */
)
DESCRIPTION
This routine provides a method to set the video sync signals to a fixed state. This could
be used to manually implement Display Power Management (DPMS) to force the display
monitor into a standby or off state. Not all drivers may implement this function or all
possible sync states.
The sync state is defined in sdl.h as:
#define SYNC_NORMAL 0
#define SYNC_LOW 1
#define SYNC_HIGH 2
#define SYNC_OFF 3
#define SYNC_INVERT 4
sdl.h
/* ===== $Id: sdl.h,v 1.104 2005/01/03 16:09:50 billr Exp $ ===== */
/**************************************************************************/
/* STANDARD DRAWING LIBRARY */
/* */
/* Rastergraf, Inc. */
/* Used under license from CURTISS-WRIGHT CONTROLS, INC. */
/* COPYRIGHT (C) 2001 CURTISS-WRIGHT CONTROLS, INC. */
/* */
/* This software is licensed software subject to the terms of the */
/* Source Code License Agreement. Refer to the file LICENSE for details. */
/**************************************************************************/
/* FILE NAME :sdl.h */
/* DATE CREATED:6/8/95 */
/* PROJECT NAME:SDL */
/* DESCRIPTION :contains global variables, prototypes and structure defs */
/* AUTHOR :BR */
/* REVISIONS : */
/* NOTES : */
/* STRUCTURES :Point */
/* Rectangle */
/* Pattern */
/* FontInfo */
/* FontStruct */
/* geCharInfo */
/* RGFontInfo */
/* RGFont */
/**************************************************************************/
#ifndef SDL_H
# define SDL_H
#ifdef __cplusplus
extern "C" {
#endif
#ifndef FALSE
# define FALSE 0
# define TRUE !FALSE
#endif
#ifndef NULL
# define NULL (void*)0
#endif
/* HANDY MACROS */
#ifndef MAX
# define MAX(_a,_b) (((_a) > (_b)) ? (_a) : (_b))
#endif
#ifndef MIN
# define MIN(_a,_b) (((_a) < (_b)) ? (_a) :(_b))
#endif
96 SDL C Library Reference Manual
sdl.h, Continued
/* FILL STYLES */
#define SOLID_FILL 0
#define STIPPLE_FILL 1
#define OPAQUE_FILL 2 /* not available on two color systems! */
/* ARC MODES */
#define SECTOR_MODE 0
#define CHORD_MODE 1
/* FLAT PANEL TYPES - not all panels are supported by all drivers */
#define P_NEC_NL6448AC33_18 0x0000
#define P_SHARP_640X480X18_TFT 0x0100
#define P_VT_LCD70X_640X480X18_TFT 0x0200
#define P_GENERIC_18BIT_TFT 0x0E00
#define P_GENERIC_24BIT_TFT 0x0F00
#define P_SYNC_ON_GREEN 0x1000
#define P_COMPOSITE_SYNC 0x2000
#define P_DVI 0x3000
#define P_SEC_DAC 0x08000 /* enable secondary DAC */
#define P_SEC_DAC_SOG 0x10000 /* SOG on secondary RGB DAC */
#define P_BLOCK_SYNC_ON_GREEN 0x20000 /* block mode SOG on main */
#define P_SEC_BLOCK_SOG 0x40000 /* block mode SOG on secondary */
#define P_LVDS1 0x80000 /* enable LVDS1 output */
#define P_LVDS2 0x100000 /* enable LVDS2 output */
#define P_NO_WFIFO 0x200000 /* do not use WFIFO with tvout */
/* SOG types for Duros */
#define P_SOG_XOR 0x001000
#define P_SOG_STANAG 0x020000
#define P_SOG_AND 0x021000
#define PANEL_MASK 0x00f00 /* allows for 256 flat panel types */
98 SDL C Library Reference Manual
/* Custom source video modes (or'd into base source mode above) */
#define CCIR_PAL_CCD (0x01<<8) /* 752h x 582v PAL CCIR */
******************************************************************/
}sRGFontInfo,*spRGFontInfo;
#ifdef __cplusplus
};
#endif
#endif
SDL C Library Reference Manual 105
#ifndef EXTERN_H
# define EXTERN_H
extern void (*fatLineFunc)(int x1, int y1, int x2, int y2);
extern void (*fatDashLineFunc)(spPoint pt1, spPoint pt2,
int tindex, int toffset, RGBool swapped);
extern int (*sdl_numPciBussesFunc)(void);
extern int (*sdl_pciConfigInLongFunc)(int busNo, int deviceNo,
int funcNo, int address, unsigned int *pData);
extern int (*sdl_pciConfigOutLongFunc)(int busNo, int deviceNo,
int funcNo, int address, unsigned int data);
#endif
SDL C Library Reference Manual 107
#ifdef __cplusplus
extern "C" {
#endif
/*
* This file defines macros for delays in increments of clock ticks
* (typically 1/60th of a second) and in increments of seconds.
* One and only one of these OS types must be defined in the Makefile
* or make.include file.
*/
#ifdef VXWORKS
#include <taskLib.h>
#define TICK_DELAY(_n) taskDelay(_n)
#define SLEEP(_n) taskDelay(60*(_n))
#endif
#ifdef OS9_OS
#define TICK_DELAY(_n) tsleep(_n)
#define SLEEP(_n) sleep(_n)
#endif
#ifdef _OS9000
/* close-enough conversion from 1/60 second to 1/256 second */
#define TICK_DELAY(_n) {int t; unsigned long int s;\
t = ((_n)*5)|0x80000000;\
_os_sleep(&t, &s);\
}
#define SLEEP(_n) {int t; unsigned long int s;\
t = ((_n)*256)|0x80000000;\
_os_sleep(&t, &s);\
}
#endif
108 SDL C Library Reference Manual
#ifdef AIX
#include <X11/Xlib.h>
#include <unistd.h>
#include <sys/select.h>
#define TICK_DELAY(_n) {struct timeval delay;\
extern Display *dpy;\
XSync(dpy,0);\
delay.tv_sec = (_n)/1000000;\
delay.tv_usec = (((_n)*1000000)/60)%1000000;\
select(0, 0, 0, 0, &delay);\
}
#define SLEEP(_n) {extern Display *dpy;\
XSync(dpy,0);\
sleep(_n);\
}
#endif
#ifdef __cplusplus
};
#endif
#endif
110 SDL C Library Reference Manual
#ifndef COLORS_H
# define COLORS_H
#ifdef RG752
/*
* The RG-752 is a direct color board (i.e no lookup palette) with
* 3 bits of color information for each gun, mapped into a 16-bit
* word: o000rrr0ggg0bbb0. The leading 'o' bit, when set, makes the
* color opaque when used in the overlay plane.
* The defines below are an attempt to map the palettized colors
* used in 8-bit systems into the RG-752 color space. This provides
* a common color name space for demo programs designed to run on
* different hardware/boards.
*/
/* Color Name Color Value */
/* CGA Colors */
#define XBrown 0x8026
#define Black 0x8000 /* 0 */
#define Blue 0x8006 /* 1 */
#define Green 0x8060 /* 2 */
#define Cyan 0x8066 /* 3 */
#define Red 0x8600 /* 4 */
#define Magenta 0x8606 /* 5 */
#define Brown 0x8660 /* 6 */
#define LightGray 0x8888 /* 7 */
#define DarkGray 0x8444 /* 8 */
#define LightBlue 0x800e /* 9 */
#define LightGreen 0x80e0 /* 10 */
#define LightCyan 0x80ee /* 11 */
#define LightRed 0x8e00 /* 12 */
#define LightMagenta 0x8e0e /* 13 */
#define Yellow 0x8ee0 /* 14 */
#define White 0x8eee /* 15 */
SDL C Library Reference Manual 111
#else
116 SDL C Library Reference Manual
/* CGA Colors */
#define Black 0
#define Blue 1
#define Green 2
#define Cyan 3
#define Red 4
#define Magenta 5
#define Brown 6
#define Gray 7
#define DarkGray 8
#define LightBlue 9
#define LightGreen 10
#define LightCyan 11
#define LightRed 12
#define BrightMagenta 13
#define Yellow 14
#define White 15
/*Shades of Gray */
#define Gray0 16 /* Darkest Shade */
#define Gray1 17
#define Gray2 18
#define Gray3 19
#define Gray4 20
#define Gray5 21
#define Gray6 22
#define Gray7 23
#define Gray8 24
#define Gray9 25
#define Gray10 26
#define Gray11 27
#define Gray12 28
#define Gray13 29
#define Gray14 30
#define Gray15 31 /* Lightest Shade */
SDL C Library Reference Manual 117
#endif
#endif
SDL C Library Reference Manual 123
#ifndef FONTS_H
#define FONTS_H
#endif
124 SDL C Library Reference Manual
The following are samples of the 16 fonts supplied with SDL and the number of bytes of memory
required for the font. The complete character sets for these fonts are shown on the following
pages.
6216
5600
5912
6816
8372
11124
1124
1380
2404
8880
6988
8924
11392
7540
9232
12096
37924
40804
SDL C Library Reference Manual 125
ACKNOWLEDGEMENTS:
The Clean fonts are Copyright 1989 Dale Schumacher, dal@syntel.mn.org, 399 Beacon
Ave., St. Paul, MN 55104-3527
Permission to use, copy, modify, and distribute this software and its documentation for
any purpose and without fee is hereby granted, provided that the above copyright notice
appear in all copies and that both that copyright notice and this permission notice appear
in supporting documentation, and that the name of Dale Schumacher not be used in
advertising or publicity pertaining to distribution of the software without specific, written
prior permission. Dale Schumacher makes no representations about the suitability of this
software for any purpose. It is provided "as is" without express or implied warranty.
The bitmap, size and name of the predefined cursors supported by SDL are shown in the
table below. Cursors 40-49 are only available on VMEbus graphics boards.
0 16 x16 MSC_left_arrow
1 16 x16 MSC_arrow
2 16 x16 MSC_center_ptr
3 16 x16 MSC_down_center_ptr
4 16 x16 MSC_double_arrow
5 16 x16 MSC_lr_double_arrow
6 16 x16 MSC_fleur
7 16 x16 MSC_exchange
8 16 x16 MSC_left_side
9 16 x16 MSC_right_side
10 16 x16 MSC_top_side
11 16 x16 MSC_bottom_side
12 16 x16 MSC_top_left_corner
13 16 x16 MSC_top_right_corner
14 16 x16 MSC_bottom_left_corner
15 16 x16 MSC_bottom_right_corner
16 16 x16 MSC_sb_left_arrow
17 16 x16 MSC_sb_right_arrow
18 16 x16 MSC_sb_up_arrow
19 16 x16 MSC_sb_down_arrow
20 16 x16 MSC_sb_h_double_arrow
21 16 x16 MSC_sb_v_double_arrow
22 16 x16 MSC_circle
23 16 x16 MSC_target
24 16 x16 MSC_cross
25 16 x16 MSC_crosshair
26 16 x16 MSC_plus
27 16 x16 MSC_tcross
130 SDL C Library Reference Manual
28 16 x16 MSC_left_hand1
29 16 x16 MSC_hand1
30 16 x16 MSC_hand2
31 16 x16 MSC_right_hand2
32 16 x16 MSC_leftbutton
33 16 x16 MSC_middlebutton
34 16 x16 MSC_rightbutton
35 16 x16 MSC_xterm
36 16 x16 MSC_watch
37 16 x16 MSC_pencil
38 16 x16 MSC_gumby
39 16 x21 MSC_hour_glass16
40 32x32 MSC_NW_arrow32
41 32x32 MSC_NE_arrow32
42 32x32 MSC_NW_hand32
43 32x32 MSC_NE_hand32
44 32x32 MSC_xhair32a
45 32x32 MSC_xhair32b
46 32x32 MSC_xhair32c
47 32x32 MSC_xhair32d
48 32x32 MSC_watch32
49 32x32 MSC_hour_glass32
SDL C Library Reference Manual 131
This appendix describes the SDL extensions for capturing and displaying video signals
(NTSC or PAL) as used with graphics cards with onboard video decoders. The decoder
digitizes the incoming video stream, converts to YUV 4:2:2 or RGB16 format and feeds it
either to the VPORT port on the graphics controller or DMA’s it direct to frame buffer
memory. The graphics controller supports cropping and scaling of the input image and
panning and zooming of the image as it is displayed on screen.
The size and position of the image on the screen is controlled by three rectangles:
vidSrcRect, vidCapRect and vidDstRect and the pan start point vidPanStart. Their
relationship is roughly this:
video
memory
image image rect screen
pan start
display rect
scale capture rect zoom
source rect
capture playback
132 SDL C Library Reference Manual
This example shows how to use some of the SDL video capture extensions. The
example starts by initializing the graphics and video capture hardware, then sets up the
hardware to capture and display the upper left quarter of the video source image. The
color-key feature is used to show video only in a specific window on the display. Next, the
video image is resized to full screen capture and display. The use of color-keying to
overlay graphics objects on top of the video image is demonstrated, followed by a single
frame capture. Finally, the video image is rescaled to one-half full size and displayed in
the center of the screen.
Listing of captest.c
/* example video capture program */
#include <sdl.h>
#include <extern.h>
#include <colors.h>
#ifndef SDL2_X
/* in SDL 3.1 and later, we need to configure the video decoder */
/* and capture port on the graphics controller NTSC analog input */
/* to first decoder and YUV422 output on SPI port */
setVideoDeviceConfig(VDEV_DECODER1, VDEC_ANALOG, NTSC, VDEC_SPI,
VID_YUV422);
/* associate first video decoder with first graphics controller, */
/* with input to the graphics controller coming from the Vport */
/* interface in YUV422 pixel format */
setVideoDisplayConfig(GDEV_0, VDEV_DECODER1, VPORT_VPORT, VID_YUV422,
CAPTURE_ODD, 0, 0);
#endif
/* continuous grab */
grabFrame(0);
capture
NAME
capture - enable/disable video capture
SYNOPSIS
void capture
(
int con /* 0 == disable, 1 == enable */
)
DESCRIPTION
When con is TRUE, this function configures the video capture hardware and enables it.
When con is FALSE, the video capture hardware is disabled.
No video data will actually be stored in capture memory unless the graphics processor
hardware has been started with grabFrame(). No video data will be visible on the display
unless video playback has been enabled with playback().
INCLUDE FILES
sdl.h
SEE ALSO
grabFrame(), playback()
138 SDL C Library Reference Manual
checkDma
NAME
checkDma – test for completion of a DMA operation
SYNOPSIS
int checkDma
(
sDmaInfo *dma /* DMA info for this transfer */
)
DESCRIPTION
This function may be used to check for completion of a non-continuous DMA operation
previously started with startDma().
RETURNS
int /* DMA status: 0 = not finished, 1 = completed */
INCLUDE FILES
sdl.h
SEE ALSO
startDma(), stopDma()
SDL C Library Reference Manual 139
colorKey
NAME
colorKey - enable/disable color key insert of video
SYNOPSIS
void colorKey
(
int kon /* 0 == disable, 1 == enable */
)
DESCRIPTION
Color keying is used to “window” the displayed video image onto the screen. When color
keying is enabled, the pixels of the screen that are displaying the color key color are
replaced by the corresponding pixel of the video image data. When kon is TRUE, color
keying is enabled; when kon is FALSE, color keying is disabled. Use setColorKey() to
set the color key color.
Color keying can also be used to simulate a display that has a video image with
overlayed graphics. Normally, on a graphics display, the background color is black. By
setting the color key color to black and enabling color keying, all of the black pixels will
display parts of the video image, while graphics other than black will display those
graphics. This makes it appear as though the graphics were drawn on top of (overlayed
on) the video image. This will not work if the graphics data contains objects that are
drawn or filled in black.
INCLUDE FILES
sdl.h
SEE ALSO
setColorKey()
+
video image color key region
decoderFrameIRQ
NAME
decoderFrameIRQ – report status of video decoder interrupt
SYNOPSIS
int decoderFrameIRQ(void)
DESCRIPTION
This function can be used to help determine the source of an interrupt in an interrupt
handler. If the function returns true, the interrupt should be cleared by calling
decoderFrameIRQClear() after doing any required interrupt processing.
RETURNS
int /* 0 = no pending interrupt, 1 = interrupt pending */
INCLUDE FILES
sdl.h
SEE ALSO
decoderFrameIRQClear(), enableDecoderIRQ()
SDL C Library Reference Manual 141
decoderFrameIRQClear
NAME
decoderFrameIRQClear – clear any pending video decoder interrupts
SYNOPSIS
void decoderFrameIRQClear(void)
DESCRIPTION
This function is called at the end of an interrupt handler or polling loop to clear the
interrupt request after it has been handled.
INCLUDE FILES
sdl.h
SEE ALSO
decoderFrameIRQ(), enableDecoderIRQ()
142 SDL C Library Reference Manual
doubleBuffer
NAME
doubleBuffer – enable or disable double buffering on capture
SYNOPSIS
void doubleBuffer
(
int dbon /* 0 == disable, 1 == enable */
)
void doubleBuffer
(
int extra_bufs /* number of extra buffers (Atlas) */
)
DESCRIPTION
This function may be used to override the default use of double buffer for video capture.
The default for non-interlaced sources is to not use double buffering. It is enabled, by
default, when capturing interlaced video on the RG-101 boards.
Double buffering places each captured field (or frame if non-interlaced) into alternating
memory buffers. This is most often used when capturing interlaced video to allow
interleaving the two fields to build a complete frame for display. It is also useful when
doing post processing on the video data, as it allows capturing a new frame while
working on another frame.
With the VFG-M boards, interlaced video is automatically stored in interleaved memory
such that when both fields have been captured, the full frame is available in contiguous
capture memory and the double buffering flag is usually ignored.
Starting with SDL version 3.6.1 the Atlas driver supports multiple capture buffers. Each
buffer will contain a full frame of video data. The extra_bufs argument to doubleBuffer()
specifies the number of extra capture buffers desired. Each buffer is of length
getCapBuffSize() and adjacent to each other in memory. An argument value of 1 means
one extra buffer (total of two), an argument of 2 means two extra buffers (three total). The
default is 0 (no extra buffers).
INCLUDE FILES
sdl.h
SEE ALSO
interlace(), getCapBuffSize()
SDL C Library Reference Manual 143
enableDecoderIRQ
NAME
enableDecoderIRQ – enable/disable video decoder interrupt
SYNOPSIS
void enableDecoderIRQ(int onOff)
DESCRIPTION
EnableDecoderIRQ is used to enable (onOff = 1) or disable (onOff = 0) interrupts from
the video decoder. Interrupts are generated at the end of each frame, which may consist
of odd fields only, even fields only, or both odd and even fields. Video decoder interrupts
are not supported on all graphics boards.
INCLUDE FILES
sdl.h
SEE ALSO
decoderFrameIRQ(), decoderIRQClear()
144 SDL C Library Reference Manual
enableVBlankIRQ
NAME
enableVBlankIRQ – enable/disable video blanking interrupt
SYNOPSIS
void enableVBlankIRQ(int onOff)
DESCRIPTION
EnableVBlankIRQ is used to enable (onOff = 1) or disable (onOff = 0) interrupts from the
graphics controller. Interrupts are generated at the start of each vertical blanking interval.
Video blanking interrupts are not supported on all graphics boards.
INCLUDE FILES
sdl.h
SEE ALSO
vBlankIRQ(), vBlankIRQClear()
SDL C Library Reference Manual 145
getCapBuffSize
NAME
getCapBuffSize – get size of the video capture buffer
SYNOPSIS
int getCapBuffSize(void)
DESCRIPTION
This routine returns the size of the video capture buffer. This size is valid only for the
current device context. If the active video device is changed, the size may become
invalid, so this function should be called again to obtain the updated value.
This is most often used in double buffer situations to find the address of the second and
subsequent video capture or display buffers given the starting address of the capture
region.
RETURNS
int /* size of video capture buffer */
INCLUDE FILES
sdl.h
SEE ALSO
doubleBuffer(), getVideoFramebufPtr()
146 SDL C Library Reference Manual
getDisplayBuffer
NAME
getDisplayBuffer – gets current video display buffer number
SYNOPSIS
int getDisplayBuffer(void)
DESCRIPTION
This routine returns the index of the video display buffer in current use.
This is most often used in double buffer situations. Not all graphics boards support
multiple video display buffers. Note this is different from multiple graphics display buffers
(pages), manipulated by getDisplayPage() and getWritePage(). The video display
buffer contains captured video data for display by the graphics controller harware overlay
feature.
RETURNS
int /* index (0-n) of video display buffer */
INCLUDE FILES
sdl.h
SEE ALSO
setDisplayBuffer()
SDL C Library Reference Manual 147
getVideoFramebufPtr
NAME
getVideoFramebufPtr – gets current value of the video capture buffer pointer
SYNOPSIS
unsigned char *getVideoFramebufPtr(void)
DESCRIPTION
This routine looks up the current value of the video capture buffer pointer. This pointer is
only valid for the current device context. If the active graphics device is changed, the
pointer may become invalid, so this function should be called again to obtain the updated
value.
RETURNS
unsigned char * /* pointer to video capture buffer memory (in CPU address space) */
INCLUDE FILES
sdl.h
SEE ALSO
getCapBuffSize(), getFramebufPtr()
148 SDL C Library Reference Manual
getVideoImage
NAME
getVideoImage - copy image from capture memory to host memory
SYNOPSIS
void getVideoImage
(
int x, /* x coord of upper left corner */
int y, /* y coord of upper left corner */
int w, /* width of image to copy */
int h, /* height of image to copy */
unsigned char *buff, /* buffer for image data */
int buffno /* buffer number (0 or 1) */
)
DESCRIPTION
This function copies image data from the video capture buffer and puts it in the buffer
pointed to by buff. X and y are the starting position within the capture buffer; w and h are
the width and height of the rectangular area copied. Note that the video data is typically
16-bits wide (4:2:2 YUV), so the size of the buffer pointed to by buff should be twice the
width times height. In double buffer configurations, setting buffno to 1 will copy the data
from the second capture buffer.
INCLUDE FILES
sdl.h
SEE ALSO
putVideoImage(), writeRGB16(), writeRGB32, writeYUV(), video capture example
programs
video host
memory memory
buff
(x,y)
w
h
SDL C Library Reference Manual 149
grabFrame
NAME
grabFrame - grab frames continuously or as a single-shot
SYNOPSIS
void grabFrame
(
int sshot /* 0==continuous, 1==single shot */
)
DESCRIPTION
This function signals the graphics processor to read and store the digitized video into the
video capture buffer. When sshot is 1 or -1, a single frame is grabbed and transferred to
the video capture buffer, otherwise the video data in the capture buffer is continuously
updated. Normally, the grab is not initiated until after the next vertical sync. The special
value –1 for sshot skips the wait for vertical sync in single shot mode, allowing the
capture to overlap other processing.
No video data will actually be stored in capture memory unless the video capture
hardware has been enabled with capture(). No video data will be visible on the display
unless video playback has been enabled with playback().
INCLUDE FILES
sdl.h
SEE ALSO
capture(), playback()
150 SDL C Library Reference Manual
initCapture
NAME
initCapture - initialize video capture hardware
SYNOPSIS
void initCapture
(
int mode /* video source format */
)
DESCRIPTION
This function initializes the video capture and processing hardware. It does not actually
start the capture or display process. In SDL version 3.1 and later, the video decoder
hardware and video capture hardware are configured independently, as some graphics
boards have multiple decoders and multiple graphics controllers on the same board. This
configuration is done with the setVideoDeviceConfig() and setVideoCaptureConfig()
functions. The available modes are listed in sdl.h as:
#define NTSC 0 /* NTSC square pixel [640x480] */
#define PAL 1 /* PAL square pixel [768x576] */
#define CCIR_NTSC 2 /* NTSC CCIR601 [720x480] */
#define CCIR_PAL 3 /* PAL CCIR601 [720x576] */
#define NTSC_2_1 4 /* NTSC square pixel CIF (2:1 scaling) [320x240] */
#define PAL_2_1 5 /* PAL square pixel CIF (2:1 scaling) [384x288] */
#define SECAM 8 /* SECAM */
#define CCIR_656 16 /* CCIR 656 digital video */
#define SMPTE_125 17 /* Modified SMPTE-125 digital video */
#define VGA_RGB 18 /* RGBHV input to AD9882 on Stratus */
#define VGA_MONO 19 /* monochrome RGB input to AD9882 on Stratus */
#define VGA_YC 19 /* old name */
#define VGA_RGB_SOG 20 /* RGB+SOG input to AD9882 on Stratus */
#define VGA_MONO_SOG 21 /* monochrome RGB+SOG input to AD9882 */
#define VGA_DVI 22 /* DVI input to AD9882 on Stratus */
#define STANAG_A 23 /* STANAG-A input to AD9882 [1080x808 interlaced]
*/
#define STANAG_B 24 /* STANAG-B input to AD9882 [768x574 interlaced] */
#define STANAG_C 25 /* STANAG-C input to AD9882 [640x484 interlaced] */
#define SONY_DXC990 26 /* Sony DXC-990 cam. with AD9882 [768x494 ilace] */
Note: not all capture modes are available on all graphics boards. The STANAG-A/B/C
capture modes allow capturing a monochrome composite STANAG format signal using
the onboard AD9882 decoder on the Stratus and Garnet boards. The video source is fed
to the Red (VIN0) input. The Sony DXC-990 capture uses the RGB + SOG output from
the camera. The decoder is forced into interlaced capture.
INCLUDE FILES
sdl.h
SEE ALSO
capture(), grabFrame(), playback(), setVideoDeviceConfig(),
setVideoCaptureConfig()
SDL C Library Reference Manual 151
interlace
NAME
interlace - force interlaced/non-interlaced video capture
SYNOPSIS
void interlace
(
int ion, /* 0 = non-interlaced, 1 = interlaced */
int zoom /* 0 = normal, 1 = 2X vertical zoom */
)
DESCRIPTION
This routine is used to override the default setting of the interlaced capture flag. The
default for most video decoders is to enable interlaced operation. The default for the
AD9882 decoder, used on the some graphics boards, is non-interlaced. When ion is
TRUE, interlaced video capture is enabled. This also enables double buffering.
The zoom flag enables a 2x vertical zoom in non-interlaced mode. This would be useful
when aquiring video data from an interlaced source with the controller in non-interlaced
mode. This has the effect of capturing half the active lines and compressing them into
half the normal memory space. E.g. on a 640x480 interlaced camera image, acquiring in
non-interlaced mode will use only 640x240*2 bytes of capture memory. The 2x vertical
zoom will restore the original vertical size (with duplicated lines).
INCLUDE FILES
sdl.h
SEE ALSO
doubleBuffer (), initCapture()
152 SDL C Library Reference Manual
lastBuffer
NAME
lastBuffer – gets number of the last buffer filled
SYNOPSIS
int lastBuffer(void)
DESCRIPTION
In double buffer capture (default for interlaced video sources), two memory buffers are
used for the digitized video data (one for each field). This function can be used to
determine which buffer was last filled.
RETURNS
int /* last buffer filled (0 or 1) */
INCLUDE FILES
sdl.h
SEE ALSO
doubleBuffer()
SDL C Library Reference Manual 153
playback
NAME
playback - enable/disable video playback
SYNOPSIS
void playback
(
int pon /* 0 = disable, 1 = enable */
)
DESCRIPTION
This routine is used enable and disable the display of the captured video data on the
screen. When pon is TRUE, playback is enabled; when pon is FALSE, playback is
disabled.
No video data will actually be stored in capture memory unless the video capture
hardware has been enabled with capture() and the graphics processor hardware has
been started with grabFrame().
INCLUDE FILES
sdl.h
SEE ALSO
capture(), grabFrame()
154 SDL C Library Reference Manual
putVideoImage
NAME
putVideoImage - copy image from host memory to capture memory
SYNOPSIS
void putVideoImage
(
unsigned char *buff, /* buffer containing image data */
int x, /* x coord of upper left corner */
int y, /* y coord of upper left corner */
int w, /* width of image to copy */
int h, /* height of image to copy */
int buffno /* buffer number (0 or 1) */
)
DESCRIPTION
This function copies image data from the buffer pointed to by buff and puts it in the video
capture buffer. X and y are the starting position within the capture buffer; w and h are the
width and height of the rectangular area copied. Note that the video data is typically 16-
bits wide (4:2:2 YUV), so the size of the buffer pointed to by buff should be twice the
width times height. In double buffer configurations, setting buffno to 1 will copy the data
from the second capture buffer.
INCLUDE FILES
sdl.h
SEE ALSO
getVideoImage(), writeRGB16(), writeRGB32, writeYUV(), video capture example
programs
video host
memory memory
buff
(x,y)
w
h
SDL C Library Reference Manual 155
setCaptureSize
NAME
setCaptureSize - set size of video capture buffer
SYNOPSIS
void setCaptureSize
(
int cwidth, /* width of capture buffer rect */
int height /* height of capture buffer rect */
)
DESCRIPTION
This function sets the size (width and height) of the memory region used for the video
capture buffer. The digitized video stream is scaled, by dropping pixels or scan lines, to fit
into the capture buffer width and height. When possible, downsizing is done in the video
decoder device, then via the V-Port hardware on the graphics chip, if applicable.
The function setVideoSourceRect() automatically calls setCaptureSize() to resize the
capture buffer to match the source size. To change the scaling, then, setCaptureSize()
must be called after any calls to setVideoSourceRect().
Note: for proper image display, the capture buffer size (in pixels) should be at least as
large as the video display rectangle.
NOTES
In SDL version 2.x, the width should be set to twice the desired pixel width, as the
digitized video stream is 16-bits per pixel. In SDL 3.1 and later, the actual capture buffer
width is automatically computed based on the video data pixel size. In SDL 3.1 and later,
this function is typically not used. In most instances, setVideoSourceRect() should be
used instead.
INCLUDE FILES
sdl.h
SEE ALSO
setVideoDisplayRect(), setVideoSourceRect()
156 SDL C Library Reference Manual
setColorKey
NAME
setColorKey - set color used for color-keying video insert
SYNOPSIS
void setColorKey
(
unsigned long color /* color key color */
)
DESCRIPTION
Color keying is used to “window” the displayed video image onto the screen. When color
keying is enabled, the pixels of the screen that are displaying the color key color are
replaced by the corresponding pixel of the video image data. Color specifies the color to
use as the color key. Use colorKey() to actually enable and disable the color key
operation.
Color keying can also be used to simulate a display that has a video image with
overlayed graphics. Normally, on a graphics display, the background color is black. By
setting the color key color to black and enabling color keying all of the black pixels will
display parts of the video image, while graphics other than black will display those
graphics. This makes it appear as though the graphics were drawn on top of (overlayed
on) the video image. This will not work if the graphics data contains objects that are
drawn or filled in black.
INCLUDE FILES
sdl.h, colors.h
SEE ALSO
colorKey()
+
video image color key region
setDisplayBuffer
NAME
setDisplayBuffer – set current video display buffer number
SYNOPSIS
void setDisplayBuffer
(
int buffer /* buffer number to display */
)
DESCRIPTION
This routine sets the index of the active video display buffer. The change becomes
effective at the next video blanking interval.
This is most often used in double buffer situations. Not all graphics boards support
multiple video display buffers. The Atlas board supports upto six video buffers. Note this
is different from using multiple graphics display buffers (pages), as manipulated by
setDisplayPage() and setWritePage(). The video display buffer contains captured video
data for display by the graphics controller hardware overlay feature.
INCLUDE FILES
sdl.h
SEE ALSO
doubleBuffer(), getDisplayBuffer()
158 SDL C Library Reference Manual
setVideoCaptureConfig
NAME
setVideoCaptureConfig - configure video capture/display hardware
SYNOPSIS
void setVideoCaptureConfig
(
int gdev, /* graphics controller device */
int vdec, /* video decoder device */
int iport, /* input port on graphics device */
int format, /* pixel format */
int fields, /* which fields to capture */
int skip, /* number of fields/frames to skip*/
int window /* video window number */
)
DESCRIPTION
This function configures the video capture and display hardware and associates a video
decoder device to this capture/display configuration. This function should be called after
the video decoder is configured via setVideoDeviceConfig(). Window can be set to
force the use of a specific overlay window when the hardware supports more than one,
or to force the use of software overlay when set to 0. Not all graphics boards will support
all the features of this command. [E.g., the RG-101 has only one video decoder and one
graphics controller, while the VFG-M has two decoders and two controllers.] Note: this
function is only available in SDL version 3.1 and later.
Macro definitions for most of the function parameters are defined in sdl.h:
/* graphics controller device */
#define GDEV_0 0x000 /* first (or only) graphics controller */
#define GDEV_1 0x100 /* second graphics controller */
/* video decoder device */
#define VDEV_HOST 0 /* host supplied video data */
#define VDEV_DECODER1 1 /* first (or only) video decoder */
#define VDEV_DECODER2 2 /* second video decoder */
#define VPORT_VPORT 0 /* capture digitized video on V-Port */
#define VPORT_PCI 1 /* capture digitized video from the PCI bus */
/* decoder input port */
#define VDEC_ANALOG 0 /* standard analog input to the multiplexor */
#define VDEC_DIGITAL 1 /* CCIR 656 digital video input */
#define VDEC_DVI 2 /* DVI digital video input */
/* decoder output pixel format */
#define VID_YUV422 0 /* YUV 4:2:2 pixel format */
#define VID_RGB16 1 /* RGB 5-6-5 pixel format */
#define VID_RGB24 2 /* RGB 8-8-8 pixel format */
#define VID_RGB32 3 /* RGB 8-8-8-8 pixel format */
#define VID_Y8 4 /* 8-bit luminance only (for monochrome) */
/* field selection */
#define CAPTURE_EVEN 1 /* capture/display EVEN field only */
#define CAPTURE_ODD 2 /* capture/display ODD field only */
#define CAPTURE_BOTH 3 /* capture/display both EVEN and ODD fields */
INCLUDE FILES
sdl.h
SEE ALSO
initCapture(), setVideoDeviceConfig()
SDL C Library Reference Manual 159
setVideoCropOffset
NAME
setVideoCropOffset – set offset to default capture cropping rectangle
SYNOPSIS
void setVideoCropOffset
(
int ox, /* x offset to default left edge */
int oy /* y offset to default top edge */
)
DESCRIPTION
Set current values for video cropping offset. The offsets determine how much of the
incoming video image to skip before starting to save data into video memory. This can be
used to fine tune the image as it appears in the capture memory to account for
differences in vertical or horizontal blanking intervals. It is primary used with the AD982
video capture on the Stratus graphics board. Offset can be positive or negative and is an
offset from the default values. Ox is specified in pixels and oy is lines.
INCLUDE FILES
sdl.h
SEE ALSO
setVideoSourceRect()
160 SDL C Library Reference Manual
setVideoDeviceConfig
NAME
setVideoDeviceConfig - configure video decoder hardware
SYNOPSIS
void setVideoDeviceConfig
(
int vdev, /* video decoder device */
int iport, /* input port on decoder */
int iformat, /* input video format */
int oport, /* output port on decoder */
int oformat /* output pixel format */
)
DESCRIPTION
This function configures the video decoder hardware on a graphics board. This function
should be the first function called prior to using the video capture and display hardware. It
provides a way to specify the origin and destination of the video signal/data and the
video/pixel format. Note: this function is only available in SDL version 3.1 and later.
Macro definitions for most of the function parameters are defined in sdl.h:
/* video decoder device */
#define VDEV_HOST 0 /* host supplied video data */
#define VDEV_DECODER1 1 /* first (or only) video decoder */
#define VDEV_DECODER2 2 /* second video decoder */
/* decoder input port */
#define VDEC_ANALOG 0 /* standard analog input to the multiplexor */
#define VDEC_DIGITAL 1 /* CCIR 656 digital video input */
#define VDEC_DVI 2 /* DVI digital video input */
/* video input format */
#define NTSC 0 /* standard full scale NTSC video */
#define PAL 1 /* standard full scale PAL video */
#define CCIR_NTSC 2
#define CCIR_PAL 3
#define NTSC_2_1 4 /* 2:1 scaled NTSC video */
#define PAL_2_1 5 /* 2:1 scaled PAL video */
#define CCIR_NTSC_2_1 6
#define CCIR_PAL_2_1 7
#define SECAM 8 /* SECAM */
#define CCIR_656 16 /* CCIR 656 digital video */
#define SMPTE_125 17 /* Modified SMPTE-125 digital video */
#define VGA_RGB 18 /* RGBHV input to AD9882 on Stratus */
#define VGA_MONO 19 /* monochrome RGB input to AD9882 on Stratus */
#define VGA_YC 19 /* old name */
#define VGA_RGB_SOG 20 /* RGB+SOG input to AD9882 on Stratus */
#define VGA_MONO_SOG 21 /* monochrome RGB+SOG input to AD9882 */
#define VGA_DVI 22 /* DVI input to AD9882 on Stratus */
#define STANAG_A 23 /* STANAG-A input to AD9882 [1080x808 interlaced] */
#define STANAG_B 24 /* STANAG-B input to AD9882 [768x574 interlaced] */
#define STANAG_C 25 /* STANAG-C input to AD9882 [640x484 interlaced] */
#define SONY_DXC990 26 /* Sony DXC-990 cam. with AD9882 [768x494 ilace] */
SDL C Library Reference Manual 161
setVideoDisplayRect
NAME
setVideoDisplayRect - set size and position of inserted video window
SYNOPSIS
void setVideoDisplayRect
(
int x, /* x coord of origin on screen */
int y, /* y coord of origin on screen */
int w, /* width of displayed image */
int h /* height of displayed image */
)
DESCRIPTION
This function sets the origin and size of the video display window on the screen. If the
displayed image are is larger than the source image, the image is zoomed (horizontally
and vertically as needed) by pixel and/or row replication before display. Portions of the
display rectangle can be off screen, in which case the image is clipped to the screen
boundary.
Note: the width and height of the video display rectangle should not be larger than the
pixel width and height of the capture buffer.
INCLUDE FILES
sdl.h
SEE ALSO
setCaptureSize(), setVideoSourceRect()
video
memory
w*2
screen
h (x,y) w
capture rect
display rect
SDL C Library Reference Manual 163
setVideoFormatRect
NAME
setVideoFormatRect - set size and position of capture window
SYNOPSIS
void setVideoFormatRect
(
int x, /* x coord of source origin */
int y, /* y coord of source origin */
int w, /* width of image to capture */
int h, /* height of image to capture */
int vf /* vertical refresh frequency */
)
DESCRIPTION
This function sets the origin and size of the video source window (rectangle). This is used
primarily when the AD9882 is selected as the video source to “window” a smaller source
image in the display. By default, the source image size is assumed to be the same as the
display size. This function also provides a method for the driver to optimize the video
capture for the specific refresh frequency of the analog RGB image data. Vf is specified
in Hz. X and y are usually always zero.
INCLUDE FILES
sdl.h
SEE ALSO
setCaptureSize(), setVideoSourceRect(), setVideoDisplayRect()
source image
(x,y) w
h
164 SDL C Library Reference Manual
setVideoPanStart
NAME
setVideoPanStart - pan displayed video insert window
SYNOPSIS
void setVideoPanStart
(
int sx, /* x coord of pan starting point */
int sy /* y coord of pan starting point */
)
DESCRIPTION
This routine sets the origin in capture buffer memory for the video display window
(rectangle). The default origin is (0, 0) – or the start of the capture buffer. This function, in
conjunction with setVideoDisplayRect(), allows displaying just a portion of (or window
into) the captured video image.
INCLUDE FILES
sdl.h
SEE ALSO
setVideoDisplayRect()
video video
memory memory
setVideoSourceRect
NAME
setVideoSourceRect - set size and position of capture window
SYNOPSIS
void setVideoSourceRect
(
int x, /* x coord of source origin */
int y, /* y coord of source origin */
int w, /* width of image to capture */
int h /* height of image to capture */
)
DESCRIPTION
This function sets the origin and size of the video source window (rectangle). This can be
used to capture all, or just a portion of, the digitized video stream. If the source image is
larger than the capture buffer size, the image is scaled (horizontally and vertically as
needed) by pixel and/or scan line removal before storing in memory.
INCLUDE FILES
sdl.h
SEE ALSO
setCaptureSize(), setVideoDisplayRect()
image
video
memory
startDma
NAME
startDma – start a DMA operation
SYNOPSIS
sDmaInfo *startDma
(
int dmaDev, /* DMA source this transfer */
int flags, /* DMA flags */
unsigned char *vptr, /* virtual address of destination */
unsigned char *pptr /* physical address of dest. */
)
DESCRIPTION
This function initiates a DMA transfer from graphics or video memory to another block of
memory. The destination is often system memory, but could be the framebuffer of
another graphics/video controller or another device on the PCI bus. The value of vptr is
not used by current drivers, but is saved in the DMA info structure for the convenience of
the user.
DmaDev is the source device and can have the following values, defined in sdl.h:
/* DMA source flags (support varies by board type) */
#define DMA_NONE 0
#define DMA_GDEV0_GRMEM 1 /* graphics device 0 - graphics memory */
#define DMA_GDEV0_VIMEM 2 /* graphics device 0 - video capture memory */
#define DMA_GDEV1_GRMEM 3 /* graphics device 1 - graphics memory */
#define DMA_GDEV1_VIMEM 4 /* graphics device 1 - video capture memory */
#define DMA_VDEC0 5 /* video decoder 0 */
#define DMA_VDEC1 6 /* video decoder 1 */
#define DMA_ADEC0 7 /* audio decoder 0 */
#define DMA_ADEC1 8 /* audio decoder 1 */
The flags argument is used to indicate the transfer type and is OR of the flags bits
defined in sdl.h:
/* DMA transfer flags (support varies by board type) */
#define DMA_WAIT 0 /* polled wait for entire transfer */
#define DMA_NOWAIT 1 /* interrupt driven transfer */
#define DMA_CONTINUOUS 2 /* copy on each Vblank or ZV port interrupt */
#define DMA_INTERLACE 4 /* transfer even fields only */
#define DMA_GRAPHICS_MEM 8 /* copy graphics mem instead of video mem */
RETURNS
sDmaInfo * /* pointer to DMA info structure */
NOTES
DMA_CONTINUOUS and DMA_NOWAIT are available with VxWorks and some Linux
versions only. The functionality of DMA is very dependent on the CPU board and
host bridge chip. Many PowerPC systems have problems, but it is reported to work
on the Motorola MVME5100.
INCLUDE FILES
sdl.h
SEE ALSO
checkDma(), stopDma()
SDL C Library Reference Manual 167
stopDma
NAME
stopDma – stop a DMA operation
SYNOPSIS
void stopDma
(
sDmaInfo *dma /* DMA info for this transfer */
)
DESCRIPTION
This function may be used to terminate a DMA operation previously started with
startDma().
INCLUDE FILES
sdl.h
SEE ALSO
checkDma(), startDma()
168 SDL C Library Reference Manual
vBlankIRQ
NAME
vBlankIRQ – report status of vertical blanking interrupt
SYNOPSIS
int vBlankIRQ(void)
DESCRIPTION
This function can be used to help determine the source of an interrupt in an interrupt
handler. If the function returns true, the interrupt should be cleared by calling
vBlankIRQClear() after doing any required interrupt processing. If the graphics controller
supports multiple channels, the return value will indicate which channel generated the
interrupt.
RETURNS
int /* 0 = no pending interrupt, non-zero = interrupt pending and channel */
INCLUDE FILES
sdl.h
SEE ALSO
vBlankIRQClear(), enableVBlankIRQ()
SDL C Library Reference Manual 169
vBlankIRQClear
NAME
vBlankIRQClear – clear any pending graphics controller interrupts
SYNOPSIS
void vBlankIRQClear(void)
DESCRIPTION
This function is called at the end of an interrupt handler or polling loop to clear the
interrupt request after it has been handled.
INCLUDE FILES
sdl.h
SEE ALSO
vBlankIRQ(), enableVBlankIRQ()
170 SDL C Library Reference Manual
videoBrightness
NAME
videoBrightness - Set brightness level of digitized video
SYNOPSIS
char videoBrightness
(
char bright /* signed brightness adjustment */
)
DESCRIPTION
This routine is used to adjust the brightness to the digitized video. This value is added to
the luminance value to adjust the final brightness. The brightness can be adjusted in 255
steps, from –100% (–128) to +100% (+127). Each step is a 0.78% change with respect to
the full scale. The previous brightness adjustment value is returned.
The default value for the brightness adjust is 0 (0%).
INCLUDE FILES
sdl.h
RETURNS
char /* old brightness adjustment */
SEE ALSO
videoContrast(), videoHue(), videoSatU(), videoSatV()
SDL C Library Reference Manual 171
videoContrast
NAME
videoContrast - set contrast level of digitized video
SYNOPSIS
int videoContrast
(
int cont /* luma gain adjustment */
)
DESCRIPTION
This routine is used to adjust the luma gain of the digitized video. This value is multiplied
by the luminance value to provide contrast adjustment. The luma gain can be adjusted in
512 steps, from 236.57% (511) to 0% (0). Each step is a 0.46% change with respect to
the incoming luma value. The previous luma gain value is returned.
The default value for luma gain is 216 (100%).
INCLUDE FILES
sdl.h
RETURNS
int /* old gain value */
SEE ALSO
videoBrightness(), videoHue(), videoSatU(), videoSatV()
172 SDL C Library Reference Manual
videoHue
NAME
videoHue - set hue level of digitized video
SYNOPSIS
char videoHue
(
char hue /* signed hue adjustment */
)
DESCRIPTION
This routine is used to adjust the hue to the digitized video. The hue can be adjusted in
256 steps, from –90° (–128) to +89.3° (+127). Each step is a 0.7° change. The previous
hue adjustment value is returned.
The default value for hue adjustment is 0 (0°).
INCLUDE FILES
sdl.h
RETURNS
char /* old hue adjustment */
SEE ALSO
videoBrightness(), videoContrast(), videoSatU(), videoSatV()
SDL C Library Reference Manual 173
videoSatU
NAME
videoSatU - set U saturation level of digitized video
SYNOPSIS
int videoSatU
(
int satu /* chroma U value */
)
DESCRIPTION
This routine is used to add a gain adjustment to the U component of the video [chroma]
signal. This value is multiplied by the luminance value to provide contrast adjustment.
The U gain can be adjusted in 512 steps, from 201.18% (511) to 0% (0). Each step is a
0.39% change with respect to the incoming U value. The previous U gain value is
returned.
By adjusting the U and V color components of the video stream by the same amount, the
saturation is adjusted. For normal saturation adjustment, the gain in both color difference
paths must be the same (i.e. the ratio between the U gain and the V gain should be kept
constant at the default ratio).
The default value for the U gain is 254 (100%).
INCLUDE FILES
sdl.h
RETURNS
int /* old gain value */
SEE ALSO
videoBrightness(), videoContrast(), videoHue(), videoSatV()
174 SDL C Library Reference Manual
videoSatV
NAME
videoSatV - set V saturation level of digitized video
SYNOPSIS
int videoSatV
(
int satv /* chroma V value */
)
DESCRIPTION
This routine is used to add a gain adjustment to the V component of the video [chroma]
signal. This value is multiplied by the luminance value to provide contrast adjustment.
The V gain can be adjusted in 512 steps, from 283.89% (511) to 0% (0). Each step is a
0.56% change with respect to the incoming V value. The previous V gain value is
returned.
By adjusting the U and V color components of the video stream by the same amount, the
saturation is adjusted. For normal saturation adjustment, the gain in both color difference
paths must be the same (i.e. the ratio between the U gain and the V gain should be kept
constant at the default ratio).
The default value for the V gain is 180 (100%).
INCLUDE FILES
sdl.h
RETURNS
int /* old gain value */
SEE ALSO
videoBrightness(), videoContrast(), videoHue(), videoSatU()
SDL C Library Reference Manual 175
videoSelect
NAME
videoSelect - select video capture source
SYNOPSIS
void videoSelect
(
int channel, /* video input select */
int monochrome /* 0 == color, 1 == monochrome */
)
DESCRIPTION
This function selects which video source is digitized and sent to the graphics processor
(when more than one channel is supported). The RG-101 supports three video input
sources — two composite video and one component video (Svideo). The VFG-M
supports four composite and one component video sources. They are listed in sdl.h as:
#define CVIDEO1 0 /* composite video 1 (Mux0 on VFG-M) */
#define CVIDEO2 1 /* composite video 2 (Mux1 on VFG-M) */
#define CVIDEO3 3 /* composite video 3 (Mux2 on VFG-M) */
#define CVIDEO4 4 /* composite video 4 (Mux3 on VFG-M) */
#define SVIDEO 2 /* S-video 1 */
#define GPIO_DIG 16 /* digital video on GPIO port */
#define RGBHV 17 /* analog RGBHsVs video */
#define TEST_PATN 64 /* internal test pattern (e.g. color bars) */
#define LOOPBACK 65 /* loopback from composite video output */
Set monochrome to TRUE to optimize the video digitization when the video signal is
known to be monochrome (black and white).
The default value for the video source is CVIDEO1 (color).
INCLUDE FILES
sdl.h
176 SDL C Library Reference Manual
waitForFrame
NAME
waitForFrame – wait for capture of a new frame
SYNOPSIS
int waitForFrame
(
int rdy /* wait flag: 0 = not ready, 1 = ready */
)
DESCRIPTION
This function may be used to check the status of a capture operation previously started
with grabFrame().This is most often used to detect when a full image has been captured
so the host program can do processing on the video data. The timeout is approximately
60-80 ms.
RETURNS
int /* Frame status: 0 = no frame (timeout), 1 = match found (grab or no grab) */
INCLUDE FILES
sdl.h
SEE ALSO
waitForSync()
SDL C Library Reference Manual 177
waitForSync
NAME
waitForSync – wait for vertical sync or timeout
SYNOPSIS
int waitForSync(void)
DESCRIPTION
This function may be used to delay a program until a vertical sync is recognized by the
capture engine or video decoder. It can also be used as a check for presence of a valid
video input for testing for a timeout error return. The timeout is approximately 60-80 ms.
RETURNS
int /* Vsync status: 0 = no sync (timeout), 1 = Vsync found */
INCLUDE FILES
sdl.h
SEE ALSO
waitForFrame()
178 SDL C Library Reference Manual
writeRGB16
NAME
writeRGB16 – convert and write 16-bit pixels to a file
SYNOPSIS
int writeRGB16
(
unsigned int pixel, /* 32-bit word from framebuffer */
void *fp, /* FILE pointer */
int gray, /* grayscale flag */
int raw /* raw data write flag */
)
DESCRIPTION
This function converts the 32-bit word, pixel, into two 16-bit (5-6-5 RGB) pixels, which are
wriiten to the file specified by fp. Byte swapping is done on pixel if required by the CPU
architecture. If gray is non-zero, the image data is treated as grayscale, rather than color.
The raw flag switches between binary (if non-zero), or hexadecimal (with a leading “0x”)
if zero.
RETURNS
int /* 0 = sucess, -1 = error */
EXAMPLE
The following example writes a 16-bit RGB video image from the capture buffer to a file:
FILE *fp;
int i, size = 640*480*2;
unsigned int *vbuff = (unsigned int *)malloc(size);
writeRGB32
NAME
writeRGB32 – convert and write 32-bit pixels to a file
SYNOPSIS
int writeRGB32
(
unsigned int pixel, /* 32-bit word from framebuffer */
void *fp, /* FILE pointer */
int gray, /* grayscale flag */
int raw /* raw data write flag */
)
DESCRIPTION
This function converts the 32-bit word, pixel, into three 8-bit bytes (8-8-8 RGB), which are
wriiten to the file specified by fp. Byte swapping is done on pixel if required by the CPU
architecture. If gray is non-zero, the image data is treated as grayscale, rather than color.
The raw flag switches between binary (if non-zero), or hexadecimal (with a leading “0x”)
if zero.
RETURNS
int /* 0 = sucess, -1 = error */
EXAMPLE
The following example writes a 32-bit RGB video image from the capture buffer to a file:
FILE *fp;
int i, size = 640*480*2;
unsigned int *vbuff = (unsigned int *)malloc(size);
writeYUV
NAME
writeYUV – convert and write 16-bit YUV format pixels to a file
SYNOPSIS
int writeYUV
(
unsigned int pixel, /* 32-bit word from framebuffer */
void *fp, /* FILE pointer */
int gray, /* grayscale flag */
int raw /* raw data write flag */
)
DESCRIPTION
This function converts the 32-bit word, pixel, into two 16-bit (YUV) pixels, which are
wriiten to the file specified by fp. Byte swapping is done on pixel if required by the CPU
architecture. If gray is non-zero, the image data is treated as grayscale, rather than color.
The raw flag switches between binary (if non-zero), or hexadecimal (with a leading “0x”)
if zero.
RETURNS
int /* 0 = sucess, -1 = error */
EXAMPLE
The following example writes a YUV video image from the capture buffer to a file:
FILE *fp;
int i, size = 640*480*2;
unsigned int *vbuff = (unsigned int *)malloc(size);
Index
arc 18
arc2 19
boardOK 20
boardTemp 21
capture 139
checkDma 140
circle 22
clearScreen 23
closeGraphics 24
Code Size 129, 130
colorKey 141
copyImage 25
copyPage 26
copyPageImage 27
dashedLine 28
dashedPolyline 29
dashedRectangle 30
decoderFrameIRQ 142
decoderFrameIRQClear 143
doubleBuffer 144
drawPixel 31
drawText 32
ellipse 33
enableDecoderIRQ 145
enableStereo 34
enableVBlankIRQ 146
filledArc 35
filledArc2 36
filledCircle 37
filledEllipse 38
filledPolygon 39
filledRectangle 40
flushKeyboard 41
flushMouse 42
Fonts 125, 126
Function Summary 14
Function Summary (Video) 137
getCapBuffSize 147
getColor 43
getDisplayBuffer 148
getFontStruct 44
getFrameBufPtr 45
getImage 46
getMouseXY 47
getPixel 48
getTextWidth 49
getVideoFramebufPtr 149
getVideoImage 150
grabFrame 151
Graphics Programming Example 9
Header Files 95, 112
initCapture 152
initGraphics 50
interlace 153
keyboardRead 51
keyboardReady 52
lastBuffer 154
182 SDL C Library Reference Manual
line 53
Mouse 131
mouseCursorOn 54
mouseCursorXY 55
mouseRead 56
mouseReady 57
mouseRect 58
mouseScale 59
panelType 60
playback 155
polyline 61
putImage 62
putVideoImage 156
rectangle 63
setArcMode 64
setBackground 65
setCaptureSize 157
setClipRect 66
setColorKey 158
setDashOffset 67
setDashPattern 68
setDashStyle 69
setDisplayBuffer 159
setDisplayPage 70
setFillRule 71
setFillStyle 72
setFont 73
setForeground 74
setGraphicsDevice 75
setLineWidth 77
setMode 78
setMouseCursor 79
setMousePage 80
setMouseParam 81
setOrigin 82
setPanStart 83
setPattern 84
setPatternOrigin 85
setPixelProcessing 86
setTextDirection 87
setTiming 88
setTransparency 89
setVideoCaptureConfig 160
setVideoCropOfset 162
setVideoDeviceConfig 163
setVideoDisplayRect 165
setVideoFormatRect 166
setVideoPanStart 167
setVideoSourceRect 168
setVirtualSize 90
setWritePage 91
startDma 169
stopDma 170
storeColor 92
syncControl 93
vBlankIRQ 171
vBlankIRQClear 172
Video Capture 133
Video Capture Programming Example 134
videoBrightness 173
videoContrast 174
videoHue 175
videoSatU 176
videoSatV 177
SDL C Library Reference Manual 183
videoSelect 178
waitForFrame 179
waitForSync 180
writeRGB16 181
writeRGB32 182
writeYUV 183