CAD/CAM Developer's Kit/3D

 

Reference Guide

 

1. Introduction

 

2. 2D Geometry

 

3. 3D Geometry

 

4. DXF

 

5. Display

 

6. Lists

 

7. Home

 

 

Copyright (c) 1988-2009 Building Block Software, Inc. All rights reserved.

 

CAD/CAM Developer's Kit/3D

 

 

Overview

========

 

The Building Block Software CAD/CAM Developer's Kit / 3D  (CCDK/3D) provides

functions that enable programs to set up 2D and  3D viewports, and to display

geometry in them.  These functions are  collectively called the "CCDK/3D

display routines."

 

CCDK/3D display routines, by default, invoke Windows GDI functions to perform

rendering.  However, they may be adapted to any other graphics library by editing

a few low-level files (grr.c, grl.c, grldefs.h).

 

 

Fundamental Concepts

====================

 

Introduction

------------

 

This section describes objects and operations related to display  without

getting into any programming details.  The purpose of this  section is to

provide a basis for the sections of this reference  that present programming

information.

 

Display Levels

--------------

 

CCDK/3D display is organized into three levels:

 

* graphics utility

 

* viewport

 

* window manager

 

The graphics utility routines are shells for graphics library  routines.  The

graphics utility routines may be adapted to any  graphics library by editing

them.  Drawing operations at this level  perform such tasks as moving the

drawing "pen" and clearing  rectangles.

 

The viewport routines create, initialize, use, modify and  discard viewports.

The routines at this level call the graphics  utility routines for display

operations.  Drawing commands at this  level specify: "draw this object in

this viewport".

 

The window manager routines create a windowing environment.  The functions in this

group have been deprecated, and should not be used.

 

 

Display Objects

---------------

 

CCDK/3D display provides three objects that are used for  displaying

geometry:

 

* views

 

* screen boxes

 

* viewport

 

A view is a rectangular channel in space, defined by a view  center point,

the channel width and height, and view and up  directions. For 2D views, the

axis of the channel is parallel to the  z-axis, with the up direction aligned

with the y-axis.

 

A screen box is a rectangle which specifies where on the  screen a view

should appear, where the upper left corner of the  screen is (0,0) and the

lower right is (1,1). 

 

A viewport is a combination of these two objects. It is a  "mapping" of the

rectangular view channel in 3D space to a rectangle  on the screen.

 

Display Operations

------------------

 

The operations supported by CCDK/3D display are:

 

* graphics utility

 

* viewport

 

* window manager

 

The graphics utility operations enable graphics mode, and  control drawing

color and pattern.

 

The viewport operations create and manage viewports, and draw  curves and

points in them.

 

The window manager operations create and manage viewports  registered in the

window manager environment, and draw curves and  points in them.

 

 

Object Types

=============

 

This section presents programming information for creating and using  the

objects in CCDK/3D display.  Use this section of the manual to  locate the

name of object types and the access macros that access  the attributes of

these types.

 

Display Types and Constants

---------------------------

 

CCDK/3D display functions use the following types:

 

Types

 

______________________________________________________________________________

| Type                                 | Meaning                             |

|----------------------------------------------------------------------------|

| GR_COLOR                             | color                               |

| GR_PATT                              | line pattern                        |

| VP_VIEW                              | view; consists of a view center     |

|                                      | point, and the width and height     |

|                                      | of a viewing rectangle              |

|                                      | perpendicular to the viewing        |

|                                      | direction; view  directions         |

|                                      | include: front, top and isometric,  |

|                                      | and user-defined                    |

| VP_SCREEN_BOX                        | screen box; a rectangular region    |

|                                      | on a virtual screen which  has      |

|                                      | coordinates (0,0) at the upper      |

|                                      | left corner and (1,1) at the lower  |

|                                      |  right corner                       |

| VP_VIEWPORT                          | viewport; the combination of a      |

|                                      | view and a screen box; the  width   |

|                                      | and height of the view rectangle    |

|                                      | are adjusted to match the aspect    |

|                                      | ratio of the screen box             |

| VP_TRANSFORM                         | a matrix that provides the          |

|                                      | conversion from user space to       |

|                                      | screen space                        |

------------------------------------------------------------------------------

 

None of the attributes of these objects should be accessed directly,  so

there are no macros provided for this purpose.  Routines are  provided for

reading and setting these attributes.

 

GR_COLOR and GR_PATT are defined by including the header file  grdefs.h.

VP_VIEW, VP_SCREEN_BOX,  VP_VIEWPORT, VP_TRANSFORM are defined in the header

file  vpdefs.h. 

 

The following table lists the constants defined by  CCDK/3D display for

colors:

 

______________________________________________________________________________

| Constant                             | Meaning                             |

|----------------------------------------------------------------------------|

| GR_BLACK                             | black                               |

| GR_BLUE                              | blue                                |

| GR_GREEN                             | green                               |

| GR_CYAN                              | cyan                                |

| GR_RED                               | red                                 |

| GR_MAGENTA                           | magenta                             |

| GR_BROWN                             | brown                               |

| GR_LIGHTGRAY                         | light gray                          |

| GR_DARKGRAY                          | dark gray                           |

| GR_LIGHTBLUE                         | light blue                          |

| GR_LIGHTGREEN                        | light green                         |

| GR_LIGHTCYAN                         | light cyan                          |

| GR_LIGHTRED                          | light red                           |

| GR_LIGHTMAGENTA                      | light magenta                       |

| GR_LIGHTYELLOW                       | light yellow                        |

| GR_WHITE                             | white                               |

------------------------------------------------------------------------------

 

The following table lists the constants defined by CCDK/3D  display for

drawing patterns:

 

______________________________________________________________________________

| Constant                             | Meaning                             |

|----------------------------------------------------------------------------|

| GR_SOLID_PATT                        | solid line drawing pattern          |

| GR_DASHED_PATT                       | dashed line drawing pattern         |

------------------------------------------------------------------------------

 

Functions and Macros By Category

================================

 

Introduction

------------

 

This section presents CCDK/3D display functions grouped according to  the

operations they perform.

 

Category Overview

-----------------

 

Display functions are divided into the following  categories:

 

* graphics utilities

 

* viewport

 

* window manager

 

Graphics utilities perform basic graphics operations.  They  include

functions that initialize and exit graphics mode, and manage  drawing color

and patterns.

 

Viewport functions set up and maintain viewports, and draw  curves and points

in  them.

 

Window manager functions set up, maintain registered  viewports, and draw in

them.

 

Graphics utility functions are divided into the  following groups:

 

* initialize/exit graphics

 

* maintain current color and pattern

 

Viewport functions are divided into the following  groups:

 

* create viewports

 

* manage viewports - dimension-independent

 

* manage viewports - 2D and 3D

 

* draw curves and points - 2D and 3D

 

Window manager functions divided into the following  groups:

 

* initialize/exit the window manager

 

* create viewports registered with the window manager

 

* manage window manager environment

 

* draw curves and points in viewport registered with the  window manager - 2D

  and 3D

 

Function Prefixes

-----------------

 

CCDK/3D functions are labelled with prefixes to indicate  the general type of

operation they perform.  Prefixes used in  CCDK/3D display include:

 

______________________________________________________________________________

| Prefix                               | Meaning                             |

|----------------------------------------------------------------------------|

| grr                                  | graphics utilities                  |

| vp2,                                 | viewport creation and management    |

|                                      | routines                            |

| v2d,                                 | viewport display routines           |

| wm2,                                 | window manager viewport creation    |

|                                      | and management routines             |

| w2d,                                 | window manager display routines     |

------------------------------------------------------------------------------

 

Graphics Utilities

------------------

 

Graphics utility functions set up and maintain the graphics mode

environment.  They eliminate direct references to functions in  specific

graphics libraries.

 

The graphic utilities that initialize and exit  graphics mode

are:

 

______________________________________________________________________________

| Function                             | Use                                 |

|----------------------------------------------------------------------------|

| grr_init                             | to initialize graphics mode         |

| grr_exit                             | to exit graphics mode               |

| grr_clear_screen                     | to clear the screen to a specified  |

|                                      | color                               |

------------------------------------------------------------------------------

 

The graphics utilities that maintain current color and pattern

are:

 

______________________________________________________________________________

| Function                             | Use                                 |

|----------------------------------------------------------------------------|

| grr_get_color                        | to get the current drawing color    |

| grr_get_patt                         | to get the current drawing pattern  |

| grr_set_color                        | to set the current drawing color    |

| grr_set_patt                         | to set the current drawing pattern  |

| grr_set_solid_patt                   | to set the current drawing pattern  |

|                                      | to solid                            |

------------------------------------------------------------------------------

 

The following graphics utilities convert between  physical pixel

coordinates and "normalized screen coordinates",  where (0,0) is the upper

left corner of the screen, and (1,1) is the  lower right corner of the

screen:

 

______________________________________________________________________________

| Function                             | Use                                 |

|----------------------------------------------------------------------------|

| grr_pixel_to_point                   | to convert a pixel into normalized  |

|                                      | screen coordinates                  |

| grr_point_to_pixel                   | to convert normalized screen        |

|                                      | coordinates into pixel              |

|                                      | coordinates                         |

------------------------------------------------------------------------------

 

When using these functions, include the header file grrdefs.h.

 

Viewport Creation

-----------------

 

Viewport functions set up and maintain viewports, and draw geometry  in them.

 The viewports created by these functions are independent  objects, and are

not registered with the window manager.  These  viewports can be registered

with the window manager using the  routine wmi_register.

 

The functions that create viewports are:

 

______________________________________________________________________________

| Function                             | Use                                 |

|----------------------------------------------------------------------------|

| vp2_create                           | to create a viewport viewing a      |

|                                      | rectangle on the x-y plane          |

| vp3_create                           | to create a viewport centered on a  |

|                                      | point, viewing from a  specified    |

|                                      | "eye" point, and with a specified   |

|                                      | sense of "up"; in  effect, to       |

|                                      | create a viewport with an           |

|                                      | arbitrary view direction            |

| vp3_front                            | to create a viewport aligned with   |

|                                      | the y-axis looking from  the front  |

|                                      | to the back                         |

| vp3_right                            | to create a viewport aligned with   |

|                                      | the x-axis looking to the  left     |

| vp3_top                              | to create a view aligned with the   |

|                                      | z-axis looking downward             |

| vp3_isometric                        | to create a viewport with an        |

|                                      | isometric view                      |

------------------------------------------------------------------------------

 

When using these functions, include the header file vp2defs.h  or vp3defs.h,

depending on the prefix of the routine.

 

Viewport Management - Dimension-Independent

-------------------------------------------

 

Certain viewport operations, such as changing the width and height  of a view

channel, are not specifically 2D or 3D in nature.   CCDK/3D display routines

that perform these types of operations are  termed dimension-independent.

 

The dimension-independent CCDK/3D display viewport management functions  are:

 

______________________________________________________________________________

| Function                             | Use                                 |

|----------------------------------------------------------------------------|

| vpi_show                             | to display a viewport               |

| vpi_unshow                           | to remove a viewport from the       |

|                                      | screen                              |

| vpi_fill                             | to clear a viewport                 |

| vpi_pt_inside                        | to determine if a pixel is inside   |

|                                      | a viewport                          |

| vpi_clip                             | to set clipping on in a viewport;   |

|                                      | clipping must be set on to          |

|                                      | prevent drawing outside a viewport  |

|                                      |                                     |

| vpi_unclip                           | to turn clipping off in a viewport  |

| vpi_get_screen_box                   | to get the screen box of a          |

|                                      | viewport                            |

| vpi_set_screen_box                   | to set the screen box of a          |

|                                      | viewport                            |

| vpi_get_wh                           | to get the view channel width and   |

|                                      | height of a viewport                |

| vpi_set_wh                           | to set the view channel width and   |

|                                      | height of a viewport                |

| vpi_set_bd_color                     | to set the border color of a        |

|                                      | viewport                            |

| vpi_set_bk_color                     | to set the background color of a    |

|                                      | viewport                            |

| vpi_free                             | to free a viewport                  |

------------------------------------------------------------------------------

 

When using these functions, include the header file vpidefs.h.

 

Viewport Management - 2D and 3D

-------------------------------

 

Many display operations are specifically 2D or 3D.  For example,  setting a

viewing orientation with x, y and z  components is a 3D operation.

 

The CCDK/3D display functions that perform 2D and 3D viewport  management

are:

 

______________________________________________________________________________

| Function                             | Use                                 |

|----------------------------------------------------------------------------|

| vp2_fit                              | to fit a viewport to a specified    |

|                                      | box                                 |

| vp2_get_ctr                          | to get the view center of a         |

|                                      | viewport                            |

| vp2_get_view_box                     | to read the view box of a viewport  |

| vp2_set_ctr                          | to set the x and y coordinates of   |

|                                      | the view center of a  viewport      |

| vp2_set_view_box                     | to set the view box of a viewport   |

| vp2_append_transform                 | to add a 2D transform to a          |

|                                      | viewport's transform                |

| vp3_fit                              | to set the size and location of a   |

|                                      | viewport so that all  objects       |

|                                      | inside a 3D bounding box are        |

|                                      | visible in it                       |

| vp3_get_ctr                          | to get the center point of a        |

|                                      | viewport                            |

| vp3_get_view_dir                     | to get the view direction of a      |

|                                      | viewport                            |

| vp3_get_view                         | to get the center, x-axis and       |

|                                      | y-axis of a viewport                |

| vp3_set_ctr                          | to set the x, y and z coordinates   |

|                                      | of the view center of a  viewport   |

| vp3_set_view_dir                     | to set the view direction of a      |

|                                      | viewport                            |

| vp3_set_view                         | to set the center, x-axis and       |

|                                      | y-axis of a viewport                |

| vp3_append_transform                 | to add a 3D transform to a          |

|                                      | viewport's transform                |

------------------------------------------------------------------------------

 

When using these functions, include the header file vp2defs.h  or vp3defs.h,

depending on the prefix of the routine.

 

The following viewport functions provide a conversion  between 2D and 3D

coordinates and screen coordinates:

 

______________________________________________________________________________

| Function                             | Use                                 |

|----------------------------------------------------------------------------|

| vp2_point_to_pixel                   | to compute the pixel corresponding  |

|                                      | to a 2D point in a  viewport        |

| vp2_pixel_to_point                   | to compute the 2D point             |

|                                      | corresponding to a pixel            |

| vp3_point_to_pixel                   | to compute the pixel corresponding  |

|                                      | to a 3D point in a  viewport        |

| vp3_pixel_to_point                   | to compute the 3D point             |

|                                      | corresponding to a pixel            |

------------------------------------------------------------------------------

 

When using these functions, include the header file vp2defs.h  or vp3defs.h,

depending on the prefix of the routine.

 

Viewport - Drawing Curves and Points

------------------------------------

 

CCDK/3D display provides functions that draw curves and points, both in  2D

and 3D, in viewports independent of the window manager.

 

These functions are:

 

______________________________________________________________________________

| Function                             | Use                                 |

|----------------------------------------------------------------------------|

| v2d_curve                            | to draw a curve in a viewport       |

| v2d_lineto                           | to draw a line in a viewport from   |

|                                      | the current drawing  location to a  |

|                                      | specified point                     |

| v2d_moveto                           | to move the current drawing         |

|                                      | location in a viewport to a new     |

|                                      | location                            |

| v2d_point                            | to draw a point in a viewport       |

| v3d_curve                            | to draw a curve in a viewport       |

| v3d_lineto                           | to draw a line in a viewport from   |

|                                      | the current drawing  location to a  |

|                                      | specified point                     |

| v3d_moveto                           | to move the current drawing         |

|                                      | location in a viewport to a new     |

|                                      | location                            |

| v3d_point                            | to draw a point in a viewport       |

------------------------------------------------------------------------------

 

When using these functions, include the header file v2ddefs.h  or v3ddefs.h,

depending on the prefix of the routine.

 

Window Manager

--------------

 

The functions that initialize and exit the window manager are:

 

______________________________________________________________________________

| Function                             | Use                                 |

|----------------------------------------------------------------------------|

| wmi_init                             | to initialize the                   |

|                                      | highest-resolution graphics mode    |

|                                      | available, and the window manager   |

|                                      | environment                         |

| wmi_init_gmode                       | to initial a specific graphics      |

|                                      | mode and the window manager         |

|                                      | environment                         |

| wmi_exit                             | to exit graphics mode and the       |

|                                      | close the window manager            |

|                                      | environment                         |

------------------------------------------------------------------------------

 

When using these functions, include the header file wmidefs.h.

 

The functions that create viewports registered with the  window manager are:

 

______________________________________________________________________________

| Function                             | Use                                 |

|----------------------------------------------------------------------------|

| wm2_create                           | to create a two-dimensional         |

|                                      | viewport, and to register it  with  |

|                                      | the window manager                  |

| wm3_front                            | to create a viewport aligned with   |

|                                      | the y-axis looking from  the front  |

|                                      | to the back, and to register with   |

|                                      | the window manager                  |

| wm3_right                            | to create a viewport aligned with   |

|                                      | the x-axis looking  leftward, and   |

|                                      | to register with the window         |

|                                      | manager                             |

| wm3_top                              | to create a viewport aligned with   |

|                                      | the z-axis looking  down, and to    |

|                                      | register with the window manager    |

| wm3_isometric                        | to create a viewport with an        |

|                                      | isometric view, and to register     |

|                                      | with the window manager             |

------------------------------------------------------------------------------

 

When using these functions, include the header file wm2defs.h  or wm3defs.h,

depending on the prefix.

 

The functions that manage the window manager  environment are:

 

______________________________________________________________________________

| Function                             | Use                                 |

|----------------------------------------------------------------------------|

| wmi_select                           | to get a registered viewport that   |

|                                      | contains a screen point             |

| wmi_get_current                      | to get the current viewport         |

| wmi_set_current                      | to make a specified viewport        |

|                                      | current                             |

| wmi_close                            | to remove a viewport from the       |

|                                      | screen and from the window          |

|                                      | manager environment                 |

| wmi_fill                             | to clear the current viewport       |

| wmi_show                             | to show the current viewport        |

| wmi_unshow                           | to remove the current viewport      |

|                                      | from the screen                     |

| wmi_set_display_all                  | to set drawing mode so that         |

|                                      | drawing operations are directed     |

|                                      | to all registered windows           |

| wmi_set_display_current              | to set drawing mode so that         |

|                                      | drawing operations are directed     |

|                                      | only to the current window          |

| wmi_get_screen_color                 | to get the screen color             |

| wmi_set_screen_color                 | to set the screen color             |

| wmi_register                         | to register a viewport with the     |

|                                      | window manager                      |

------------------------------------------------------------------------------

 

When using these functions, include the header file wmidefs.h.

 

The routines that draw curves and points in viewports  registered with the

window manager are:

 

______________________________________________________________________________

| Function                             | Use                                 |

|----------------------------------------------------------------------------|

| w2d_curve                            | to draw a 2D curve in the current   |

|                                      | viewport                            |

| w2d_lineto                           | to draw a line in the current       |

|                                      | viewport from the current  drawing  |

|                                      | location to a specified point       |

| w2d_moveto                           | to move the current drawing         |

|                                      | location to a specified point       |

| w2d_point                            | to draw a 2D point in the current   |

|                                      | viewport                            |

| w3d_curve                            | to draw a 3D curve in the current   |

|                                      | viewport                            |

| w3d_lineto                           | to draw a line in the current       |

|                                      | viewport from the current  drawing  |

|                                      | location to a specified point       |

| w3d_moveto                           | to move the current drawing         |

|                                      | location to a specified point       |

| w3d_point                            | to draw a 3D point in the current   |

|                                      | viewport                            |

------------------------------------------------------------------------------

 

When using these functions, include the header file wm2defs.h  or wm3defs.h,

depending on the prefix.

 

Alphabetized Reference

======================

 

***>> grr_clear_screen <<***

 

****** Summary ******

 

#include <grrdefs.h>

 

void grr_clear_screen (screen_color);

 

****** Description ******

 

This function clears the screen with a specified color.

 

****** Input ******

 

------------------------------------------------------------------------------

| GR_COLOR               | screen_color       | the color to which the       |

|                        |                    | screen is cleared            |

------------------------------------------------------------------------------

 

See grr_get_color for valid color options.

 

****** Example ******

 

#include <grrdefs.h>

 

void main()

{

      grr_init ( GR_VGA16, GR_DARKGRAY );

      grr_clear_screen ( GR_BLUE );

      getch();

      grr_exit();

}

This program initializes graphics mode, clears the screen with blue,  and

exits graphics mode.

 

***>> grr_exit <<***

 

****** Summary ******

 

#include <grrdefs.h>

 

void grr_exit() ;

 

****** Description ******

 

This function exits graphics mode.

 

****** Example ******

 

See grr_init

 

***>> grr_get_color <<***

 

****** Summary ******

 

#include <grrdefs.h>

 

GR_COLOR grr_get_color();

 

****** Description ******

 

This function returns the current drawing color.

 

****** Return Value ******

 

The return value is the current drawing color.   Possible values are:

 

______________________________________________________________________________

| Constant                             | Meaning                             |

|----------------------------------------------------------------------------|

| GR_BLACK                             | black                               |

| GR_BLUE                              | blue                                |

| GR_GREEN                             | green                               |

| GR_CYAN                              | cyan                                |

| GR_RED                               | red                                 |

| GR_MAGENTA                           | magenta                             |

| GR_BROWN                             | brown                               |

| GR_LIGHTGRAY                         | light gray                          |

| GR_DARKGRAY                          | dark gray                           |

| GR_LIGHTBLUE                         | light blue                          |

| GR_LIGHTGREEN                        | light green                         |

| GR_LIGHTCYAN                         | light cyan                          |

| GR_LIGHTRED                          | light red                           |

| GR_LIGHTMAGENTA                      | light magenta                       |

| GR_LIGHTYELLOW                       | light yellow                        |

| GR_WHITE                             | white                               |

------------------------------------------------------------------------------

 

****** Example ******

 

#include <grrdefs.h>

 

void main()

{

      grr_init ( GR_VGA16, GR_DARKGRAY );

      grr_set_color ( GR_MAGENTA );

      grr_clear_screen ( grr_get_color() );

      getch();

      grr_exit();

}

This program initializes graphics mode, sets magenta as the default  drawing

color, clears the screen with this color, and exits graphics  mode.

 

***>> grr_get_patt <<***

 

****** Summary ******

 

#include <grrdefs.h>

 

PATT grr_get_patt();

 

****** Description ******

 

This function reads the current drawing pattern.

 

****** Return Value ******

 

The return value is the current drawing pattern.   Possible values are:

 

______________________________________________________________________________

| Constant                             | Meaning                             |

|----------------------------------------------------------------------------|

| GR_SOLID_PATT                        | solid line drawing pattern          |

| GR_DASHED_PATT                       | dashed line drawing pattern         |

------------------------------------------------------------------------------

 

****** Example ******

 

#include <grrdefs.h>

#include <vp2defs.h>

#include <vpidefs.h>

#include <v2ddefs.h>

void draw_curves ( curve1, curve2 )

C2_CURVE curve1, curve2;

{

      VP_VIEWPORT vp;

      PATT oldpatt = grr_get_patt();

 

      grr_init ( GR_VGA16, GR_DARKGRAY );

      vp = vp2_create ( 0.0, 0.0, 5.0, 4.0, 0.0, 0.0,

            1.0, 1.0, GR_RED, GR_BLACK );

      vpi_show ( vp );

      grr_set_color ( GR_CYAN );

      grr_set_patt ( GR_SOLID_PATT );

      vpi_clip ( vp );

      v2d_curve ( curve1, NULL, NULL, vp );

      grr_set_patt ( oldpatt );

      v2d_curve ( curve2, NULL, NULL, vp );

      vpi_unclip ( vp );

      getch();

      vpi_free ( vp );

      grr_exit();

}

This program draws a curve in a viewport, using cyan as the drawing  color.

 

***>> grr_init <<***

 

****** Summary ******

 

#include <grrdefs.h>

 

BOOLEAN grr_init ( gmode, screen_color );

 

****** Description ******

 

This function initializes graphics mode and clears the screen to the

specified color.  It should be used to enable graphics mode when you  are

using viewports without the window manager environment.  If you  want to use

the window manager, initialize graphics mode with wmi_init.

 

Use grr_exit to disable graphics mode when it was enabled with  this

function.

 

****** Input ******

 

------------------------------------------------------------------------------

| int                    | gmode              | a graphics mode              |

------------------------------------------------------------------------------

| GR_COLOR               | screen_color       | the color to which the       |

|                        |                    | screen is cleared            |

------------------------------------------------------------------------------

 

The following enumerated constants specify the video  modes invoked by the

CCDK display setup routines.

 

______________________________________________________________________________

| Constant                             | Meaning                             |

|----------------------------------------------------------------------------|

| GR_NOVMODE                           | no video mode                       |

| GR_DETECT                            | select the highest video mode       |

|                                      | available                           |

| GR_VGA16                             | VGA 16 color                        |

| GR_EGA                               | EGA                                 |

| GR_VGA2                              | VGA monochrome                      |

| GR_EGA0                              | EGA monochrome                      |

| GR_HRES16                            | CGA 16 color                        |

| GR_HERC                              | Hercules                            |

| GR_HRES0                             | CGA monochrome                      |

------------------------------------------------------------------------------

 

See grr_get_color for valid color options.

 

****** Return Value ******

 

The return value is TRUE if the selected graphics mode was successfully

enabled, and FALSE otherwise.

 

****** Example ******

 

#include <grrdefs.h>

#include <vp2defs.h>

#include <vpidefs.h>

 

void main()

{

      VP_VIEWPORT vp;

 

      grr_init ( GR_VGA16, GR_DARKGRAY );

      vp = vp2_create ( 0.0, 0.0, 5.0, 4.0, 0.0, 0.0,

            1.0, 1.0, GR_RED, GR_BLACK );

      vpi_show ( vp );

      getch();

      vpi_free ( vp );

      grr_exit();

}

This program initializes graphics mode, creates a viewport, shows  the

viewport, and exits graphics mode.

 

***>> grr_pixel_to_point <<***

 

****** Summary ******

 

#include <grrdefs.h>

 

void grr_pixel_to_point ( pixel, point );

 

****** Description ******

 

This function computes the "normalized screen coordinates" of a  pixel.  In

this coordinate system, (0,0) corresponds to the upper  left corner of the

screen, and (1,1) corresponds to the lower right  corner of the screen.

 

****** Input ******

 

------------------------------------------------------------------------------

| INT                    | pixel[2]           | a pair of pixel coordinates  |

------------------------------------------------------------------------------

 

****** Output ******

 

------------------------------------------------------------------------------

| REAL                   | point[2]           | the normalized screen        |

|                        |                    | coordinates of the pixel     |

------------------------------------------------------------------------------

 

****** Example ******

 

#include <grrdefs.h>

void convert_pixel ( point )

REAL point[2];

{

      INT pixel[2];

      printf ( "enter pixel coordintes" );

      scanf ( "%d%d", pixel, pixel+1 );

      grr_pixel_to_point ( pixel, point );

}

This function computes the normalized coordinates of a pixel.

 

***>> grr_point_to_pixel <<***

 

****** Summary ******

 

#include <grrdefs.h>

 

void grr_point_to_pixel ( point, pixel );

 

****** Description ******

 

This function computes the pixel corresponding to a point in  "normalized

screen coordinates", where (0,0) corresponds to the  upper left corner of the

screen, and (1,1) corresponds to the lower  right corner of the screen.

 

****** Input ******

 

****** Output ******

 

------------------------------------------------------------------------------

| REAL                   | point[2]           | a set of normalized screen   |

|                        |                    | coordinates                  |

------------------------------------------------------------------------------

| INT                    | pixel[2]           | the pixel coordinates of the  |

|                        |                    | point                        |

------------------------------------------------------------------------------

 

****** Example ******

 

#include <grrdefs.h>

void convert_point ( pixel )

INT pixel[2];

{

      REAL point[2];

      printf ( "enter a pixel in normalized " );

      printf ( "screen coordintes" );

      scanf ( "%lf%lf", point, point+1 );

      grr_point_to_pixel ( point, pixel );

}

This function computes the pixel coordinates of a screen point in  normalized

coordinates.

 

***>> grr_set_color <<***

 

****** Summary ******

 

#include <grrdefs.h>

 

void grr_set_color ( color );

 

****** Description ******

 

This function sets the current drawing color.

 

****** Input ******

 

------------------------------------------------------------------------------

| GR_COLOR               | color              | a color                      |

------------------------------------------------------------------------------

 

See grr_get_color for valid color options.

 

****** Example ******

 

#include <grrdefs.h>

#include <vp2defs.h>

#include <vpidefs.h>

#include <v2ddefs.h>

void draw_curve ( curve )

C2_CURVE curve;

{

      VP_VIEWPORT vp;

 

      grr_init ( GR_VGA16, GR_DARKGRAY );

      vp = vp2_create ( 0.0, 0.0, 5.0, 4.0, 0.0, 0.0,

            1.0, 1.0, GR_RED, GR_BLACK );

      vpi_show ( vp );

      grr_set_color ( GR_CYAN );

      grr_set_patt ( GR_SOLID_PATT );

      vpi_clip ( vp );

      v2d_curve ( curve, NULL, NULL, vp );

      vpi_unclip ( vp );

      getch();

      vpi_free ( vp );

      grr_exit();

}

This program draws a curve in a viewport using cyan as the drawing  color.

 

***>> grr_set_patt <<***

 

****** Summary ******

 

#include <grrdefs.h>

 

void grr_set_patt ( patt );

 

****** Description ******

 

This function sets the current drawing pattern.

 

****** Input ******

 

------------------------------------------------------------------------------

| GR_PATT                | patt               | drawing pattern; valid       |

|                        |                    | options include:             |

|                        |                    | GR_SOLID_PATT and            |

|                        |                    | GR_DASHED_PATT               |

------------------------------------------------------------------------------

 

****** Example ******

 

#include <grrdefs.h>

#include <vp2defs.h>

#include <vpidefs.h>

#include <v2ddefs.h>

 

void draw_curve ( curve )

 

C2_CURVE curve;

{

      VP_VIEWPORT vp;

 

      grr_init ( GR_VGA16, GR_DARKGRAY );

      vp = vp2_create ( 0.0, 0.0, 5.0, 4.0, 0.0, 0.0,

            1.0, 1.0, GR_RED, GR_BLACK );

      vpi_show ( vp );

      grr_set_color ( GR_CYAN );

      grr_set_patt ( GR_DASHED_PATT );

      vpi_clip ( vp );

      v2d_curve ( curve, NULL, NULL, vp );

      vpi_unclip ( vp );

      getch();

      vpi_free ( vp );

      grr_exit();

}

This program draws a curve in a viewport using the dashed line pattern.

 

***>> grr_set_solid_patt <<***

 

****** Summary ******

 

#include <grrdefs.h>

 

void grr_set_solid_patt();

 

****** Description ******

 

This function sets the current drawing pattern to solid.

 

****** Example ******

 

#include <grrdefs.h>

#include <vp2defs.h>

#include <vpidefs.h>

#include <v2ddefs.h>

 

void draw_curve ( curve )

 

C2_CURVE curve;

{

      VP_VIEWPORT vp;

 

      grr_init ( GR_VGA16, GR_DARKGRAY );

      vp = vp2_create ( 0.0, 0.0, 5.0, 4.0, 0.0, 0.0,

            1.0, 1.0, GR_RED, GR_BLACK );

      vpi_show ( vp );

      grr_set_color ( GR_CYAN );

      grr_set_solid_patt();

      vpi_clip ( vp );

      v2d_curve ( curve, NULL, NULL, vp );

      vpi_unclip ( vp );

      getch();

      vpi_free ( vp );

      grr_exit();

}

This routine draws a curve in a viewport using the solid line pattern.

 

***>> v2d_curve  <<***

 

****** Summary ******

 

#include <v2ddefs.h>

 

void v2d_curve ( curve, parm0, parm1, viewport );

 

****** Description ******

 

This function draws a 2D curve, optionally trimmed to a specified  parameter

interval, with the current color and line pattern in a  specified viewport.

 

****** Input ******

 

------------------------------------------------------------------------------

| C2_CURVE               | curve              | a curve                      |

------------------------------------------------------------------------------

| PARM                   | parm0, parm1       | curve parameters which       |

|                        |                    | specify the interval on the  |

|                        |                    | curve which  should be       |

|                        |                    | drawn; if parm0 is NULL,     |

|                        |                    | drawing begins at the curve   |

|                        |                    | start point; if parm1 is     |

|                        |                    | NULL, drawing ends at the    |

|                        |                    | curve end  point             |

------------------------------------------------------------------------------

| VP_VIEWPORT            | viewport           | the viewport to draw in      |

------------------------------------------------------------------------------

 

****** Example ******

 

#include <grrdefs.h>

#include <vp2defs.h>

#include <vpidefs.h>

#include <v2ddefs.h>

void draw_curve ( curve )

C2_CURVE curve;

{

      VP_VIEWPORT vp;

      grr_init ( GR_VGA16, GR_DARKGRAY );

      vp = vp2_create ( 0.0, 0.0, 5.0, 4.0, 0.0, 0.0,

            1.0, 1.0, GR_RED, GR_BLACK );

      vpi_show ( vp );

      grr_set_color ( GR_CYAN );

      grr_set_patt ( GR_SOLID_PATT );

      vpi_clip ( vp );

      v2d_curve ( curve, NULL, NULL, vp );

      vpi_unclip ( vp );

      getch();

      vpi_free ( vp );

      grr_exit();

}

This program draws a curve in a viewport.

 

***>> v2d_lineto  <<***

 

****** Summary ******

 

#include <v2ddefs.h>

 

void v2d_lineto ( pt, viewport );

 

****** Description ******

 

This function draws a line from the current drawing position to a  specified

point in a specified viewport.  The current drawing position  can be set

using v2d_moveto.

 

****** Input ******

 

------------------------------------------------------------------------------

| PT2                    | pt                 | the point to draw to         |

------------------------------------------------------------------------------

| VP_VIEWPORT            | viewport           | the viewport to draw in      |

------------------------------------------------------------------------------

 

****** Example ******

 

#include <grrdefs.h>

#include <vp2defs.h>

#include <vpidefs.h>

#include <v2ddefs.h>

 

void draw_between_pts ( p0, p1 )

PT2 p0, p1;

{

      VP_VIEWPORT vp;

 

      grr_init ( GR_VGA16, GR_DARKGRAY );

      vp = vp2_create ( 0.0, 0.0, 5.0, 4.0, 0.0, 0.0,

            1.0, 1.0, GR_RED, GR_BLACK );

      vpi_show ( vp );

      grr_set_color ( GR_CYAN );

      grr_set_patt ( GR_SOLID_PATT );

      vpi_clip ( vp );

      v2d_moveto ( p0, vp );

      v2d_lineto ( p1, vp );

      vpi_unclip ( vp );

      getch();

      vpi_free ( vp );

      grr_exit();

}

This program draws a line between two points in a viewport.

 

***>> v2d_moveto  <<***

 

****** Summary ******

 

#include <v2ddefs.h>

 

void v2d_moveto ( pt, viewport );

 

****** Description ******

 

This function moves the current drawing position to a specified point  in a

viewport.

 

****** Input ******

 

------------------------------------------------------------------------------

| PT2                    | pt                 | the point to moveto          |

------------------------------------------------------------------------------

| VP_VIEWPORT            | viewport           | the viewport to move in      |

------------------------------------------------------------------------------

 

****** Example ******

 

See v2d_lineto.

 

***>> v2d_point  <<***

 

****** Summary ******

 

#include <v2ddefs.h>

 

void v2d_point ( pt, size, viewport );

 

****** Description ******

 

This function draws a 2D point, using the current color, in a specified

viewport.  A point is represented with crosshairs centered on the  point

which have height and width equal to a given size specified  as a fraction of

the screen width.

 

****** Input ******

 

------------------------------------------------------------------------------

| PT2                    | pt                 | the point to draw            |

------------------------------------------------------------------------------

| REAL                   | size               | the size of the crosshairs   |

|                        |                    | representing the point,      |

|                        |                    | expressed  as a fraction of  |

|                        |                    | the width of the screen      |

------------------------------------------------------------------------------

| VP_VIEWPORT            | viewport           | the viewport to draw in      |

------------------------------------------------------------------------------

 

****** Example ******

 

#include <grrdefs.h>

#include <vp2defs.h>

#include <vpidefs.h>

#include <v2ddefs.h>

void draw_point ( pt )

PT2 pt;

{

      VP_VIEWPORT vp;

      grr_init ( GR_VGA16, GR_DARKGRAY );

      vp = vp2_create ( 0.0, 0.0, 5.0, 4.0, 0.0, 0.0,

            1.0, 1.0, GR_RED, GR_BLACK );

      vpi_show ( vp );

      grr_set_color ( GR_CYAN );

      grr_set_patt ( GR_SOLID_PATT );

      vpi_clip ( vp );

      v2d_point ( pt, 1.0 / 20.0, vp );

      vpi_unclip ( vp );

      vpi_free ( vp );

      grr_exit();

}

This program draws crosshairs to represent a point in a viewport.   The width

and height of the crosshairs are 1/20th of the screen  width.

 

***>> v3d_curve  <<***

 

****** Summary ******

 

#include <v3ddefs.h>

 

void v3d_curve ( curve, parm0, parm1, vp );

 

****** Description ******

 

This function draws a 3D curve in a viewport.

 

****** Input ******

 

------------------------------------------------------------------------------

| C3_CURVE               | curve              | a curve                      |

------------------------------------------------------------------------------

| PARM                   | parm0, parm1       | the curve parameters which   |

|                        |                    | specify the start and end of  |

|                        |                    | the  interval to draw; if    |

|                        |                    | parm0 is NULL, then the      |

|                        |                    | interval begins  at the      |

|                        |                    | start point of the curve; if  |

|                        |                    | parm1 is NULL, then the      |

|                        |                    | interval ends at the end     |

|                        |                    | point of the curve           |

------------------------------------------------------------------------------

| VP_VIEWPORT            | vp                 | a viewport                   |

------------------------------------------------------------------------------

 

****** Example ******

 

#include <grrdefs.h>

#include <vp2defs.h>

#include <vpidefs.h>

#include <v3ddefs.h>

void draw_curve ( curve )

C3_CURVE curve;

{

      VP_VIEWPORT vp;

      grr_init ( GR_VGA16, GR_DARKGRAY );

      vp = vp2_create ( 0.0, 0.0, 5.0, 4.0, 0.0, 0.0,

            1.0, 1.0, GR_RED, GR_BLACK );

      vpi_show ( vp );

      grr_set_color ( GR_CYAN );

      grr_set_patt ( GR_SOLID_PATT );

      vpi_clip ( vp );

      v3d_curve ( curve, NULL, NULL, vp );

      vpi_unclip ( vp );

      getch();

      vpi_free ( vp );

      grr_exit();

}

This program draws a curve in a viewport.

 

***>> v3d_lineto  <<***

 

****** Summary ******

 

#include <v3ddefs.h>

 

void v3d_lineto ( pt, vp );

 

****** Description ******

 

This function draws a line in a viewport from the current pen position  to a

specified 3D point. The color and the pattern of the line is  set using the

functions grr_set_color and grr_set_patt.

 

****** Input ******

 

------------------------------------------------------------------------------

| PT3                    | pt                 | a 3D point to draw to        |

------------------------------------------------------------------------------

| VP_VIEWPORT            | vp                 | a viewport                   |

------------------------------------------------------------------------------

 

****** Example ******

 

#include <grrdefs.h>

#include <vp2defs.h>

#include <vpidefs.h>

#include <v3ddefs.h>

 

void draw_between_pts ( p0, p1 )

PT3 p0, p1;

{

      VP_VIEWPORT vp;

 

      grr_init ( GR_VGA16, GR_DARKGRAY );

      vp = vp2_create ( 0.0, 0.0, 5.0, 4.0, 0.0, 0.0,

            1.0, 1.0, GR_RED, GR_BLACK );

      vpi_show ( vp );

      grr_set_color ( GR_CYAN );

      grr_set_patt ( GR_SOLID_PATT );

      vpi_clip ( vp );

      v3d_point ( p0, 0.05, vp );

      v3d_point ( p1, 0.05, vp );

      v3d_moveto ( p0, vp );

      v3d_lineto ( p1, vp );

      vpi_unclip ( vp );

      getch();

      vpi_free ( vp );

      grr_exit();

}

This program draws a line between two points in a viewport.

 

***>> v3d_moveto  <<***

 

****** Summary ******

 

#include <v3ddefs.h>

 

void v3d_moveto ( pt, vp );

 

****** Description ******

 

This function changes the current pen position in a viewport.

 

****** Input ******

 

------------------------------------------------------------------------------

| PT3                    | pt                 | the point which should be    |

|                        |                    | the current pen position     |

------------------------------------------------------------------------------

| VP_VIEWPORT            | vp                 | a viewport                   |

------------------------------------------------------------------------------

 

****** Example ******

 

See v3d_lineto.

 

***>> v3d_point  <<***

 

****** Summary ******

 

#include <v3ddefs.h>

 

void v3d_point ( pt, size, vp );

 

****** Description ******

 

This function draws crosshairs in a viewport at a specified 3D point.  The

size of the crosshairs is specified as a fraction of the screen  width.  The

drawing color and pattern is set with grr_set_color  and grr_set_patt.

 

****** Input ******

 

------------------------------------------------------------------------------

| PT3                    | pt                 | a point                      |

------------------------------------------------------------------------------

| REAL                   | size               | the size of the crosshairs,  |

|                        |                    | as a fraction of the screen  |

|                        |                    | width                        |

------------------------------------------------------------------------------

| VP_VIEWPORT            | vp                 | a viewport                   |

------------------------------------------------------------------------------

 

****** Example ******

 

See v3d_lineto.

 

***>> vp2_append_transform <<***

 

****** Summary ******

 

#include <vp2defs.h>

 

VP_VIEWPORT vp2_append_transform ( vp, transform );

 

****** Description ******

 

This function adds a transform to the view transform of a specified

viewport.  The transform makes 2D geometry appear in a local  coordinate

system in 2D space.  Use c2t_transform to create  the transform.

 

****** Input  ******

 

------------------------------------------------------------------------------

| VP_VIEWPORT            | vp                 | a viewport                   |

------------------------------------------------------------------------------

| C2_TRANSFORM           | transform          | the transform to append      |

------------------------------------------------------------------------------

 

****** Return Value ******

 

The return value is the viewport with the transform appended.  If  the

transform could not be appended, NULL is returned.

 

****** Example ******

 

 

#include <grrdefs.h>

#include <vp2defs.h>

#include <vpidefs.h>

#include <c2vdefs.h>

#include <c2tdefs.h>

 

void main()

{

      VP_VIEWPORT vp;

      VP_TRANSFORM vpt;

      C2_TRANSFORM *c2t;

      PT2 c, x, y;

 

      grr_init ( GR_VGA16, GR_DARKGRAY );

      vp = vp2_create ( 0.0, 0.0, 5.0, 4.0, 0.0, 0.0,

            1.0, 1.0, GR_RED, GR_BLACK );

      vpi_show ( vp );

      c2v_set ( 1, 2, c );

      c2v_normalize ( c2v_set ( 1, 1, x ), x );

      c2v_rotate_vec ( x, HALF_PI, y );

      c2t = c2t_create();

      c2t_lcs ( c, x, y, *c2t );

      vpi_get_transform ( vp, vpt );

      vp2_append_transform ( vp, *c2t );

      c2t_free ( *c2t );

      getch();

      vpi_set_transform ( vp, vpt );

      getch();

      vpi_free ( vp );

      grr_exit();

}

This program creates a viewport centered on (0,0), and which has a  width of

5 units, a height of 4 units, occupies the entire screen,  has a red border

and a black interior. Then it modifies the viewport  transform to make

geometry appear in a local coordinate system.   Finally it restores the

original transform.

 

***>> vp2_create  <<***

 

****** Summary ******

 

#include <vp2defs.h>

 

VP_VIEWPORT vp2_create ( x, y, w, h, ulx, uly, lrx,  lry, bd_color, bk_color

);

 

****** Description ******

 

This function creates a viewport centered on a given point, with a  given

width, height, screen location, border color and background  color.

 

****** Input ******

 

------------------------------------------------------------------------------

| REAL                   | x, y               | the x and y coordinates of   |

|                        |                    | the view center point        |

------------------------------------------------------------------------------

| REAL                   | w, h               | the width and the height of  |

|                        |                    | the view                     |

------------------------------------------------------------------------------

| REAL                   | ulx, uly, lrx, lry | the coordinates of the upper  |

|                        |                    | left and lower right corners  |

|                        |                    | of  the viewport screen box,  |

|                        |                    | where (0,0) is the upper     |

|                        |                    | left corner of the  screen,  |

|                        |                    | and (1,1) is the lower right  |

|                        |                    | corner of the screen         |

------------------------------------------------------------------------------

| GR_COLOR               | bd_color           | border color                 |

------------------------------------------------------------------------------

| GR_COLOR               | bk_color           | background color             |

------------------------------------------------------------------------------

 

Color options include: GR_BLACK, GR_BLUE, GR_GREEN, GR_CYAN, GR_RED,

GR_MAGENTA, GR_BROWN, GR_LIGHTGRAY, GR_DARKGRAY, GR_LIGHTBLUE, GR_LIGHTGREEN,

 GR_LIGHTCYAN, GR_LIGHTRED, GR_LIGHTMAGENTA, GR_LIGHTYELLOW, GR_WHITE

 

****** Return Value ******

 

The return value is a pointer to a viewport.  If a viewport could  not be

created, NULL is returned.

 

 

****** Example ******

 

 

#include <grrdefs.h>

#include <vp2defs.h>

#include <vpidefs.h>

 

void main()

{

      VP_VIEWPORT vp;

 

      grr_init ( GR_VGA16, GR_DARKGRAY );

      vp = vp2_create ( 0.0, 0.0, 5.0, 4.0, 0.0, 0.0,

            1.0, 1.0, GR_RED, GR_BLACK );

      vpi_show ( vp );

      getch();

      vpi_free ( vp );

      grr_exit();

}

This program creates a viewport centered on (0,0), which has a width  of 5

units, a height of 4 units, occupies the entire screen, has a  red border and

a black interior.

 

***>> vp2_fit <<***

 

****** Summary ******

 

#include <vp2defs.h>

 

void vp2_set_view_box ( vp, box, border_factor);

 

****** Description ******

 

This function fits the view box of a viewport to a specified box  which has

beed magnified by a "border factor".

 

****** Input ******

 

------------------------------------------------------------------------------

| VP_VIEWPORT            | vp                 | a viewport                   |

------------------------------------------------------------------------------

| C2_BOX                 | box                | the desired view box         |

------------------------------------------------------------------------------

| REAL                   | border_factor      | box magnification factor for  |

|                        |                    | creating a border around the  |

|                        |                    |  box in the viewport; it     |

|                        |                    | should be greater than 1     |

------------------------------------------------------------------------------

 

****** Example ******

 

#include <grrdefs.h>

#include <vp2defs.h>

#include <vpidefs.h>

#include <v2ddefs.h>

void draw_curve ( curve )

C2_CURVE curve;

{

      VP_VIEWPORT vp;

      grr_init ( GR_VGA16, GR_DARKGRAY );

      vp = vp2_create ( 0.0, 0.0, 5.0, 4.0, 0.0, 0.0,

            1.0, 1.0, GR_RED, GR_BLACK );

      vp2_fit ( vp, C2_CURVE_BOX(curve), 1.05 );

      vpi_show ( vp );

      grr_set_color ( GR_CYAN );

      grr_set_patt ( GR_SOLID_PATT );

      vpi_clip ( vp );

      v2d_curve ( curve, NULL, NULL, vp );

      vpi_unclip ( vp );

      getch();

      vpi_free ( vp );

      grr_exit();

}

This routine fits a viewport to a curve before drawing it.  The fit  function

creates a 5% border around the curve.

 

***>> vp2_get_ctr <<***

 

****** Summary ******

 

#include <vp2defs.h>

 

void vp2_get_ctr ( vp, ctr );

 

****** Description ******

 

This function reads the view center point of a viewport.

 

****** Input ******

 

------------------------------------------------------------------------------

| VP_VIEWPORT            | vp                 | a viewport                   |

------------------------------------------------------------------------------

 

****** Output ******

 

------------------------------------------------------------------------------

| PT2                    | ctr                | view center point            |

------------------------------------------------------------------------------

 

 

****** Example ******

 

#include <grrdefs.h>

#include <vp2defs.h>

#include <vpidefs.h>

#include <v2ddefs.h>

void draw_curve ( curve )

C2_CURVE curve;

{

      VP_VIEWPORT vp;

      PT2 center;

      grr_init ( GR_VGA16, GR_DARKGRAY );

      vp = vp2_create ( 0.0, 0.0, 5.0, 4.0, 0.0, 0.0,

            1.0, 1.0, GR_RED, GR_BLACK );

      vp2_fit ( vp, C2_CURVE_BOX(curve), 1.05 );

      vp2_get_ctr ( vp, center );

      PT2_X(center) += 1.0;

      vp2_set_ctr ( vp, center );

      vpi_show ( vp );

      grr_set_color ( GR_CYAN );

      grr_set_patt ( GR_SOLID_PATT );

      vpi_clip ( vp );

      v2d_curve ( curve, NULL, NULL, vp );

      vpi_unclip ( vp );

      getch();

      vpi_free ( vp );

      grr_exit();

}

This routine fits a viewport to a curve, and then "pans" the view  center by

one unit to the right before drawing the curve.

 

***>> vp2_get_view_box <<***

 

****** Summary ******

 

#include <vp2defs.h>

 

void vp2_get_view_box ( vp, box );

 

****** Description ******

 

This function reads the view box of a viewport.

 

****** Input ******

 

------------------------------------------------------------------------------

| VP_VIEWPORT            | vp                 | a viewport                   |

------------------------------------------------------------------------------

 

****** Output ******

 

------------------------------------------------------------------------------

| C2_BOX                 | box                | view box                     |

------------------------------------------------------------------------------

 

****** Example ******

 

#include <c2adefs.h>

#include <grrdefs.h>

#include <vp2defs.h>

#include <vpidefs.h>

#include <v2ddefs.h>

void draw_curve ( curve )

C2_CURVE curve;

{

      VP_VIEWPORT vp;

      C2_BOX_S box;

      PT2 center;

      grr_init ( GR_VGA16, GR_DARKGRAY );

      vp = vp2_create ( 0.0, 0.0, 5.0, 4.0, 0.0, 0.0,

            1.0, 1.0,  GR_RED, GR_BLACK );

      vp2_get_view_box ( vp, &box ); /* save orig. box */

      vp2_fit ( vp, C2_CURVE_BOX(curve), 1.05 );

      vp2_get_ctr ( vp, center );

      PT2_X(center) += 1.0;

      vp2_set_ctr ( vp, center );

      vpi_show ( vp );

      grr_set_color ( GR_CYAN );

      grr_set_patt ( GR_SOLID_PATT );

      vpi_clip ( vp );

      v2d_curve ( curve, NULL, NULL, vp );

      vpi_unclip ( vp );

      vp2_set_view_box ( vp, &box ); /*restore orig. box*/

      vpi_fill ( vp ); /* clear the viewport */

      vpi_clip ( vp );

      v2d_curve ( curve, NULL, NULL, vp );

      vpi_unclip ( vp );

      vpi_free ( vp );

      grr_exit();

}

This routine fits a viewport to a curve, and draws the curve. Then  it

restores the original view box and draws the curve again.

 

***>> vp2_pixel_to_point <<***

 

****** Summary ******

 

#include <qgldefs.h>

 

void vp2_pixel_to_point ( pxl, vp, pt );

 

****** Description ******

 

This function computes the 2D point corresponding to a pixel in a  viewport.

 

****** Input ******

 

------------------------------------------------------------------------------

| INT                    | pxl[2]             | pixel coordinates            |

------------------------------------------------------------------------------

| VP_VIEWPORT            | vp                 | viewport                     |

------------------------------------------------------------------------------

 

****** Output ******

 

------------------------------------------------------------------------------

| PT2                    | pt                 | the 2D point corresponding   |

|                        |                    | to the pixel                 |

------------------------------------------------------------------------------

 

****** Example ******

 

#include <vp2defs.h>

 

void get_point_on_pixel ( vp, p )

 

VP_VIEWPORT vp;

PT2 p;

{

      INT pixel[2];

      printf ( "enter pixel coordinates" );

      scanf ( "%d%d", pixel, pixel+1 );

      vp2_pixel_to_point ( pixel, vp, p );

}

This function converts a specified pixel into its corresponding 2D  point in

a viewport.

 

***>> vp2_point_to_pixel <<***

 

****** Summary ******

 

#include <qgldefs.h>

 

void vp2_point_to_pixel ( pt, vp, pxl );

 

****** Description ******

 

This function computes the pixel corresponding to a 2D point in a  viewport.

 

****** Input ******

 

------------------------------------------------------------------------------

| PT2                    | pt                 | a 2D point                   |

------------------------------------------------------------------------------

| VP_VIEWPORT            | vp                 | a viewport                   |

------------------------------------------------------------------------------

 

****** Output ******

 

------------------------------------------------------------------------------

| INT                    | pxl[2]             | the pixel corresponding to   |

|                        |                    | the point                    |

------------------------------------------------------------------------------

 

****** Example ******

 

#include <vp2defs.h>

 

void get_point_on_pixel ( vp, pixel )

 

VP_VIEWPORT vp;

INT pixel[];

{

      PT2 p;

 

      printf ( "enter a 2D point" );

      scanf ( "%lf%lf", p, p+1 );

      vp2_point_to_pixel ( p, vp, pixel );

}

This function converts a specified 2D point in a viewport into its

corresponding pixel.

 

***>> vp2_set_ctr  <<***

 

****** Summary ******

 

#include <vp2defs.h>

 

void vp2_set_ctr ( viewport, view_ctr_pt );

 

****** Description ******

 

This function sets the view center of a viewport.

 

****** Input ******

 

------------------------------------------------------------------------------

| VP_VIEWPORT            | viewport           | a viewport                   |

------------------------------------------------------------------------------

| PT2                    | view_ctr_pt        | the point to move the view   |

|                        |                    | center to                    |

------------------------------------------------------------------------------

 

****** Example ******

 

See vp2_get_ctr.

 

***>> vp2_set_view_box <<***

 

****** Summary ******

 

#include <vp2defs.h>

 

void vp2_set_view_box ( vp, box );

 

****** Description ******

 

This function sets the view box of a viewport to a specified box.

 

****** Input ******

 

------------------------------------------------------------------------------

| VP_VIEWPORT            | vp                 | a viewport                   |

------------------------------------------------------------------------------

| C2_BOX                 | box                | the desired view box         |

------------------------------------------------------------------------------

 

****** Example ******

 

See vp2_get_view_box.

 

***>> vp3_append_transform <<***

 

****** Summary ******

 

#include <vp3defs.h>

 

VP_VIEWPORT vp3_append_transform ( vp, transform );

 

****** Description ******

 

This function adds a transform to the view transform of a specified

viewport.  The transform makes geometry appear in a local coordinate  system

in 3D space.  Create the transform with c3t_create.

 

****** Input  ******

 

------------------------------------------------------------------------------

| VP_VIEWPORT            | vp                 | a viewport                   |

------------------------------------------------------------------------------

| C3_TRANSFORM           | transform          | the transform to append      |

------------------------------------------------------------------------------

 

****** Return Value ******

 

The return value is the viewport with the transform appended.  If  the

transform could not be appended, NULL is returned.

 

****** Example ******

 

 

#include <grrdefs.h>

#include <vp3defs.h>

#include <vpidefs.h>

#include <c3vdefs.h>

#include <c3tdefs.h>

 

void main()

{

      VP_VIEWPORT vp;

      VP_TRANSFORM vpt;

      C3_TRANSFORM *c3t;

      PT3 c, n, x, y;

 

      grr_init ( GR_VGA16, GR_DARKGRAY );

      vp = vp3_right ( 0.0, 0.0, 0.0, 5.0, 4.0, 0.0, 0.0,

            1.0, 1.0, GR_RED, GR_BLACK );

      vpi_show ( vp );

      c3v_set ( 1, 2, 2, c );

      c3v_set ( 1, 1, 1, n );

      c3v_basis ( n, x, y );

      c3t = c3t_create();

      c3t_lcs ( c, x, y, *c3t );

      vpi_get_transform ( vp, vpt );

      vp3_append_transform ( vp, *c3t );

      c3t_free ( *c3t );

      getch();

      vpi_set_transform ( vp, vpt );

      getch();

      vpi_free ( vp );

      grr_exit();

}

This program creates a viewport centered on (0,0,0) viewing leftward  along

the x-axis, and which has a width of 5 units, a height of 4  units, occupies

the entire screen, has a red border and a black  interior. Then it modifies

the viewport transform to make 2D  geometry appear in a local coordinate

system.  Finally it restores  the original transform.

 

***>> vp3_create <<***

 

****** Summary ******

 

#include <vp3defs.h>

 

VP_VIEWPORT vp3_create ( view, eye, up, w, h, ulx, uly, lrx,  lry, bd_color,

bk_color )

 

****** Description ******

 

This function creates a viewport looking at the view center from a  specified

eye point with a specified "up" direction.

 

****** Input  ******

 

------------------------------------------------------------------------------

| REAL                   | view[3]            | the coordinates of the view  |

|                        |                    | center                       |

------------------------------------------------------------------------------

| REAL                   | eye[3]             | the coordinates of the       |

|                        |                    | observer                     |

------------------------------------------------------------------------------

| REAL                   | up[3]              | the coordinates of the "up"  |

|                        |                    | vector; if NULL, (0,0,1) is   |

|                        |                    | assumed                      |

------------------------------------------------------------------------------

| REAL                   | w, h               | the width and the height of  |

|                        |                    | the view channel             |

------------------------------------------------------------------------------

| REAL                   | ulx, uly, lrx, lry | the screen coordinates of    |

|                        |                    | the upper left and lower     |

|                        |                    | right corners  of the        |

|                        |                    | viewport screen box; (0,0)   |

|                        |                    | corresponds to the extreme   |

|                        |                    | upper  left of the screen,   |

|                        |                    | and (1,1) corresponds to the  |

|                        |                    | extreme lower right  of the  |

|                        |                    | screen                       |

------------------------------------------------------------------------------

| GR_COLOR               | bd_color, bk_color  | border and background colors  |

------------------------------------------------------------------------------

 

See grr_get_color for valid color options.

 

****** Return Value ******

 

The return value is a viewport.  If the viewport could not be created,  NULL

is returned.

 

 

****** Example ******

 

 

#include <grrdefs.h>

#include <c3vdefs.h>

#include <vp3defs.h>

#include <vpidefs.h>

 

void main()

{

      VP_VIEWPORT vp;

      REAL center[3], eye[3], up[3];

 

      grr_init ( GR_VGA16, GR_DARKGRAY );

      c3v_set ( 1., 2., 3., center );

      c3v_set ( 5., 5., 5., eye );

      c3v_set ( 0., 1., 1., center );

      vp = vp3_create ( center, eye, up, 5.0, 4.0, 0.0, 0.0,

            1.0, 1.0, GR_RED, GR_BLACK );

      vpi_show ( vp );

      getch();

      vpi_free ( vp );

      grr_exit();

}

This program creates a viewport centered on (1,2,3) viewing from the  point

(5,5,5).  The "viewing channel" has a width of 5 units, a  height of 4 units,

occupies the entire screen, has a red border and  a black interior.

 

***>> vp3_fit  <<***

 

****** Summary ******

 

#include <vp3defs.h>

 

void vp3_fit ( vp, box, border_factor );

 

****** Description ******

 

This function adjusts the view center point, the width and the height  of a

viewport so that a specified box is entirely visible within the  viewport.

This adjustment is performed regardless of the viewing  direction.  An empty

margin can be added around the box by specifying  a "border factor" greater

than one.

 

****** Input ******

 

------------------------------------------------------------------------------

| VP_VIEWPORT            | vp                 | a viewport                   |

------------------------------------------------------------------------------

| C3_BOX                 | box                | a 3D box                     |

------------------------------------------------------------------------------

| REAL                   | border_factor      | a magnification factor that  |

|                        |                    | specifies the size of the    |

|                        |                    | margin  around the box; e.g.  |

|                        |                    | a value of 1.05 creates a 5%  |

|                        |                    | margin around the  box       |

------------------------------------------------------------------------------

 

****** Example ******

 

#include <vp3defs.h>

void fit_to_curve ( vp, curve )

 

VP_VIEWPORT vp;

C3_CURVE curve;

{

      C3_BOX box = C3_CURVE_BOX(curve);

      vp3_fit ( vp, box, 1.1 );

}

 

This function fits a viewport to a curve.

 

***>> vp3_front  <<***

 

****** Summary ******

 

#include <vp3defs.h>

 

VP_VIEWPORT vp3_front ( x, y, z, w, h, ulx, uly, lrx,  lry, bd_color,

bk_color );

 

****** Description ******

 

This function creates a viewport looking at the view center from the  front

(along the vector (0,1,0)).

 

****** Input ******

 

------------------------------------------------------------------------------

| REAL                   | x, y, z            | the coordinates of the view  |

|                        |                    | center                       |

------------------------------------------------------------------------------

| REAL                   | w, h               | the width and the height of  |

|                        |                    | the view channel             |

------------------------------------------------------------------------------

| REAL                   | ulx, uly, lrx, lry | the screen coordinates of    |

|                        |                    | the upper left and lower     |

|                        |                    | right corners  of the        |

|                        |                    | viewport screen box; (0,0)   |

|                        |                    | corresponds to the extreme   |

|                        |                    | upper  left of the screen,   |

|                        |                    | and (1,1) corresponds to the  |

|                        |                    | extreme lower right  of the  |

|                        |                    | screen                       |

------------------------------------------------------------------------------

| GR_COLOR               | bd_color, bk_color  | border and background colors  |

------------------------------------------------------------------------------

 

See grr_get_color for valid color options.

 

****** Return Value ******

 

The return value is a viewport.  If the viewport could not be created,  NULL

is returned.

 

****** Example ******

 

 

#include <grrdefs.h>

#include <vp3defs.h>

#include <vpidefs.h>

 

void main()

{

      VP_VIEWPORT vp;

 

      grr_init ( GR_VGA16, GR_DARKGRAY );

      vp = vp3_front ( 0.0, 0.0, 0.0, 5.0, 4.0, 0.0, 0.0,

            1.0, 1.0, GR_RED, GR_BLACK );

      vpi_show ( vp );

      getch();

      vpi_free ( vp );

      grr_exit();

}

This program creates a viewport centered on (0,0,0) viewing along  the y axis

from the front to the back, and which has a width of 5  units, a height of 4

units, occupies the entire screen, has a red  border and a black interior.

 

***>> vp3_get_ctr <<***

 

****** Summary ******

 

#include <vp3defs.h>

 

void vp3_get_ctr ( vp, center );

 

****** Description ******

 

This function reads the view center of a viewport. 

 

****** Input  ******

 

------------------------------------------------------------------------------

| PT3                    | center             | the view center              |

------------------------------------------------------------------------------

| VP_VIEWPORT            | vp                 | a viewport                   |

------------------------------------------------------------------------------

 

****** Example ******

 

#include <vp3defs.h>

#include <c3vdefs.h>

void pan_viewport ( vp, v )

 

VP_VIEWPORT vp;

PT3 v;

{

      PT3 center;

      vp3_get_ctr ( vp, center );

      c3v_add ( center, v, center );

      vp3_set_ctr ( vp, center );

}

This function pans a viewport by a specified vector.

 

***>> vp3_get_view <<***

 

****** Summary ******

 

#include <vp3defs.h>

 

void vp3_get_view ( vp, origin, x_vec, y_vec );

 

****** Description ******

 

This function obtains the origin, x-axis and y-axis of a viewport.

 

****** Input  ******

 

------------------------------------------------------------------------------

| VP_VIEWPORT            | vp                 | a viewport                   |

------------------------------------------------------------------------------

 

****** Output ******

 

------------------------------------------------------------------------------

| REAL                   | origin[3]          | the x, y and z coordinates   |

|                        |                    | of the viewport center       |

------------------------------------------------------------------------------

| REAL                   | x_vec[3], y_vec[3] | the x, y and z components of  |

|                        |                    | the x and y axes of the      |

|                        |                    | viewport                     |

------------------------------------------------------------------------------

 

****** Example ******

 

#include <c3vdefs.h>

#include <vp3defs.h>

void pan_viewport ( vp, across, up )

 

VP_VIEWPORT vp;

REAL across, up;

{

      PT3 c, x, y, v;

      vp3_get_view ( vp, c, x, y );

      c3v_normalize ( x, v );

      c3v_addt ( c, v, across, c );

      c3v_normalize ( y, v );

      c3v_addt ( c, y, up, c );

      vp3_set_ctr ( vp, c );

}

This function pans the center of a viewport by specified horizontal  and

vertical displacements.

 

***>> vp3_get_view_dir <<***

 

****** Summary ******

 

#include <vp3defs.h>

 

void vp3_get_view_dir ( vp, theta, phi );

 

****** Description ******

 

This function provides the spherical angles of the view direction of  a

viewport. 

 

****** Input  ******

 

------------------------------------------------------------------------------

| VP_VIEWPORT            | vp                 | a viewport                   |

------------------------------------------------------------------------------

 

****** Output ******

 

------------------------------------------------------------------------------

| REAL *                 | theta              | the angle about the z-axis   |

|                        |                    | measured from the x-z plane;  |

|                        |                    |  expressed in radians        |

------------------------------------------------------------------------------

| REAL *                 | phi                | the angle from the z-axis;   |

|                        |                    | expressed in radians         |

------------------------------------------------------------------------------

 

****** Example ******

 

#include <vp3defs.h>

void rotate_viewport ( vp, up, over )

 

VP_VIEWPORT vp;

REAL up, over;

{

      REAL theta, phi;

      vp3_get_view_dir ( vp, &theta, &phi );

      theta += over;

      phi -= up;

      vp3_set_view_dir ( vp, theta, phi );

}

This function rotates a viewport by specified spherical angles.

 

***>> vp3_isometric <<***

 

****** Summary ******

 

#include <vp3defs.h>

 

VP_VIEWPORT vp3_isometric ( x, y, z, w, h, ulx, uly,  lrx, lry, bd_color,

bk_color );

 

****** Description ******

 

This function creates a viewport looking at the view center from the

isometric position (along the vector (-1,1,-1)).

 

****** Input  ******

 

------------------------------------------------------------------------------

| REAL                   | x, y, z            | the coordinates of the view  |

|                        |                    | center                       |

------------------------------------------------------------------------------

| REAL                   | w, h               | the width and the height of  |

|                        |                    | the view channel             |

------------------------------------------------------------------------------

| REAL                   | ulx, uly, lrx, lry | the screen coordinates of    |

|                        |                    | the upper left and lower     |

|                        |                    | right corners  of the        |

|                        |                    | viewport screen box; (0,0)   |

|                        |                    | corresponds to the extreme   |

|                        |                    | upper  left of the screen,   |

|                        |                    | and (1,1) corresponds to the  |

|                        |                    | extreme lower right  of the  |

|                        |                    | screen                       |

------------------------------------------------------------------------------

| GR_COLOR               | bd_color, bk_color  | border and background colors  |

------------------------------------------------------------------------------

 

See grr_get_color for valid color options.

 

****** Return Value ******

 

The return value is a viewport.  If the viewport could not be created,  NULL

is returned.

 

****** Example ******

 

 

#include <grrdefs.h>

#include <vp3defs.h>

#include <vpidefs.h>

 

void main()

{

      VP_VIEWPORT vp;

 

      grr_init ( GR_VGA16, GR_DARKGRAY );

      vp = vp3_isometric ( 0.0, 0.0, 0.0, 5.0, 4.0, 0.0, 0.0,

            1.0, 1.0, GR_RED, GR_BLACK );

      vpi_show ( vp );

      getch();

      vpi_free ( vp );

      grr_exit();

}

This program creates a viewport centered on (0,0,0) viewing along  the vector

(-1,-1,-1), and which has a width of 5 units, a height of  4 units, occupies

the entire screen, has a red border and a black  interior.

 

***>> vp3_pixel_to_point <<***

 

****** Summary ******

 

#include <qgldefs.h>

 

void vp3_pixel_to_point ( pxl, vp, pt );

 

****** Description ******

 

This function computes the 3D point corresponding to a pixel in a  viewport.

 

****** Input ******

 

------------------------------------------------------------------------------

| INT                    | pxl[2]             | pixel coordinates            |

------------------------------------------------------------------------------

| VP_VIEWPORT            | vp                 | viewport                     |

------------------------------------------------------------------------------

 

****** Output ******

 

------------------------------------------------------------------------------

| PT3                    | pt                 | the 3D point corresponding   |

|                        |                    | to the pixel                 |

------------------------------------------------------------------------------

 

****** Example ******

 

#include <vp3defs.h>

 

void get_point_on_pixel ( vp, p )

 

VP_VIEWPORT vp;

PT3 p;

{

      INT pixel[2];

      printf ( "enter pixel coordinates" );

      scanf ( "%d%d", pixel, pixel+1 );

      vp3_pixel_to_point ( pixel, vp, p );

}

This function converts a pixel into its corresponding 3D point in a

viewport.

 

***>> vp3_point_to_pixel <<***

 

****** Summary ******

 

#include <qgldefs.h>

 

void vp3_point_to_pixel ( pt, vp, pxl );

 

****** Description ******

 

This function computes the pixel corresponding to a 3D point in a  viewport.

 

****** Input ******

 

------------------------------------------------------------------------------

| PT3                    | pt                 | a 3D point                   |

------------------------------------------------------------------------------

| VP_VIEWPORT            | vp                 | a viewport                   |

------------------------------------------------------------------------------

 

****** Output ******

 

------------------------------------------------------------------------------

| INT                    | pxl[2]             | the pixel corresponding to   |

|                        |                    | the point                    |

------------------------------------------------------------------------------

 

****** Example ******

 

#include <vp3defs.h>

 

void get_point_on_pixel ( vp, pixel )

 

VP_VIEWPORT vp;

INT pixel[2];

{

      PT3 p;

 

      printf ( "enter a 3D point" );

      scanf ( "%lf%lf%lf", p, p+1, p+2 );

      vp3_point_to_pixel ( p, vp, pixel );

}

This function converts a 3D point in a viewport into its  corresponding

pixel.

 

***>> vp3_right <<***

 

****** Summary ******

 

#include <vp3defs.h>

 

VP_VIEWPORT vp3_right ( x, y, z, w, h, ulx, uly, lrx,  lry, bd_color,

bk_color );

 

****** Description ******

 

This function creates a viewport looking at the view center from the  right

(along the vector (-1,0,0)).

 

****** Input  ******

 

------------------------------------------------------------------------------

| REAL                   | x, y, z            | the coordinates of the view  |

|                        |                    | center                       |

------------------------------------------------------------------------------

| REAL                   | w, h               | the width and the height of  |

|                        |                    | the view channel             |

------------------------------------------------------------------------------

| REAL                   | ulx, uly, lrx, lry | the screen coordinates of    |

|                        |                    | the upper left and lower     |

|                        |                    | right corners  of the        |

|                        |                    | viewport screen box; (0,0)   |

|                        |                    | corresponds to the extreme   |

|                        |                    | upper  left of the screen,   |

|                        |                    | and (1,1) corresponds to the  |

|                        |                    | extreme lower right  of the  |

|                        |                    | screen                       |

------------------------------------------------------------------------------

| GR_COLOR               | bd_color, bk_color  | border and background colors  |

------------------------------------------------------------------------------

 

See grr_get_color for valid color options.

 

****** Return Value ******

 

The return value is a viewport.  If the viewport could not be created,  NULL

is returned.

 

 

****** Example ******

 

 

#include <grrdefs.h>

#include <vp3defs.h>

#include <vpidefs.h>

 

void main()

{

      VP_VIEWPORT vp;

 

      grr_init ( GR_VGA16, GR_DARKGRAY );

      vp = vp3_right ( 0.0, 0.0, 0.0, 5.0, 4.0, 0.0, 0.0,

            1.0, 1.0, GR_RED, GR_BLACK );

      vpi_show ( vp );

      getch();

      vpi_free ( vp );

      grr_exit();

}

This program creates a viewport centered on (0,0,0) viewing leftward  along

the x-axis, and which has a width of 5 units, a height of 4  units, occupies

the entire screen, has a red border and a black  interior.

 

***>> vp3_set_ctr <<***

 

****** Summary ******

 

#include <vp3defs.h>

 

void vp3_set_ctr ( vp, center );

 

****** Description ******

 

This function sets the view center of a viewport.  It does not change  the

view orientation.

 

****** Input  ******

 

------------------------------------------------------------------------------

| VP_VIEWPORT            | vp                 | a viewport                   |

------------------------------------------------------------------------------

| PT3                    | center             | the view center              |

------------------------------------------------------------------------------

 

****** Example ******

 

See vp3_get_ctr.

 

***>> vp3_set_view_dir <<***

 

****** Summary ******

 

#include <vp3defs.h>

 

void vp3_set_view_dir ( vp, theta, phi );

 

****** Description ******

 

This function sets the view direction of a viewport to specified  spherical

angles.

 

****** Input  ******

 

------------------------------------------------------------------------------

| VP_VIEWPORT            | vp                 | a viewport                   |

------------------------------------------------------------------------------

| REAL                   | theta              | the angle about the z-axis   |

|                        |                    | measured from the x-z plane;  |

|                        |                    | must  be expressed in        |

|                        |                    | radians                      |

------------------------------------------------------------------------------

| REAL                   | phi                | the angle from the z-axis;   |

|                        |                    | must be expressed in radians  |

|                        |                    |                              |

------------------------------------------------------------------------------

 

****** Example ******

 

See vp3_get_view_dir.

 

***>> vp3_top <<***

 

****** Summary ******

 

#include <vp3defs.h>

 

VP_VIEWPORT vp3_top ( x, y, z, w, h, ulx, uly, lrx,  lry, bd_color, bk_color

)

 

****** Description ******

 

This function creates a viewport looking at the view center from the  top

(along the vector (0,0,-1)).

 

****** Input  ******

 

------------------------------------------------------------------------------

| REAL                   | x, y, z            | the coordinates of the view  |

|                        |                    | center                       |

------------------------------------------------------------------------------

| REAL                   | w, h               | the width and the height of  |

|                        |                    | the view channel             |

------------------------------------------------------------------------------

| REAL                   | ulx, uly, lrx, lry | the screen coordinates of    |

|                        |                    | the upper left and lower     |

|                        |                    | right corners  of the        |

|                        |                    | viewport screen box; (0,0)   |

|                        |                    | corresponds to the extreme   |

|                        |                    | upper  left of the screen,   |

|                        |                    | and (1,1) corresponds to the  |

|                        |                    | extreme lower right  of the  |

|                        |                    | screen                       |

------------------------------------------------------------------------------

| GR_COLOR               | bd_color, bk_color  | border and background colors  |

------------------------------------------------------------------------------

 

See grr_get_color for valid color options.

 

****** Return Value ******

 

The return value is a viewport.  If the viewport could not be created,  NULL

is returned.

 

 

****** Example ******

 

 

#include <grrdefs.h>

#include <vp3defs.h>

#include <vpidefs.h>

 

void main()

{

      VP_VIEWPORT vp;

 

      grr_init ( GR_VGA16, GR_DARKGRAY );

      vp = vp3_top ( 0.0, 0.0, 0.0, 5.0, 4.0, 0.0, 0.0,

            1.0, 1.0, GR_RED, GR_BLACK );

      vpi_show ( vp );

      getch();

      vpi_free ( vp );

      grr_exit();

}

This program creates a viewport centered on (0,0,0) viewing downward  along

the z-axis, and which has a width of 5 units, a height of 4  units, occupies

the entire screen, has a red border and a black  interior.

 

***>> vpi_clip  <<***

 

****** Summary ******

 

#include <vpidefs.h>

 

void vpi_clip ( vp );

 

****** Description ******

 

This function sets clipping on in a viewport.  Clipping restricts  drawing

output to the area inside the viewport border, and must be  "unset" with

vpi_unclip to allow drawing in other viewports.

 

****** Input ******

 

------------------------------------------------------------------------------

| VP_VIEWPORT            | vp                 | a viewport                   |

------------------------------------------------------------------------------

 

****** Example ******

 

#include <grrdefs.h>

#include <vp2defs.h>

#include <vpidefs.h>

#include <v2ddefs.h>

void draw_curve ( curve )

C2_CURVE curve;

{

      VP_VIEWPORT vp;

      grr_init ( GR_VGA16, GR_DARKGRAY );

      vp = vp2_create ( 0.0, 0.0, 5.0, 4.0, 0.0, 0.0,

            1.0, 1.0, GR_RED, GR_BLACK );

      vpi_show ( vp );

      grr_set_color ( GR_CYAN );

      grr_set_patt ( GR_SOLID_PATT );

      vpi_clip ( vp );

      v2d_curve ( curve, NULL, NULL, vp );

      vpi_unclip ( vp );

      getch();

      vpi_free ( vp );

      grr_exit();

}

This program draws a curve in a viewport.  If vpi_clip is not  called before

drawing the curve, some parts of the curve may be drawn  outside the

viewport.  The vpi_unclip disables clipping to allow  drawing in areas of the

screen other than in the viewport.

 

***>> vpi_fill  <<***

 

****** Summary ******

 

#include <vpidefs.h>

 

void vpi_fill ( vp );

 

****** Description ******

 

This function clears the drawing area of a viewport with its background

color.

 

****** Input ******

 

------------------------------------------------------------------------------

| VP_VIEWPORT            | vp                 | a viewport                   |

------------------------------------------------------------------------------

 

****** Example ******

 

 

#include <grrdefs.h>

#include <vp2defs.h>

#include <vpidefs.h>

 

void main()

{

      VP_VIEWPORT vp;

 

      grr_init ( GR_VGA16, GR_DARKGRAY );

      vp = vp2_create ( 0.0, 0.0, 5.0, 4.0, 0.0, 0.0,

            1.0, 1.0,  GR_RED, GR_BLACK );

      vpi_show ( vp );

      getch();

      vpi_set_bk_color ( vp, GR_BLUE );

      vpi_fill ( vp );

      getch();

      vpi_free ( vp );

      grr_exit();

}

This program creates a viewport with a black interior, and then changes  the

interior to blue.

 

***>> vpi_free  <<***

 

****** Summary ******

 

#include <vpidefs.h>

 

void vpi_free ( vp );

 

****** Description ******

 

This function frees a viewport.

 

****** Input ******

 

------------------------------------------------------------------------------

| VP_VIEWPORT            | vp                 | a viewport                   |

------------------------------------------------------------------------------

 

****** Example ******

 

See vp2_create.

 

***>> vpi_get_screen_box  <<***

 

****** Summary ******

 

#include <vpidefs.h>

 

void vpi_get_screen_box ( vp, p0, p1 );

 

****** Description ******

 

This function obtains the upper left and lower right corner points  of a

viewport screen box.

 

****** Input ******

 

------------------------------------------------------------------------------

| VP_VIEWPORT            | vp                 | a viewport                   |

------------------------------------------------------------------------------

 

****** Output ******

 

------------------------------------------------------------------------------

| PT2                    | p0, p1             | upper left and lower right   |

|                        |                    | corner points of the         |

|                        |                    | viewport screen  box; points  |

|                        |                    | are in the rectangle (0,0)   |

|                        |                    | and (1,1), which correspond   |

|                        |                    | to the extreme upper left    |

|                        |                    | and the extreme lower right  |

|                        |                    | corners of the  screen       |

------------------------------------------------------------------------------

 

****** Example ******

 

#include <grrdefs.h>

#include <vp2defs.h>

#include <vpidefs.h>

void main()

{

      VP_VIEWPORT vp;

      PT2 ul, lr;

      grr_init ( GR_VGA16, GR_DARKGRAY );

      vp = vp2_create ( 0.0, 0.0, 5.0, 4.0, 0.0, 0.0,

            0.5, 0.5,  GR_RED, GR_BLACK );

      vpi_show ( vp );

      vpi_unshow ( vp, GR_DARKGRAY );

      vpi_get_screen_box ( vp, ul, lr );

      PT2_X(lr) += 0.1;

      PT2_Y(lr) += 0.1;

      vpi_set_screen_box ( vp, ul, lr );

      vpi_show ( vp );

      vpi_free ( vp );

      grr_exit();

}

This program creates a viewport, displays it, and stretches it  downward.

 

***>> vpi_get_transform <<***

 

****** Summary ******

 

#include <vpidefs.h>

 

void vpi_get_transform ( vp, t );

 

****** Description ******

 

This function reads the view transform of a viewport.

 

****** Input ******

 

------------------------------------------------------------------------------

| VP_VIEWPORT            | vp                 | a viewport                   |

------------------------------------------------------------------------------

 

****** Output ******

 

------------------------------------------------------------------------------

| VP_TRANSFORM           | t                  | viewport transform           |

------------------------------------------------------------------------------

 

****** Example ******

 

See vp3_append_transform.

 

***>> vpi_get_wh  <<***

 

****** Summary ******

 

#include <vpidefs.h>

 

void vpi_get_wh ( vp, w, h );

 

****** Description ******

 

This function reads the view channel width and height of a viewport.

 

****** Input ******

 

------------------------------------------------------------------------------

| VP_VIEWPORT            | vp                 | a viewport                   |

------------------------------------------------------------------------------

 

****** Output ******

 

------------------------------------------------------------------------------

| REAL *                 | w, h               | the width and height of the  |

|                        |                    | view channel; passed by      |

|                        |                    | reference                    |

------------------------------------------------------------------------------

 

****** Example ******

 

 

#include <grrdefs.h>

#include <vp2defs.h>

#include <vpidefs.h>

#include <v2ddefs.h>

 

void draw_curve ( curve )

 

C2_CURVE curve;

{

      VP_VIEWPORT vp;

      REAL w, h;

 

      grr_init ( GR_VGA16, GR_DARKGRAY );

      vp = vp2_create ( 0.0, 0.0, 5.0, 4.0, 0.0, 0.0,

            1.0, 1.0, GR_RED, GR_BLACK );

      vp2_fit ( vp, C2_CURVE_BOX(curve), 1.05 );

      vpi_get_wh ( vp, &w, &h );

      w += 1.0;

      h += 1.0;

      vpi_set_wh ( vp, w, h );

      vpi_show ( vp );

      grr_set_color ( GR_CYAN );

      grr_set_patt ( GR_SOLID_PATT );

      vpi_clip ( vp );

      v2d_curve ( curve, NULL, NULL, vp );

      vpi_unclip ( vp );

      getch();

      vpi_free ( vp );

      grr_exit();

}

This routine fits a viewport to a curve, and then expands the width  and the

height of the view box by one unit before drawing the curve.

 

***>> vpi_pt_inside <<***

 

****** Summary ******

 

#include <vpidefs.h>

 

BOOLEAN vpi_pt_inside ( vp, p );

 

****** Description ******

 

This function determines if a pixel is inside a viewport.  The pixel  is

expressed in "normalized screen coordinates", where (0,0) is the  upper left

corner of the screen, and (1,1) is the lower right corner  of the screen.

 

****** Input ******

 

------------------------------------------------------------------------------

| VP_VIEWPORT            | vp                 | a viewport                   |

------------------------------------------------------------------------------

| PT2                    | p                  | a pixel in normalized screen  |

|                        |                    | coordinates                  |

------------------------------------------------------------------------------

 

****** Example ******

 

#include <grrdefs.h>

#include <vpidefs.h>

void test_pixel ( vp, pixel )

VP_VIEWPORT vp;

INT pixel[2];

{

      PT2 screen_point;

      grr_pixel_to_point ( pixel, screen_point );

      if ( vpi_pt_inside ( vp, screen_point ) )

            printf ( "pixel is inside viewport\n" );

      else

            printf ( "pixel is outside viewport\n" );

}

This function determines if a pixel is in a viewport.

 

***>> vpi_set_bd_color  <<***

 

****** Summary ******

 

#include <vpidefs.h>

 

void vpi_set_bd_color ( vp, bd_color );

 

****** Description ******

 

This function sets the border color of a viewport. 

 

****** Input ******

 

------------------------------------------------------------------------------

| VP_VIEWPORT            | vp                 | a viewport                   |

------------------------------------------------------------------------------

| GR_COLOR               | bd_color           | border color                 |

------------------------------------------------------------------------------

 

Valid color options are: GR_BLACK, GR_BLUE, GR_GREEN, GR_CYAN, GR_RED,

GR_MAGENTA, GR_BROWN, GR_LIGHTGRAY, GR_DARKGRAY, GR_LIGHTBLUE, GR_LIGHTGREEN,

 GR_LIGHTCYAN, GR_LIGHTRED, GR_LIGHTMAGENTA, GR_LIGHTYELLOW, GR_WHITE

 

****** Example ******

 

#include <grrdefs.h>

#include <vp2defs.h>

#include <vpidefs.h>

void main()

{

      VP_VIEWPORT vp;

      grr_init ( GR_VGA16, GR_DARKGRAY );

      vp = vp2_create ( 0.0, 0.0, 5.0, 4.0, 0.0, 0.0,

            1.0, 1.0, GR_RED, GR_BLACK );

      vpi_show ( vp );

      getch();

      vpi_unshow ( vp, GR_DARKGRAY );

      vpi_set_bd_color ( vp, GR_BLUE );

      vpi_set_bk_color ( vp, GR_CYAN );

      vpi_show ( vp );

      getch();

      vpi_free ( vp );

      grr_exit();

}

This program initializes graphics mode, creates a viewport, shows  the

viewport, changes its border and background colors, shows it again,  and

exits graphics mode.

 

***>> vpi_set_bk_color  <<***

 

****** Summary ******

 

#include <vpidefs.h>

 

void vpi_set_bk_color ( vp, bk_color );

 

****** Description ******

 

This function sets the background color of a viewport.  The background  color

is used to clear or refresh a viewport.

 

****** Input ******

 

------------------------------------------------------------------------------

| VP_VIEWPORT            | vp                 | a viewport                   |

------------------------------------------------------------------------------

| GR_COLOR               | bk_color           | background color             |

------------------------------------------------------------------------------

 

Valid color options are: GR_BLACK, GR_BLUE, GR_GREEN, GR_CYAN, GR_RED,

GR_MAGENTA, GR_BROWN, GR_LIGHTGRAY, GR_DARKGRAY, GR_LIGHTBLUE, GR_LIGHTGREEN,

 GR_LIGHTCYAN, GR_LIGHTRED, GR_LIGHTMAGENTA, GR_LIGHTYELLOW, GR_WHITE

 

****** Example ******

 

See vpi_set_bd_color.

 

***>> vpi_set_screen_box  <<***

 

****** Summary ******

 

#include <vpidefs.h>

 

void vpi_set_screen_box ( vp, p0, p1 );

 

****** Description ******

 

This function sets the corners of a viewport screen box to the specified

points. 

 

To stretch a viewport, or to move a viewport on the screen, read the  current

screen box settings of the viewport with vpi_get_screen_box,  then adjust one

or both corners, and finally reset the viewport screen  box with the new

points.

 

****** Input ******

 

------------------------------------------------------------------------------

| VP_VIEWPORT            | vp                 | a viewport                   |

------------------------------------------------------------------------------

| PT2                    | p0, p1             | the desired upper left and   |

|                        |                    | lower right corners of the   |

|                        |                    | viewport  screen box         |

------------------------------------------------------------------------------

 

****** Example ******

 

See vpi_get_screen_box.

 

***>> vpi_set_transform <<***

 

****** Summary ******

 

#include <vpidefs.h>

 

void vpi_set_transform ( vp, t );

 

****** Description ******

 

This function sets the view transform of a viewport.  Viewport  transforms

may be obtained from a viewport using  vpi_get_transform.

 

****** Input ******

 

------------------------------------------------------------------------------

| VP_VIEWPORT            | vp                 | a viewport                   |

------------------------------------------------------------------------------

| VP_TRANSFORM           | t                  | viewport transform           |

------------------------------------------------------------------------------

 

****** Example ******

 

See vp3_append_transform.

 

***>> vpi_set_wh  <<***

 

****** Summary ******

 

#include <vpidefs.h>

 

void vpi_set_wh ( vp, w, h );

 

****** Description ******

 

This function sets the view channel width and height of a viewport.

 

****** Input ******

 

------------------------------------------------------------------------------

| VP_VIEWPORT            | vp                 | a viewport                   |

------------------------------------------------------------------------------

| REAL                   | w, h               | view channel width and       |

|                        |                    | height; these values may be  |

|                        |                    | adjusted  to make the aspect  |

|                        |                    | ratio of the view channel    |

|                        |                    | the same as that of the      |

|                        |                    | screen box                   |

------------------------------------------------------------------------------

 

****** Example ******

 

See vpi_get_wh.

 

***>> vpi_show  <<***

 

****** Summary ******

 

#include <vpidefs.h>

 

void vpi_show ( vp );

 

****** Description ******

 

This function displays a viewport.

 

****** Input ******

 

------------------------------------------------------------------------------

| VP_VIEWPORT            | vp                 | a viewport                   |

------------------------------------------------------------------------------

 

****** Example ******

 

#include <grrdefs.h>

#include <vp2defs.h>

#include <vpidefs.h>

 

void main()

{

      VP_VIEWPORT vp;

 

      grr_init ( GR_VGA16, GR_DARKGRAY );

      vp = vp2_create ( 0.0, 0.0, 5.0, 4.0, 0.0, 0.0,

            1.0, 1.0, GR_RED, GR_BLACK );

      vpi_show ( vp );

      getch();

      vpi_unshow ( vp, GR_DARKGRAY );

      getch();

      vpi_free ( vp );

      grr_exit();

}

This program initializes graphics mode, creates a viewport, shows  the

viewport, unshows the viewport, and exits graphics mode.

 

***>> vpi_unclip  <<***

 

****** Summary ******

 

#include <vpidefs.h>

 

void vpi_unclip ( vp  );

 

****** Description ******

 

This function "unsets" clipping in a viewport.  Clipping is enabled  by

vpi_clip.

 

****** Input ******

 

------------------------------------------------------------------------------

| VP_VIEWPORT            | vp                 | a viewport                   |

------------------------------------------------------------------------------

 

****** Example ******

 

See vpi_clip.

 

***>> vpi_unshow  <<***

 

****** Summary ******

 

#include <vpidefs.h>

 

void vpi_unshow ( vp, scr_color );

 

****** Description ******

 

This function removes a viewport from the screen, filling the rectangle

occupied by the viewport with the specified screen color.

 

****** Input ******

 

------------------------------------------------------------------------------

| VP_VIEWPORT            | vp                 | a viewport                   |

------------------------------------------------------------------------------

| GR_COLOR               | scr_color          | fill color                   |

------------------------------------------------------------------------------

 

Valid color options are: GR_BLACK, GR_BLUE, GR_GREEN, GR_CYAN, GR_RED,

GR_MAGENTA, GR_BROWN, GR_LIGHTGRAY, GR_DARKGRAY, GR_LIGHTBLUE, GR_LIGHTGREEN,

 GR_LIGHTCYAN, GR_LIGHTRED, GR_LIGHTMAGENTA, GR_LIGHTYELLOW, GR_WHITE

 

****** Output ******

 

****** Return Value ******

 

****** Example ******

 

See vpi_show.

 

***>> w2d_curve  <<***

 

****** Summary ******

 

#include <w2ddefs.h>

 

void w2d_curve ( curve, parm0, parm1 );

 

****** Description ******

 

This function draws a 2D curve, optionally trimmed to a curve  parameter

interval, with the current color and current line pattern  in the current

viewport or viewports.

 

****** Input ******

 

------------------------------------------------------------------------------

| C2_CURVE               | curve              | a curve                      |

------------------------------------------------------------------------------

| PARM                   | parm0, parm1       | the curve parameters where   |

|                        |                    | drawing should begin and     |

|                        |                    | end; if  parm0 is NULL,      |

|                        |                    | drawing begins at the start  |

|                        |                    | point of the curve; if       |

|                        |                    | parm1 is NULL, drawing ends  |

|                        |                    | at the end point of the      |

|                        |                    | curve                        |

------------------------------------------------------------------------------

 

****** Example ******

 

#include <wmidefs.h>

#include <wm2defs.h>

#include <grrdefs.h>

#include <w2ddefs.h>

 

void draw_curve ( curve )

 

C2_CURVE curve;

{

      wmi_init ( GR_DARKGRAY );

      wm2_create ( 0.0, 0.0, 5.0, 4.0, 0.0, 0.0,

            1.0, 1.0, GR_RED, GR_BLACK );

      wmi_show();

      grr_set_color ( GR_CYAN );

      w2d_curve ( curve, NULL, NULL );

      getch();

      wmi_exit();

}

This program draws a curve in a viewport, using cyan as the drawing  color.

 

***>> w2d_lineto  <<***

 

****** Summary ******

 

#include <w2ddefs.h>

 

void w2d_lineto ( pt );

 

****** Description ******

 

This function draws a line from the current drawing position to the

specified 2D point, using the current drawing color and line pattern.

 

The current drawing position is moved to the specified point.

 

****** Input ******

 

------------------------------------------------------------------------------

| PT2                    | pt                 | the point to draw to         |

------------------------------------------------------------------------------

 

****** Example ******

 

 

#include <wmidefs.h>

#include <wm2defs.h>

#include <grrdefs.h>

#include <w2ddefs.h>

 

void draw_between_pts ( p0, p1 )

 

PT2 p0, p1;

{

      wmi_init ( GR_DARKGRAY );

      wm2_create ( 0.0, 0.0, 5.0, 4.0, 0.0, 0.0,

            1.0, 1.0, GR_RED, GR_BLACK );

      wmi_show();

      grr_set_color ( GR_CYAN );

      w2d_moveto ( p0 );

      w2d_lineto ( p1 );

      getch();

      wmi_exit();

}

This program draws a line between two points.

 

***>> w2d_moveto  <<***

 

****** Summary ******

 

#include <w2ddefs.h>

 

void w2d_moveto ( pt );

 

****** Description ******

 

This function moves the current drawing location to the specified  2D point.

 

****** Input ******

 

------------------------------------------------------------------------------

| PT2                    | pt                 | the point to move to         |

------------------------------------------------------------------------------

 

****** Example ******

 

See w2d_lineto.

 

***>> w2d_point  <<***

 

****** Summary ******

 

#include <w2ddefs.h>

 

void w2d_point ( pt, size );

 

****** Description ******

 

This function draws crosshairs of a specified size centered on a  given 2D

point using the current color and line pattern in the  current viewport or

viewports.  The size is expressed as a fraction  of the screen width.

 

****** Input ******

 

------------------------------------------------------------------------------

| PT2                    | pt                 | the point at which to draw   |

|                        |                    | the crosshairs               |

------------------------------------------------------------------------------

| REAL                   | size               | the width and height of the  |

|                        |                    | crosshairs as a fraction of  |

|                        |                    | the  screen width            |

------------------------------------------------------------------------------

 

****** Example ******

 

#include <wmidefs.h>

#include <wm2defs.h>

#include <grrdefs.h>

#include <w2ddefs.h>

 

void draw_pts ( p0, p1 )

 

PT2 p0, p1;

{

      wmi_init ( GR_DARKGRAY );

      wm2_create ( 0.0, 0.0, 5.0, 4.0, 0.0, 0.0,

            1.0, 1.0, GR_RED, GR_BLACK );

      wmi_show();

      grr_set_color ( GR_CYAN );

      w2d_point ( p0, 1.0 / 2.0 );

      w2d_point ( p1, 1.0 / 2.0 );

      getch();

      wmi_exit();

}

This program draws two cyan points.

 

***>> w3d_curve  <<***

 

****** Summary ******

 

#include <w3ddefs.h>

 

void w3d_curve ( curve, parm0, parm1 );

 

****** Description ******

 

This function draws a 3D curve, optionally trimmed to a parameter  interval,

in the current viewport or viewports.

 

****** Input ******

 

------------------------------------------------------------------------------

| C3_CURVE               | curve              | a curve                      |

------------------------------------------------------------------------------

| PARM                   | parm0, parm1       | curve parameters that define  |

|                        |                    | the curve interval to draw;  |

|                        |                    | if  parm0 is NULL, the       |

|                        |                    | interval begins at the curve  |

|                        |                    | start point;  if parm1 is    |

|                        |                    | NULL, the interval ends at   |

|                        |                    | the curve end point          |

------------------------------------------------------------------------------

 

****** Example ******

 

#include <wmidefs.h>

#include <wm3defs.h>

#include <grrdefs.h>

#include <w3ddefs.h>

 

void draw_curve ( curve )

 

C3_CURVE curve;

{

      wmi_init ( GR_DARKGRAY );

      wm3_isometric ( 0.0, 0.0, 0.0, 5.0, 4.0, 0.0, 0.0,

            1.0, 1.0, GR_RED, GR_BLACK );

      wmi_show();

      grr_set_color ( GR_CYAN );

      w3d_curve ( curve, NULL, NULL );

      getch();

      wmi_exit();

}

This program draws a curve in a viewport, using cyan as the drawing  color.

 

***>> w3d_lineto  <<***

 

****** Summary ******

 

#include <w3ddefs.h>

 

void w3d_lineto ( pt );

 

****** Description ******

 

This function draws a line in the current viewport from the current  pen

position to a specified 3D point.  The drawing color and pattern  are set

with grr_set_color and grr_set_patt.

 

****** Input ******

 

------------------------------------------------------------------------------

| PT3                    | pt                 | the point to draw to         |

------------------------------------------------------------------------------

 

****** Example ******

 

 

#include <wmidefs.h>

#include <wm3defs.h>

#include <grrdefs.h>

#include <w3ddefs.h>

 

void draw_between_pts ( p0, p1 )

 

PT3 p0, p1;

{

      wmi_init ( GR_DARKGRAY );

      wm3_isometric ( 0.0, 0.0, 0.0, 5.0, 4.0, 0.0, 0.0,

            1.0, 1.0, GR_RED, GR_BLACK );

      wmi_show();

      grr_set_color ( GR_CYAN );

      w3d_moveto ( p0 );

      w3d_lineto ( p1 );

      getch();

      wmi_exit();

}

This program draws a line between two points.

 

***>> w3d_moveto  <<***

 

****** Summary ******

 

#include <w3ddefs.h>

 

void w3d_moveto ( pt );

 

****** Description ******

 

This function moves the current pen position to a specified 3D point.

 

****** Input ******

 

------------------------------------------------------------------------------

| PT3                    | pt                 | the point which should be    |

|                        |                    | the current pen position     |

------------------------------------------------------------------------------

 

****** Example ******

 

See w3d_lineto.

 

***>> w3d_point  <<***

 

****** Summary ******

 

#include <w3ddefs.h>

 

void w3d_point ( pt, size );

 

****** Description ******

 

This function draws crosshairs in the current viewport or viewports  at a

specified 3D point.  The size of the crosshairs is specified as  a fraction

of the screen width.

 

****** Input ******

 

------------------------------------------------------------------------------

| PT3                    | pt                 | a 3D point                   |

------------------------------------------------------------------------------

| REAL                   | size               | the size of the crosshairs,  |

|                        |                    | as a fraction of the screen  |

|                        |                    | width                        |

------------------------------------------------------------------------------

 

****** Example ******

 

#include <wmidefs.h>

#include <wm2defs.h>

#include <grrdefs.h>

#include <w3ddefs.h>

 

void draw_pts ( p0, p1 )

 

PT3 p0, p1;

{

      wmi_init ( GR_DARKGRAY );

      wm2_create ( 0.0, 0.0, 5.0, 4.0, 0.0, 0.0,

            1.0, 1.0, GR_RED, GR_BLACK );

      wmi_show();

      grr_set_color ( GR_CYAN );

      w3d_point ( p0, 0.05 );

      w3d_point ( p1, 0.05 );

      getch();

      wmi_exit();

}

This program draws two cyan points.

 

***>> wm2_create  <<***

 

****** Summary ******

 

#include <wm2defs.h>

 

VP_VIEWPORT wm2_create ( x, y, w, h, ulx, uly, lrx,  lry, bd_color, bk_color

);

 

****** Description ******

 

This window creates a viewport centered on a given point, with a  given width

and height, screen location, and border and background  colors.  The viewport

is added to the window manager viewport list.

 

****** Input ******

 

------------------------------------------------------------------------------

| REAL                   | x, y               | the x and y coordinates of   |

|                        |                    | the center point of the view  |

------------------------------------------------------------------------------

| REAL                   | w, h               | the width and height of the  |

|                        |                    | view                         |

------------------------------------------------------------------------------

| REAL                   | ulx, uly, lrx, lry | the coordinates of the upper  |

|                        |                    | left and lower right corners  |

|                        |                    | of  the viewport screen box;  |

|                        |                    | (0.0, 0.0) corresponds to    |

|                        |                    | the upper left  corner of    |

|                        |                    | the screen, and (1.0, 1.0)   |

|                        |                    | corresponds to the lower     |

|                        |                    | right  corner of the screen   |

------------------------------------------------------------------------------

| GR_COLOR               | bd_color           | viewport border color        |

------------------------------------------------------------------------------

| GR_COLOR               | bk_color           | viewport background color    |

------------------------------------------------------------------------------

 

Color constants include: GR_BLACK, GR_BLUE, GR_GREEN, GR_CYAN,  GR_RED,

GR_MAGENTA, GR_BROWN, GR_LIGHTGRAY, GR_DARKGRAY,  GR_LIGHTBLUE,

GR_LIGHTGREEN, GR_LIGHTCYAN, GR_LIGHTRED,  GR_LIGHTMAGENTA, GR_LIGHTYELLOW,

GR_WHITE

 

****** Return Value ******

 

The return value is a pointer to a viewport.  If a viewport could  not be

created, NULL is returned.

 

 

****** Example ******

 

 

#include <wmidefs.h>

#include <wm2defs.h>

 

void main()

{

      wmi_init ( GR_DARKGRAY );

      wm2_create ( 0.0, 0.0, 5.0, 4.0, 0.0, 0.0,

            1.0, 1.0, GR_RED, GR_BLACK );

      wmi_show();

      getch();

      wmi_exit();

}

This program initializes the window manager, creates a viewport,  shows the

viewport, and exits the window manager.

 

***>> wm3_front  <<***

 

****** Summary ******

 

#include <wm3defs.h>

 

VP_VIEWPORT wm3_front ( x, y, z, w, h, ulx, uly, lrx,  lry, bd_color,

bk_color );

 

****** Description ******

 

This function creates a viewport looking at the view center from the  front

(along the vector (0,1,0)).

 

****** Input  ******

 

------------------------------------------------------------------------------

| REAL                   | x, y, z            | the coordinates of the view  |

|                        |                    | center                       |

------------------------------------------------------------------------------

| REAL                   | w, h               | the width and the height of  |

|                        |                    | the view channel             |

------------------------------------------------------------------------------

| REAL                   | ulx, uly, lrx, lry | the screen coordinates of    |

|                        |                    | the upper left and lower     |

|                        |                    | right corners  of the        |

|                        |                    | viewport screen box; (0,0)   |

|                        |                    | corresponds to the extreme   |

|                        |                    | upper  left of the screen,   |

|                        |                    | and (1,1) corresponds to the  |

|                        |                    | extreme lower right  of the  |

|                        |                    | screen                       |

------------------------------------------------------------------------------

| GR_COLOR               | bd_color, bk_color  | border and background colors  |

------------------------------------------------------------------------------

 

Color options include: GR_BLACK, GR_BLUE, GR_GREEN, GR_CYAN, GR_RED,

GR_MAGENTA, GR_BROWN, GR_LIGHTGRAY, GR_DARKGRAY, GR_LIGHTBLUE, GR_LIGHTGREEN,

 GR_LIGHTCYAN, GR_LIGHTRED, GR_LIGHTMAGENTA, GR_LIGHTYELLOW, GR_WHITE

 

****** Return Value ******

 

The return value is a viewport.  If the viewport could not be created,  NULL

is returned.

 

****** Example ******

 

 

#include <wmidefs.h>

#include <wm3defs.h>

 

void main()

{

      wmi_init ( GR_DARKGRAY );

      wm3_front ( 0.0, 0.0, 0.0, 5.0, 4.0, 0.0, 0.0,

            1.0, 1.0, GR_RED, GR_BLACK );

      wmi_show();

      getch();

      wmi_exit();

}

This program initializes the window manager, creates a viewport  aligned with

the y-axis, shows the viewport, and exits the window  manager.

 

***>> wm3_isometric  <<***

 

****** Summary ******

 

#include <wm3defs.h>

 

VP_VIEWPORT wm3_isometric ( x, y, z, w, h, ulx, uly,  lrx, lry, bd_color,

bk_color );

 

****** Description ******

 

This function creates a viewport looking at the view center from the

isometric position (along the vector (-1,1,-1)).

 

****** Input  ******

 

------------------------------------------------------------------------------

| REAL                   | x, y, z            | the coordinates of the view  |

|                        |                    | center                       |

------------------------------------------------------------------------------

| REAL                   | w, h               | the width and the height of  |

|                        |                    | the view channel             |

------------------------------------------------------------------------------

| REAL                   | ulx, uly, lrx, lry | the screen coordinates of    |

|                        |                    | the upper left and lower     |

|                        |                    | right corners  of the        |

|                        |                    | viewport screen box; (0,0)   |

|                        |                    | corresponds to the extreme   |

|                        |                    | upper  left of the screen,   |

|                        |                    | and (1,1) corresponds to the  |

|                        |                    | extreme lower right  of the  |

|                        |                    | screen                       |

------------------------------------------------------------------------------

| GR_COLOR               | bd_color, bk_color  | border and background colors  |

------------------------------------------------------------------------------

 

Color options include: GR_BLACK, GR_BLUE, GR_GREEN, GR_CYAN, GR_RED,

GR_MAGENTA, GR_BROWN, GR_LIGHTGRAY, GR_DARKGRAY, GR_LIGHTBLUE, GR_LIGHTGREEN,

 GR_LIGHTCYAN, GR_LIGHTRED, GR_LIGHTMAGENTA, GR_LIGHTYELLOW, GR_WHITE

 

****** Return Value ******

 

The return value is a viewport.  If the viewport could not be created,  NULL

is returned.

 

****** Example ******

 

 

#include <wmidefs.h>

#include <wm3defs.h>

 

void main()

{

      wmi_init ( GR_DARKGRAY );

      wm3_isometric ( 0.0, 0.0, 0.0, 5.0, 4.0, 0.0, 0.0,

            1.0, 1.0, GR_RED, GR_BLACK );

      wmi_show();

      getch();

      wmi_exit();

}

This program initializes the window manager, creates a viewport  aligned with

the y-axis, shows the viewport, and exits the window  manager.

 

***>> wm3_right  <<***

 

****** Summary ******

 

#include <wm3defs.h>

 

VP_VIEWPORT wm3_right ( x, y, z, w, h, ulx, uly, lrx,  lry, bd_color,

bk_color );

 

****** Description ******

 

This function creates a viewport looking at the view center from the  right

(along the vector (-1,0,0)).

 

****** Input  ******

 

------------------------------------------------------------------------------

| REAL                   | x, y, z            | the coordinates of the view  |

|                        |                    | center                       |

------------------------------------------------------------------------------

| REAL                   | w, h               | the width and the height of  |

|                        |                    | the view channel             |

------------------------------------------------------------------------------

| REAL                   | ulx, uly, lrx, lry | the screen coordinates of    |

|                        |                    | the upper left and lower     |

|                        |                    | right corners  of the        |

|                        |                    | viewport screen box; (0,0)   |

|                        |                    | corresponds to the extreme   |

|                        |                    | upper  left of the screen,   |

|                        |                    | and (1,1) corresponds to the  |

|                        |                    | extreme lower right  of the  |

|                        |                    | screen                       |

------------------------------------------------------------------------------

| GR_COLOR               | bd_color, bk_color  | border and background colors  |

------------------------------------------------------------------------------

 

Color options include: GR_BLACK, GR_BLUE, GR_GREEN, GR_CYAN, GR_RED,

GR_MAGENTA, GR_BROWN, GR_LIGHTGRAY, GR_DARKGRAY, GR_LIGHTBLUE, GR_LIGHTGREEN,

 GR_LIGHTCYAN, GR_LIGHTRED, GR_LIGHTMAGENTA, GR_LIGHTYELLOW, GR_WHITE

 

****** Return Value ******

 

The return value is a viewport.  If the viewport could not be created,  NULL

is returned.

 

****** Example ******

 

 

#include <wmidefs.h>

#include <wm3defs.h>

 

void main()

{

      wmi_init ( GR_DARKGRAY );

      wm3_right ( 0.0, 0.0, 0.0, 5.0, 4.0, 0.0, 0.0,

            1.0, 1.0, GR_RED, GR_BLACK );

      wmi_show();

      getch();

      wmi_exit();

}

This program initializes the window manager, creates a viewport  aligned with

the y-axis, shows the viewport, and exits the window  manager.

 

***>> wm3_top  <<***

 

****** Summary ******

 

#include <wm3defs.h>

 

VP_VIEWPORT wm3_top ( x, y, z, w, h, ulx, uly, lrx,  lry, bd_color, bk_color

);

 

****** Description ******

 

This function creates a viewport looking at the view center from the  top

(along the vector (0,0,-1)).

 

****** Input  ******

 

------------------------------------------------------------------------------

| REAL                   | x, y, z            | the coordinates of the view  |

|                        |                    | center                       |

------------------------------------------------------------------------------

| REAL                   | w, h               | the width and the height of  |

|                        |                    | the view channel             |

------------------------------------------------------------------------------

| REAL                   | ulx, uly, lrx, lry | the screen coordinates of    |

|                        |                    | the upper left and lower     |

|                        |                    | right corners  of the        |

|                        |                    | viewport screen box; (0,0)   |

|                        |                    | corresponds to the extreme   |

|                        |                    | upper  left of the screen,   |

|                        |                    | and (1,1) corresponds to the  |

|                        |                    | extreme lower right  of the  |

|                        |                    | screen                       |

------------------------------------------------------------------------------

| GR_COLOR               | bd_color, bk_color  | border and background colors  |

------------------------------------------------------------------------------

 

Color options include: GR_BLACK, GR_BLUE, GR_GREEN, GR_CYAN, GR_RED,

GR_MAGENTA, GR_BROWN, GR_LIGHTGRAY, GR_DARKGRAY, GR_LIGHTBLUE, GR_LIGHTGREEN,

 GR_LIGHTCYAN, GR_LIGHTRED, GR_LIGHTMAGENTA, GR_LIGHTYELLOW, GR_WHITE

 

****** Return Value ******

 

The return value is a viewport.  If the viewport could not be created,  NULL

is returned.

 

****** Example ******

 

 

#include <wmidefs.h>

#include <wm3defs.h>

 

void main()

{

      wmi_init ( GR_DARKGRAY );

      wm3_top ( 0.0, 0.0, 0.0, 5.0, 4.0, 0.0, 0.0,

            1.0, 1.0, GR_RED, GR_BLACK );

      wmi_show();

      getch();

      wmi_exit();

}

This program initializes the window manager, creates a viewport  aligned with

the y-axis, shows the viewport, and exits the window  manager.

 

***>> wmi_close  <<***

 

****** Summary ******

 

#include <wmidefs.h>

 

BOOLEAN wmi_close ( viewport );

 

****** Description ******

 

This function removes a specified view from the window manager viewport

list.

 

****** Input ******

 

------------------------------------------------------------------------------

| VP_VIEWPORT            | viewport           | the viewport to remove       |

------------------------------------------------------------------------------

 

****** Return Value ******

 

The return value is TRUE if the viewport was successfully removed.  Otherwise

it is FALSE.

 

****** Example ******

 

 

#include <wmidefs.h>

#include <wm2defs.h>

 

void main()

{

      VP_VIEWPORT vp;

      wmi_init ( GR_DARKGRAY );

      vp = wm2_create ( 0.0, 0.0, 5.0, 4.0, 0.0, 0.0,

            1.0, 1.0, GR_RED, GR_BLACK );

      wmi_show();

      getch();

      wmi_unshow();

      wmi_close ( vp );

      wm2_create ( 5.0, 5.0, 10.0, 7.0, 0.0, 0.0,

            1.0, 1.0, GR_BLUE, GR_BLACK );

      wmi_show();

      getch();

      wmi_exit();

}

This program initializes the window manager, creates a viewport, and  shows

the viewport.  Then it deletes the viewport, creates another  viewport, shows

that viewport, and exits the window manager.

 

***>> wmi_exit  <<***

 

****** Summary ******

 

#include <wmidefs.h>

 

void wmi_exit ();

 

****** Description ******

 

This routines exits the window manager environment, and restores text  mode.

 

****** Example ******

 

See wmi_init.

 

***>> wmi_fill  <<***

 

****** Summary ******

 

#include <wmidefs.h>

 

void wmi_fill ( );

 

****** Description ******

 

This function fills each current viewport with its background color.

 

****** Example ******

 

 

#include <wmidefs.h>

#include <wm2defs.h>

 

void main()

{

      wmi_init ( GR_DARKGRAY );

      wm2_create ( 0.0, 0.0, 5.0, 4.0, 0.0, 0.0,

            1.0, 1.0, GR_RED, GR_BLACK );

      wmi_show();

      /* add "w2d" drawing calls here */

      wmi_fill();

      getch();

      wmi_exit();

}

This program initializes the window manager, creates a viewport, shows  the

viewport, clears it, and exits the window manager.

 

***>> wmi_get_current  <<***

 

****** Summary ******

 

#include <wmidefs.h>

 

VP_VIEWPORT wmi_get_current ( );

 

****** Description ******

 

This function returns the current viewport on the window manager viewport

list.

 

****** Return Value ******

 

The return value is the current viewport on the window manager viewport

list.

 

****** Example ******

 

#include <wmidefs.h>

#include <wm2defs.h>

#include <c2vdefs.h>

void main()

{

      VP_VIEWPORT vp;

      PT2 p;

      wmi_init_gmode ( GR_VGA16, GR_DARKGRAY );

      wm2_create ( 0.0, 0.0, 5.0, 4.0, 0.0, 0.0,

            0.4, 0.4, GR_RED, GR_BLACK );

      vp = wmi_get_current();

      wm2_create ( 0.0, 0.0, 5.0, 4.0, 0.5, 0.5,

            1.0, 1.0, GR_BLUE, GR_BLACK );

      wmi_show();

      wmi_set_current ( vp );

      wmi_show();

      c2v_set ( 0.6, 0.6, p );

      vp = wmi_select ( p );

      wmi_show();

      wmi_set_display_all();

      wmi_unshow();

      wmi_show();

      wmi_set_display_current();

      wmi_unshow();

      wmi_exit();

}

This program initializes the window manager, creates two viewports,  and then

shows and unshows them in a variety of combinations.

 

***>> wmi_get_screen_color  <<***

 

****** Summary ******

 

#include <wmidefs.h>

 

GR_COLOR wmi_get_screen_color ();

 

****** Description ******

 

This function returns the current drawing color.

 

****** Return Value ******

 

The return value is the current drawing color.  See  grr_get_color for color

constants.

 

****** Example ******

 

 

#include <wmidefs.h>

#include <wm2defs.h>

 

void main()

{

      wmi_init ( GR_DARKGRAY );

      wmi_set_screen_color ( GR_BLACK );

      wm2_create ( 0.0, 0.0, 5.0, 4.0, 0.0, 0.0,

            1.0, 1.0, GR_RED, GR_BLACK );

      wmi_show();

      printf ( "%d\n", wmi_get_screen_color() );

      getch();

      wmi_exit();

}

This program initializes the window manager and prints the value of  the

screen color.

 

***>> wmi_init  <<***

 

****** Summary ******

 

#include <wmidefs.h>

 

BOOLEAN wmi_init (screen_color);

 

****** Description ******

 

This function initializes graphics mode and the window manager environment.  The

graphics mode selected is the highest resolution mode available.  After

performing initialization, this function clears the screen to a specified

color.

 

****** Input ******

 

------------------------------------------------------------------------------

| GR_COLOR               | screen_color       | the color to which the       |

|                        |                    | screen is cleared            |

------------------------------------------------------------------------------

 

See grr_get_color for valid color options.

 

****** Return Value ******

 

The return value is TRUE if graphics mode and the window manager were

initialized correctly.  It is FALSE otherwise.

 

****** Example ******

 

 

#include <wmidefs.h>

#include <wm2defs.h>

 

void main()

{

      wmi_init ( GR_DARKGRAY );

      wm2_create ( 0.0, 0.0, 5.0, 4.0, 0.0, 0.0,

            1.0, 1.0, GR_RED, GR_BLACK );

      wmi_show();

      getch();

      wmi_exit();

}

This program initializes the window manager, creates a viewport, shows  the

viewport, and exits the window manager.

 

***>> wmi_init_gmode  <<***

 

****** Summary ******

 

#include <wmidefs.h>

 

BOOLEAN wmi_init_gmode ( gmode, screen_color );

 

****** Description ******

 

This function initializes graphics mode to a specified mode, and then

initializes the window manager.  After initialization, this function  clears

the screen to a specified color.

 

****** Input ******

 

------------------------------------------------------------------------------

| int                    | gmode              | a graphics mode              |

------------------------------------------------------------------------------

| GR_COLOR               | screen_color       | the color to which the       |

|                        |                    | screen is cleared            |

------------------------------------------------------------------------------

 

See grr_init for valid graphics mode constants.

 

See grr_get_color for valid color options.

 

****** Return Value ******

 

The return value is TRUE if graphics mode and the window manager were

initialized correctly.  It is FALSE otherwise.

 

****** Example ******

 

#include <wmidefs.h>

#include <wm2defs.h>

void main()

{

      wmi_init_gmode ( GR_VGA16, GR_DARKGRAY );

      wm2_create ( 0.0, 0.0, 5.0, 4.0, 0.0, 0.0,

            1.0, 1.0, GR_RED, GR_BLACK );

      wmi_show();

      getch();

      wmi_exit();

}

This program initializes the window manager, creates a viewport, shows  the

viewport, and exits the window manager.

 

***>> wmi_register  <<***

 

****** Summary ******

 

#include <wmidefs.h>

 

VP_VIEWPORT wmi_register ( viewport );

 

****** Description ******

 

This function adds an unregistered viewport to the window manager  viewport

list.

 

****** Input ******

 

------------------------------------------------------------------------------

| VP_VIEWPORT            | viewport           | the viewport to add          |

------------------------------------------------------------------------------

 

****** Return Value ******

 

The return value is a pointer to the viewport that was added to the  window

manager viewport list, or NULL if it could not be added.

 

****** Example ******

 

 

#include <wmidefs.h>

#include <vp2defs.h>

 

void main()

{

      VP_VIEWPORT vp;

 

      wmi_init_gmode ( GR_VGA16, GR_DARKGRAY );

      vp = vp2_create ( 0.0, 0.0, 5.0, 4.0, 0.0, 0.0,

            1.0, 1.0, GR_RED, GR_BLACK );

 

      wmi_register ( vp );

      wmi_show();

      getch();

      wmi_close ( vp );

      wmi_exit();

}

This program initializes the window manager, creates a viewport, registers

the viewport with the window manager, and shows the viewport. Then  it

removes the viewport from the window manager environment, and exits  the

window manager.

 

***>> wmi_select <<***

 

****** Summary ******

 

#include <wmidefs.h>

 

VP_VIEWPORT wmi_select ( p );

 

****** Description ******

 

This function locates a registered viewport that contains a screen  point.

 

****** Input ******

 

------------------------------------------------------------------------------

| PT2                    | p                  | a screen point expressed in  |

|                        |                    | "normalized screen           |

|                        |                    | coordinates"                 |

------------------------------------------------------------------------------

 

****** Return Value ******

 

The return value is the selected viewport.  If no viewport contains  the

point, NULL is returned.

 

****** Example ******

 

See wmi_get_current.

 

***>> wmi_set_current  <<***

 

****** Summary ******

 

#include <wmidefs.h>

 

BOOLEAN wmi_set_current ( viewport );

 

****** Description ******

 

This function instructs the window manager to make the specified  viewport

the current viewport.  If the viewport is not on the list,  the current

viewport is not changed.

 

****** Input ******

 

------------------------------------------------------------------------------

| VP_VIEWPORT            | viewport           | the viewport to make current  |

------------------------------------------------------------------------------

 

****** Return Value ******

 

The return value is TRUE if the specified viewport is registered and  was

made current.  Otherwise it is FALSE.

 

****** Example ******

 

See wmi_get_current.

 

***>> wmi_set_display_all  <<***

 

****** Summary ******

 

#include <wmidefs.h>

 

void wmi_set_display_all ( );

 

****** Description ******

 

This function instructs the window manager that any drawing operations

should be directed to all registered viewports.

 

****** Example ******

 

Set wmi_get_current.

 

***>> wmi_set_display_current  <<***

 

****** Summary ******

 

#include <wmidefs.h>

 

void wmi_set_display_current ( );

 

****** Description ******

 

This function instructs the window manager to direct drawing operations  only

to the current viewport.

 

****** Example ******

 

Set wmi_get_screen_color.

 

***>> wmi_set_screen_color  <<***

 

****** Summary ******

 

#include <wmidefs.h>

 

void wmi_set_screen_color ( color );

 

****** Description ******

 

This function sets the screen color.  This color is used to fill rectangles

occupied by viewports that are removed from the screen.

 

****** Input ******

 

------------------------------------------------------------------------------

| GR_COLOR               | color              | screen color                 |

------------------------------------------------------------------------------

 

See grr_get_color for valid colors.

 

***>> wmi_show  <<***

 

****** Summary ******

 

#include <wmidefs.h>

 

void wmi_show ( );

 

****** Description ******

 

This function draws the background and the border of the current  viewport or

viewports. 

 

This function is used to display a viewport after it has been  created, or to

bring it to the front if it is behind other  viewports. 

 

****** Example ******

 

#include <wmidefs.h>

#include <wm2defs.h>

 

void main()

{

      wmi_init ( GR_DARKGRAY );

      wm2_create ( 0.0, 0.0, 5.0, 4.0, 0.0, 0.0,

            1.0, 1.0,  GR_RED, GR_BLACK );

      wmi_show();

      getch();

      wmi_unshow();

      getch();

      wmi_exit();

}

This program initializes the window manager, creates a viewport, shows  it,

and then unshows it.

 

***>> wmi_unshow  <<***

 

****** Summary ******

 

#include <wmidefs.h>

 

void wmi_unshow ( );

 

****** Description ******

 

This function removes the current viewport or viewports from the  screen and

fills the rectangle occupied by this viewport with the  current screen color.

 

 

****** Example ******

 

See wmi_show.