Basic Points for Kamui 2 conversion
While not trying to be a full programming guide, this document should help to overcome some basic pitfalls is converting a Kamui application to use Kamui2.
Added Initialisation
An extra initialisation function "kmInitDevice()" must be called after "syHwInit();" as below.
syHwInit();
syMallocInit(HEAP_AREA, HEAP_SIZE);
kmInitDevice(KM_DREAMCAST);
Changes to the KMSYSTEMCONFIGSTRUCT type
typedef struct _tagKMSYSTEMCONFIGSTRUCT {
KMDWORD dwSize; /* Size Of KMSYSTEMCONFIGSTRUCT */
KMDWORD flags; /* System Configuration Flags */
/* for Frame Buffer */
PPKMSURFACEDESC ppSurfaceDescArray; /* Array of SurfaceDesc Pointer */
struct{
KMUINT32 nNumOfFrameBuffer;/* Number Of Frame Buffer*/
KMUINT32 nStripBufferHeight;/*Height of Strip Buffer*/
}fb;
/* for Texture Memory*/
KMUINT32 nTextureMemorySize;/* Texture Memory size */
KMUINT32 nNumOfTextureStruct;/*number of TextureStructure */
KMUINT32 nNumOfSmallVQStruct;
PKMDWORD pTextureWork;/* Pointer to kamui work area*/
/* for Vertex Buffer */
PKMVERTEXBUFFDESC pBufferDesc;/* pointer to KMVERTEXBUFFDESC */
KMUINT32 nNumOfVertexBank; /* Number of VertexBank */
PKMDWORD pVertexBuffer;/* VertexBuffer Pointer*/
KMUINT32 nVertexBufferSize;/* VertexBuffer Size*/
KMUINT32 nPassDepth; /* Path Depth */
KMPASSINFO Pass[KM_MAX_DISPLAY_LIST_PASS];/*Pass Information*/
} KMSYSTEMCONFIGSTRUCT, *PKMSYSTEMCONFIGSTRUCT;
Please refer to the samples in the Kamui2 directory for further details.
VertexContexts have been replaced
KMSTRIPCONTEXT strip_context;
KMSTRIPHEAD strip_head;
Instead of kmProcessVertexRenderState, Kamui2 uses kmGenerateStripHeadXX() for the required vertex type. (XX being replaced with the type number) An example of this is below.
pStripContext->nSize = sizeof(KMSTRIPCONTEXT);
pStripContext->StripControl.nListType = KM_OPAQUE_POLYGON;
pStripContext->StripControl.nUserClipMode = KM_USERCLIP_DISABLE;
pStripContext->StripControl.nShadowMode = KM_NORMAL_POLYGON;
pStripContext->StripControl.bOffset = KM_FALSE;
pStripContext->StripControl.bGouraud = KM_TRUE;
pStripContext->ObjectControl.nDepthCompare = KM_GREATER;
pStripContext->ObjectControl.nCullingMode = KM_CULLSMALL;
pStripContext->ObjectControl.bZWriteDisable = KM_FALSE;
pStripContext->ObjectControl.bDCalcControl = KM_FALSE;
pStripContext->ImageControl[KM_IMAGE_PARAM1].nSRCBlendingMode = KM_ONE;
pStripContext->ImageControl[KM_IMAGE_PARAM1].nDSTBlendingMode = KM_ZERO;
pStripContext->ImageControl[KM_IMAGE_PARAM1].bSRCSelect = KM_FALSE;
pStripContext->ImageControl[KM_IMAGE_PARAM1].bDSTSelect = KM_FALSE;
pStripContext->ImageControl[KM_IMAGE_PARAM1].nFogMode = KM_NOFOG;
pStripContext->ImageControl[KM_IMAGE_PARAM1].bColorClamp = KM_FALSE;
pStripContext->ImageControl[KM_IMAGE_PARAM1].bUseAlpha = KM_FALSE;
pStripContext->ImageControl[KM_IMAGE_PARAM1].bIgnoreTextureAlpha = KM_FALSE;
pStripContext->ImageControl[KM_IMAGE_PARAM1].nFlipUV = KM_NOFLIP;
pStripContext->ImageControl[KM_IMAGE_PARAM1].nClampUV = KM_NOCLAMP;
pStripContext->ImageControl[KM_IMAGE_PARAM1].nFilterMode = KM_BILINEAR;
pStripContext->ImageControl[KM_IMAGE_PARAM1].bSuperSampleMode = KM_FALSE;
pStripContext->ImageControl[KM_IMAGE_PARAM1].dwMipmapAdjust = KM_MIPMAP_D_ADJUST_1_00;
pStripContext->ImageControl[KM_IMAGE_PARAM1].nTextureShadingMode = KM_MODULATE;
pStripContext->ImageControl[KM_IMAGE_PARAM1].pTextureSurfaceDesc=pTextureDesc;
kmGenerateStripHead03( pStripHead,pStripContext );
The generated StripHead is then used when calling kmStartStrip() as a second parameter like this. (When used with Macros)
kmxxGetCurrentPtr(&vertex_buffer_desc);
kmxxStartStrip(&vertex_buffer_desc,&strip_head);
Scene and MultiPass handling
The flow and functions required are shown below.
kmBeginScene(&SystemConfig);
kmBeginPass(&vertex_buffer_desc);
kmxxGetCurrentPtr(&vertex_buffer_desc);
kmxxStartStrip(&vertex_buffer_desc,&strip_head);
SET VERTEX
kmxxReleaseCurrentPtr(&vertex_buffer_desc);
kmEndPass(&vertex_buffer_desc);
kmRender(KM_RENDER_FLIP);
kmEndScene(&SystemConfig);
Reduced parameters for kmLoadTexture()
kmLoadTexture( pTexSurfaceDesc , pTexture )
KmChangeStripXXXXXXX() function set
These functions allow you to change a parameter of an already generated StripHead without regenerating. This function set includes kmChangeStripTextureSurface() whereas Kamui 1 had no equivalent function.