Okay... in the above post I attempted to include the code.. but it didn't work out... I shall try again...
This is the main file:
#include "DarkSDK.h"
#include "..\..\SerenityInterface\CSerenity.h"
#include "..\..\SerenityInterface\CSerenityGameInterface.h"
#include "CInterface.h"
CSerenity* g_pSerenity = 0;
CInterface* g_pInterface = 0;
void DarkSDK ( void )
{
dbSetDir ( "" );
dbSyncOn ( );
dbSyncRate ( 60 );
dbColorBackdrop ( 20 );
dbSetDisplayMode(640,480,32);
g_pInterface = new CInterface();
g_pSerenity = new CSerenity();
g_pSerenity->SetInterface(g_pInterface);
g_pSerenity->SetBasePath("Media");
g_pSerenity->Load("ui",320,1000,1000,320);
g_pSerenity->SetSize(640,480);
g_pSerenity->SetDesiredSize(640,480);
g_pSerenity->SetOffset(0,0);
g_pSerenity->SetInputMode(SERENITY_CONSOLE_MODE);
while(LoopSDK())
{
if(dbEscapeKey( ))
{
return;
}
dbCLS();
char szFPS [ 256 ] = "";
strcpy ( szFPS, "fps = " );
strcat ( szFPS, dbStr ( dbScreenFPS ( ) ) );
dbText ( dbScreenWidth ( ) - 20 - dbTextWidth ( szFPS ), dbScreenHeight ( ) - 40, szFPS );
g_pInterface->StartFrame();
g_pSerenity->Advance();
g_pSerenity->Render();
dbSync ( );
}
}
and this is the integration file:
#pragma once
#include <stdio.h>
#include "c:\XiotexCode\SIDemo\ui.h"
#define TEXTURE_START 1000
class CInterface : public CSerenityGameInterface
{
public:
CInterface()
{
m_su32TextureID = 0;
m_su32StartSprite = 1000;
}
virtual ~CInterface()
{
}
void* Load(char* pName)
{
FILE* pIn;
int version;
int fileLength;
void* pFile;
pIn = fopen(pName,"rb");
if(!pIn)
{
return NULL;
}
fread(&version,4,1,pIn);
fread(&fileLength,4,1,pIn);
pFile = malloc(fileLength-8);
fread(pFile,fileLength-8,1,pIn);
return pFile;
}
void Unload(void* pAsset)
{
free(pAsset);
}
void RenderQWD(PQUAD_PRIMITIVE pQuad)
{
SU32 SizeX = pQuad->m_fX2-pQuad->m_fX1;
SU32 SizeY = pQuad->m_fY3-pQuad->m_fY1;
dbSprite(m_su32StartSprite,pQuad->m_fX1,pQuad->m_fY1,(int)pQuad->m_Texture);
dbSizeSprite(m_su32StartSprite,SizeX,SizeY);
dbSetSpritePriority(m_su32StartSprite, m_su32StartSprite);
dbSetSpriteAlpha(m_su32StartSprite,pQuad->m_su8Colour[3]);
++m_su32StartSprite;
}
void RenderTXT(char* pText, char* pFont, SU32 u32FontSize, BOUNDING_BOX BoundingBox)
{
}
void* LoadTexture(char* pBasePath, char* pName)
{
char Path[256];
sprintf(Path,"%s\\%s.png",pBasePath,pName);
SU32 TextureID = m_su32TextureID + TEXTURE_START;
dbLoadImage(Path,TextureID,1);
++m_su32TextureID;
return (void*)TextureID;
}
void UnloadTexture(void* pTexture)
{
}
void* Malloc(size_t sz)
{
return malloc(sz);
}
void Free(void* ptr)
{
free(ptr);
}
void Notify(unsigned int NotificationCode)
{
}
void InstanceCreated(SU32 InstanceName)
{
}
void InstanceRenderCallback(SU32 InstanceName, SU32 Data, PBOUNDING_BOX pBoundingBox)
{
}
void RenderTRK(SU32 InstanceName, BOUNDING_BOX BoundingBox)
{
}
void StartFrame()
{
SU32 i;
for(i = 1000; i < m_su32StartSprite; ++i)
{
dbDeleteSprite(i);
}
m_su32StartSprite = 1000;
}
private:
SU32 m_su32TextureID;
SU32 m_su32StartSprite;
};
Xiotex Studios
www.xiotex.com
DarkGameSDK@xiotex.com