gopen(3G)
NAME
gopen − open I/O path to, create environment for, and initialize graphics device
SYNOPSIS
C Syntax:
int gopen (path,kind,driver,mode);
char *path,*driver;
int kind,mode;
FORTRAN77 Syntax:
integer*4 function gopen(path,kind,driver,mode)
character*(*) path,driver
integer*4 kind,mode
Pascal Syntax:
function gopen(path:string255;kind:integer;
driver:string255;mode:integer):integer;
DESCRIPTION
Input Parameters
path Device file name for the device to be opened. This file is usually found in the /dev directory.
kind One of the constants:
INDEV Device is to be used for input only.
OUTDEV Device is to be used for output only.
OUTINDEV Device is to be used for both input and output.
driver One of the following:
Character String Character representation of the hardware device type. See the Starbase Device Drivers Library Manual for details.
NULL Use a device driver based upon the path, kind, and the mode parameter.
mode Word containing flags used at open to specify control. The following flags can be bitwise ORed together:
SPOOLED Output is spooled to a file. Do not inquire from the device. If this bit is set, the path parameter should name a regular file or FIFO special file.
RESET_DEVICE Device is completely initialized, including color map initialization and clearing the view surface.
INIT Device is initialized in a device-dependent manner.
THREE_D All transformations are three dimensional, including point, line, and polygon transformations as well as matrix concatenations.
MODEL_XFORM As part of the opening, the device is prepared for shading of output primitives and/or removal of back-facing polygons. This means that output primitives must be transformed in two stages:
1. All output primitives are transformed by the top matrix on the matrix stack (if any exist on the stack). This transforms the primitives from modeling coordinates to world coordinates. At this stage rendering calculations can be made.
2. Primitives are transformed from world coordinates to device coordinates by the current viewing and vdc-to-device units transformations. If the device is not opened in this mode, all transformations can be concatenated and performed simultaneously.
INT_XFORM Only integer and common operations will be performed. All Floating point operations will cause an error.
INT_XFORM_32 Only integer and common operations will be performed. All Floating point operations will cause an error. This mode is provided for compatibility of integer precision with previous devices. INT_XFORM will use a faster transformation pipeline with slightly less precision. It is recommend to use INT_XFORM unless maximum precision is required. If maximum precision is required, even at the expense of performance, use INT_XFORM_32.
FLOAT_XFORM Only Floating point and common operations will be performed. All integer operations will cause an error.
ACCELERATED Use the accelerated device driver if possible. This flag only has meaning when the driver parameter is NULL.
UNACCELERATED Use the unaccelerated device driver if possible. This flag only has meaning when the driver parameter is NULL.
Discussion
This function returns a non-negative integer upon a successful device opening. This integer is called the file descriptor and is referred to by the name fildes in this manual. The file descriptor remains open across exec system calls. See fcntl(2). However, state descriptor information is NOT preserved across exec system calls.
If the SPOOLED bit is set, the named file will be created or overwritten.
No process can have more than _NFILE file descriptors open simultaneously. _NFILE is an HP-UX system variable that defines the number of open files allowed per process at any given time. The value assigned to this variable is found in /usr/include/stdio.h.
When a graphics device is opened, many defaults are set. They are described more fully in the file /usr/lib/starbase/defaults.
The device file name path is created by the mknod command. For information about creating the device file, consult the Starbase Device Drivers Library manual in the chapter describing the device of interest.
Integer operations are only available when using the INT_XFORM or INT_XFORM_32 gopen mode. When in INT_XFORM or INT_XFORM_32 mode Floating point operations are not available for that fildes. Floating point operations are available by the default, or can be specified with FLOAT_XFORM mode. For a list of Integer operations, Floating point operations and common operations see the starbase(3G) manual page.
If the driver parameter is NULL, then gopen() will make a call to inquire_device_driver() to determine which device driver to use. The mode parameter is passed to inquire_device_driver(). See inquire_device_driver(3g) for more information on how a device driver is selected.
RETURN VALUE
Upon successful completion, a non-negative integer called the file descriptor (fildes) is returned. Otherwise, a value of -1 is returned and errno is set to indicate the error.
EXAMPLES
The following example opens the raster device associated with the device file for output and performs the device initialization. This example is valid for raster devices only.
fildes=gopen("/dev/crt",OUTDEV,NULL, INIT|THREE_D|MODEL_XFORM);
For non-raster devices the device driver must be specified. For example, the following gopen statement is valid for a terminal device:
fildes=gopen("/dev/tty",OUTDEV,"hpterm", INIT);
DEFAULTS
By default all transform operations are floating point.
SEE ALSO
errno(2), gclose(3G), make_x11_gopen_string(3G), inquire_device_driver(3G), Starbase Device Drivers Library, Starbase Programming with X11.
Hewlett-Packard Company — HP-UX Release 9.10: April 1995