EDN Admin
Well-known member
//-----------------------------------------------------------------------------<br/>
// File: CreateDevice.cpp<br/>
//<br/>
// Desc: This is the first tutorial for using Direct3D. In this tutorial, all<br/>
// we are doing is creating a Direct3D device and using it to clear the<br/>
// window.<br/>
//<br/>
// Copyright (c) Microsoft Corporation. All rights reserved.<br/>
//-----------------------------------------------------------------------------<br/>
#include <tchar.h><br/>
#include <d3d9.h><br/>
#pragma warning( disable : 4996 ) // disable deprecated warning <br/>
#include <strsafe.h><br/>
#pragma warning( default : 4996 )<br/>
#include <d3dx9.h><br/>
#include <dsound.h><br/>
#pragma comment(lib,"d3dx9.lib")<br/>
#pragma comment(lib,"d3d9.lib")<br/>
#pragma comment(lib,"Dsound.lib")<br/>
//#pragma comment(lib,"Dxguid.lib")<br/>
//-----------------------------------------------------------------------------<br/>
//Globale variables<br/>
//-----------------------------------------------------------------------------<br/>
#define IDT_TIMER1 1<br/>
//-----------------------------------------------------------------------------<br/>
//Function Prototype<br/>
//-----------------------------------------------------------------------------<br/>
HRESULT InitD3D( HWND);<br/>
VOID Cleanup();<br/>
VOID Render();<br/>
LPDIRECT3DSURFACE9 getSurfaceFromBitmap(LPTSTR);<br/>
bool initSprites();<br/>
HRESULT InitDSound(HWND);<br/>
//-----------------------------------------------------------------------------<br/>
// Global variables<br/>
//-----------------------------------------------------------------------------<br/>
LPDIRECT3D9 g_pD3D = NULL; // The pointer to our IDirect3D9 interface
<br/>
LPDIRECT3DDEVICE9 g_pd3dDevice = NULL; //The pointer to our IDirect3DDevice9 interface. Our rendering device<br/>
LPDIRECT3DSURFACE9 g_pd3dSurface = NULL;// The pointer to our IDirect3DSurface9 interface<br/>
LPDIRECTSOUND8 g_pd3dSound = NULL; // The Pointer to IDirectSound8 interface<br/>
int count = 0; // use for count loop;<br/>
<br/>
//-----------------------------------------------------------------------------<br/>
// Name: InitD3D()<br/>
// Desc: Initializes Direct3D<br/>
//-----------------------------------------------------------------------------<br/>
HRESULT InitD3D( HWND hWnd )<br/>
{<br/>
// Create the D3D object, which is needed to create the D3DDevice.<br/>
if( NULL == ( g_pD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) )<br/>
return E_FAIL; //mot gia tri thuoc kieu HRESULT<br/>
<br/>
// Set up the structure used to create the D3DDevice. Most parameters are<br/>
// zeroed out. We set Windowed to TRUE, since we want to do D3D in a<br/>
// window, and then set the SwapEffect to "discard", which is the most<br/>
// efficient method of presenting the back buffer to the display. And
<br/>
// we request a back buffer format that matches the current desktop display
<br/>
// format.<br/>
D3DPRESENT_PARAMETERS d3dpp;<br/>
ZeroMemory( &d3dpp, sizeof( d3dpp ) );<br/>
d3dpp.Windowed = TRUE;<br/>
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;<br/>
d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;<br/>
<br/>
// Create the Direct3D device. Here we are using the default adapter (most<br/>
// systems only have one, unless they have multiple graphics hardware cards<br/>
// installed) and requesting the HAL (which is saying we want the hardware<br/>
// device rather than a software one). Software vertex processing is
<br/>
// specified since we know it will work on all cards. On cards that support
<br/>
// hardware vertex processing, though, we would see a big performance gain
<br/>
// by specifying hardware vertex processing.<br/>
if( FAILED( g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,<br/>
D3DCREATE_SOFTWARE_VERTEXPROCESSING,<br/>
&d3dpp, &g_pd3dDevice ) )
)<br/>
{<br/>
return E_FAIL;<br/>
}<br/>
<br/>
// Device state would normally be set here<br/>
<br/>
return S_OK;<br/>
}<br/>
<br/>
//-----------------------------------------------------------------------------<br/>
// Name: InitDSound()<br/>
// Desc: Initializes DirectSound<br/>
//--------------------------l--------------------------------------------------<br/>
HRESULT InitDSound(HWND hwnd)<br/>
{<br/>
HRESULT hResult;<br/>
// Create Dsound <br/>
hResult = DirectSoundCreate8(NULL,&g_pd3dSound,NULL);<br/>
if(FAILED(hResult)) return E_FAIL;<br/>
// set cooperative level<br/>
hResult = g_pd3dSound->SetCooperativeLevel(hwnd,DSSCL_PRIORITY);<br/>
if(FAILED(hResult)) return E_FAIL;<br/>
return S_OK;<br/>
}<br/>
//-----------------------------------------------------------------------------<br/>
// Name: InitDSound()<br/>
// Desc: Initializes DirectSound<br/>
//--------------------------l--------------------------------------------------<br/>
<br/>
//-----------------------------------------------------------------------------<br/>
// Name: Cleanup()<br/>
// Desc: Releases all previously initialized objects<br/>
//-----------------------------------------------------------------------------<br/>
VOID Cleanup()<br/>
{<br/>
if( g_pd3dDevice != NULL )<br/>
g_pd3dDevice->Release();<br/>
<br/>
if( g_pD3D != NULL )<br/>
g_pD3D->Release();<br/>
}<br/>
<br/>
<br/>
<br/>
<br/>
//-----------------------------------------------------------------------------<br/>
// Name: Render()<br/>
// Desc: Draws the scene<br/>
//-----------------------------------------------------------------------------<br/>
VOID Render()<br/>
{<br/>
if( NULL == g_pd3dDevice )<br/>
return;<br/>
LPDIRECT3DSURFACE9 backbuffer = NULL; // pointer to backbuffer<br/>
// Clear the backbuffer to a blue color<br/>
g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB( 0, 0, 255 ), 1.0f, 0 );<br/>
//g_pd3dSurface = getSurfaceFromBitmap(_T("pic1.bmp"));<br/>
// Begin the scene<br/>
if( SUCCEEDED( g_pd3dDevice->BeginScene() ) )<br/>
{<br/>
// Rendering of scene objects can happen here<br/>
// get back buffer pointer<br/>
g_pd3dDevice->GetBackBuffer(0,0,D3DBACKBUFFER_TYPE_MONO,&backbuffer);<br/>
//copy image into backbuffer<br/>
g_pd3dDevice->StretchRect(g_pd3dSurface,NULL,backbuffer,NULL,D3DTEXF_NONE);<br/>
<br/>
// End the scene<br/>
g_pd3dDevice->EndScene();<br/>
}<br/>
<br/>
// Present the backbuffer contents to the display<br/>
g_pd3dDevice->Present( NULL, NULL, NULL, NULL );<br/>
}<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
//-----------------------------------------------------------------------------<br/>
// Name: getSurfaceFromBitmap()<br/>
// Desc: get image info, create off_screen surface, load image into surface<br/>
//-----------------------------------------------------------------------------<br/>
LPDIRECT3DSURFACE9 getSurfaceFromBitmap(LPTSTR filename)<br/>
{<br/>
//variable for check result<br/>
HRESULT hResult;<br/>
//temp pointer to IDirect3DSurface9 interface<br/>
LPDIRECT3DSURFACE9 surface = NULL;<br/>
//create structer hold image info<br/>
D3DXIMAGE_INFO imageInfo;<br/>
//clear structer for use<br/>
ZeroMemory(&imageInfo, sizeof(imageInfo));<br/>
//get image info<br/>
hResult = D3DXGetImageInfoFromFile(filename,&imageInfo);<br/>
if(FAILED(hResult)) return NULL;<br/>
//Creat off_srceen sufface<br/>
hResult = g_pd3dDevice->CreateOffscreenPlainSurface(imageInfo.Width,imageInfo.Height,D3DFMT_X8R8G8B8,D3DPOOL_DEFAULT,&surface,NULL);<br/>
if(FAILED(hResult)) return NULL;<br/>
//Load image <br/>
hResult = D3DXLoadSurfaceFromFile(surface,NULL,NULL,filename,NULL,D3DX_DEFAULT,0,&imageInfo);<br/>
if(FAILED(hResult)) return NULL;<br/>
return surface;<br/>
}<br/>
<br/>
<br/>
<br/>
<br/>
//-----------------------------------------------------------------------------<br/>
// Name: MsgProc()<br/>
// Desc: The windows message handler<br/>
//-----------------------------------------------------------------------------<br/>
LRESULT WINAPI MsgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )<br/>
{<br/>
switch( msg )<br/>
{<br/>
case WM_DESTROY:<br/>
Cleanup();<br/>
PostQuitMessage( 0 );<br/>
KillTimer(hWnd,IDT_TIMER1);<br/>
return 0;<br/>
break;<br/>
case WM_TIMER:<br/>
switch(wParam)<br/>
{<br/>
case IDT_TIMER1:<br/>
if(count == 0)<br/>
{<br/>
g_pd3dSurface = getSurfaceFromBitmap(_T("pic1.bmp"));<br/>
Render();<br/>
count = 1;<br/>
return 0;<br/>
break;<br/>
}<br/>
if(count == 1)<br/>
{<br/>
g_pd3dSurface = getSurfaceFromBitmap(_T("pic2.bmp"));<br/>
Render();<br/>
count = 0;<br/>
return 0;<br/>
break;<br/>
}<br/>
break;<br/>
} <br/>
break;<br/>
//case WM_PAINT:<br/>
// Render();<br/>
// ValidateRect( hWnd, NULL );<br/>
return 0;<br/>
}<br/>
<br/>
return DefWindowProc( hWnd, msg, wParam, lParam );<br/>
}<br/>
<br/>
<br/>
<br/>
<br/>
//-----------------------------------------------------------------------------<br/>
// Name: wWinMain()<br/>
// Desc: The applications entry point<br/>
//-----------------------------------------------------------------------------<br/>
INT WINAPI wWinMain( HINSTANCE hInst, HINSTANCE, LPWSTR, INT )<br/>
{<br/>
UNREFERENCED_PARAMETER( hInst );<br/>
<br/>
// Register the window class<br/>
WNDCLASSEX wc =<br/>
{<br/>
sizeof( WNDCLASSEX ), CS_CLASSDC, MsgProc, 0L, 0L,<br/>
GetModuleHandle( NULL ), NULL, NULL, NULL, NULL,<br/>
L"D3D Tutorial", NULL<br/>
};<br/>
RegisterClassEx( &wc );<br/>
<br/>
// Create the applications window<br/>
HWND hWnd = CreateWindow( L"D3D Tutorial", L"D3D Tutorial 01: CreateDevice",<br/>
WS_OVERLAPPEDWINDOW, 0, 0, 1280, 720,<br/>
NULL, NULL, wc.hInstance, NULL );<br/>
<br/>
// Initialize Direct3D<br/>
if( SUCCEEDED( InitD3D( hWnd ) ) )<br/>
{<br/>
// Show the window<br/>
ShowWindow( hWnd, SW_SHOWDEFAULT );<br/>
UpdateWindow( hWnd );<br/>
// set frist show<br/>
g_pd3dSurface = getSurfaceFromBitmap(_T("pic2.bmp"));<br/>
Render();<br/>
//set timer for show image<br/>
SetTimer(hWnd,IDT_TIMER1,5000,NULL);<br/>
// Enter the message loop<br/>
MSG msg;<br/>
while(true)<br/>
{<br/>
while( PeekMessage(&msg,NULL,0U,0U,PM_REMOVE) )<br/>
{<br/>
TranslateMessage( &msg );<br/>
DispatchMessage( &msg );<br/>
}<br/>
if(msg.message == WM_QUIT) break;<br/>
//run code here;<br/>
<br/>
<br/>
}<br/>
<br/>
<br/>
}<br/>
UnregisterClass( L"D3D Tutorial", wc.hInstance );<br/>
return 0;<br/>
}
I use Sample file of directX brower and add my seft code. it run well in my computer but in company computer it not work ??? it built correctly (end of debug show :The program [5960] withAudio.exe: Native has exited with code 0 (0x0).) but dont
show the window ( use Ctr + F5) . I was test it in anorther computer and it run well too. So what wrong with company computer ??? . plus, i have use breakpoint to check then i thing SUCCEEDED( InitD3D( hWnd )) not return true ??? -> why in my computer
it return true ( all computer have win7 ultime 32bit, use VC++ express) . thanks for read it.
View the full article
// File: CreateDevice.cpp<br/>
//<br/>
// Desc: This is the first tutorial for using Direct3D. In this tutorial, all<br/>
// we are doing is creating a Direct3D device and using it to clear the<br/>
// window.<br/>
//<br/>
// Copyright (c) Microsoft Corporation. All rights reserved.<br/>
//-----------------------------------------------------------------------------<br/>
#include <tchar.h><br/>
#include <d3d9.h><br/>
#pragma warning( disable : 4996 ) // disable deprecated warning <br/>
#include <strsafe.h><br/>
#pragma warning( default : 4996 )<br/>
#include <d3dx9.h><br/>
#include <dsound.h><br/>
#pragma comment(lib,"d3dx9.lib")<br/>
#pragma comment(lib,"d3d9.lib")<br/>
#pragma comment(lib,"Dsound.lib")<br/>
//#pragma comment(lib,"Dxguid.lib")<br/>
//-----------------------------------------------------------------------------<br/>
//Globale variables<br/>
//-----------------------------------------------------------------------------<br/>
#define IDT_TIMER1 1<br/>
//-----------------------------------------------------------------------------<br/>
//Function Prototype<br/>
//-----------------------------------------------------------------------------<br/>
HRESULT InitD3D( HWND);<br/>
VOID Cleanup();<br/>
VOID Render();<br/>
LPDIRECT3DSURFACE9 getSurfaceFromBitmap(LPTSTR);<br/>
bool initSprites();<br/>
HRESULT InitDSound(HWND);<br/>
//-----------------------------------------------------------------------------<br/>
// Global variables<br/>
//-----------------------------------------------------------------------------<br/>
LPDIRECT3D9 g_pD3D = NULL; // The pointer to our IDirect3D9 interface
<br/>
LPDIRECT3DDEVICE9 g_pd3dDevice = NULL; //The pointer to our IDirect3DDevice9 interface. Our rendering device<br/>
LPDIRECT3DSURFACE9 g_pd3dSurface = NULL;// The pointer to our IDirect3DSurface9 interface<br/>
LPDIRECTSOUND8 g_pd3dSound = NULL; // The Pointer to IDirectSound8 interface<br/>
int count = 0; // use for count loop;<br/>
<br/>
//-----------------------------------------------------------------------------<br/>
// Name: InitD3D()<br/>
// Desc: Initializes Direct3D<br/>
//-----------------------------------------------------------------------------<br/>
HRESULT InitD3D( HWND hWnd )<br/>
{<br/>
// Create the D3D object, which is needed to create the D3DDevice.<br/>
if( NULL == ( g_pD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) )<br/>
return E_FAIL; //mot gia tri thuoc kieu HRESULT<br/>
<br/>
// Set up the structure used to create the D3DDevice. Most parameters are<br/>
// zeroed out. We set Windowed to TRUE, since we want to do D3D in a<br/>
// window, and then set the SwapEffect to "discard", which is the most<br/>
// efficient method of presenting the back buffer to the display. And
<br/>
// we request a back buffer format that matches the current desktop display
<br/>
// format.<br/>
D3DPRESENT_PARAMETERS d3dpp;<br/>
ZeroMemory( &d3dpp, sizeof( d3dpp ) );<br/>
d3dpp.Windowed = TRUE;<br/>
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;<br/>
d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;<br/>
<br/>
// Create the Direct3D device. Here we are using the default adapter (most<br/>
// systems only have one, unless they have multiple graphics hardware cards<br/>
// installed) and requesting the HAL (which is saying we want the hardware<br/>
// device rather than a software one). Software vertex processing is
<br/>
// specified since we know it will work on all cards. On cards that support
<br/>
// hardware vertex processing, though, we would see a big performance gain
<br/>
// by specifying hardware vertex processing.<br/>
if( FAILED( g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,<br/>
D3DCREATE_SOFTWARE_VERTEXPROCESSING,<br/>
&d3dpp, &g_pd3dDevice ) )
)<br/>
{<br/>
return E_FAIL;<br/>
}<br/>
<br/>
// Device state would normally be set here<br/>
<br/>
return S_OK;<br/>
}<br/>
<br/>
//-----------------------------------------------------------------------------<br/>
// Name: InitDSound()<br/>
// Desc: Initializes DirectSound<br/>
//--------------------------l--------------------------------------------------<br/>
HRESULT InitDSound(HWND hwnd)<br/>
{<br/>
HRESULT hResult;<br/>
// Create Dsound <br/>
hResult = DirectSoundCreate8(NULL,&g_pd3dSound,NULL);<br/>
if(FAILED(hResult)) return E_FAIL;<br/>
// set cooperative level<br/>
hResult = g_pd3dSound->SetCooperativeLevel(hwnd,DSSCL_PRIORITY);<br/>
if(FAILED(hResult)) return E_FAIL;<br/>
return S_OK;<br/>
}<br/>
//-----------------------------------------------------------------------------<br/>
// Name: InitDSound()<br/>
// Desc: Initializes DirectSound<br/>
//--------------------------l--------------------------------------------------<br/>
<br/>
//-----------------------------------------------------------------------------<br/>
// Name: Cleanup()<br/>
// Desc: Releases all previously initialized objects<br/>
//-----------------------------------------------------------------------------<br/>
VOID Cleanup()<br/>
{<br/>
if( g_pd3dDevice != NULL )<br/>
g_pd3dDevice->Release();<br/>
<br/>
if( g_pD3D != NULL )<br/>
g_pD3D->Release();<br/>
}<br/>
<br/>
<br/>
<br/>
<br/>
//-----------------------------------------------------------------------------<br/>
// Name: Render()<br/>
// Desc: Draws the scene<br/>
//-----------------------------------------------------------------------------<br/>
VOID Render()<br/>
{<br/>
if( NULL == g_pd3dDevice )<br/>
return;<br/>
LPDIRECT3DSURFACE9 backbuffer = NULL; // pointer to backbuffer<br/>
// Clear the backbuffer to a blue color<br/>
g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB( 0, 0, 255 ), 1.0f, 0 );<br/>
//g_pd3dSurface = getSurfaceFromBitmap(_T("pic1.bmp"));<br/>
// Begin the scene<br/>
if( SUCCEEDED( g_pd3dDevice->BeginScene() ) )<br/>
{<br/>
// Rendering of scene objects can happen here<br/>
// get back buffer pointer<br/>
g_pd3dDevice->GetBackBuffer(0,0,D3DBACKBUFFER_TYPE_MONO,&backbuffer);<br/>
//copy image into backbuffer<br/>
g_pd3dDevice->StretchRect(g_pd3dSurface,NULL,backbuffer,NULL,D3DTEXF_NONE);<br/>
<br/>
// End the scene<br/>
g_pd3dDevice->EndScene();<br/>
}<br/>
<br/>
// Present the backbuffer contents to the display<br/>
g_pd3dDevice->Present( NULL, NULL, NULL, NULL );<br/>
}<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
//-----------------------------------------------------------------------------<br/>
// Name: getSurfaceFromBitmap()<br/>
// Desc: get image info, create off_screen surface, load image into surface<br/>
//-----------------------------------------------------------------------------<br/>
LPDIRECT3DSURFACE9 getSurfaceFromBitmap(LPTSTR filename)<br/>
{<br/>
//variable for check result<br/>
HRESULT hResult;<br/>
//temp pointer to IDirect3DSurface9 interface<br/>
LPDIRECT3DSURFACE9 surface = NULL;<br/>
//create structer hold image info<br/>
D3DXIMAGE_INFO imageInfo;<br/>
//clear structer for use<br/>
ZeroMemory(&imageInfo, sizeof(imageInfo));<br/>
//get image info<br/>
hResult = D3DXGetImageInfoFromFile(filename,&imageInfo);<br/>
if(FAILED(hResult)) return NULL;<br/>
//Creat off_srceen sufface<br/>
hResult = g_pd3dDevice->CreateOffscreenPlainSurface(imageInfo.Width,imageInfo.Height,D3DFMT_X8R8G8B8,D3DPOOL_DEFAULT,&surface,NULL);<br/>
if(FAILED(hResult)) return NULL;<br/>
//Load image <br/>
hResult = D3DXLoadSurfaceFromFile(surface,NULL,NULL,filename,NULL,D3DX_DEFAULT,0,&imageInfo);<br/>
if(FAILED(hResult)) return NULL;<br/>
return surface;<br/>
}<br/>
<br/>
<br/>
<br/>
<br/>
//-----------------------------------------------------------------------------<br/>
// Name: MsgProc()<br/>
// Desc: The windows message handler<br/>
//-----------------------------------------------------------------------------<br/>
LRESULT WINAPI MsgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )<br/>
{<br/>
switch( msg )<br/>
{<br/>
case WM_DESTROY:<br/>
Cleanup();<br/>
PostQuitMessage( 0 );<br/>
KillTimer(hWnd,IDT_TIMER1);<br/>
return 0;<br/>
break;<br/>
case WM_TIMER:<br/>
switch(wParam)<br/>
{<br/>
case IDT_TIMER1:<br/>
if(count == 0)<br/>
{<br/>
g_pd3dSurface = getSurfaceFromBitmap(_T("pic1.bmp"));<br/>
Render();<br/>
count = 1;<br/>
return 0;<br/>
break;<br/>
}<br/>
if(count == 1)<br/>
{<br/>
g_pd3dSurface = getSurfaceFromBitmap(_T("pic2.bmp"));<br/>
Render();<br/>
count = 0;<br/>
return 0;<br/>
break;<br/>
}<br/>
break;<br/>
} <br/>
break;<br/>
//case WM_PAINT:<br/>
// Render();<br/>
// ValidateRect( hWnd, NULL );<br/>
return 0;<br/>
}<br/>
<br/>
return DefWindowProc( hWnd, msg, wParam, lParam );<br/>
}<br/>
<br/>
<br/>
<br/>
<br/>
//-----------------------------------------------------------------------------<br/>
// Name: wWinMain()<br/>
// Desc: The applications entry point<br/>
//-----------------------------------------------------------------------------<br/>
INT WINAPI wWinMain( HINSTANCE hInst, HINSTANCE, LPWSTR, INT )<br/>
{<br/>
UNREFERENCED_PARAMETER( hInst );<br/>
<br/>
// Register the window class<br/>
WNDCLASSEX wc =<br/>
{<br/>
sizeof( WNDCLASSEX ), CS_CLASSDC, MsgProc, 0L, 0L,<br/>
GetModuleHandle( NULL ), NULL, NULL, NULL, NULL,<br/>
L"D3D Tutorial", NULL<br/>
};<br/>
RegisterClassEx( &wc );<br/>
<br/>
// Create the applications window<br/>
HWND hWnd = CreateWindow( L"D3D Tutorial", L"D3D Tutorial 01: CreateDevice",<br/>
WS_OVERLAPPEDWINDOW, 0, 0, 1280, 720,<br/>
NULL, NULL, wc.hInstance, NULL );<br/>
<br/>
// Initialize Direct3D<br/>
if( SUCCEEDED( InitD3D( hWnd ) ) )<br/>
{<br/>
// Show the window<br/>
ShowWindow( hWnd, SW_SHOWDEFAULT );<br/>
UpdateWindow( hWnd );<br/>
// set frist show<br/>
g_pd3dSurface = getSurfaceFromBitmap(_T("pic2.bmp"));<br/>
Render();<br/>
//set timer for show image<br/>
SetTimer(hWnd,IDT_TIMER1,5000,NULL);<br/>
// Enter the message loop<br/>
MSG msg;<br/>
while(true)<br/>
{<br/>
while( PeekMessage(&msg,NULL,0U,0U,PM_REMOVE) )<br/>
{<br/>
TranslateMessage( &msg );<br/>
DispatchMessage( &msg );<br/>
}<br/>
if(msg.message == WM_QUIT) break;<br/>
//run code here;<br/>
<br/>
<br/>
}<br/>
<br/>
<br/>
}<br/>
UnregisterClass( L"D3D Tutorial", wc.hInstance );<br/>
return 0;<br/>
}
I use Sample file of directX brower and add my seft code. it run well in my computer but in company computer it not work ??? it built correctly (end of debug show :The program [5960] withAudio.exe: Native has exited with code 0 (0x0).) but dont
show the window ( use Ctr + F5) . I was test it in anorther computer and it run well too. So what wrong with company computer ??? . plus, i have use breakpoint to check then i thing SUCCEEDED( InitD3D( hWnd )) not return true ??? -> why in my computer
it return true ( all computer have win7 ultime 32bit, use VC++ express) . thanks for read it.
View the full article