// Main header file for the XDK
#include
<xtl.h>
/////////////////////////////////////////////////////////////////////////////
//
//
// All our sound loading code and playing code is all nice and tidy in
//
// sound.h/.cpp...so it should be easy for you to use it and understand
//
// it without getting mixed up with loads of other problem code.
//
//
//
/////////////////////////////////////////////////////////////////////////////
//** NEW ** NEW ** NEW ** NEW ** NEW ** NEW ** NEW
** NEW ** NEW **
//** NEW ** NEW ** NEW ** NEW ** NEW ** NEW ** NEW
** NEW ** NEW **
#include
"sound.h" // So we can use CSound!
/////////////////////////////////////////////////////////////////////////////
//
//
// This is just a file I use in the splash screen...its the location of
//
// the jpg file which will display on screen while we listen to our music
//
//
//
/////////////////////////////////////////////////////////////////////////////
#define
szTexFile "D:\\media\\xfactordev.jpg"
/////////////////////////////////////////////////////////////////////////////
//
//
// These are used for our directX initilisation and so I can display my
//
// wonderful splash image on the screen.
//
//
//
/////////////////////////////////////////////////////////////////////////////
IDirect3D8* g_pD3D = NULL; //
DirectX Object
IDirect3DDevice8* g_pD3DDevice = NULL; //
Screen Object
/////////////////////////////////////////////////////////////////////////////
//
//
// Our sound class...well I create a single global instance of it here
//
// then call Create etc for it later on...and we can play our sound .wav
//
// file which I have in the media folder!
//
// Don't forget to include the media folder, which as the .wav sound
//
//
file which you need!.. or else it will CRASH!
//
//
//
/////////////////////////////////////////////////////////////////////////////
//** NEW ** NEW ** NEW ** NEW ** NEW ** NEW ** NEW
** NEW ** NEW **
//** NEW ** NEW ** NEW ** NEW ** NEW ** NEW ** NEW
** NEW ** NEW **
CSound
g_Madonna; // CSound is
defined in sound.h
/////////////////////////////////////////////////////////////////////////////
//
//
// Well this is our DirectX initilsation code, we call this once when
//
// our program starts up.
//
//
//
/////////////////////////////////////////////////////////////////////////////
void
InitialiseD3D()
{
//First of all, create the main D3D object. If it
is created successfully we
//should get a pointer to an IDirect3D8 interface.
g_pD3D = Direct3DCreate8(D3D_SDK_VERSION);
//Create a structure to hold the settings for our
device
D3DPRESENT_PARAMETERS d3dpp;
ZeroMemory(&d3dpp, sizeof(d3dpp));
//Fill the structure.
//Set fullscreen 640x480x32 mode
d3dpp.BackBufferWidth = 640;
d3dpp.BackBufferHeight = 480;
d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
// Create one backbuffer and a zbuffer
d3dpp.BackBufferCount = 1;
// Set up how the backbuffer is "presented" to the
frontbuffer each time
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
//Create a Direct3D device.
g_pD3D->CreateDevice(0, D3DDEVTYPE_HAL, NULL,
D3DCREATE_HARDWARE_VERTEXPROCESSING,
&d3dpp, &g_pD3DDevice);
}
void
CleanUp()
{
g_pD3DDevice->Release();
g_pD3D->Release();
}
/////////////////////////////////////////////////////////////////////////////
//
//
// This little function is nothing to do with the sound! I just added it
//
// in, so that while your listening to the mega cool .wav sound I gave you
//
// the screen would display more than just a blank screen or a triangle.
//
// Its the basic's...and it loads in file which I've specified above as
//
// "D:\\xfactodev.net" with a define (so you can change it later... and
//
// displays it.
//
//
//
/////////////////////////////////////////////////////////////////////////////
void
XFactorTextureAdvert()
{
///.......
<cut
out to keep it simple>
///.....
}
/////////////////////////////////////////////////////////////////////////////
//
//
// Our applicatoin entry point!
//
// Now note the **NEW** comments...so you can't get mixed up with where
//
// sound code is being initilised and used :)
//
//
//
/////////////////////////////////////////////////////////////////////////////
//Application entry point
void
__cdecl main()
{
InitialiseD3D();
//** NEW ** NEW ** NEW ** NEW ** NEW ** NEW ** NEW
** NEW ** NEW **
//** NEW ** NEW ** NEW ** NEW ** NEW ** NEW ** NEW
** NEW ** NEW **
g_Madonna.Create( "D:\\media\\do_it_with_madonna.wav" );
//** NEW ** NEW ** NEW ** NEW ** NEW ** NEW ** NEW
** NEW ** NEW **
//** NEW ** NEW ** NEW ** NEW ** NEW ** NEW ** NEW
** NEW ** NEW **
g_Madonna.playsound();
while(true)
{
//Clear the backbuffer to black
g_pD3DDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,
0, 255), 1.0f, 0);
//Begin the scene
g_pD3DDevice->BeginScene();
XFactorTextureAdvert();
//End the scene
g_pD3DDevice->EndScene();
//Filp the back and front buffers so
that whatever has been
//rendered
on the back buffer
//will now be visible on screen (front
buffer).
g_pD3DDevice->Present(NULL, NULL, NULL, NULL);
}
g_Madonna.Release();
CleanUp();
}
|