#include "sgl.h"
PDATA * pol;
Bool slPutPolygon (pol);
PDATA * pol-A pointer to the PDATA structure that contains the polygon data to display.
Bool --Error code (see below).
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.
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-A pointer to the PDATA structure that contains the polygon data to display.
Bool --Error code (see below).
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.
slPushMatrix ();
{
slTranslate (pos [ X ], pos [ Y ], pos [ Z ]);
slRotX (ang [ X ]);
slRotY (ang [ Y ]);
slRotZ (ang [ Z ]);
slPutPolygonS (& polygons);
}
slPopMatrix ();
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.
#include "sgl.h"
PDATA * pol;
Uint16 mode;
Bool slDispPolygon ( PDATA * pat, Uint16 mode)
PDATA * pol --Model data Uint16 mode --Flag (see below).
Bool --Error code (see below).
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.
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 ();
This function does a fluoroscopic transformation of polygons. Therefore, slPutPolygon
The processing is slightly lighter than.
#include "sgl.h"
OBJECT * obj;
Bool slPutObject (obj);
OBJECT * obj --Model data.
Bool --Error code.
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);
}
}
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 * /
}
}
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.
slPutPolygon | slPutPolygonS | slPutPolygonX | slWindow |
slZdspLevel | slLight | slDispPolygon | SlPbufPtr |
SpritePtr | ComWrPtr | ComRdPtr | DispPolygons |
DMAEndFlag | DMASetFlag | PutCount |
#include "sgl.h"
GOURAUDTBL * tbl;
Uint32 max;
Uint32 * gaddr_A;
Uint8 * vaddr_A;
void slInitGouraud (tbl, max, gaddr_A, vaddr_A);
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.
void --Nothing is returned.
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)
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 --Nothing is returned.
Outputs model data.
Polygons for which Use Gouraud is not specified as an option are also output normally.
extern XPDATA polygons [];
slPushMatrix ();
{
slTranslate (pos [ X ], pos [ Y ], pos [ Z ]);
slRotX (ang [ X ]);
slRotY (ang [ Y ]);
slRotZ (ang [ Z ]);
slPutPolygonX (polygons);
}
slPopMatrix ();
It must be initialized with the slInitGouraud function before executing this function.
#include "sgl.h"
void slGouraudTblCopy (void)
void --Do not give anything.
void --Nothing is returned.
Transfer the goo data calculated in the library to VRAM.
Normally, it is transferred during V-Blank using slIntFunction or the like.
slIntFunction ( slGouraudTblCopy );
while (-1) {
::
slSynch
}
Be sure to use this function when using real-time gouro with slPutPolygonX.
slSynch | slIntFunction | slInitGouraud | slSetGouraudTbl |
slPutPolygonX | slSetGouraudColor |
#include "sgl.h"
Uint16 * tbl;
void slSetGouraudTbl (tbl);
void --Do not give anything.
void --Nothing is returned.
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.
#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 source color.
void --Nothing is returned.
Set the light source color for real-time gourd.
The setting of the slSetGouraudTbl function is ignored.
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-a vector of rays.
void --Nothing is returned.
Sets the direction of the light source.
VECTOR vec = { toFIXED (0.05), toFIXED (0.07), toFIXED (0.65)};
slLight (vec);
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.
slPutPolygon | slPutPolygonS | slPutPolygonX | slDispPolygon |
slPutObject | ComWrPtr | ComRdPtr | MsLightVector |
#include "sgl.h"
Uint16 col;
void slSetFlatColor (col);
Uint16 col --Light source color.
void --Nothing is returned.
Sets the light source color of the normal light source. ( Use Light light source)
slSetFlatColor ( C_RGB (0, 5, 2));
slPutPolygon | slPutPolygonS | slDispPolygon | slPutObject |
#include "sgl.h"
Uint16 col;
void slSetAmbient (col);
Uint16 col --Environmental color.
void --Nothing is returned.
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.
slSetAmbient ( C_RGB (1, 1, 1));
For the table set directly with the slSetGouraudTbl function,
It will be invalid.
slSetGouraudColor | slSetFlatColor | slInitGouraud |
#include "sgl.h"
Uint32 flag;
void slSetNearClipFlag (flag);
Uint32 flag --Near clipping flag (see below).
void --Nothing is returned.
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)
slSetNearClipFlag (0);
For games that do not use near clips, you can select 0 (no correction) to
You can improve the calculation speed.
slWindowClipLevel | ComWrPtr | ComRdPtr |
#include "sgl.h"
Sint32 level;
void slWindowClipLevel (level);
Sint32 level --Clipping value (see below).
void --Nothing is returned.
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.
slWindowClipLevel (37);
slSetNearClipFlag | ComWrPtr | ComRdPtr |
#include "sgl.h"
Uint32 near;
Uint16 depth;
Uint16 step;
void slSetDepthLimit ( Uint32 near, Uint16 depth, Uint16 step)
Uint32 near --Foreground position Uint16 depth --Depth (multiplier of 2)
Uint16 step-Step (multiplier of 2)
void --Nothing is returned.
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.
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 --Glow table for depth skew.
Uint16 * addr_A --Glow table (absolute) address.
Uint16 size --Table size.
void --Nothing is returned.
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.
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);
slInitGouraud | slPutPolygonX | slSetDepthLimit | ComWrPtr |
ComRdPtr |
#include "sgl.h"
Sint32 level;
void slDispPlaneLevel (level);
Sint32 level --Polygon front and back judgment level (initial value 0)
void --Nothing is returned.
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.
slDispPlaneLevel (-10);
slPutPolygon | slPutPolygonS | slDispPolygon | slPutObject |
slPutPolygonX |