:orphan:

==============
Startup
==============

When you make the first call to any HOOPS routine, (either the first time on the application or since the last ``Reset_System``), HOOPS performs a standard startup sequence. This "startup sequence" is where items such as the default colors, segments, and aliases get created. This chapter describes the operation in detail.
  

Startup Error Handler
---------------------

When HOOPS first starts up, it has no default states or error handling. The first thing that happens is ``Define_Error_Handler`` is called with a special startup error handler. This special error handler forces all incoming "warning" and "error" severities to "fatal error." The error handler calls ``Report_Error`` to print the text, no matter what the severity was. Then forces program exit. This traps any errors whatsoever in the startup sequence.


"Crayola 73" Color Set
----------------------

Next, the default color names are defined. These names, and the screen colors they are matched with, are derived from the standard "Crayola 64" box of crayons and 8 new colors added. In addition, cyan has been defined, so there are 73 colors.

The exact definitions for the colors used in HOOPS are listed in Table 3.1 below:

.. csv-table::
	:header: "Name", "1st degree", "2nd degree", "HIC definition"
	
	"apricot", "", "", "22, 0.83, 1.00"
	"aquamarine", "", "", "166, 0.48, 1.00"
	"bittersweet", "", "", "8, 0.41, 1.00"
	"black", "", "", "166, 0.48, 1.00"
	"aquamarine", "dimmer, dim, darker, dark, blacker", "darkish, blackish", "0, 0, 0"
	"blue", "bluer", "bluish", "240, 0.50, 1.00"
	"blue green", "", "", "169, 0.35, 1.00"
	"blue grey", "", "", "205, 0.41, 0.60"
	"blue violet", "", "", "266, 0.13, 1.00"
	"brick red", "", "", "4, 0.32, 1.00"
	"brown, moose brown", "browner", "brownish", "12, 0.63, 0.89"
	"burnt orange", "", "", "27, 0.35, 1.00"
	"burnt sienna", "", "", "12, 0.31, 0.84"
	"cadet blue", "", "", "240, 0.44, 0.29"
	"cerulean", "", "", "197, 0.20, 1.00"
	"copper", "", "", "26, 0.26, 1.00"
	"cornflower", "", "", "240, 0.71, 1.00"
	"cyan", "", "", "180, 0.50, 1.00"
	"dandelion", "", "", "43, 0.45, 1.00"
	"forest green", "", "", "140, 0.18, 1.00"
	"fuchsia", "", "", "325, 0.33, 1.00"
	"gold", "golder", "goldish", "31, 0.34, 1.00"
	"goldenrod", "", "", "24, 0.50, 1.00"
	"green", "greener", "greenish", "120, 0.50, 1.00"
	"green blue", "", "", "20, 0.40, 1.00"
	"green yellow", "", "", "72, 0.50, 1.00"
	"grey, gray", "greyer, grayer", "greyish, grayish", "24, 0.50, 0.00"
	"indian red", "", "", "0, 0.25, 1.00"
	"jungle green", "", "", "154, 0.33, 1.00"
	"lavender", "", "", "330, 0.78, 1.00"
	"lemon yellow", "", "", "45, 0.52, 1.00"
	"magenta", "", "", "325, 0.50, 1.00"
	"mahogany", "", "", "0, 0.27, 1.00"
	"maize", "", "", "36, 0.50, 1.00"
	"maroon", "", "", "331, 0.25, 1.00"
	"melon", "", "", "12, 0.63, 0.89"
	"midnight blue, midnite blue", "", "", "12, 0.63, 0.89"
	"mulberry", "", "", "325, 0.38, 1.00"
	"navy blue", "", "", "240, 0.24, 1.00"
	"olive green", "", "", "60, 0.25, 1.00"
	"orange", "oranger", "orangish", "13, 0.50, 1.00"
	"orange red", "", "", "7, 0.38, 1.00"
	"orange yellow", "", "", "30, 0.50, 1.00"
	"orchid", "", "", "317, 0.59, 0.88"
	"peach", "", "", "21, 0.75, 1.00"
	"periwinkle", "", "", "221, 0.84, 1.00"
	"pine green", "", "", "160, 0.18, 1.00"
	"pink, carnation pink", "pinker", "pinkish", "240, 0.44, 0.29"
	"plum", "", "", "316, 0.27, 1.00"
	"purple, violet", "purpler", "purplish", "334, 0.32, 1.00"
	"raw sienna", "", "", "24, 0.29, 0.97"
	"raw umber", "", "", "28, 0.16, 1.00"
	"red", "redder", "reddish", "0, 0.50, 1.00"
	"red orange", "", "", "7, 0.50, 1.00"
	"red violet", "", "", "313, 0.31, 1.00"
	"royal purple", "", "", "274, 0.20, 1.00"
	"salmon", "", "", "17, 0.69, 1.00"
	"sea green", "", "", "120, 0.58, 1.00"
	"sepia", "", "", "17, 0.08, 1.00"
	"silver", "", "silverish", "0, 0.72, 0.00"
	"sky blue", "", "", "200, 0.72, 1.00"
	"spring green", "", "", "84, 0.63, 1.00"
	"strawberry, wild strawberry", "", "", "34, 0.40, 1.00"
	"tan", "", "", "18, 0.35, 1.00"
	"tangerine, vivid tangerine", "", "", "26, 0.50, 1.00"
	"teal, teal blue", "", "", "154, 0.33, 1.00"
	"thistle", "", "", "317, 0.43, 0.91"
	"turquoise blue", "", "", "193, 0.32, 1.00"
	"violet blue", "", "", "260, 0.08, 1.00"
	"violet red", "", "", "334, 0.32, 1.00"
	"white", "brighter, bright, lighter, light, whiter", "lightish, whitish", "0, 1.00, 0.00"
	"yellow", "yellower", "yellowish", "60, 0.50, 1.00"
	"yellow green", "", "", "90, 0.50, 1.00"
	"yellow orange", "", "", "19, 0.50, 1.00"



Startup Segments
================

Initial Alias Definitions
-------------------------

Segment definitions are made for a number of standard aliases. The table below describes each segment created. The root segment is created by the first subsegment creation. The "?Include Library" and "?Style Library" segments are given dummy -1.0. +1.0 window attributes. This is done to prevent window-clearing changes from propagating up the tree, causing the root segment to repaint.

.. csv-table::
	:header: "Alias", "Definition", "Intended Use"
	
	"?Home", "/", "The root of the world. Starting place for all other segments."
	"?Include Library", "/include library", "A standard non-visible place to keep segments used for including."
	"?Style Library", "/style library", "A standard non-visible place to keep segments used as styles."
	"?Driver", "/driver", "A standard place for device drivers (i.e., segments with 'driver' attributes)."
	"?Null", "?Driver/null", "A segment that just has the null driver attached."
	"?Picture", "?Driver/<generic>/<specific>", "The segment with an attached driver. Used as the default display surface."
	"?Locater", "?Driver/<generic>/<specific>", "The driver segment. Used for default location and selection input."
	"?Keyboard", "?Driver/<generic>/<specific>", "The driver segment. Used for default button and string input."


Generic Device Drivers
----------------------

There is one generic device driver for each supported device type (See your installation instructions for the list of those available on your system; "UIS", "X", and "Iris" are typical names). The drivers attached to supported devices wait and watch for any segment to be created within them. If such a segment appears, the driver calls Set_Driver on the new segment with a pointer to the *real * device driver for given device type. When you create segments within "?Driver/*", you automatically initialize physical devices.


The "?Picture" Segment and "HOOPS_PICTURE"
------------------------------------------

The "?Picture" device is created automatically during startup. The definition for "?Picture" is obtained by asking the operating system for the current definition of the environment variable or logical name "HOOPS_PICTURE", which is normally defined before you start your program. "?Driver" is concatenated with whatever "HOOPS_PICTURE" translates to, and the result ("?Driver/X11/unix:0.0", for example) is defined as "?Picture" and created. 

If "HOOPS_LOCATER" and/or "HOOPS_KEYBOARD" are defined outside your program, then "?locater" and/or "?Keyboard" are defined in a similar way to "?Picture". If the separate environment variables are not defined, the "?locater" and "?Keyboard" aliases are set equal to "?Picture". 

"?driver" has a special device driver. This driver's only function is to check that every segment appearing within "?driver" has a generic or specific driver attached to it. This guards against "?Picture", "?locater", or "?Keyboard" being given a value that doesn't correspond to any known device type. 


Default Attributes
==================

The root segment ("/") is given a value for every attribute HOOPS uses, as shown in the table below. This is done by calling the appropriate Set routines, one after another. HOOPS attribute settings in a segment are inherited by the sub-segments (unless the sub-segment has a different setting). Since the root segment is at the top of the tree, these HOOPS attribute settings have the effect of being default attributes for the whole world. 

* If the environment variable ``HOOPS_APPLICATION`` is set, the value is used for the "application" system option.
* If ``HOOPS_SYSTEM_OPTIONS`` is set, the entire value is passed to ``Define_System_Options``.
* If ``HOOPS_DRIVER_OPTIONS`` is set, the value overrides (is merged with) the default Driver Options on the root segment.
* Similarly, if ``HOOPS_HEURISTICS`` is set, the value overrides the default heuristics set on the root segment.
* If ``HOOPS_RENDERING_OPTIONS`` is set, the value overrides the default rendering options on the root segment.
* If ``HOOPS_COLORS`` is set, the value overrides the default color on the root segment.
* If ``HOOPS_TEXT_FONT`` is set, the value overrides the default text font on the root segment.
* If ``HOOPS_FONT_DIRECTORY`` is set, the value overrides the default font directory on the root segment.  
* If ``HOOPS_METAFLE_DIRECTORY`` is set, the value overrides the default metafile directory on the root segment.
* If ``HOOPS_VISIBILITY`` is set, the value overrides the default visibilities on the root segment.
* If ``HOOPS_PICTURE`` is set *and* ``HOOPS_PICTURE_OPTIONS`` is set, the value is passed to ``QSet_Driver_Options`` on the "?picture" segment. This overrides the default from ``HOOPS_DRIVER_OPTIONS``.
* Similarly, if ``HOOPS_HARDCOPY`` and ``HOOPS_HARDCOPY_OPTIONS`` are set, the value is passed to ``QSet_Driver_Options`` on the "?hardcopy" segment.
* If ``HOOPS_LICENSE`` is set, the value overrides the default license on the root segment. 
* If your program overrides any of these environment values (for example, by calling the "getenv()" and "putenv()" routines available on some UNIX systems), the override should happen before the first HOOPS call in the program.

.. |mm|  image:: /general/images/mm.gif

=================  
Attribute         Default Setting                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
=================  
Camera            position  = (0.0, 0.0, -5.0), target = (0.0, 0.0, 0.0), up vector = (0.0, 1.0, 0.0), width = 2.0, height = 2.0, projection = Perspective                                                                                                                                                                                                                                                                                                                                                                                                                                                   
Color             geometry = window contrast = black, windows = face contrast = lighting = white, ambient = dark gray                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
Color_Map         none (length zero)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
Driver            the null driver                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
Driver_Options    no backing store, border, color consolidation = 1.5625%, control area, no debug, no disable input, no double-buffering, no first color, no fixed colors, no force black-and-white, no gamma correction, landscape orientation, no light scaling, locater transform = (0,0,0,0,0,0), no number of colors, no output for mat, pen speed=1.0, no physical size, no selection proximity, no special events, no subscreen, subscreen moving, subscreen resizing, no subscreen stretching, no title, update interrupts, no use color map ID, no use window ID, no use window ID2, write mask = 0 
Edge_Pattern      ---                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
Edge_Weight       1.0                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
Face_Pattern      solid                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
Handedness        left                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
Heuristics        backplane cull, clipping, no concave polygons, hidden surfaces, incremental updates, no intersecting polygons, no memory purge, no partial erase, no polygon crossings, no polygon handedness, no quick moves, related selection limit = 5, transformations                                                                                                                                                                                                                                                                                                                                
Line_Pattern      ---                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
Line_Weight       1.0                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
Marker_Size       1.0                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
Marker_Symbol     O                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
Metafile          no read, no write, no name, no directory, no follow cross-references, no overwrite, no state save, no use color names                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
Modelling_Matrix  |mm|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
Rendering_Options lighting interpolation, color interpolation, color index interpolation, no attribute lock, hsr algorithm = hardware z-buffer, software frame buffer options = (no size limit, color depth = match device, no retention), face displacement = 8, quantization = ordered dither, no debug, no atmospheric attenuation                                                                                                                                                                                                                                                                        
Selectability     everything= off, windows = v                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
Streaming_Mode    off                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
Options           fatal errors, errors, warnings, info, no continuous update, no C string length, application = <from OS>, no message limit, no debug, no event checker, update control, bounding volumes, no font directory, no code generation, no license                                                                                                                                                                                                                                                                                                                                                 
Text_Alignment    \*\*                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
Text_Font         name=sans serif, size=0.03 sru, size tolerance=50%, no transforms, no rotation, no slant, no extra space                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
Text_Path         1.0, 0.0, 0.0                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
Text_Spacing      1.0                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
User_Options      (none)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
User_Value        zero                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
Visibility        on                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
Window            -1.0, 1.0, -1.0, 1.0                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
Window_Frame      on                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
Window_Pattern    solid                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
=================  
  
   
Nonsegmented Mode
-----------------  
   
If the first routine called by the program - the routine that initiated the whole startup sequence - was a simple Set or Insert routine, then one more thing is done: the system is put into "non-segmented" mode. In other words, if you didn't start by opening a segment, but instead you just started *drawing* things, the system assumes you don't want to be bothered with knowing about segments at all.

"Non-segmented" mode consists of: 

#. Opening up "?Picture" (and leaving it open).
#. Setting the "Streaming Mode" attribute to "on".
#. Calling ``Update_Display`` once to make sure that the screen is properly initialized
#. Locking "?Picture" open (via an internal flag) so that a stray ``Close_Segment`` in the application program won't accidentally close it. 


The Finish
==========
  
Once all of that is done, the regular error handler, ``Report_Error`` is defined and the special always-fatal handler is undefined. Control returns to the originally-called HOOPS Visualize routine and that routine proceeds as normal.
