| United States-English |
|
|
|
![]() |
Starbase Display List Programmer's Manual: HP 9000 Series 700 Computers > Chapter 4 The Basics of Using a Display ListPreparation |
|
The instructions concerning the execution of the example programs presented in this manual assume that you are working in your "current working directory." It makes no difference where your current working directory is within the hierarchical directory structure of HP-UX. (A discussion of the hierarchical directory structure used by the HP-UX Operating System is found in the A Beginner's Guide to HP-UX and the How HP-UX Works: Concepts for the System Administrator supplied with your system.) The following table lists files that are used when writing code that uses the Display List. There are include files, which are copied into the source code via "include" statements, and there are library files, which must be linked to the object code before program execution. Note that the include files are located in the directory 〈sb-incl〉 [1] and the library files are located in the following directory:
Table 4-1 Display List Files
The calling conventions for the programming languages C, Fortran77, and Pascal are defined for each function in the Display List Reference section of this manual. As mentioned above, the instructions concerning the execution of the example program presented in this chapter assume that you are working in your "current working directory." Conceptually, Starbase has two levels: device-independent and device-dependent. The high-level Starbase code provides user procedures that are device independent; they work the same way regardless of the graphics device you have. The Starbase device drivers contain the code that drives the graphics devices. Because different devices have different requirements, the drivers must be device dependent. Note that a single driver (for example, the HP-GL driver) may support several similar devices (for example, the HP 7475, HP 7550 plotters, etc.). Since code from both levels is required to create a usable program, the user must link both device-independent code (Starbase high-level routines) and device-dependent code (drivers) in order to generate the final object file. The Starbase archived and shared libraries are located in the directory[2]
The device drivers have file names starting with "libdd". The Starbase high-level routines are libhpgfx.sl for shared libraries and libhpgfx1.a and libhpgfx2.a for archive libraries. The Starbase Display List device-independent routines are libdl.sl for shared libraries and libdl.a for archive libraries. Take a moment and list the library files to see which libraries are available with your system. To look at the Starbase high-level routines for archived and shared libraries, type:
To look at the device-dependent archived and shared libraries, typeTitle not available:
Starbase Display List libraries are available in two types: archive and shared. The Starbase Display List archive library file names end with .a, while shared library file names end with .sl. These files are located in the directory
If you have installed both versions of these files, the linker/loader program `ld' uses the shared file (ending in .sl). (To force the archive version, the environment variable LDOPTS must be set to include -a archive before compiling). See ld(1) for additional information about which library to load. Starbase libraries must not be mixed in the linking process, that is, either all libraries must be linked as archive or all libraries must be linked as shared. The Starbase Display List archive libraries are comprised of object files which contain device-independent code (Display List procedures). The Starbase archive libraries are comprised of object files which contain device-independent code or device-dependent code (device drivers). These libraries are copied into the application object code resulting from compilation and linking. Device dependent code is comprised of the device drivers. For example, one archive device driver library is libddgcrx.a (see the HP-UX Starbase Device Drivers Manual for a detailed description of all the device drivers available). The Starbase archive device drivers must be linked at compile time for every device a particular application may possibly use. To use archive libraries the filesets SBDL-PRG, STAR-RUN and STAR-PROG must be installed. To compile with archive libraries, set the environment variable LDOPTS to include -a archive. The environment variable can be set in your shell configuration file or interactively. For C shell:
For Korn shell
To compile and link archive libraries, use the following command format[3]:
The link sequence above is identical to the standard Starbase link sequence with the addition of the Starbase Display List library, -ldl. The library -ldl must precede the device-independent Starbase libraries -lhpgfx1 and -lhpgfx2 in the link sequence. The Display List device driver, if included, is treated like any other graphics device driver and linked prior to the Starbase Display List library. Also note the presence of "-lm" in the script above. This links in the math library. This is included in the link sequence in case some of your programs use back-facing cull, shading, the camera model, or any other operations that need the math library.
Table 4-2 Abridged Table of Device Drivers
The Starbase and Starbase Display List shared libraries contain relocatable object code just like the archive libraries. However, the linker does not copy the object code from the library into the application object code. Instead, the linker notes which routines are called from the shared libraries. When the application program that uses shared libraries executes, the calls to library routines are resolved by the dynamic loader libdld.sl. The necessary libraries are explicitly loaded at run-time. Thus, several application programs can "share" the same library routines, even if the applications are executing concurrently. The Starbase Display List device-independent code is located in the file[4]:
The Starbase device-independent code is located in the file:
The Starbase device-dependent code (drivers) is located in the files:
for example, libddgcrx.sl. The important difference between shared and archive drivers is that the linkage parameters in the compile statement for shared libraries do not include the device driver library, the dynamic loader is linked instead. In addition, the Starbase device-independent library
replaces the two archive libraries:
and
To develop Starbase Display List programs with shared libraries the filesets SBDL-PRG, SBDL-SHLIBS, STAR-RUN, STAR-SHLIBS, and STAR-PRG must be installed on your system. To compile a program using shared libraries, use the following command format:
Note the order of the parameters -ldl -lhpgfx must be as shown. The following Makefile (or a modified version thereof) will save you some typing as you compile and execute the example programs discussed in this manual. Makefile examples are given below for both shared and archive libraries.
For shared libraries, create a file named Makefile to include the following[5]:
For archive libraries, first set the environment variable LDOPTS to:
(see the previous discussion on archive libraries). Create a file named Makefile to include the following:
For example, a Makefile to link the archive drivers, HP 98705, HP CRX, and HP 98766[6]:
And from now on, to compile the program, locate yourself in the directory where the Makefile and program are held and type:
To execute the program, type the name of the executable (named by the -o option), for the above example.c program, you would type:
Because Starbase can support many active graphics devices simultaneously, a means must exist to distinguish between them in your programs. This is the file descriptor. When a graphics device is "opened" (declared that it is to be accessed by a program), a unique file descriptor is assigned to that device running to a window named starbase_window. For example, for a raster graphics device, the 〈fildes〉 is assigned as follows:
Note that the device is specified by the path 〈screen〉/starbase_window. The NULL device driver parameter (for C programming, for other bindings, see gopen(3g)) allows gopen to inquire the system for the installed raster device associated with the device file. By default, the associated driver will be "accelerated" if an accelerated driver exists for the device. The gopen example above is equivalent to[7]:
The flag UNACCELERATED may be OR'ed with INIT to force the unaccelerated driver (see gopen(3g)).
For other devices the device path must be specific to the particular device file created for that device (see the HP-UX Starbase Device Drivers Manual). For devices that do not have "accelerated" drivers the ACCELERATED/UNACCELERATED flags are meaningless. In this example, the fildes variable is used in Starbase procedures to reference one raster graphics device, while other graphics devices must have their own unique file descriptors.
At the end of the program, the device is closed:
The file dl.c.h contains C compiler directives describing constants and external definitions for the Starbase Display List library. This file must be included after the Starbase include file starbase.c.h. The file dl.f1.h contains Fortran77 compiler directives describing the parameter passing conventions for the Starbase Display List library.
The file dl.f2.h contains the definition of constants defined for use with the Starbase Display List. This file must be included in each subroutine or program unit that uses the constants. The include statement for this file must follow the include statement for the file starbase.f2.h. This is illustrated below[8].
The file dl.p2.h contains Pascal compiler directives describing the parameter-passing conventions for the Starbase Display List library.
The file dl.p2.h contains Pascal constant definitions for use with the Starbase Display List. This file must be included in the constant definition part of a Pascal main program, function, or procedure. It must follow the inclusion of the Starbase constant definitions in the file starbase.p1.h. This is illustrated below. The following is a template for a Pascal Starbase Display List application[9].
The following example program is a Display List version of the program of the same name in the Starbase Graphics Techniques. It draws a line from the lower left corner to the upper right corner of the default viewport of an HP graphics window. This example is presented to show what is (basically) the minimum needed to have a program that uses the Starbase Display List[10] .
This is what the graphical output looks like: Now that you've written, compiled, and run a simple Display List program, we'll discuss the statements involved. The next section gets into this topic. [1] The actual path names of directories in angle brackets depend on the file system structure. See the Graphics Administration Guide for details. [2] The actual path names of directories in angle brackets depend on the file system structure. See the Graphics Administration Guide for details. [3] The actual path names of directories in angle brackets depend on the file system structure. See the Graphics Administration Guide for details. [4] The actual path names of directories in angle brackets depend on the file system structure. See the Graphics Administration Guide for details. [5] The actual path names of directories in angle brackets depend on the file system structure. See the Graphics Administration Guide for details. [6] The actual path names of directories in angle brackets depend on the file system structure. See the Graphics Administration Guide for details. [7] The actual path names of directories in angle brackets depend on the file system structure. See the Graphics Administration Guide for details. [8] The actual path names of directories in angle brackets depend on the file system structure. See the Graphics Administration Guide for details. [9] The actual path names of directories in angle brackets depend on the file system structure. See the Graphics Administration Guide for details. [10] The actual path names of directories in angle brackets depend on the file system structure. See the Graphics Administration Guide for details. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||