home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 6 / AACD06.ISO / AACD / System / Mesa-3.1 / src / AOS / USAGE < prev    next >
Text File  |  1999-09-23  |  15KB  |  579 lines

  1. /*
  2.  * Example usage:
  3.  * 
  4.  * 1. Make a window using Intuition calls
  5.  * 
  6.  * 2. Call AMesaCreateContext() to make a rendering context and attach it
  7.  * to the window made in step 1.
  8.  * 
  9.  * 3. Call AMesaMakeCurrent() to make the context the active one.
  10.  * 
  11.  * 4. Make gl* calls to render your graphics.
  12.  * 
  13.  * 5. When exiting, call AMesaDestroyContext().
  14.  * 
  15.  */
  16.  
  17. /**********************************************************************/
  18. /*****              amigaMesa structures [private]                *****/
  19. /**********************************************************************/
  20.  
  21. /**********************************************************************/
  22. /*****               amigaMesa functions [private]                *****/
  23. /**********************************************************************/
  24.  
  25. /**********************************************************************/
  26. /*****            amigaMesa dependency-defines [private]          *****/
  27. /**********************************************************************/
  28.  
  29.   /* prevent assertations */
  30. #define    NDEBUG
  31.   /* prevent any kind of debuging-output */
  32. #define    NODEBUG
  33.   /* profile Mesa */
  34. #define    PROFILE
  35.   /* prevent LUTs for calculation and use direct arithmetic */
  36. #define    PREVENT_LUT
  37.   /* do not pass library-bases over contexts */
  38. #define    NO_CONTEXT_LIBRARIES
  39.   /* do not use the library-bases contained in contexts */
  40. #define    NO_CONTEXT_AVAILABLE
  41.   /* replace malloc/calloc/free with pool-functions (only in libMesaGL) */
  42. #define    REPLACE_ALLOC
  43.  
  44.   /* this code depends on kernel-informations */
  45. #define    AOS_KERNEL
  46.   /* this code should include Warp3D-support */
  47. #define    AOS_WARP3D
  48.  
  49. /**********************************************************************/
  50. /*****             amigaMesa function-defines [private]           *****/
  51. /**********************************************************************/
  52.  
  53.   /* set a flag */
  54. #define    SetF(field, flag)
  55.   /* clear a flag */
  56. #define    ClrF(field, flag)
  57.   /* swap a flag */
  58. #define    SwpF(field, flag)
  59.   /* test a flag */
  60. #define    TstF(field, flag)
  61.   /* convert a flag to a boolean */
  62. #define    FtoB(field, flag)
  63.  
  64.   /* get the inner width of a layer */
  65. #define    LayerWidth(l)
  66.   /* get the inner height of a layer */
  67. #define    LayerHeight(l)
  68.  
  69.   /* alignment for native displays */
  70. #define    natFixedMask(width)
  71.   /* alignment for cgfx displays */
  72. #define    cybFixedMask(width)
  73.  
  74.   /* calculate layer-coordinate of x */
  75. #define FIXx(x)
  76.   /* calculate layer-coordinate of y */
  77. #define FIXy(y)
  78.   /* calculate offset of x/y in layer */
  79. #define FIXxy(x, y)
  80.  
  81.   /* get base-address of BackArray or LUT for 1-8bit chunky-pixels */
  82. #define    dbPenGet(am)
  83.   /* get address of BackArray for x/y */
  84. #define    dbPen(db, x, y)
  85.   /* get base-address of BackArray or LUT for 32bit ulongs */
  86. #define    dbRGBAGet(am)
  87.   /* get address of BackArray for x/y */
  88. #define    dbRGBA(db, x, y)
  89.  
  90. #define    DEBUGOUT(level, str, args...)
  91. #define    Error(str, args...)
  92.  
  93.   /* convert palette-mode to include dithering */
  94. #define    MATCHtoDITHER(bool)
  95.   /* convert palette-mode to exclude dithering */
  96. #define    DITHERtoMATCH(bool)
  97.  
  98. #define    IS_WEIGHTED(bool)
  99. #define    IS_HPCR(bool)
  100. #define    IS_GREY(bool)
  101. #define    IS_332SHIFT(bool)
  102. #define    IS_332MATCH(bool)
  103. #define    IS_TRUECOLOR(bool)
  104.  
  105. #define    IS_SHIFT(bool)
  106. #define    IS_MATCH(bool)
  107. #define    IS_DITHER(bool)
  108.  
  109. #define c8toc32(x)
  110. #define    c24tocg(r, g, b)
  111. #define    c24toc8(r, g, b)
  112.  
  113. #define TC_RGBA(r, g, b)
  114. #define TC_ARGB(r, g, b)
  115. #define    TC_Color(col, rr, gg, bb, aa)
  116.  
  117. #define    GR_RGBA(am, r, g, b)
  118.  
  119. #define PLD_RGBA(am, r, g, b, x, y)
  120. #define PLG_RGBA(am, r, g, b)
  121. #define PL8_RGBA(am, r, g, b)
  122.  
  123. #define MakeRGBP(am, r, g, b, x, y)
  124. #define MakeRGBA(am, r, g, b, a)
  125.  
  126. #define    GetRGBP(am, idx)
  127. #define    GetRGBPLocal(idx)
  128. #define    GetIndex(am, idx)
  129. #define    GetIndexLocal(idx)
  130.  
  131. /**********************************************************************/
  132. /*****              amigaMesa value-defines [private]             *****/
  133. /**********************************************************************/
  134.  
  135. #define    CACHED
  136. #define    INVALID
  137.  
  138. #define palNumCols332
  139. #define palNumCols
  140. #define palNumColsGrey
  141. #define palNumColsHPCR
  142. #define    palNumColsMax
  143.  
  144. /**********************************************************************/
  145. /*****             amigaMesa boolean-defines [private]            *****/
  146. /**********************************************************************/
  147.  
  148.   /* visual is double-buffered */
  149. #define    VISUAL_DOUBLEBUFFER
  150.   /* visual do stereo-rendering */
  151. #define    VISUAL_STEREO
  152.   /* visual is in rgb-mode */
  153. #define    VISUAL_RGBMODE
  154.   /* visual has alpha-chanel */
  155. #define    VISUAL_ALPHACHANNEL
  156.   /* visual detects accuracity itself */
  157. #define    VISUAL_AUTORGB
  158.  
  159.   /* visual is our own */
  160. #define    RESOURCE_VISUAL
  161.   /* buffer is our own */
  162. #define    RESOURCE_BUFFER
  163.  
  164.   /* palette-match should be cached */
  165. #define    PALETTE_CACHE
  166.   /* palette-match is dithered */
  167. #define    PALETTE_DITHER
  168.  
  169. /**********************************************************************/
  170. /*****                amigaMesa functions [public]                *****/
  171. /**********************************************************************/
  172.  
  173. /**********************************************************************/
  174. /*****               amigaMesa structures [public]                *****/
  175. /**********************************************************************/
  176.  
  177.   /*
  178.    * definition:
  179.    *  AMESA_HPCR* gives the palette of the Hewlett-Packard Color-Recovery
  180.    *  and try to find the best exact match
  181.    *  AMESA_GREY* gives 64 grey-levels and try to find the best exact match
  182.    *  AMESA_TRUECOLOR* gives a palette based upon 3bits red, 3bits blue
  183.    *  2bits green and try to find the best exact match
  184.    * notes:
  185.    *  first part defines amigaMesa-specifig tag
  186.    *  second part defines the choosen palette (aka modelling of available colors)
  187.    *  third part defines methog to fetch data (aka encoding of given colors
  188.    *
  189.    *  at the moment dithering is only available in RGBMode, that means if we are
  190.    *  in index-mode the index-pixels are directly (without dither) mapped to
  191.    *  pen-pixels, it could be an improvement to offer dithering even for index-modes
  192.    */
  193.   typedef enum PaletteModeID {
  194.     /* dithering */
  195.     AMESA_HPCR_DITHER = -8,                            /* hp-color-recovery */
  196.     AMESA_GREY_DITHER = -4,
  197.     AMESA_WEIGHTED_DITHER = -2,                            /* default standard 0 */
  198.     AMESA_TRUECOLOR_DITHER = -1,                        /* matches below 0 */
  199.     /* matching */
  200.     AMESA_HPCR_MATCH = 8,                            /* hp-color-recovery */
  201.     AMESA_GREY_MATCH = 4,
  202.     AMESA_WEIGHTED_MATCH = 2,                            /* default standard 0 */
  203.     AMESA_TRUECOLOR_MATCH = 1,                            /* matches below 0 */
  204.     /* shifting */
  205.     AMESA_TRUECOLOR_SHIFT = 0,                            /* shifts above 0 */
  206.     /* invalid */
  207.     AMESA_DEADFOOD = 0xDEAD                            /* dead man */
  208.   } palMode;
  209.  
  210. /**********************************************************************/
  211. /*****        amigaMesa TAGS (Create/Get/Change) [public]         *****/
  212. /**********************************************************************/
  213.  
  214.   /*
  215.    * Amiga Mesa Attribute tag ID's.  These are used in the ti_Tag field
  216.    * of TagItem arrays passed to amigaMesaGet*()-, amigaMesaCreate*()-
  217.    * and amigaMesaChange*()-functions
  218.    */
  219. #define AMA_Dummy        (TAG_USER + 32)
  220.  
  221.   /*
  222.    * definition:
  223.    *  border-sizes of drawable area
  224.    *  (drawable-size = layer-size - amesa-borders)
  225.    *  (visible-size = layer-size - layer-border)
  226.    * default:
  227.    *  left = top = bottom = right = 0
  228.    * notes:
  229.    *  amesa checks for valid ranges from 0 upto the rastport-size
  230.    *  and shrinks width/height if they doesn't fit them or fall below
  231.    *  0 and aborts if left/right or bottom/top overlaps
  232.    *  amesa prefers borders before sizes
  233.    *  if amesa find a window-tag it sets the borders to at least
  234.    *  the window-borders, so if you want to use GZZ you have NOT to
  235.    *  use the window-tag, use the rastport- and screen-tag instead
  236.    *  this too is a behaviour to make the system safe
  237.    * type:
  238.    *  GLshort
  239.    * availability:
  240.    *  Create/Get/Change
  241.    * affects:
  242.    *  Context
  243.    */
  244. #define AMA_Left        (AMA_Dummy + 0x0001)
  245. #define AMA_Bottom        (AMA_Dummy + 0x0002)
  246. #define AMA_Right        (AMA_Dummy + 0x0003)
  247. #define AMA_Top            (AMA_Dummy + 0x0004)
  248.  
  249.   /*
  250.    * definition:
  251.    *  the width and height of the drawable area
  252.    * default:
  253.    *  width = height = layer-size - layer-borders
  254.    * notes:
  255.    *  amesa checks for valid ranges from 0 upto the rastport-size
  256.    *  and shrinks width/height if they doesn't fit them or fall below
  257.    *  0 and aborts if left/right or bottom/top overlaps
  258.    *  amesa prefers borders before sizes
  259.    * type:
  260.    *  GLshort
  261.    * availability:
  262.    *  Create/Get/Change
  263.    * affects:
  264.    *  Context
  265.    */
  266. #define AMA_Width        (AMA_Dummy + 0x0010)
  267. #define AMA_Height        (AMA_Dummy + 0x0011)
  268.  
  269.   /*
  270.    * definition:
  271.    *  the default procedure for mapping rgb to pen
  272.    * default:
  273.    *  AMESA_WEIGHTEDCOLOR
  274.    * type:
  275.    *  palmode
  276.    * availability:
  277.    *  Create/Get/Change
  278.    * affects:
  279.    *  Context
  280.    */
  281. #define AMA_PaletteMode        (AMA_Dummy + 0x0020)
  282.   /*
  283.    * definition:
  284.    *  tries to cache previous calculated pens for faster matching
  285.    * default:
  286.    *  GL_FALSE
  287.    * notes:
  288.    *  not used if AMESA_TRUECOLORSHIFT
  289.    * type:
  290.    *  GLboolean
  291.    * availability:
  292.    *  Create/Get/Change
  293.    * affects:
  294.    *  Context
  295.    */
  296. #define AMA_PaletteCache    (AMA_Dummy + 0x0021)
  297.  
  298. #define AMA_PaletteDither    (AMA_Dummy + 0x0022)
  299.  
  300.   /*
  301.    * definition:
  302.    *  the screen the context is bind to (needs a rastport too)
  303.    * default:
  304.    *  NULL
  305.    * notes:
  306.    *  amesa prefers windows before screens and rastports
  307.    *  if you want to use a screens rastport for rendering
  308.    *  (fullscreen) you have to pass &Screen->RastPort, I
  309.    *  havn't enabled it by default to force knowledge of
  310.    *  what you are doing there
  311.    *  screens are needed for palette-allocation and remapping
  312.    *  only
  313.    * type:
  314.    *  struct Screen *
  315.    * availability:
  316.    *  Create/Get/Change
  317.    * affects:
  318.    *  Context
  319.    */
  320. #define AMA_Screen        (AMA_Dummy + 0x0030)
  321.   /*
  322.    * definition:
  323.    *  the rastport the context is bind to (needs a screen too)
  324.    * default:
  325.    *  NULL
  326.    * notes:
  327.    *  amesa prefers windows before screens and rastports
  328.    *  at the moment you can't render to a unvisible rastport
  329.    *  but i'm working of that
  330.    *  rastports are the areas amesa renders to, checks it's sizes
  331.    *  etc. pp. (rastports are the main-devices)
  332.    * type:
  333.    *  struct RastPort *
  334.    * availability:
  335.    *  Create/Get/Change
  336.    * affects:
  337.    *  Context
  338.    */
  339. #define AMA_RastPort        (AMA_Dummy + 0x0032)
  340.  
  341.   /*
  342.    * definition:
  343.    *  the window the context is bind to
  344.    * default:
  345.    *  NULL
  346.    * notes:
  347.    *  amesa prefers windows before screens and rastports
  348.    *  windows are needed for getting the rastport/screen only
  349.    * type:
  350.    *  struct Window *
  351.    * availability:
  352.    *  Create/Get/Change
  353.    * affects:
  354.    *  Context
  355.    */
  356. #define AMA_Window        (AMA_Dummy + 0x0031)
  357.  
  358.   /*
  359.    * definition:
  360.    *  use offscreen-rendering instead of direct drawing and
  361.    *  flush the contents of the offscreen-buffer at swap
  362.    * default:
  363.    *  GL_FALSE
  364.    * type:
  365.    *  GLboolean
  366.    * availability:
  367.    *  Create/Get/Change
  368.    * affects:
  369.    *  Context/Visual
  370.    */
  371. #define AMA_DoubleBuffer    (AMA_Dummy + 0x0040)
  372.   /*
  373.    * definition:
  374.    *  use rgb-rendering instead of direct index-rendering and
  375.    *  convert the rgb-values at first in the driver (or in case
  376.    *  of double-buffering at swap)
  377.    * default:
  378.    *  GL_FALSE
  379.    * type:
  380.    *  GLboolean
  381.    * availability:
  382.    *  Create/Get/Change
  383.    * affects:
  384.    *  Context/Visual
  385.    */
  386. #define AMA_RGBMode        (AMA_Dummy + 0x0041)
  387.   /*
  388.    * definition:
  389.    *  use an alpha-channel in addition to rgb (for ? (blending?))
  390.    * default:
  391.    *  GL_FALSE
  392.    * type:
  393.    *  GLboolean
  394.    * notes:
  395.    *  requires rgb
  396.    * availability:
  397.    *  Create/Get/Change
  398.    * affects:
  399.    *  Context/Visual
  400.    */
  401. #define AMA_AlphaChannel    (AMA_Dummy + 0x0042)
  402.   /*
  403.    * definition:
  404.    *  ? (stereo-rendering?)
  405.    * default:
  406.    *  GL_FALSE
  407.    * type:
  408.    *  GLboolean
  409.    * availability:
  410.    *  Create/Get/Change
  411.    * affects:
  412.    *  Context/Visual
  413.    */
  414. #define AMA_Stereo        (AMA_Dummy + 0x0043)
  415.  
  416.   /*
  417.    * definition:
  418.    *  number of bits used in depth-buffers
  419.    *  or <= 0 for disabling
  420.    * default:
  421.    *  DEPTH_BITS
  422.    * type:
  423.    *  GLint
  424.    * availability:
  425.    *  Create/Get/Change
  426.    * affects:
  427.    *  Context/Visual
  428.    */
  429. #define AMA_BitsDepth        (AMA_Dummy + 0x0044)
  430.   /*
  431.    * definition:
  432.    *  number of bits used in accumulation-buffers
  433.    *  or <= 0 for disabling
  434.    * default:
  435.    *  ACCUM_BITS
  436.    * type:
  437.    *  GLint
  438.    * availability:
  439.    *  Create/Get/Change
  440.    * affects:
  441.    *  Context/Visual
  442.    */
  443. #define AMA_BitsAccum        (AMA_Dummy + 0x0045)
  444.   /*
  445.    * definition:
  446.    *  number of bits used in stencil-buffers
  447.    *  or <= 0 for disabling
  448.    * default:
  449.    *  STENCIL_BITS
  450.    * type:
  451.    *  GLint
  452.    * availability:
  453.    *  Create/Get/Change
  454.    * affects:
  455.    *  Context/Visual
  456.    */
  457. #define AMA_BitsStencil        (AMA_Dummy + 0x0046)
  458.  
  459.   /*
  460.    * definition:
  461.    *  disable use of 3D-hardware
  462.    * default:
  463.    *  GL_FALSE
  464.    * type:
  465.    *  GLboolean
  466.    * availability:
  467.    *  Create/Get/Change
  468.    * affects:
  469.    *  Context/Visual
  470.    */
  471. #define AMA_No3D        (AMA_Dummy + 0x0047)
  472.  
  473.   /*
  474.    * definition:
  475.    *  specify an shared context for this context
  476.    * default:
  477.    *  NULL
  478.    * type:
  479.    *  amigaMesaContext
  480.    * availability:
  481.    *  Create/Get/Change
  482.    * affects:
  483.    *  Context
  484.    */
  485. #define AMA_ShareGLContext    (AMA_Dummy + 0x0050)
  486.   /*
  487.    * definition:
  488.    *  get the context of a given context
  489.    * default:
  490.    *  NULL
  491.    * type:
  492.    *  GLcontext *
  493.    * availability:
  494.    *  Get
  495.    * affects:
  496.    *  Context
  497.    */
  498. #define AMA_GLContext        (AMA_Dummy + 0x0054)
  499.  
  500.   /*
  501.    * definition:
  502.    *  get the visual of a given context
  503.    * default:
  504.    *  NULL
  505.    * type:
  506.    *  amigaMesaVisual
  507.    * availability:
  508.    *  Get
  509.    * affects:
  510.    *  Context/Visual
  511.    */
  512. #define AMA_Visual        (AMA_Dummy + 0x0051)
  513.   /*
  514.    * definition:
  515.    *  get the buffer of a given context
  516.    * default:
  517.    *  NULL
  518.    * type:
  519.    *  amigaMesaBuffer
  520.    * availability:
  521.    *  Get
  522.    * affects:
  523.    *  Context/Visual/Buffer
  524.    */
  525. #define AMA_Buffer        (AMA_Dummy + 0x0052)
  526.   /*
  527.    * definition:
  528.    *  specify a window-id for this buffer
  529.    * default:
  530.    *  NULL
  531.    * type:
  532.    *  GLshort
  533.    * availability:
  534.    *  Create/Get/Change
  535.    * affects:
  536.    *  Buffer
  537.    */
  538. #define AMA_WindowID        (AMA_Dummy + 0x0053)
  539.  
  540.   /*
  541.    * definition:
  542.    *  get the depth of a given visual
  543.    * default:
  544.    *  Screen->RastPort.BitMap->Depth
  545.    * type:
  546.    *  GLint
  547.    * availability:
  548.    *  Get
  549.    * affects:
  550.    *  Visual
  551.    */
  552. #define    AMA_VisualDepth        (AMA_Dummy + 0x0060)
  553.   /*
  554.    * definition:
  555.    *  get the depth of a given context
  556.    * default:
  557.    *  Screen->RastPort.BitMap->Depth
  558.    * type:
  559.    *  GLint
  560.    * availability:
  561.    *  Get
  562.    * affects:
  563.    *  Context
  564.    */
  565. #define    AMA_ContextDepth    (AMA_Dummy + 0x0061)
  566.   /*
  567.    * definition:
  568.    *  get the visual of a given visual
  569.    * default:
  570.    *  ...
  571.    * type:
  572.    *  GLvisual *
  573.    * availability:
  574.    *  Get
  575.    * affects:
  576.    *  Visual
  577.    */
  578. #define    AMA_VisualGLVisual    (AMA_Dummy + 0x0062)
  579.