PEXConvertSingleFloat - Convert Single Precision Native Floating-Point Numbers to Protocol Floating-Point Format


Synopsis

 
   Status PEXConvertSingleFloat(
           Display *display,
           unsigned int numfloats,
           float *floats,
           unsigned int *retsize,
           PEXPointer *retfloats
     )
 

Arguments

display
A pointer to a display structure returned by a successful XOpenDisplay call.

numfloats
The number of floating-point numbers to convert.

floats
A pointer to the list of contiguous floating-point numbers to be converted.

retsize
The size, in bytes, of the generated protocol floating- point list returned by this function. This size value is returned by this function in retsize.

retfloats
A pointer to the list of protocol floating-point numbers generated by this function. This function allocates space for these returned values and places a pointer to this space in retfloats

Returns

Zero if successful; otherwise, one of the following return values:

PEXBadLocalAlloc
Indicates that this function ran out of memory.

Description

Invoke PEXConvertSingleFloat to convert a contiguous list of single precision floating-point numbers from the client program's native floating-point format to the format the Display connection currently uses. This function generates a list of untyped data that you use as a single block of data for the object that requires the converted floating-point data.

The native floating-point format is the format currently being used on the machine on which the PEXlib client application is executing. This function is intended mainly for use with vendor-specific GSE's, GDP's, Escapes, or output commands that contain floating-point data. A standard PEXlib implementation cannot convert the floating-point data while generating protocol if the native and protocol floating-point formats are not the same because the standard implementation is not aware of vendor extensions and the location of the floating-point data within these extensions. If the native floating-point format is different from the protocol floating-point format, then the client program should invoke this function to convert the floating-point data and then use the resulting list to create the GSE, GDP, Escape, or vendor OC.

Specify with the numfloats argument the number of floats that this function is to convert.

Specify with the floats argument the list of contiguous floating-point numbers that need to be converted.

The function returns the parameters retsize and retfloats. You use the XFree function to free the storage returned in retfloats.

Example:

The following GDP defined by the ACME company takes 6 points and 3 floats as parameters.

 
   #define ACMEGDPFOOID 0x80000000
 
   PEXCoord        my_FOO_pts[6] = {....};
   float           my_FOO_parms[3] = {1.0, 1.0, 5.0};
   unsigned int    retsize;
   PEXPointer      retfloats;
 
   PEXConvertSingleFloat(display, 3, my_FOO_parms, &retsize, &retfloats);
   PEXOCCGDP(context, ACMEGDPFOOID, 6, my_FOO_pts, retsize,
                (char*)retfloats);
   XFree(retfloats);
 

Errors

None.

See Also

For an overview, see PEXlib Access and Information Functions.