Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP PEX Implementation and Programming Supplement: HP9000 Series 700 Color Workstations > Chapter 4 Utilities, Compiling And Linking, Examples and Demos

Introduction

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

 » Glossary

 » Index

The PEXlib Programming Manual, Chapter 3, "Getting Started", and the on-line version of Chapter 3, HP PEX On-Line Information System, both illustrate the general steps for creating and running PEXlib programs. Specifics are included in the on-line documentation, where source code is compiled; see the make files for details. Instructions in this chapter are supplemental and necessary in order to develop and run programs on Hewlett-Packard workstations.

Listing the contents of the 〈pex〉 directory\Footnote The actual pathname of this directory depends on the file system structure. See the Graphics Administration Guide for details.\EndFootnote{}, you will see a number of important subdirectories, including:

Table 4-1 Demos, Utilities, and Program Examples

Subdirectory

Description

demos

Contains programs that demonstrate 3D capabilities of HP PEX. The PEX verification program verify_install, for example, is included here.

hp-examples

The program examples in this directory illustrate ways to achieve special graphics effects using PEXlib calls.

ora-examples

Contains source files for all the programs and utilities described in the PEXlib Programming Manual.

cge-examples

Contains program examples that demonstrate some of the portability and functionality of the CGE PEX 5.1 extensions.

pex-utils

Contains general information and a number of important utilities dealing with colormaps and visuals, double-buffering, gamma correction, and use of Motif widgets.

cge-utils

Contains important, highly recommended utilities that will assist you in creating highly portable applications.

README

Read this file to learn about obtaining and using the source files.

 

Including Header Files In Your Applications

HP PEX uses standard C and X11 header files, providing definitions and declarations shared among program files (list the 〈pex_incl〉 directory\Footnote The actual pathname of this directory depends on the file system structure. See the Graphics Administration Guide for details.\EndFootnote{}). Most, if not all programs, will require that at least these header files must be included at the beginning of your programs. Your program may require others in addition to these.

#include <sys/types.h>
#include <stdio.h>
#include <string.h>
#include <X11/X.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>

Most HP PEXlib programs and applications that only use the standard PEXlib data types, definitions, and function declarations, need only include the header file PEXlib.h under the 〈include〉 directory. Use the following syntax:

#include <X11/PEX5/PEXlib.h>

Notice that PEXlib.h includes several key Xlib header files such as Xlib.h. It also includes PEX.h, which is a separate file in the same directory, and contains the definitions and types defined by the PEX protocol.

Still other header files may be needed by your program, depending on your application. For example, in order to provide access to the additional functionality of multi-buffering extension and the CGE extensions (among varied workstation platforms from workstation vendors, including Hewlett-Packard) you must include PEXExtlib.h, as shown below. Among these header files are PEXExtlib.h and PEXHPlib.h, which must be included in your program after PEXlib.h, as the final include example shows.

#include <X11/PEX5/PEXExtlib.h>
#include <X11/PEX5/PEXHPlib.h>

For 5.1v3 and later HP PEX releases, a new header file, PEXHPlibint.h is included by PEXlib.h.

Another example is the colormap and visual utilities that require you to include PEXUtCmap.h from the 〈cge_utils〉\Footnote The actual pathname of this directory depends on the file system structure. See the Graphics Administration Guide for details.\EndFootnote{} directory. This header file defines the constants and structure types for use with these utilities.

Instructions for including various additional header files are usually provided with the README file that accompanies the utility or function. The README also includes instructions for using or operating the utilities.

Table 4-2 Header Files for Advanced Functionality

File [1]

Description

PEXHPlib.h

Contains the data types, declarations, and function declarations required by extensions to the PEXlib API that are supported by Hewlett-Packard.

PEXExtlib.h

Contains CGE extensions for portability and interoperability.

multibuf.h

Multi-buffering extension from libXext.sl. [2]

[1] See list below for complete pathnames

[2] See the O'Reilly PEXlib Programming Manual, 14.2: "The Multi-buffering Extension" for further information.

 

Now your header file declarations at the beginning of your program should appear:

#include <sys/types.h>
#include <stdio.h>
#include <string.h>
#include <X11/X.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/PEX5/PEXlib.h>
#include <X11/PEX5/PEXExtlib.h>
#include <X11/PEX5/PEXHPlib.h>
#include <X11/extensions/multibuf.h>

Using the Utility Programs

A number of utilities have been added to the HP PEXlib product that simplify and speed programming or which enable you to display sophisticated images.

Utilities For The Common Graphics Environment

To encourage and assist you in the development of applications based on the common graphics interoperability conventions, a number of highly recommended utilities are made available in the directory 〈cge-utils〉\Footnote The actual pathname of this directory depends on the file system structure. See the Graphics Administration Guide for details.\EndFootnote{}:

PEXUtCmap.c
PEXUtCmap.h
PEXUtCmapint.c
PEXUtCmapint.h
PEXUtExt.h
PEXUtdbint.h

A shared library providing these utilities is shipped as 〈pex-lib4/libPEXUt.sl.

Utilities From the O'Reilly Manual

The directory 〈ora_examples〉, which contains the examples from PEXlib Programming Manual, also contains the book_utils.c utility. O'Reilly developed this utility to set up the workstation. However, it is important to notice that HP has modified book_utils.c shipped with the HP PEX product to provide improved interoperability and properly set up HP workstations to run the O'Reilly programs.

Hewlett-Packard recommends that you use the HP-modified utility instead, especially if you intend to use programs from other workstations which use O'Reilly examples, or if you obtain the programs again directly from O'Reilly &Associates per the instructions in the Preface of PEXlib Programming Manual, "Obtaining the Example Programs."

#include "book_utils.h"

Utilities from Hewlett-Packard

Hewlett-Packard ships a number of additional utilities with the HP PEX product. These utilities are in the 〈pex_utils〉 directory\Footnote The actual pathname of this directory depends on the file system structure. See the Graphics Administration Guide for details.\EndFootnote{}. See the README file in this directory to learn about these utilities and how they are useful.

Table 4-3 HP Utilities in Utilities Directory

Subdirectory

Description

PEXSimple.c

A basic Motif widget for a PEX drawing area.

hpgamma.c

An HP utility to enable gamma-correction for anti-aliasing.

pexutcmap.c pexutcmaphp.c pexutcmapint.c

Source code for HP-originated utilities for visual selection and colormap creation.

pexutdb.c pexutdbint.c

Source code for HP-originated utilities for portable double buffering.

 

Examples, Utilities and Demo Programs

The HP PEX product contains many examples and programs, in addition to those supplied with the O'Reilly PEXlib Programming Manual, that demonstrate use of various functions and utilities that can make you more productive or to display more sophisticated images.

The 〈pex〉 directory contains the examples and demos. This directory and subdirectories for each of the examples and programs also contains a README file to explain the contents and, importantly, instructions for using the programs. This table notes some of these examples; see the directories themselves for a complete list, and the README files in the directories for explanations.

  • hp-examples/SubsetAAModeling — Interactive demos showing the differences between subset mode, mixed mode and immediate mode rendering. These examples also demonstrate antialiasing capabilities.

  • pex〉/demos/drive/PEXdrive — HP's networked driving simulator.

  • hp-examples/TexMap/boundary.c,.../composition.c, .../orientation.c,.../param.c, and .../texture.c — Texture-mapping examples (see Chapter 9 “Overview of CGE PEX Texture Mapping ”)

  • hp-examples/pexdpyinfo — A utility for developers; displays PEX extension information, plus information on the enumerated types, implementation-dependent constants, lookup table entries, and sup ported PEX visuals for a particular display. See pexdpyinfo.

  • hp-examples/dblbuffer_pexut — Rotates a cube using the PEXUt double-buffering and color utilities.

  • hp-examples/wireframe.c — Uses two supplied graphic object data files to display both wire frame and solid surface image with shading.

  • hp-examples/overlay.c — Simple example of overlay and image plane use.

  • hp-examples/screen_dump.c — Example of programmatic invocation of the screenpr(1) command to generate a screen-resolution dump to a PCL printer.

  • hp-examples/alpha_blend.c, alpha/alpha_twopass.c — Alpha blending examples demonstrate the use of the HP alpha blending extensions to PEX functionality.

  • pex/demos/verify_install — Rotates the PEX cube.

  • hp-examples/hp_example_utils.c — Utility procedures for the examples

  • hp-examples/cge_simplewin.c and 〈hp-examples/cge_makewin.c — Programs that illustrate the use of the two most powerful colormap/visual utilities in CGE.

  • hp-examples/widgetdemo — Demonstrates creation of XgPEXSimple Motif widget, displays dotted line in it, and provides a pulldown menu to close it.

  • hp-examples/wideline_ctl.c — Demonstrates the control of stroked versus filled widelines.

  • hp-examples/polyoff/polyoff_ctl.c — Demonstrates use of the polygon offset performance feature.

Using the HP Examples

The file\Footnote The actual pathname of this directory depends on the file system structure. See the Graphics Administration Guide for details.\EndFootnote{} 〈hp-examples/README describes how Makefile is used to build executable programs of the various examples included in the directory.

How To Link To Shared Libraries

HP PEXlib is supported on the Series 700 workstations using shared libraries that must be linked with the application program.

When you compile your PEXlib programs, you must link the application with the PEXlib library libPEX5 just as described in the PEXlib Programming Manual and on-line system. Notice that the PEX library is dependent on the math library.

A compile line will typically appear:

cc program.c -I/usr/include/X11R6 -I〈pex-incl〉/X11R6 -L〈x11r6〉 \
-L〈pex-lib〉 -lPEX5 -lXext -lX11 -lm

See the Graphics Administration Guide for more information on compiling.

This table summarizes the shared libraries and X11 directories that are linked on the command line example above.

Table 4-4 Shared Libraries and X11 Directories

Library

Description

libX11

X11 routines

libXext

X11 extensions

libPEX5

PEXlib routines

libm

math functions

 

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1996 Hewlett-Packard Development Company, L.P.