📄 ch60.htm
字号:
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<SCRIPT>
<!--
function displayWindow(url, width, height) {
var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>
-->
<font face="Arial,Helvetica" size="-1" color="#006666">
<b>Linux</b></font><p>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<H1></H1>
<UL>
<LI><A HREF="#Heading1">- 60 -</A>
<UL>
<LI><A HREF="#Heading2">Server Support for PEX</A>
<LI>
<UL>
<LI><A HREF="#Heading4">What Is PEX?</A>
<LI><A HREF="#Heading5">PEX Server</A>
<LI><A HREF="#Heading6">Building a Server</A>
<LI><A HREF="#Heading7">NOTE</A>
<LI><A HREF="#Heading8">Listing 60.1. Sample site.def file</A>
<LI><A HREF="#Heading9
<LI><A HREF="#Heading10">NOTE</A>
<LI><A HREF="#Heading11">TIP</A>
<UL>
<LI><A HREF="#Heading12">Writing Your Own Driver</A>
</UL>
<LI><A HREF="#Heading13">Getting PEX</A>
<LI><A HREF="#Heading14">NOTE</A>
<LI><A HREF="#Heading15">Sample PEX Source File</A>
<LI><A HREF="#Heading16">PEXlib and Motif</A>
<UL>
<LI><A HREF="#Heading17">Initializing the Toolkit</A>
<LI><A HREF="#Heading18">Creating the Window</A>
</UL>
<LI><A HREF="#Heading19">TIP</A>
<LI><A HREF="#Heading20">Listing 60.2. A sample PEX application with Motif</A>
<LI><A HREF="#Heading21
<LI><A HREF="#Heading22">Where to Look for More Information</A>
<LI><A HREF="#Heading23">Summary</A>
</UL>
</UL>
</UL>
<P>
<HR SIZE="4">
<H2 ALIGN="CENTER"><A NAME="Heading1<FONT COLOR="#000077">- 60 -</FONT></H2>
<H2 ALIGN="CENTER"><A NAME="Heading2<FONT COLOR="#000077">Server Support for
PEX</FONT></H2>
<H2 ALIGN="CENTER"><FONT COLOR="#000077"></FONT></H2>
<P><I>by Kamran Husain</I></P>
<P>IN THIS CHAPTER</P>
<UL>
<LI>What Is PEX?
<P>
<LI>PEX Server
<P>
<LI>Building a Server
<P>
<LI>Getting PEX
<H1></H1>
<LI>Sample PEX Source File
<P>
<LI>PEXlib and Motif
<P>
<LI>Where to Look for More Information
</UL>
<P>This chapter is really two chapters in one. I will discuss two topics here:
<UL>
<LI>Building a new server for X.
<P>
<LI>To build this new server, we will add PEX support to it. This will serve as an
example of how to add more capabilities to the X server.
</UL>
<P>After you read this chapter, you will have an idea of how to draw to an X drawable,
and use Motif and PEX together. This chapter is not a tutorial on PEX, nor will you
become the world's expert on writing additions to X servers. This chapter will introduce
you to techniques that you can use to add features to the X server. You will also
learn where to look for more information about PEX and X servers.
<H3 ALIGN="CENTER"><A NAME="Heading4<FONT COLOR="#000077">What Is PEX?</FONT></H3>
<P>The X Window system is primarily a two-dimensional graphical system. Due to the
lack of standards in the three-dimensional (3-D) area, there hasn't been an evolution
of good 3-D developmental tool libraries. However, PEX is supposed to alleviate this
problem by providing a consistent set of toolkit calls, which enables a user to support
3-D software with little effort.</P>
<P>PEX originally stood for PHIGS Extensions to X. PHIGS stands for Programmer's
Hierarchical Interactive Graphics System. PEX has been adopted by the Common Open
Software Environment (COSE) for X11 releases that are later than 2.2.</P>
<P>However, PEX is simply historical at this point, because the last version of the
PEX protocol (Version 6.0) is not designed specifically for PHIGS at all. PEX is
now designed to support 3-D application programs. PEX is an extension to the Core
X Protocol to provide 3-D graphics support within the X Window environment. Included
in the X11R5 distribution is code for the Sample Implementation of the extensions
to the X Window server, which implements the functionality defined by the PEX Protocol
Extensions.</P>
<P>In order to access the PEX functional extensions to the X server, one must use
an application that generates PEX Protocol. The application can either generate the
Protocol bytestream itself, or use something called an Application Protocol Interface
(API). One such API provided with the X11R5 distribution is the PHIGS 3-D graphics
standard. This is a port of the PHIGS C language binding onto an internal layer,
which generates the PEX Protocol enabling this particular PHIGS implementation to
work within the X Window environment. Other alternate APIs are available via anonymous
FTP from <TT>export.lcs.mit.edu</TT>.</P>
<P>When discussing PEX, it is important not to confuse the protocol with the API.
The API is the conceptual model of 3-D graphics that the application developer sees
when developing a client program. The PEX protocol is generated by the API, and is
interpreted by the X server to perform graphics requests on behalf of the client
program.</P>
<P>One API provided with the R5 PEX-SI is a PHIGS/PHIGS-PLUS API. The PHIGS/PHIGS-PLUS
standards are specified in two parts. First, a functional description explains each
operation conceptually, in a language-independent manner. Second, language bindings
are used to bind the particular PHIGS functions to the semantics of the language.
The PEX-SI comes with an application programmer interface that conforms to the latest
revision of the PHIGS/PHIGS-PLUS C language binding.</P>
<P>If your version of R5 is patched through patch number 22, you have a second <TT>MIT</TT>-supplied
API called <TT>PEXlib</TT>. <TT>PEXlib</TT> is to the PEX protocol what <TT>Xlib</TT>
is to the core X protocol. <TT>PEXlib</TT> provides an interface that is as close
as possible to a one-to-one correspondence between functions and protocol requests.
It is intended to be a systems programming interface (so, people developing graphics
toolkits and graphics systems will implement their system on top of <TT>PEXlib</TT>).
It is proposed that the PHIGS API be ported to <TT>PEXlib</TT> when <TT>PEXlib</TT>
is finalized. This change would not affect programs written to the existing PHIGS
API.</P>
<P>However, because <TT>PEXlib</TT> is intimately tied to the protocol, it is expected
that there will be changes between the current <TT>PEXlib</TT> (which supports Version
5.0 and 5.1 of the PEX protocol) and the <TT>PEXlib</TT> that supports the next major
version of the PEX protocol, Version 6.0. Naturally, every attempt will be made to
make the changes to the API minimal. The nature of the changes from 5.1 to 6.0 are
not such that every primitive will be affected; rather the changes deal with the
sticky problems of subsets, multibuffering, and other issues of global rendering
semantics.
<H3 ALIGN="CENTER"><A NAME="Heading5<FONT COLOR="#000077">PEX Server</FONT></H3>
<P>Find out whether you have PEX available on your X server first. By default, PEX
support is not built into the servers you received for Linux. The <TT>xdpyinfo</TT>
command displays all the extensions supported by a server.</P>
<P>Output from the <TT>PEX</TT> command should contain strings of the following form:</P>
<PRE><FONT COLOR="#0066FF"> number of extensions: 7
XTestExtension1
SHAPE
MIT-SHM
X3D-PEX (<-- This is the line you are looking for)
Multi-buffering
MIT-SUNDRY-NONSTANDARD
</FONT></PRE>
<P>If one of the extensions listed is <TT>X3D-PEX</TT>, your server supports PEX.
If you do not see this line, you must build the server yourself.
<H3 ALIGN="CENTER"><A NAME="Heading6<FONT COLOR="#000077">Building a Server</FONT></H3>
<P>To build a server that only includes the drivers you need, use the LinkKit instead
of compiling the complete X system. Using the LinkKit package is much easier. The
LinkKit package can be found in <TT>/usr/X386/lib/Server</TT>.</P>
<P>The LinkKit package contains a file called <TT>site.def</TT> for you to edit.
The <TT>site.def</TT> file contains the site-specific information for your system.
Edit the <TT>site.def</TT> file to define which servers you want to build, and the
drivers and font renderers (programs that generate fonts for display) you want to
include.
<DL>
<DT></DT>
</DL>
<DL>
<DD>
<HR>
<A NAME="Heading7<FONT COLOR="#000077"><B>NOTE:</B> </FONT>You must run all
the commands in this section as root.
<HR>
</DL>
<P>Let's examine the <TT>site.def</TT> file in a bit of detail. See Listing 60.1
for the <TT>site.def</TT> file that I used to create a PEX server for my machine.
<H3 ALIGN="CENTER"><A NAME="Heading8<FONT COLOR="#000077">Listing 60.1. Sample
site.def file.</FONT></H3>
<PRE><FONT COLOR="#0066FF">XCOMM $XFree86: mit/server/ddx/x386/LinkKit/site.def.LK,v 2.11
1994/04/10 05:49:56 dawes Exp $
/* Configuration file for Server Link Kit */
#ifdef BeforeVendorCF
/*
* Change these definitions if you need to override the defaults:
*/
/*
* HasGcc: defaults:
* SVR3,4: YES
* Mach, 386bsd: YES
*/
/* #define HasGcc NO */
/*
* HasGcc2: (should also set HasGcc)
* defaults:
* SVR3,4: YES
* Mach: YES
* 386bsd: NO
*/
/* #define HasGcc2 NO */
/*
* If the link kit you are using was built with gcc2, and you are using
* a different compiler:
* 1. Install libgcc.a in a directory searched by your `ld'
* 2. Set NeedLibGcc to YES
*/
#define NeedLibGcc NO
/*
* Uncomment this if you want to link with the Gnu malloc library
*/
/* #define GnuMalloc YES */
/*
* GnuMallocLib: link-time flags to include the Gnu malloc library.
* this is only used when GnuMalloc is set to YES.
* defaults:
* 386bsd: -lgnumalloc
* others: -lgmalloc
*/
/* #define GnuMallocLib -L/usr/local/gnu -lmalloc */
/*
* Server configuration parameters
*/
#define FontRenderers Speedo Type1
#define X386Vga2Drivers et4000 et3000 pvga1 gvga tvga8900 ncr \
compaq oak generic
#define X386Vga16Drivers et4000 tvga8900 generic
#define X386Vga256Drivers et4000 et3000 pvga1 gvga ati tvga8900 cirrus \
ncr compaq oak
#define X386Hga2Drivers /**/
/* To enable the hga2 driver, replace the above line with the following */
/* #define X386Hga2Drivers hga6845 */
/*
* To include the generic banked monochrome driver in the monochrome server,
* uncomment this with one of the following low level drivers
* hgc1280 [Hyundai HGC-1280 1280x1024]
* sigma [Sigma L-View]
* visa [???]
* apollo [???]
* ...
* (list is subject to grow)
*/
/* #define X386Bdm2Drivers hgc1280 sigma visa apollo */
/* #define XF86S3Drivers mmio_928 s3_generic */
/*
* Set which servers to build. Change the YES to NO for servers you don't
* want to build.
*/
/* The SVGA color server */
#define XF86SVGAServer YES
/* The 16-color VGA server */
#define XF86VGA16Server NO
/* The VGA mono server */
#define XF86MonoServer NO
/* The S3 server */
#define XF86S3Server NO
/* The IBM 8514/A server */
#define XF86I8514Server NO
/* The Mach8 server */
#define XF86Mach8Server NO
/* The Mach32 server */
#define XF86Mach32Server NO
/* Set the default server (ie the one that gets the sym-link to "X") */
/* #define XFree86DefaultServer XF86_S3 */
/*
* If you want PEX (and this link kit was built with PEX support), uncomment
* the following
*/
/* #define BuildPexExt YES */
#define BuildPexExt YES
#endif /* BeforeVendorCF */
#ifdef AfterVendorCF
/* If you are using a different ProjectRoot, set it here */
/*
#ifdef ProjectRoot
#undef ProjectRoot
#endif
#define ProjectRoot /usr/X11R5
*/
#endif /* AfterVendorCF */
</FONT></PRE>
<P>Note the following items about this <TT>site.def</TT> file:
<UL>
<LI>The HasGcc and HasGcc2 definitions have been commented out for Linux.
<P>
<LI>If the LinkKit was built with gcc-2.x and you are using some other compiler,
you must install <TT>libgcc.a</TT> and set <TT>NeedLibGcc</TT> to <TT>YES</TT>.
</UL>
<P>For Linux, <TT>NeedLibGcc</TT> is set to <TT>NO</TT>.</P>
<P>The servers are available to you via LinkKit are shown in Table 60.1. To create
any of these servers, you have to set value of the corresponding variable to <TT>YES</TT>:
</P>
<CENTER>
<P><B>Table 60.1. Server types in site.def. </B>
<TABLE BORDER="0">
<TR ALIGN="LEFT" rowspan="1">
<TD ALIGN="LEFT"><B><I>Server Type</I></B></TD>
<TD ALIGN="LEFT"><B><I>Variable to Set</I></B></TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD ALIGN="LEFT">256-color server</TD>
<TD ALIGN="LEFT"><TT>XF86SVGAServer</TT></TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
<TD ALIGN="LEFT">256-color server</TD>
<TD ALIGN="LEFT"><TT>XF86SVGAServer</TT></TD>
</TR>
<TR ALIGN="LEFT" rowspan="1">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -