So far no one has replied to my post

. I have added some samples of code hoping this will spark some interest.
Windows Application Setup
Code:
Initialize(EngineData *Data) //|
{ //|
ClassName = CopybyValue((char*)Data->sAppName); //|
m_hInstance=Data->hInstance; //|
WNDCLASSEX wc; // The window class used to create our window //|
//|
// The name of our class and also the title window //|
//static char strAppName[] = "First Windows App, Zen Style"; //|
//|
// Fill in the window class with the attributes for our main window //|
//|
// The size of this structure in bytes //|
wc.cbSize = sizeof( WNDCLASSEX ); //|
//|
// The style of the window //|
wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; //|
//|
// Useless info set to 0 //|
wc.cbClsExtra = 0; //|
//|
// More Useless info //|
wc.cbWndExtra = 0; //|
//|
// The name of our event handler //|
wc.lpfnWndProc = WndProc; //|
//|
// A handle to the applications instance //|
wc.hInstance = Data->hInstance; //|
//|
// A handle to the brush to use for the window background //|
wc.hbrBackground = (HBRUSH)GetStockObject(DKGRAY_BRUSH); //|
//|
// A handle to the icon used for the window //|
wc.hIcon = Data->hIcon; //|
//|
// A handle to the small version of the window icon //|
wc.hIconSm = Data->hIconSm; //|
//|
// A handle to the cursor to use while the mouse is over our window //|
wc.hCursor = Data->hCursor; //|
//|
// A handle to the resource to use as our menu //|
wc.lpszMenuName = 0; //|
//|
// The human readable name for this class //|
wc.lpszClassName = Data->sAppName; //|
//|
// Register the class with windows //|
RegisterClassEx( &wc ); //|
//|
DWORD WStyle; //|
if(Data->Windowed) //|
{ //|
//WStyle=WS_BORDER|WS_SYSMENU|WS_MINIMIZEBOX|WS_EX_TOOLWINDOW;
WStyle=WS_POPUP;
} //|
else //|
{ //|
WStyle=WS_POPUP; //|
} //|
// Create the window based on the previous class //|
m_hWnd = CreateWindowEx( NULL, // Advanced style settings //|
Data->sAppName, // The name of the class //|
Data->sAppName, // The window Caption //|
WStyle, // The window style //|
CW_USEDEFAULT, // The Initial x position //|
CW_USEDEFAULT, // The Initial y position //|
Data->Width, // The initial width //|
Data->Height, // The initial height //|
NULL, // Handle to the parent window //|
NULL, // Handle to the menu //|
Data->hInstance, // Handle to the apps instance //|
NULL ); // Advanced Context //|
if(m_hWnd == NULL) //|
{ //|
return E_FAIL; //|
} //|
//m_hDC= GetDC(m_hWnd); // Device Context //|
//|
// Display the window we just created //|
ShowWindow(m_hWnd, Data->iCmdShow ); //|
//|
// Draw the window contents for the first time //|
UpdateWindow( m_hWnd ); //|
//|
// Tell Windows We want to be in front now //|
SetForegroundWindow(m_hWnd); //|
//|
m_Running=true; //|
return S_OK;
DirectX setup
Code:
Initialize(HWND hWnd,EngineData *Data) //|
{ //|
bool NeedAssetReset=false; //|
if(m_Data!=NULL) //|
{ //|
if(m_Data->Windowed==Data->Windowed) //|
{ //|
// The width of the back buffer in pixels //|
m_d3dpp.BackBufferWidth = Data->Width; //|
// The height of the back buffer in pixels //|
m_d3dpp.BackBufferHeight = Data->Height; //|
// The handle to the window we want to render to //|
m_d3dpp.hDeviceWindow = hWnd; //|
// Windowed mode //|
m_d3dpp.Windowed = Data->Windowed; //|
return ResetResources(); //|
} //|
m_pDevice->Release(); //|
m_pD3D->Release(); //|
NeedAssetReset=true; //|
} //|
// get the number of counts per second //|
QueryPerformanceFrequency((LARGE_INTEGER*)&m_Frequency); //|
m_LastExecute=0; //|
// if the frequency is NULL there is no timer //|
if(m_Frequency==NULL) //|
{ //|
m_Frequency=NULL; //|
QueryPerformanceFrequency((LARGE_INTEGER*)&m_Frequency); //|
if(m_Frequency==NULL) //|
{ //|
throw -1; //|
} //|
} //|
//|
m_Data=Data; //|
// Structure holding info about the current display mode //|
D3DDISPLAYMODE d3ddm; //|
//|
// aquire a pointer to Idirect3d9 //|
m_pD3D = Direct3DCreate9( D3D_SDK_VERSION ); //|
//|
// sets up hardware acceleration //|
//m_pD3D->CheckDeviceType(D3DADAPTER_DEFAULT,D3DDEVTYPE_REF, //|
// D3DFMT_X8R8G8B8, D3DFMT_X8R8G8B8,FALSE); //|
//|
//if(m_pD3D == NULL) //|
//{ //|
// error //|
// return E_FAIL; //|
//} //|
//|
// Get the current settings for the default display adapter //|
m_pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT,&d3ddm); //|
//|
// Initiailze the struct to 0 //|
ZeroMemory(&m_d3dpp,sizeof(D3DPRESENT_PARAMETERS)); //|
//|
// The width of the back buffer in pixels //|
m_d3dpp.BackBufferWidth = Data->Width; //|
// The height of the back buffer in pixels //|
m_d3dpp.BackBufferHeight = Data->Height; //|
// set the back buffer format to e the same as the primary surface //|
m_d3dpp.BackBufferFormat = d3ddm.Format; //|
//|
// The number of back buffers //|
m_d3dpp.BackBufferCount = 1; //|
// The type of multisampling //|
m_d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE; //|
// Tell Direct3d it is free to mess with the back buffer //|
m_d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; //|
//|
// The handle to the window we want to render to //|
m_d3dpp.hDeviceWindow = hWnd; //|
// Windowed mode //|
m_d3dpp.Windowed = Data->Windowed; //|
//|
// 3D doesnt work with this.... //|
//|
// Let Direct3d manage the depth buffer //|
m_d3dpp.EnableAutoDepthStencil = true; //|
// Set the auto depth buffer to 16 bit //|
m_d3dpp.AutoDepthStencilFormat = D3DFMT_D24S8;//d3ddm.Format; //|
//|
//.... 3D doesnt work with this //|
//|
// Use the default refresh rate //|
m_d3dpp.FullScreen_RefreshRateInHz=0; //|
//|
// Present the information as fast as possible //|
m_d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; //|
// allow the back buffer to be accessed for 2d work //|
m_d3dpp.Flags = D3DPRESENTFLAG_LOCKABLE_BACKBUFFER; //|
//|
// Acquire a pointer to IDirect3DDevice9 //|
if(FAILED(m_pD3D->CreateDevice( D3DADAPTER_DEFAULT, //|
D3DDEVTYPE_HAL,hWnd, //|
D3DCREATE_HARDWARE_VERTEXPROCESSING, //|
&m_d3dpp, &m_pDevice ))) //|
{ //|
if(FAILED(m_pD3D->CreateDevice( D3DADAPTER_DEFAULT, //|
D3DDEVTYPE_HAL,hWnd, //|
D3DCREATE_MIXED_VERTEXPROCESSING, //|
&m_d3dpp, &m_pDevice ))) //|
{ //|
if(FAILED(m_pD3D->CreateDevice( D3DADAPTER_DEFAULT, //|
D3DDEVTYPE_HAL,hWnd, //|
D3DCREATE_SOFTWARE_VERTEXPROCESSING, //|
&m_d3dpp, &m_pDevice ))) //|
{ //|
return E_FAIL; //|
} //|
} //|
} //|
//|
// Turn on the Lights //|
m_pDevice->SetRenderState(D3DRS_LIGHTING, false); //|
// Turn on 3D //|
m_pDevice->SetRenderState(D3DRS_ZENABLE,true); //|
// Create our Sprite Manager //|
D3DXCreateSprite(m_pDevice,&m_SpriteManager); //|
if(NeedAssetReset)
{ //|
return ResetResources();
}
return S_OK; //|
}
Sprite Rendering
Code:
// Draw our Sprites //|
if(m_SpriteList) //|
{ //|
m_SpriteManager->Begin(D3DXSPRITE_ALPHABLEND|D3DXSPRITE_SORT_DEPTH_BACKTOFRONT|D3DXSPRITE_SORT_TEXTURE);
bool MoreInSpriteList = m_SpriteList->ToFirst(); //|
while(MoreInSpriteList) //|
{ //|
CSprite* TempSprite=NULL; //|
TempSprite = m_SpriteList->GetData(); //|
if(TempSprite!=NULL) //|
{ //|
if(TempSprite->Visible) //|
{ //|
if(TempSprite->m_CurFrame<TempSprite->GetNumCols() //|
*TempSprite->GetNumRows()&& //|
TempSprite->m_CurFrame>=0) //|
{ //|
if(Compare(TempSprite->GetSpriteName(),"Console Window"))
{
int stophere=0;
}
// rectangle to copy the sprite //|
RECT srcRect; //|
// create the rectangle for the sprite //|
srcRect.left=( //|
TempSprite->GetTexture()->GetWidth()/ //|
TempSprite->GetNumCols())* //|
(TempSprite->m_CurFrame% //|
TempSprite->GetNumCols()); //|
if(TempSprite->m_CurFrame==0) //|
{ //|
srcRect.top=0; //|
} //|
else //|
{ //|
srcRect.top=( //|
TempSprite->GetTexture()->GetHeight()/ //|
TempSprite->GetNumRows())* //|
(int)(TempSprite->m_CurFrame/ //|
TempSprite->GetNumCols()); //|
} //|
//|
srcRect.right= srcRect.left+ //|
TempSprite->GetTexture()->GetWidth()/ //|
TempSprite->GetNumCols(); //|
srcRect.bottom= srcRect.top+ //|
TempSprite->GetTexture()->GetHeight()/ //|
TempSprite->GetNumRows(); //|
//|
D3DXVECTOR3 CenterPosition; //|
/*if(TempSprite->DrawIn3dSpace) //|
{ //|
if(TempSprite->BillBoarded) //|
{ //|
m_SpriteManager->Begin( //|
D3DXSPRITE_ALPHABLEND|D3DXSPRITE_OBJECTSPACE| //|
D3DXSPRITE_BILLBOARD); //|
CenterPosition=D3DXVECTOR3( //|
(float)(TempSprite->GetTexture()->GetWidth()/2),//|
(float)(TempSprite->GetTexture()->GetHeight()/2)//|
,0.0f); //|
} //|
else //|
{ //|
m_SpriteManager->Begin( //|
D3DXSPRITE_ALPHABLEND|D3DXSPRITE_OBJECTSPACE); //|
CenterPosition=D3DXVECTOR3( //|
(float)(TempSprite->GetTexture()->GetWidth()/2),//|
(float)(TempSprite->GetTexture()->GetHeight()/2)//|
,0.0f); //|
} //|
D3DXMATRIXA16 TransforMat; //|
m_SpriteManager->GetTransform(&TransforMat); //|
D3DXMatrixRotationX( &TransforMat, //|
D3DXToRadian(180) ); //|
m_SpriteManager->SetTransform(&TransforMat); //|
} //|
else //|
{*/ //|
CenterPosition=D3DXVECTOR3(0,0,0); //|
//} //|
//|
m_SpriteManager->Draw( //|
*(TempSprite->GetTexture()->GetTexture()) //|
,&srcRect ,&CenterPosition, //|
&TempSprite->Position, //|
TempSprite->m_Color); //|
} //|
} //|
} //|
MoreInSpriteList = m_SpriteList->Next(); //|
} //|
m_SpriteManager->End();
}