ListReference

function

slPutPolygon


Drawing polygons

Form

    #include "sgl.h"

    PDATA * pol;

    Bool slPutPolygon (pol);

argument

    PDATA * pol-A pointer to the PDATA structure that contains the polygon data to display.

Number of returns

    Bool --Error code (see below).

function

    Rotate and translate a given polygon model using the current matrix,
    Performs perspective transformation and displays as polygons and deformed sprites.
If the maximum number of polygons or the maximum number of vertices is exceeded, the error code'FALSE'is returned.

Example

    slPushMatrix ();
    {
      slTranslate (pos [ X ], pos [ Y ], pos [ Z ]);
      slRotX (ang [ X ]);
      slRotY (ang [ Y ]);
      slRotZ (ang [ Z ]);
      slPutPolygon (& polygons);
                  ::

reference

 slPutPolygonS
 slPutPolygonX
 slDispPolygon
 slWindow
 slZdspLevel
 slLight
 slPutObject
 MsPbufPtr
 SlPbufPtr
 SpritePtr
 ComWrPtr
 ComRdPtr
 MsLightVector
 ColorOffset
 MsScreenDist
 MsZlimit
 WinUseFlag
 TotalPolygons
 TotalVertices
 MsWindowSizeX
 MsWindowSizeY
 MX Polygons
 FrameSizeX
 FrameSizeY
 MsWinXAdder
 MsWinYAdder
 MsClipXAdder
 MsClipYAdder
 DispPolygons
 DMAEndFlag
 DMASetFlag
 PutCount
 Resolution 



ListReference

function

slPutPolygonS


Drawing polygons

Form

    #include "sgl.h"

    PDATA * pol;

    Bool slPutPolygonS (pol);

argument

    PDATA * pol-A pointer to the PDATA structure that contains the polygon data to display.

Number of returns

    Bool --Error code (see below).

function

    Rotate and translate a given polygon model using the current matrix,
    Performs perspective transformation and displays as polygons and deformed sprites.
If the maximum number of polygons or the maximum number of vertices is exceeded, the error code'FALSE'is returned.

Example

    slPushMatrix ();
    {
      slTranslate (pos [ X ], pos [ Y ], pos [ Z ]);
      slRotX (ang [ X ]);
      slRotY (ang [ Y ]);
      slRotZ (ang [ Z ]);
      slPutPolygonS (& polygons);
    }
    slPopMatrix ();

caution


    In slPutPolygon , processing is shared according to the status of the slave CPU and executed in parallel with the master CPU, but in this function, the slave CPU executes everything.

reference

 slPutPolygon
 slPutPolygonX
 slDispPolygon
 slWindow
 slZdspLevel
 slLight
 slPutObject
 SlPbufPtr
 SpritePtr
 ComWrPtr
 ComRdPtr
 SlScreenDist
 WinUseFlag
 TotalPolygons
 TotalVertices
 MX Polygons
 FrameSizeX
 FrameSizeY
 SlWinXAdder
 SlWinYAdder
 SlClipXAdder
 SlClipYAdder
 SlZlimit
 DispPolygons
 DMAEndFlag
 DMASetFlag
 PutCount 



ListReference

function

slDispPolygon


Drawing polygons by orthographic projection

Form

    #include "sgl.h"

    PDATA * pol;
    Uint16 mode;

    Bool slDispPolygon ( PDATA * pat, Uint16 mode)

argument

    PDATA * pol --Model data Uint16 mode --Flag (see below).

Number of returns

    Bool --Error code (see below).

function

    The given polygon model is rotated and translated using the current matrix, and the polygons and deformed sprites are displayed as they are in orthographic projection.
However, options such as light source calculation and clipping cannot be used.
mode is a flag that indicates whether all polygons share the attribute. When it is 0, each polygon is displayed in the first data of the attribute table. Otherwise, it will be displayed with the specified attribute data.
If the maximum number of polygons or the maximum number of vertices is exceeded, the error code'FALSE'is returned.

Example

    slPushMatrix ();
    {
      slTranslate (pos [ X ], pos [ Y ], pos [ Z ]);
      slRotX (ang [ X ]);
      slRotY (ang [ Y ]);
      slRotZ (ang [ Z ]);
      slDispPolygon (& polygon, 0); / * All polygon attributes are the same. * /
    }
    slPopMatrix ();    

caution


    This function does a fluoroscopic transformation of polygons. Therefore, slPutPolygon
    The processing is slightly lighter than.

reference

 slPutPolygon
 slPutPolygonS
 slPutPolygonX
 slWindow
 slZdspLevel
 slLight
 slPutObject
 MsPbufPtr
 SlPbufPtr
 SpritePtr
 ComWrPtr
 ComRdPtr
 WinUseFlag
 TotalPolygons
 TotalVertices
 MX Polygons
 DispPolygons
 DMAEndFlag
 DMASetFlag
 PutCount 



ListReference

function

slPutObject


Drawing an object

Form

    #include "sgl.h"

    OBJECT * obj;

    Bool slPutObject (obj);

argument

    OBJECT * obj --Model data.

Number of returns

    Bool --Error code.

function

    Displays the polygon model by translating, rotating, and scaling the specified object structure. This function has the same result as executing the following function.
void slPutObject ( OBJECT * objptr) { slTranslate (objptr-> pos [ X ], objptr-> pos [ Y ], objptr-> pos [ Z ]); slRotZ (objptr-> ang [ Z ]); slRotY (objptr-> ang [ Y ]); slRotX (objptr-> ang [ X ]); slScale (objptr-> scl [ X ], objptr-> scl [ Y ], objptr-> scl [ Z ]); if (objptr-> pat! = NULL ) { return slPutPolygon (objptr-> pat); } }

Example

    Display sample program according to parent-child structure void PutAll ( OBJECT * obptr) {
        slPushMatrix (); / * Save parent matrix * /
        {
          slPutObject (obptr); / * Display object * /
          if (obptr-> child! = NULL ) {
            PutAll (obptr-> child); / * Show if there is a child * /
          }
        }
        slPopMatrix ();

        if (obptr-> sibling! = NULL ) {
          PutAll (obptr-> sibling); / * Display sibling objects * /
        }
      }

caution


    This function changes the current matrix, so execute the slPushMatrix () function to save the matrix if necessary.
Also, use user functions to handle the parent-child relationship of objects.

reference

 slPutPolygon
 slPutPolygonS
 slPutPolygonX
 slWindow
 slZdspLevel
 slLight
 slDispPolygon
 SlPbufPtr
 SpritePtr
 ComWrPtr
 ComRdPtr
 DispPolygons
 DMAEndFlag
 DMASetFlag
 PutCount 



ListReference

function

slInitGouraud


Declaration of use of real-time goo-net

Form

    #include "sgl.h"

    GOURAUDTBL * tbl;
    Uint32 max;
    Uint32 * gaddr_A;
    Uint8 * vaddr_A;

    void slInitGouraud (tbl, max, gaddr_A, vaddr_A);

argument

    GOURAUDTBL * tbl --Gouraud data storage area.
Uint32 max-Maximum number of goo polygons.
Uint32 * gaddr_A --Gouraud table (absolute) address.
Uint8 * vaddr_A --Vertex operation work (absolute) address.

Number of returns

    void --Nothing is returned.

function

    Initializes the real-time Gouraud shading process.
The google data storage area requires a maximum number of google polygons x 8 bytes.
The vertex operation work address requires a maximum of several bytes per model.
The gourd table address is the address that sets the gourd table in VDP1.
Specify the VDP1 offset address / 8. (Same method as the goo address of model data)

Example

    When the total number of polygons is 500 and the maximum number of vertices per model is 100.
#define MAX_POLYGON 500 #define MAX_MODEL_VERT 100 #define GOURAUD_ADDR 0xE000 GOURAUDTBL GTBL [MAX_POLYGON]; Uint8 VTBL [MAX_MODEL_VERT]; slInitGouraud (GTBL, MAX_POLYGON, GOURAUD_ADDR, VTBL);

reference

 slPutPolygonX
 slGouraudTblCopy
 slSetGouraudTbl
 slSetGouraudColor
 slSetFlatColor
 slSetAmbient
 slSetNearClipFlag
 slWindowClipLevel
 slSetDepthLimit
 slSetDepthTbl
 slDispPlaneLevel 


★ Real-time goo



ListReference

function

slPutPolygonX


Draw polygons with real-time goo

Form

    #include "sgl.h"

    XPDATA * pol;
    FIXED * lgt;

    void slPutPolygonX (pol, lgt);

argument

    XPDATA * pol --Model data.
FIXED * lgt --Light source vector.

Number of returns

    void --Nothing is returned.

function

    Outputs model data.
Polygons for which Use Gouraud is not specified as an option are also output normally.

Example

    extern XPDATA polygons [];

    slPushMatrix ();
    {
      slTranslate (pos [ X ], pos [ Y ], pos [ Z ]);
      slRotX (ang [ X ]);
      slRotY (ang [ Y ]);
      slRotZ (ang [ Z ]);
      slPutPolygonX (polygons);
    }
    slPopMatrix ();

caution


    It must be initialized with the slInitGouraud function before executing this function.

reference

 slWindow
 slPutPolygon
 slPutPolygonS
 slDispPolygon
 slPutObject
 slPerspective
 slInitGouraud
 slGouraudTblCopy
 slSetGouraudTbl
 slSetGouraudColor
 slSetFlatColor
 slSetAmbient
 slSetNearClipFlag
 slWindowClipLevel
 slSetDepthLimit
 slSetDepthTbl
 slDispPlaneLevel
 SlPbufPtr
 ComWrPtr
 ComRdPtr
 SlClipXAdder
 SlClipYAdder
 SlZlimit
 DispPolygons
 DMAEndFlag
 DMASetFlag
 PutCount 



ListReference

function

slGouraudTblCopy


Copy of goo table

Form

    #include "sgl.h"

    void slGouraudTblCopy (void)

argument

    void --Do not give anything.

Number of returns

    void --Nothing is returned.

function

    Transfer the goo data calculated in the library to VRAM.
Normally, it is transferred during V-Blank using slIntFunction or the like.

Example

    slIntFunction ( slGouraudTblCopy );

    while (-1) {
          ::
      slSynch
    }

caution


    Be sure to use this function when using real-time gouro with slPutPolygonX.

reference

 slSynch
 slIntFunction
 slInitGouraud
 slSetGouraudTbl
 slPutPolygonX
 slSetGouraudColor 



ListReference

function

slSetGouraudTbl


User-defined gouro table settings

Form

    #include "sgl.h"

    Uint16 * tbl;

    void slSetGouraudTbl (tbl);

argument

    void --Do not give anything.

Number of returns

    void --Nothing is returned.

function

    Set the user's own gourd table.
Specify in 32 steps from the darkest value on the opposite side of the light source to the brightest value on the front side of the light source.

Example

    #define GRTBL (r, g, b) (((b & 0x1f) << 10) | ((g & 0x1f) << 5) | (r & 0x1f))
    static Uint16 GourTbl [32] = {
        GRTBL (0, 16, 16), GRTBL (1, 16, 16), GRTBL (2, 16, 16),
        GRTBL (3, 16, 16), GRTBL (4, 16, 16), GRTBL (5, 16, 16),
        GRTBL (6, 16, 16), GRTBL (7, 16, 16), GRTBL (8, 16, 16),
        GRTBL (9, 16, 16), GRTBL (10, 16, 16), GRTBL (11, 16, 16),
        GRTBL (12, 16, 16), GRTBL (13, 16, 16), GRTBL (14, 16, 16),
        GRTBL (15, 16, 16), GRTBL (16, 16, 16), GRTBL (17, 16, 16),
        GRTBL (18, 16, 16), GRTBL (19, 16, 16), GRTBL (20, 16, 16),
        GRTBL (21, 16, 16), GRTBL (22, 16, 16), GRTBL (23, 16, 16),
        GRTBL (24, 16, 16), GRTBL (25, 16, 16), GRTBL (26, 16, 16),
        GRTBL (27, 16, 16), GRTBL (28, 16, 16), GRTBL (29, 16, 16),
        GRTBL (30, 16, 16), GRTBL (31, 16, 16),
    };
    
    slSetGouraudTbl (GourTbl);

reference

 slInitGouraud
 slGouraudTblCopy
 slSetGouraudTbl
 slPutPolygonX
 slSetGouraudColor 



ListReference

function

slSetGouraudColor


Setting the light source color for real-time gouro

Form

    #include "sgl.h"

    Uint16 col;

    void slSetGouraudColor (col);

argument

    Uint16 col --Light source color.

Number of returns

    void --Nothing is returned.

function

    Set the light source color for real-time gourd.
The setting of the slSetGouraudTbl function is ignored.

Example

    Uint16 gr_data;

    gr_data = (((b & 0x1f) << 10) | ((g & 0x1f) << 5) | (r & 0x1f))
    slSetGouraudColor (gr_data);

reference

 slInitGouraud
 slGouraudTblCopy
 slSetGouraudTbl
 slPutPolygonX
 slSetGouraudColor 


★ Light source settings



ListReference

function

slLight


Setting the ambient ray vector

Form

    #include "sgl.h"

    VECTOR light;

    void slLight (light);

argument

    VECTOR light-a vector of rays.

Number of returns

    void --Nothing is returned.

function

    Sets the direction of the light source.

Example

    VECTOR vec = { toFIXED (0.05), toFIXED (0.07), toFIXED (0.65)};
    slLight (vec);

caution


    The light source is a parallel ray, representing only the direction, but the vector must be a unit vector. If the size exceeds 1, it will overflow and cannot be displayed correctly (it will be displayed in a strange color).
Also, if you use slScale () when displaying the model, the normals will be scaled as well, which may cause an overflow. Try not to scale.

reference

 slPutPolygon
 slPutPolygonS
 slPutPolygonX
 slDispPolygon
 slPutObject
 ComWrPtr
 ComRdPtr
 MsLightVector 



ListReference

function

slSetFlatColor


Light source color setting for flat shading

Form

    #include "sgl.h"

    Uint16 col;

    void slSetFlatColor (col);

argument

    Uint16 col --Light source color.

Number of returns

    void --Nothing is returned.

function

    Sets the light source color of the normal light source. ( Use Light light source)

Example

    slSetFlatColor ( C_RGB (0, 5, 2));

reference

 slPutPolygon
 slPutPolygonS
 slDispPolygon
 slPutObject 



ListReference

function

slSetAmbient


Environmental light source color setting

Form

    #include "sgl.h"

    Uint16 col;

    void slSetAmbient (col);

argument

    Uint16 col --Environmental color.

Number of returns

    void --Nothing is returned.

function

    Set the lowest line for light source calculation as ambient light.
This setting, SlSetGouraudColor function, SlSetFlatColor will affect the function.
Be sure to set the light source color after this setting.
By default, col changes from 15 to -16 for each of RGB, but for example, in this function, R = -10, G = -5, B = 0. If you set like, R will change from 15 to -10, and -10 will be set for the table that should be up to -16.
In other words, the lowest value is inherited in the lower 6 steps of 32 steps.
This setting will prevent it from becoming too darker than the specified value and will be set as ambient light.

Example

    slSetAmbient ( C_RGB (1, 1, 1));

caution


    For the table set directly with the slSetGouraudTbl function,
    It will be invalid.

reference

 slSetGouraudColor
 slSetFlatColor
 slInitGouraud 


★ Clipping



ListReference

function

slSetNearClipFlag


Near clipping vertex correction settings

Form

    #include "sgl.h"

    Uint32 flag;

    void slSetNearClipFlag (flag);

argument

    Uint32 flag --Near clipping flag (see below).

Number of returns

    void --Nothing is returned.

function

    Set whether to perform vertex correction for near clips. The initial value is to correct the vertices.
The flag contains the following parameters.
0: Do not correct 1: Correct (initial value)

Example

    slSetNearClipFlag (0);

caution


    For games that do not use near clips, you can select 0 (no correction) to
    You can improve the calculation speed.

reference

 slWindowClipLevel
 ComWrPtr
 ComRdPtr 



ListReference

function

slWindowClipLevel


Near clipping level setting

Form

    #include "sgl.h"

    Sint32 level;

    void slWindowClipLevel (level);

argument

    Sint32 level --Clipping value (see below).

Number of returns

    void --Nothing is returned.

function

    Polygons for which near clips are set are not displayed when all four points are off the screen. At this time, since all four points display polygons on the corners of the screen even outside the screen, they are slightly larger than the actual screen and are set to check clipping. Check larger than the screen by the amount set in level.
If you need to set it, a value of 20-50 seems to be the best.
Specify a numerical value outside the screen (initial value is 0).
0 is in the display screen. Negative numbers can also be set.

Example

    slWindowClipLevel (37);

reference

 slSetNearClipFlag
 ComWrPtr
 ComRdPtr 


★ Depskew (real-time goo-net)



ListReference

function

slSetDepthLimit


Setting the depth queue range

Form

    #include "sgl.h"

    Uint32 near;
    Uint16 depth;
    Uint16 step;

    void slSetDepthLimit ( Uint32 near, Uint16 depth, Uint16 step)

argument

    Uint32 near --Foreground position Uint16 depth --Depth (multiplier of 2)
    Uint16 step-Step (multiplier of 2)

Number of returns

    void --Nothing is returned.

function

    Sets the range for depth queuing.
Set the range from the near position to the depth (not FIXED ) in the step stage.
Set the multiplier for the depth and step values.
For example, if you set 5, it will actually be treated as 32.

Example

    slSetDepthLimit (50, 5, 2);

reference

 slInitGouraud
 slPutPolygonX
 slSetDepthTbl 



ListReference

function

slSetDepthTbl


Depth queue table settings

Form

    #include "sgl.h"

    Uint16 * tbl;
    Uint16 * addr_A;
    Uint16 size;

    void slSetDepthTbl (tbl, addr_A, size);

argument

    Uint16 * tbl --Glow table for depth skew.
Uint16 * addr_A --Glow table (absolute) address.
Uint16 size --Table size.

Number of returns

    void --Nothing is returned.

function

    Set up a table for depth skew.
Prepare the gourd table for the number of stages and set the data from the front to the back.
Gouraud address gaddr is the address to set in VDP1.
Make sure that the step power of 2 is the same as size.
The gourd area on VRAM requires four times as much area as the gourd table.

Example

    The gourd table that divides the distance from 100 to 1124 into 32 steps is set to 0xE000.
Uint16 depthtbl [32] = { ... }; slSetDepthLimit (100, 10, 5); slSetDepthTbl (depthtbl, 0xe000, 32);

reference

 slInitGouraud
 slPutPolygonX
 slSetDepthLimit
 ComWrPtr
 ComRdPtr 


★ Polygon settings



ListReference

function

slDispPlaneLevel


Polygon front and back judgment level setting

Form

    #include "sgl.h"

    Sint32 level;

    void slDispPlaneLevel (level);

argument

    Sint32 level --Polygon front and back judgment level (initial value 0)

Number of returns

    void --Nothing is returned.

function

    Set the level of front / back judgment of polygons.
When set to plus, it draws to the back side.
If set to minus, only the front side will be drawn.

Example

    slDispPlaneLevel (-10);

reference

 slPutPolygon
 slPutPolygonS
 slDispPolygon
 slPutObject
 slPutPolygonX

return
Copyright SEGA ENTERPRISES, LTD., 1997