1992.11.13

SUBJECT: XGL 2.0 Programming

 1. ¸ñ Â÷

    1)  XGL °³¿ä

    2)  Fonts

    3)  2D rendering

    4)  Patterns

    5)  Color

    6)  Picking

    7)  Viewing

    8)  Transforms

    9)  3D Rendering

    10) Lighting

 2. °³¿ä

     1) XGLÀ̶õ ?


        (1) 2Â÷¿ø °ú 3Â÷¿øÀ» Áö¿øÇÏ´Â Graphic Library.

        (2) CAD/CAM ºÎ¹®¿¡¼­ ½Ç¿ë°¡´ÉÇÑ Graphic Library.

        (3) ±âº»ÀûÀ¸·Î X11 window ȤÀº Openwindow¿¡¼­ ¿î¿µµÇ´Â ApplicationÀ» ÀÛ¼ºÇϱâÀ§ÇÑ Graphic Library.

            ±× ÀÌÀ¯´Â XGLÀ» ÀÌ¿ëÇÑ programÀÌ ÀÛµ¿½Ã¿¡ display device¸¦ È®~ÀÎÇÏ´Â ÀýÂ÷¸¦ ÅëÇØ X11ÀÇ server

            ȤÀº News server¿¡ÀÇÇØ °ü¸®µÇ±â¶§¹®ÀÌ´Ù.

     2) XGL¿¡¼­ »ç¿ëµÇ´Â °³³ä

        (1) system state : xglÀ» À§ÇÑ data area¸¦ ÃʱâÈ­ ÇÔ.

        (2) device : drawingÀ» ÇÏ´Â °÷.

        (3) context : state¿¡´ëÇÑ Á¤º¸¿Í renderingÀ» À§ÇÑ Æ¯¼ºµîÀ» ÀúÀåÇÑ°Í.

        (4) stroke font : »ç¿ëÇÒ fontÀÇ À¯Çü.

        (5) line pattern : dash-dot À¯Çü.

        (6) color map : rgb color ȤÀº index table.

        (7) transform : °ü·ÃµÈ ½Ã½ºÅÛ°£ÀÇ º¯È­µéÀ» À§ÇÑ matrix.°³¿ä

        (8) light : shading½Ã¿¡ »ç¿ëµÇ´Â ºû, Áï ¸í¾Ï.

      3) XGL programÀÇ ÀÛ¼º ÀýÂ÷

         (1) rendering functionÀ» ÀÌ¿ëÇÏ¿© ±âÃÊÀûÀÎ graphic ±¸Á¶¸¦ ¸¸µë.

              : data±¸¼º --> renderingÀ» À§ÇÑ Æ¯¼ºÁöÁ¤ --> dataÀÇ context ÀÛ¼º

         (2) »ç¿ëÇÒ fontsÀÇ À¯Çü(Å©±â,¼­Ã¼,±â¿ï±â µî)À» ÁöÁ¤

         (3) ÀÌÂ÷¿ø ȤÀº »ïÂ÷¿øÀÇ µµÇüÀÎÁö¸¦ ÀÛ¼ºÈÄ Ç¥¸é󸮿¡´ëÇÑ Á¤ÀÇ

         (4) »ö»ó¿¡´ëÇÑ Á¤ÀÇ ¹× viewing °úÁ¤À» Á¤ÀÇ

         (5) transformÀÇ °úÁ¤À» Á¤ÀÇÈÄ ¸í¾Ï¿¡ ´ëÇÑ Á¤ÀÇ

         (6) codeÀÇ compile

         (7) ½ÇÇà È­ÀÏÀÇ ¼öÇà

      4) XGLÀ» ÀÌ¿ëÇÏ¿© ¸¸µç ApplicationÀÇ ÀÛµ¿ ÀýÂ÷

         (1) ±âº» ÀýÂ÷¸¦ º¸¸é ´ÙÀ½°ú °°´Ù.

             a) window¿¡ ±âÃÊ

             b) XGL Program ¼öÇà

             c) system stateÀÇ object°¡ ¸¸µé¾îÁü

             d) ±× object¸¦ ÅëÇØ window device object°¡ ¸¸µé¾î Áü.

             e) ±×ÈÄ context object°¡ ¸¸µé¾îÁü.

             f) ½ÇÁ¦ÀûÀÎ graphicÀÌ displayµÊ.

       5) ½ÇÁ¦ Àû¿ë ¹× Àû¿ë ´ë»ó

          (1) ½ÇÁ¦Àû¿ë »ç·Ê : AutoCad

          (2) Àû¿ë °¡´É ´ë»ó : Çö´ëÁß°ø¾÷ÀÇ ¹è ¼³°è programÀÎ Autocon softwareÀÇ »õ·Î¿î VersionÀÇ ÀÛ¼º

                ( Çâ»óµÈ ó¸® ´É·Â°ú ¼¶¼¼ÇÑ Ç¥Çö·Â¿¡µû¶ó ³ôÀº ÀÛ¾÷ÀÇ Ç⼧¼ºÀÌ ±â´ëµÊ )

 3. XGL API

    1) declarations

       Xgl_sys_state

       Xgl_win_ras

       Xgl_2d_ctx

       À§¿Í °°ÀÌ declarationµéÀº ´ë¹®ÀÚ X·Î ½ÃÀÛÇÏ°í underscore·Î ¿¬°áµÇ¸ç ()ÀÇ Ç¥½Ã°¡ ¾ø´Ù.

    2) object operators

       xgl_open()

       xgl_object_create()

       xgl_object_set()

       xgl_object_get()

       xgl_object_destroy()

       À§¿Í°°ÀÌ object operatorµéÀº ¼Ò¹®ÀÚ xgl·Î ½ÃÀÛÇÏ°í ÇÔ¼öÀÇ Æ¯¼ºÀ» °¡Áø´Ù.

     3) object attributes

        XGL_WIN_X

        XGL_CTX_DEVICE

        XGL_CTX_SFONT_CHAR_HEIGHT

        À§¿Í°°ÀÌ object attributeµéÀº »ö»ó,±æÀÌ,Æø,³ôÀ̵îÀÇ ¼Ó¼º¿¡´ëÇÑ °ÍÀ¸·Î ´ë¹®ÀڷΠǥ±âÇÑ´Ù.

        ¼Ó¼ºÀº ´ë»óüÀÇ Æ¯¼ºÀ» º¯°æ½ÃÅ°°í ±×°Í¿¡ ÇØ´çÇÏ´Â  °ªµéÀ» °¡Áö°í ÀÖ´Ù.

        ex) 

            xgl_object_set(object,

                  ATTRIBUTE, value,

                  ATTRIBUTE, value,

                  0);

             xgl_object_get(object,ATTRIBUTE,&var);

      4) primitives

         xgl_stroke_text_2d()

4. Initialization

    1) ÀýÂ÷

                                     -----------------------------
         Xlib/Toolkit Library        |          Window           |
                                     -----------------------------
                                                   |
                                                   V
                                     -----------------------------
         XGL Library                 |        system state       |
                                     -----------------------------
                                                   |
                                                   V
                                     -----------------------------
         XGL Library                 |   Device (window raster)  |
                                     -----------------------------
                                                   |
                                                   V
                                     -----------------------------
         XGL Library                 |          context          |
                                     -----------------------------

                                                  
    XGL programmingÀº drawingÀ»À§ÇØ window¸¦ ¸¸µé±âÀ§ÇØ X toolkits ȤÀº Xlib¸¦ »ç¿ëÇØ¾ß ÇÑ´Ù.

    system state object´Â ´ÜÁö Çѹø¸¸ ¸¸µé¾îÁö°í XGL¿¡ÀÇÇØ »ç¿ëµÇ´Â data area¸¦ Á¤ÀÇÇÑ´Ù.

    window device object´Â window,display,screenÀ» Á¶ÀÛÇϱâÀ§ÇØ Xlib¸¦ ÇÊ¿ä·Î ÇÑ´Ù.

    ¶ÇÇÑ display deviceÀÇ À¯ÇüÀ» °áÁ¤ÇϱâÀ§ÇØ server¿¡ query¸¦ ÇÑ´Ù.

    ±×¸®°í multiple device objects°¡ µÉ¼öÀÖ´Ù.

    context object´Â device°¡ context¿¡ ¿¬°áµÇµµ·ÏÇÏ°í,¸ðµç renderingÀº context¸¦ °¡Áö°í ¼öÇàµÇ°í,

    rendering attributes´Â context¿¡ setµÈ´Ù.

    multiple context objects°¡ µÉ¼öµµ ÀÖ´Ù.

 5. Rendering

    1) ÀýÂ÷

       data ±¸Ãà --> Rendering Attributes¸¦ set --> Primitive¸¦ call

    2) primitive data

       - data´Â ÁÂÇ¥Á¡,»ö»ó,Ç¥¸é»óÅ µîÀ» Æ÷ÇÔÇÏ°í ÀÖ´Ù.

       - unionÀ» Æ÷ÇÔÇÏ°íÀÖ´Â struct´Â integer,float,fract(ºÐ¼ö), 2D / 3D data¸¦ Áö¿øÇÑ´Ù.

       - ÁÂÇ¥ (0,0)´Â »ó´Ü ÁÂÃøÀÇ °ªÀÌ´Ù.

    3) ¸ðµç rendering ¼Ó¼º°ªÀº context object¿¡ settingµÈ´Ù.

       xgl_object_set( context,

            XGL_CTX_SFONT_CHAR_HEIGHT , 20.0

            0);

    4) primitive callÀº drawingÀ» ÇϱâÀ§ÇØ context¿Í data¸¦ »ç¿ëÇÑ´Ù.

       primitive(context,data ...);

    5) compileÀÇ ¿¹

       cc hello.c -I$XGLHOME/include -I$OPENWINHOME/include -L$OPENWINHOME/lib -L$OPENWINHOME/lib

         -lxgl -lxview -lolgx -lX11 -lm

 6. FONTS

    1) creating fonts

       font object´Â font family·ÎºÎÅÍ ÇüÅÂÀÇ Æ¯º°À¯ÇüÀ¸·Î Á¤ÀǵȴÙ.

       ÇϳªÀÇ font object´Â renderµÇ´Â °¢°¢ÀÇ font¿¡ÀÇÇØ ¸¸µé¾îÁø´Ù.

       renderµÇ´Â ¼Ó¼º(Å©±â,¹æÀ§ µî)Àº context¿¡ setµÈ´Ù.

       fontµéÀº $XGLHOME/lib/xglfonts/stroke/fontname.phont¿¡ Á¤ÀǵǾî ÀÖ´Ù.

       XGL fontµéÀÇ À̸§Àº ´ÙÀ½°ú °°´Ù.

       - Cartographic    Cartographic_M   English_G   Greek   Greek_C

         Greek_M   Headline   Miscellaneous   Miscellaneous_M  Italic_C

         Roman   Roman_D   Roman_M   Roman_T   Roman_C   Script   Script_C

       font object´Â ´ÙÀ½¿¡ÀÇÇØ ¸¸µé¾î Áø´Ù.

           font = xgl_stroke_font_create("fontname",0);

       context¿¡ÀÇÇØ »ç¿ëµÇ´Â font¸¦ È®ÀÎÇϱâÀ§Çؼ­´Â ´ÙÀ½À» ¼öÇàÇÏ¸é µÈ´Ù.

           xgl_object_set(context,XGL_CTX_SFONT,font,0);

    2) rendering text

       XGl font´Â Phigs ANSII standard¿¡ µû¸¥´Ù.

       Font rendering ATTRIBUTEµéÀº ´ÙÀ½°ú °°´Ù.

         XGL_CTX_SFONT

         XGL_CTX_SFONT_CHAR_HEIGHT

         XGL_CTX_SFONT_CHAR_SPACING

         XGL_CTX_SFONT_EXPANSION_FACTOR

         XGL_CTX_SFONT_TEXT_ALIGN_HORIZ

         XGL_CTX_SFONT_TEXT_ALIGN_VERT

         XGL_CTX_SFONT_CHAR_UP_VECTOR

         XGL_CTX_SFONT_CHAR_SLANT_ANGLE

         XGL_CTX_SFONT_TEXT_PATH

         XGL_CTX_SFONT_TEXT_COLOR

         XGL_CTX_SFONT_TEXT_PREC

        render text´Â xgl_stroke_text_2d(context,"string",point); ÀÇ ÇüŸ¦ °¡Áø´Ù.

        stringÀ» À§ÇÑ Á¡µéÀÇ ¿¬¼ÓÁ¡°ú bounding box¸¦ ¾ò±âÀ§Çؼ­´Â ´ÙÀ½À» ÀÌ¿ëÇØ¾ß ÇÑ´Ù.

          xgl_stroke_text_extent(context,"string",rect,cat_pt);

  7. 2D primitives

     2D¿¡ °ü·ÃµÈ primitiveµéÀº ´ÙÀ½°ú °°´Ù.

     xgl_multimaker()

     xgl_multipolyline()

     xgl_multirectangle()

     xgl_multicircle()

     xgl_multiarc()

     xgl_multi_simple_polygon()

     xgl_polugon()

     xgl_nu_bspline_curve()

     primitive¸¦ °¡Áö°í rederingÀ» ÇÏ´Â ÀýÂ÷´Â ´ÙÀ½°ú °°´Ù.

      1) primitive data¸¦ Á¤ÀÇ

      2) context¿¡ redering attributeµéÀ» set.

      3) context¿Í data¸¦ °¡Áö°í primitive¸¦ callÇÑ´Ù.

         ±× ÇüÅ´ ´ÙÀ½°ú °°´Ù.

           primitive(context,data parameters ...);

      multi primitiveµéÀº ´Ù¼öÀÇ single callµéº¸´Ù´Â ´õ ³ºÀº ¼öÇà ´É·ÂÀ» Á¦°øÇÑ´Ù.

  8. patterns

     ¾î¶² primitiveµéÀº Ç¥¸éÀ̳ª °¡ÀåÀÚ¸® ¼±À» renderingÇϴµ¥ »ç¿ëµÈ´Ù.    

     line patternµéÀº ÇϳªÀÇ XGL object·Î ¸¸µé¾î Áø´Ù.

        Xgl_lpat    xgl_line_pattern_create()

     °¡ÀåÀÚ¸® ¼±(EDGE)µéÀº ÆÐÅÏ,»ö»ó,ÆøÀ» °¡Áú¼ö ÀÖ´Ù.

        XGL_CTX_EDGE_STYLE

        XGL_CTX_EDGE_PATTERN

        XGL_CTX_EDGE_COLOR

        XGL_CTX_EDGE_WIDTH_SCALE_FACTOR

     ¼±(line)µéÀº ÆÐÅÏ,»ö»ó,Æø,cap style,join styleÀ» °¡Áú¼ö ÀÖ´Ù.

        XGL_CTX_LINE_STYLE

        XGL_CTX_LINE_PATTERN

        XGL_CTX_LINE_COLOR

        XGL_CTX_LINE_WIDTH_SCALE_FACTOR

        XGL_CTX_LINE_CAP

        XGL_CTX_LINE_JOIN

      patternÀ» ä¿ì´Â ¹æ¹ý(fill pattern)Àº XGL memory raster·Î½á ¸¸µé¾î Áø´Ù.

        Xgl_mem_ras    xgl_memory_raster_device_create()

      primitive surface´Â ÆÐÅÏ,»ö»ó°ú ´Ù¸¥ÇüÅÂÀÇ fill styleÀ» °¡Áú¼ö ÀÖ´Ù. 

        XGL_CTX_SURF_FRONT_FILL_STYLE

        XGL_CTX_SURF_FPAT

        XGL_CTX_SURF_FRONT_COLOR

  9. Color

       xglÀº RGB¿Í index color¸¦ ÅëÇØ Áö¿øµÈ´Ù.

       indexµÈ colormapÀº  XGL object·Î½á ¸¸µé¾î Áø´Ù.

          Xgl_cmap   xgl_color_map_create()

       color type°ú colormapÀº window rater device¿¡ ÇÒ´çµÈ´Ù.

          XGL_RAS_COLOR_TYPE
    
          XGL_RAS_COLOR_MAP

       ¿øÇÏ´Â color index(RGB value)´Â color struct¿¡ ÇÒ´çµÈ´Ù.

       color struct´Â rendering  ¼Ó¼º ȤÀº primitive data¿¡ ÇÒ´çµÈ´Ù.

       colorµéÀº primitive dege,line,marker,surface¿¡ ÇÒ´çµÈ´Ù.

       XGLÀÇ indexµÈ color programÀº RGB frame buffer¿¡¼­ ¼öÇàµÈ´Ù.

       XGL RGB color programÀº indexµÈ frame buffer»ó¿¡¼­ ¼öÇàµÈ´Ù.

  10. picking

       pick aperture(ÂïÇôÁø Á¡)Àº testµÈ volumeȤÀº Áö¿ªÀ¸·Î Á¤Àǵɼö ÀÖ´Ù.

       pickÀº aperture°¡ rendering image¸¦ °ãÃÆÀ»¶§ °Ë»çµÉ¼ö ÀÖ´Ù.

       °¢°¢ÀÇ »ç½ÇÀÇ pick test¿¡´ëÇÑ pick ID´Â pick buffer¿¡ ÀúÀåµÈ´Ù.

       * pickingÇÏ´Â ÀýÂ÷

         1) pick aperture¸¦ È®ÀÎ

         2) contex»ó¿¡¼­ pickingÀÌ °¡´ÉÇØÁü

         3) context»ó¿¡¼­ renderingÀÌ ºÒ°¡´ÉÇØÁü

         4) pick buffer¸¦ clearÇÔ

         5) °¢°¢ÀÇ image¸¦ renderingÇϱâÀü¿¡ pick ID¸¦ ÇÒ´ç

         6) context»ó¿¡¼­ pickingÀÌ ºÒ°¡´ÉÇØÁü

         7) context»ó¿¡¼­ renderingÀÌ °¡´ÉÇØÁü

         8) pick buffer¸¦ query

        pickingÀº CPU ÁýÁßÀûÀÌ°Ô µÉ¼öÀÖ´Ù.

   11. viewing

       virtual windowÀº °¡½ÃÀûÀÎ ¿µ¿ªÀ¸·Î ±ÔÁ¤µÉ¼ö ÀÖ´Ù.

       virtual window ¹ÛÀ¸·Î ³õ¿©Áø renderµÈ imageµéÀº ¹ßÃéµÈ´Ù.

       °¡½ÃÀûÀÎ windowÀÇ Å©±â ¹× À§Ä¡´Â º¯È­µÉ¼ö ÀÖ´Ù.

       virtual windowÀº device viewport¿¡ mappingµÈ´Ù.

   12. Transforms

       transformµÇ´Â ¼ø¼­´Â ¸ÕÀú Model Coordinates(MC)¸¦ °ÅÃÄ World Coordinates(WC)µÇ°í,Virtual

       Device Coordinates(VDC)µÈ´Ù.


       primitive data´Â MC¿¡¼­ ±ÔÁ¤µÈ´Ù.

       MC´Â µÎ°¡Áö transformÀÇ ÃÑÇÕÀÌ´Ù.

         XGL_CTX_LOCAL_MODEL_TRANS

         XGL_CTX_GLOBAL_MODEL_TRANS

       ¸ðµç renderµÈ primitiveµéÀº WC¿Í °ü·ÃµÈ´Ù.

       view´Â view transformÀ» Àû¿ëÇÔ¿¡ÀÇÇØ º¯°æµÉ¼ö ÀÖ´Ù.

          XGL_CTX_VIEW_TRANS

       transformµéÀº ´ÙÀ½À¸·Î ¸¸µé¾îÁø xgl objectÀÌ´Ù.

       transform operatorµéÀº ratation,scaling,translationÀ» Æ÷ÇÔÇÑ´Ù.

  13. 3D rendering

        xgl_multimarker()

        xgl_multipolyline()

        xgl_multi_simple_polygon()

        xgl_polygon()

        xgl_quadrilateral_mesh()

        xgl_triangle_strip()

        xgl_stroke_text_3d()

        xgl_nu_bspline_curve()

      Àü¸é°ú ÈĸéÀ» ±¸º°ÇϱâÀ§Çؼ­´Â ´ÙÀ½À» »ç¿ëÇÏ¿©¾ß ÇÑ´Ù.

        XGL_3D_CTX_SURF_FACE_DISTINGUISH

      Àü¸é°ú ÈĸéÀº ´Ù¸¥ »ö»óÀ» °¡Áú¼ö ÀÖ´Ù.

        XGL_CTX_SURF_FRONT_COLOR

        XGL_3D_CTX_SURF_BACK_COLOR

       polygonÀÇ Ç¥¸éÀº facet Á¤º¸·Î ±ÔÁ¤µÉ¼ö ÀÖ´Ù.

        XGL_FACET_NONE

        XGL_FACET_COLOR

        XGL_FACET_NORMAL

        XGL_FACET_COLOR_NORMAL

       NormalÀº Ç¥¸éÀÇ Àü¸éÀ» Á¤ÀÇÇÏ´Â vector °ªÀ¸·Î Á¤Àǵɼö ÀÖ´Ù.

        typedef struct {

             Xgl_pt_f3d  normal;
    
         } Xgl_normal_facet;

       3D viewingÀº view volume( window )ÀÇ zÃàÀÌ ¾Æ·¡·ÎÇؼ­ ¹ß»ýµÈ´Ù.

       view windowÀÇ ¹æÀ§´Â GL_CTX_VDC_ORIENTATION·Î¼­ º¯°æµÉ¼ö ÀÖ´Ù.

       view¸¦ ȸÀüÇϱâÀ§Çؼ­´Â view volume orignÀÌ º¯ÇüµÈ´Ù.

  14. Lighting

      light sourceÀÇ Á¾·ù´Â ´ÙÀ½°ú °°´Ù.

       - directional 

       - spot 

       - positional

       - ambient

       ( page 9 -2 ÀÇ ±×¸² )

      light source´Â context·Î ¿¬°áµÈ objectÀÌ´Ù.

         XGL_3D_CTX_LIGHT_NUM

         XGL_3D_CTX_LIGHTS

       »õ·Î¿î light objectµéÀº Xgl_light  xgl_light_create() ·Î¼­ ¸¸µé¾îÁø´Ù.

       light object ¼Ó¼ºµéÀº ´ÙÀ½°ú °°´Ù.

         - XGL_LIGHT_TYPE

           XGL_LIGHT_COLOR

           XGL_LIGHT_ATTENUATION_1

           XGL_LIGHT_DIRECTION

           XGL_LIGHT_POSITION

           XGL_LIGHT_SPOT_ANGLE

           XGL_LIGHT_SPOT_EXPONENT

         light source´Â ´ÙÀ½¿¡ÀÇÇØ ÄÑÁö°í ²¨Áú¼ö ÀÖ´Ù.

           XGL_3D_CTX_LIGHT_SWITCHES

         Ç¥¸éÀÇ ¹Ý»ç ÇüÅ´ ´ÙÀ½°ú °°´Ù.

         - diffuse

         - specular

         - ambient

         ( page 9-4 ÂüÁ¶ )

         contextÀº Ç¥¸éÀ» renderingÇϱâÀ§ÇØ Àû¿ëµÇ´Â ¼Ó¼ºÀÌ´Ù.

            XGL_3D_CTX_SURF_FRONT_AMBIENT

            XGL_3D_CTX_SURF_FRONT_DIFFUSE

            XGL_3D_CTX_SURF_FRONT_SPECULAR

            XGL_3D_CTX_SURF_FRONT_SPECULAR_COLOR

            XGL_3D_CTX_SURF_FRONT_SPECULAR_POWER

            XGL_3D_CTX_SURF_FRONT_LIGHT_COMPONENT
      
  15. sliding

      ¿©±â¿¡´Â ¼¼°¡Áö ÇüÅÂ,Áï Á¶¸éÀÌ ¾ø´Â »óÅÂ¿Í facet,vertexÀÇ À¯ÇüÀÌ ÀÖ´Ù.

         XGL_3D_CTX_SURF_FRONT_ILLUMINATION

      indexµÈ colorÀ» »ç¿ëÇÒ¶§,color rampµéÀº sadingÀ» Çϴµ¥ »ç¿ëµÈ´Ù.

         XGL_CMAP_RAMP_NUM

         XGL_CMAP_RAMP_LIST

      shadeµÇ´Â °¢°¢ÀÇ Ç¥¸éÀº normal°ú color index¸¦ °¡Á®¾ß¸¸ ÇÑ´Ù.



Revision History
Created                  on 13 Nov , 1992