#include "sgl.h"
PDATA *pol;
Bool slPutPolygon( pol );
PDATA *pol - Pointer to a PDATA structure containing the polygon data to display.
Bool - Error code (described below).
slPushMatrix ();
{
slTranslate ( pos[ X ], pos[ Y ], pos[ Z ] );
slRotX ( ang[ X ] );
slRotY ( ang[ Y ] );
slRotZ ( ang[ Z ] );
slPutPolygon ( &polygons );
:
#include "sgl.h"
PDATA *pol;
Bool slPutPolygonS( pol );
PDATA *pol - Pointer to a PDATA structure containing the polygon data to display.
Bool - Error code (described below).
slPushMatrix ();
{
slTranslate ( pos[ X ], pos[ Y ], pos[ Z ] );
slRotX ( ang[ X ] );
slRotY ( ang[ Y ] );
slRotZ ( ang[ Z ] );
slPutPolygonS ( &polygons );
}
slPopMatrix ();
#include "sgl.h"
PDATA *pol;
Uint16 mode;
Bool slDispPolygon( PDATA *pat , Uint16 mode)
PDATA *pol - Model data
Uint16 mode - Flag (described later).
Bool - Error code (described below).
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 ();
#include "sgl.h"
OBJECT *obj;
Bool slPutObject( obj );
OBJECT *obj - model data.
Bool - error code.
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 );
}
}
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 */
}
}
slPutPolygon | slPutPolygonS | slPutPolygonX | slWindow |
slZdspLevel | slLight | slDispPolygon | SlPbufPtr |
SpritePtr | ComWrPtr | ComRdPtr | DispPolygons |
DMAEndFlag | DMASetFlag | Put Count |
#include "sgl.h"
GOURAUDTBL *tbl;
Uint32 max;
Uint32 *gaddr_A;
Uint8 *vaddr_A;
void slInitGouraud( tbl, max, gaddr_A, vaddr_A );
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.
void - returns nothing.
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 );
slPutPolygonX | slGouraudTblCopy | slSetGouraudTbl | slSetGouraudColor |
slSetFlatColor | slSetAmbient | slSetNearClipFlag | slWindowClipLevel |
slSetDepthLimit | slSetDepthTbl | slDispPlaneLevel |
#include "sgl.h"
XPDATA *pol;
FIXED *lgt;
void slPutPolygonX( pol, lgt );
XPDATA *pol - model data.
FIXED *lgt - Light source vector.
void - returns nothing.
extern XPDATA polygons[];
slPushMatrix ();
{
slTranslate ( pos[ X ], pos[ Y ], pos[ Z ] );
slRotX ( ang[ X ] );
slRotY ( ang[ Y ] );
slRotZ ( ang[ Z ] );
slPutPolygonX ( polygons );
}
slPopMatrix ();
#include "sgl.h"
void slGouraudTblCopy( void )
void - gives nothing.
void - returns nothing.
slIntFunction ( slGouraudTblCopy );
while( -1 ) {
:
slSynch
}
slSynch | slIntFunction | slInitGouraud | slSetGouraudTbl |
slPutPolygonX | slSetGouraudColor |
#include "sgl.h"
Uint16 *tbl;
void slSetGouraudTbl( tbl );
void - gives nothing.
void - returns nothing.
#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 );
slInitGouraud | slGouraudTblCopy | slSetGouraudTbl | slPutPolygonX |
slSetGouraudColor |
#include "sgl.h"
Uint16 col;
void slSetGouraudColor( col );
Uint16 col - Light color.
void - returns nothing.
Uint16 gr_data;
gr_data = (((b&0x1f)<<10) | ((g&0x1f)<<5) | (r&0x1f) )
slSetGouraudColor ( gr_data );
slInitGouraud | slGouraudTblCopy | slSetGouraudTbl | slPutPolygonX |
slSetGouraudColor |
#include "sgl.h"
VECTOR light;
void slLight( light );
VECTOR light - vector of light rays.
void - returns nothing.
VECTOR vec = { toFIXED ( 0.05 ), toFIXED ( 0.07 ), toFIXED ( 0.65 ) };
slLight ( vec );
slPutPolygon | slPutPolygonS | slPutPolygonX | slDispPolygon |
slPutObject | ComWrPtr | ComRdPtr | MsLightVector |
#include "sgl.h"
Uint16 col;
void slSetFlatColor( col );
Uint16 col - Light color.
void - returns nothing.
slSetFlatColor ( C_RGB ( 0, 5, 2 ) );
slPutPolygon | slPutPolygonS | slDispPolygon | slPutObject |
#include "sgl.h"
Uint16 col;
void slSetAmbient( col );
Uint16 col - Environment color.
void - returns nothing.
slSetAmbient ( C_RGB ( 1, 1, 1 ) );
slSetGouraudColor | slSetFlatColor | slInitGouraud |
#include "sgl.h"
Uint32 flag;
void slSetNearClipFlag( flag );
Uint32 flag - Near clipping flag (described below).
void - returns nothing.
slSetNearClipFlag ( 0 );
slWindowClipLevel | ComWrPtr | ComRdPtr |
#include "sgl.h"
Sint32 level;
void slWindowClipLevel( level );
Sint32 level - Clipping value (described below).
void - returns nothing.
slWindowClipLevel ( 37 );
slSetNearClipFlag | ComWrPtr | ComRdPtr |
#include "sgl.h"
Uint32 near;
Uint16 depth;
Uint16 step;
void slSetDepthLimit( Uint32 near, Uint16 depth, Uint16 step )
Uint32 near - Near position
Uint16 depth - Depth (power of 2)
Uint16 step - step (power of 2)
void - returns nothing.
slSetDepthLimit ( 50, 5, 2 );
slInitGouraud | slPutPolygonX | slSetDepthTbl |
#include "sgl.h"
Uint16 *tbl;
Uint16 *addr_A;
Uint16 size;
void slSetDepthTbl( tbl, addr_A, size );
Uint16 *tbl - Gouraud table for depth cue.
Uint16 *addr_A - Gouraud table (absolute) address.
Uint16 size - table size.
void - returns nothing.
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 );
slInitGouraud | slPutPolygonX | slSetDepthLimit | ComWrPtr |
ComRdPtr |
#include "sgl.h"
Sint32 level;
void slDispPlaneLevel( level );
Sint32 level - Level of polygon front/back detection (initial value 0)
void - returns nothing.
slDispPlaneLevel ( -10 );
slPutPolygon | slPutPolygonS | slDispPolygon | slPutObject |
slPutPolygonX |