Japanese

ListReference

function

slPutPolygon


drawing polygons

Format

    #include "sgl.h"

    PDATA *pol;

    Bool slPutPolygon( pol );

argument

    PDATA *pol - Pointer to a PDATA structure containing the polygon data to display.

Return number

    Bool - Error code (described below).

function

Rotate and translate the given polygon model using the current matrix, Performs perspective transformation and displays as polygons and deformed sprites.
If the maximum number of polygons or vertices is exceeded, an error code ' FALSE ' will be 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
 MXPolygons
 FrameSizeX
 FrameSizeY
 MsWinXAdder
 MsWinYAdder
 MsClipXAdder
 MsClipYAdder
 DispPolygons
 DMAEndFlag
 DMASetFlag
 Put Count
 Resolution 



ListReference

function

slPutPolygonS


drawing polygons

Format

    #include "sgl.h"

    PDATA *pol;

    Bool slPutPolygonS( pol );

argument

    PDATA *pol - Pointer to a PDATA structure containing the polygon data to display.

Return number

    Bool - Error code (described below).

function

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

example

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

Note

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

reference

 slPutPolygon
 slPutPolygonX
 slDispPolygon
 slWindow
 slZdspLevel
 slLight
 slPutObject
 SlPbufPtr
 SpritePtr
 ComWrPtr
 ComRdPtr
 SlScreenDist
 WinUseFlag
 TotalPolygons
 Total Vertices
 MXPolygons
 FrameSizeX
 FrameSizeY
 SlWinXAdder
 SlWinYAdder
 SlClipXAdder
 SlClipYAdder
 SlZlimit
 DispPolygons
 DMAEndFlag
 DMASetFlag
 Put Count 



ListReference

function

slDispPolygon


Drawing polygons by orthographic projection

Format

    #include "sgl.h"

    PDATA *pol;
    Uint16 mode;

    Bool slDispPolygon( PDATA *pat , Uint16 mode)

argument

    PDATA *pol - Model data
Uint16 mode - Flag (described later).

Return number

    Bool - Error code (described below).

function

Rotates and translates the given polygon model using the current matrix, and displays the polygons and deformed sprites in orthographic projection.
However, options such as light source calculation and clipping cannot be used.
mode is a flag indicating whether the attribute is shared by all polygons, When set to 0, each polygon is displayed using the data at the beginning of the attribute table. Otherwise, the specified attribute data will be displayed.
If the maximum number of polygons or vertices is exceeded, an error code ' FALSE ' will be returned.

example

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

Note

This function does not perform perspective transformations on polygons. Therefore, slPutPolygon Processing is slightly lighter than .

reference

 slPutPolygon
 slPutPolygonS
 slPutPolygonX
 slWindow
 slZdspLevel
 slLight
 slPutObject
 MsPbufPtr
 SlPbufPtr
 SpritePtr
 ComWrPtr
 ComRdPtr
 WinUseFlag
 TotalPolygons
 Total Vertices
 MXPolygons
 DispPolygons
 DMAEndFlag
 DMASetFlag
 Put Count 



ListReference

function

slPutObject


drawing objects

Format

    #include "sgl.h"

    OBJECT *obj;

    Bool slPutObject( obj );

argument

    OBJECT *obj - model data.

Return number

    Bool - error code.

function

Displays a polygon model with the specified translation, rotation, and scaling in the specified object structure. This function produces 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

    Sample program for displaying according to parent-child structure void PutAll( OBJECT * obptr ) {
        slPushMatrix (); /* Save parent matrix */
        {
          slPutObject ( obptr ); /* Display object */
          if ( obptr->child != NULL ) {
            PutAll( obptr->child ); /* Display if there are children */
          }
        }
        slPopMatrix ();

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

Note

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

reference

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



ListReference

function

slInitGouraud


Declaration of use of real-time Gouraud

Format

    #include "sgl.h"

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

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

argument

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

Return number

    void - returns nothing.

function

Initializes real-time Gouraud shading processing.
The Gouro data storage area requires 8 bytes x the maximum number of Gouro polygons.
The vertex calculation work address requires the maximum number of bytes for one model.
The Gouraud table address is the address that sets the Gouraud table in VDP1.
Specify VDP1 offset address/8. (This is the same method as the Gouraud address for 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 Gouro



ListReference

function

slPutPolygonX


Draw polygons with real-time Gouraud

Format

    #include "sgl.h"

    XPDATA *pol;
    FIXED *lgt;

    void slPutPolygonX( pol, lgt );

argument

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

Return number

    void - returns nothing.

function

Outputs model data.
Polygons for which UseGouraud is not specified are also output correctly.

example

    extern XPDATA polygons[];

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

Note

Before executing this function, it must be initialized with the slInitGouraud 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
 Put Count 



ListReference

function

slGouraudTblCopy


Copy of Gouraud table

Format

    #include "sgl.h"

    void slGouraudTblCopy( void )

argument

    void - gives nothing.

Return number

    void - returns nothing.

function

Transfer the Gouraud data calculated by the library to VRAM.
Usually, it is transferred during V-Blank using slIntFunction etc.

example

    slIntFunction ( slGouraudTblCopy );

    while( -1 ) {
          :
      slSynch
    }

Note

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

reference

 slSynch
 slIntFunction
 slInitGouraud
 slSetGouraudTbl
 slPutPolygonX
 slSetGouraudColor 



ListReference

function

slSetGouraudTbl


Setting up a user-defined Gouraud table

Format

    #include "sgl.h"

    Uint16 *tbl;

    void slSetGouraudTbl( tbl );

argument

    void - gives nothing.

Return number

    void - returns nothing.

function

Set up your own Gouraud table.
Specify in 32 steps from the darkest value on the opposite side of the light source to the brightest value in front 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 Gouraud

Format

    #include "sgl.h"

    Uint16 col;

    void slSetGouraudColor( col );

argument

    Uint16 col - Light color.

Return number

    void - returns nothing.

function

Set the light source color for real-time Gouraud.
The settings of the slSetGouraudTbl function are 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


Environment ray vector settings

Format

    #include "sgl.h"

    VECTOR light;

    void slLight( light );

argument

    VECTOR light - vector of light rays.

Return number

    void - returns nothing.

function

Sets the direction of the light source.

example

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

Note

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

reference

 slPutPolygon
 slPutPolygonS
 slPutPolygonX
 slDispPolygon
 slPutObject
 ComWrPtr
 ComRdPtr
 MsLightVector 



ListReference

function

slSetFlatColor


Setting the light source color for flat shading

Format

    #include "sgl.h"

    Uint16 col;

    void slSetFlatColor( col );

argument

    Uint16 col - Light color.

Return number

    void - returns nothing.

function

Set the light source color of the normal light source. ( UseLight light source)

example

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

reference

 slPutPolygon
 slPutPolygonS
 slDispPolygon
 slPutObject 



ListReference

function

slSetAmbient


Setting the ambient light color

Format

    #include "sgl.h"

    Uint16 col;

    void slSetAmbient( col );

argument

    Uint16 col - Environment color.

Return number

    void - returns nothing.

function

Set the lowest line for light source calculation as the ambient light.
This setting affects the slSetGouraudColor and slSetFlatColor functions.
After making this setting, be sure to set the light source color.
col changes from 15 to -16 for RGB as standard, but for example with this function R = -10, G = -5, B = 0 If you set it like this, R will change from 15 to -10, and -10 will be set for the table that should normally be up to -16.
In other words, of the 32 levels, the lowest 6 levels will be inherited.
This setting prevents the light from becoming too dark than the specified value, and sets it as the ambient light.

example

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

Note

For tables set directly with the slSetGouraudTbl function, It becomes invalid.

reference

 slSetGouraudColor
 slSetFlatColor
 slInitGouraud 


★ Clipping



ListReference

function

slSetNearClipFlag


Vertex correction settings for near clipping

Format

    #include "sgl.h"

    Uint32 flag;

    void slSetNearClipFlag( flag );

argument

    Uint32 flag - Near clipping flag (described below).

Return number

    void - returns nothing.

function

Set whether to perform vertex correction for near clipping. The initial value is to perform vertex correction.
The flag contains the following parameters.
0: No correction 1: Correction (initial value)

example

    slSetNearClipFlag ( 0 );

Note

For games that do not use near clips, selecting 0 (no correction) will Computation speed can be improved.

reference

 slWindowClipLevel
 ComWrPtr
 ComRdPtr 



ListReference

function

slWindowClipLevel


Setting the near clipping level

Format

    #include "sgl.h"

    Sint32 level;

    void slWindowClipLevel( level );

argument

    Sint32 level - Clipping value (described below).

Return number

    void - returns nothing.

function

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

example

    slWindowClipLevel ( 37 );

reference

 slSetNearClipFlag
 ComWrPtr
 ComRdPtr 


★Depth Cue (Real Time Gouro)



ListReference

function

slSetDepthLimit


Setting the depth cue range

Format

    #include "sgl.h"

    Uint32 near;
    Uint16 depth;
    Uint16 step;

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

argument

    Uint32 near - Near position
    Uint16 depth - Depth (power of 2)
    Uint16 step - step (power of 2)

Return number

    void - returns nothing.

function

Set the range for depth cue.
Set the range from the near position to the depth (not FIXED ) in the step stage.
Please set the multiplier for the depth and step values.
For example, setting 5 will actually be treated as 32.

example

    slSetDepthLimit ( 50, 5, 2 );

reference

 slInitGouraud
 slPutPolygonX
 slSetDepthTbl 



ListReference

function

slSetDepthTbl


Depth cue table settings

Format

    #include "sgl.h"

    Uint16 *tbl;
    Uint16 *addr_A;
    Uint16 size;

    void slSetDepthTbl( tbl, addr_A, size );

argument

    Uint16 *tbl - Gouraud table for depth cue.
Uint16 *addr_A - Gouraud table (absolute) address.
Uint16 size - table size.

Return number

    void - returns nothing.

function

Set up the table for depth cue.
Prepare the Gouraud table in several stages, and set the data from the front to the back.
Gouraud address gaddr is the address to be set in VDP1.
Make sure that 2 raised to the step power is the same as size.
The Gouraud area on VRAM requires four times the area of the Gouraud table.

example

    The Gouraud table, which 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


Setting the polygon front/back detection level

Format

    #include "sgl.h"

    Sint32 level;

    void slDispPlaneLevel( level );

argument

    Sint32 level - Level of polygon front/back detection (initial value 0)

Return number

    void - returns nothing.

function

Set the level for determining whether the polygon is front or back.
If set to a positive value, it will draw further to the back side.
If set to a negative value, only the front side will be drawn.

example

    slDispPlaneLevel ( -10 );

reference

 slPutPolygon
 slPutPolygonS
 slDispPolygon
 slPutObject
 slPutPolygonX

return
Copyright SEGA ENTERPRISES, LTD., 1997