My window is twinkling,twinkling,twinkling...why???
code are as follows:
//-----------------------------------------------------------------------------
// Name: WinMain()
// Desc: The application''s entry point
//-----------------------------------------------------------------------------
INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR, INT )
{
// Register the window class
WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, MsgProc, 0L, 0L,
GetModuleHandle(NULL), NULL, NULL, NULL, NULL,
"D3D Tutorial", NULL };
RegisterClassEx( &wc );
// ҪȫÆÁ±ØÐëÒªWS_POPUP
//HWND hWnd = CreateWindow( "D3D Tutorial", "D3D Tutorial 02: Vertices",
//WS_POPUP, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN),
//GetDesktopWindow(), NULL, wc.hInstance, NULL );
HWND hWnd = CreateWindow( "D3D Tutorial", "D3D Tutorial 02: Vertices",
WS_OVERLAPPEDWINDOW, 0, 0, 300, 300,
GetDesktopWindow(), NULL, wc.hInstance, NULL );
// Initialize Direct3D
if( SUCCEEDED( InitD3D( hWnd ) ) )
{
// Create the vertex buffer
//if( SUCCEEDED( InitVB() ) )
{
//´´½¨Ìûͼ
//if( SUCCEEDED( InitGeometry() ) )
{
// Show the window
ShowWindow( hWnd, SW_SHOWDEFAULT );
UpdateWindow( hWnd );
// Enter the message loop
MSG msg;
ZeroMemory( &msg, sizeof(msg) );
while( msg.message!=WM_QUIT )
{
if( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
else
Render();
}
}
}
}
UnregisterClass( "D3D Tutorial", wc.hInstance );
return 0;
}
//-----------------------------------------------------------------------------
// Name: Render()
// Desc: Draws the scene
//-----------------------------------------------------------------------------
VOID Render()
{
// Clear the backbuffer and the zbuffer
g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER,D3DCOLOR_XRGB(0,0,255), 1.0f, 0 );
// Begin the scene
if( SUCCEEDED( g_pd3dDevice->BeginScene() ) )
{
//ÉèÖÃÎÆÀí
//g_pd3dDevice->SetTexture(0, g_pTexture);
//g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 );
// Render the vertex buffer contents
//g_pd3dDevice->SetStreamSource( 0, g_pVB, 0, sizeof(CUSTOMVERTEX) );
//g_pd3dDevice->SetFVF( D3DFVF_CUSTOMVERTEX );
//g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, 0, 2 );
// End the scene
g_pd3dDevice->EndScene();
}
// Present the backbuffer contents to the display
g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
}
HRESULT InitD3D( HWND hWnd )
{
// Create the D3D object.
if( NULL == ( g_pD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) )
return E_FAIL;
// Set up the structure used to create the D3DDevice
D3DPRESENT_PARAMETERS d3dpp;
ZeroMemory( &d3dpp, sizeof(d3dpp) );
d3dpp.Windowed = TRUE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
// Create the D3DDevice
if( FAILED( g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
D3DCREATE_SOFTWARE_VERTEXPROCESSING,
&d3dpp, &g_pd3dDevice ) ) )
{
return E_FAIL;
}
// Device state would normally be set here
return S_OK;
}
Well, I would attempt to help you. First, I need to see the vertex structure (ex. "struct/class MyVertex"). Also, have you tried taking "D3DCLEAR_ZBUFFER" out of the function call to "g_pd3dDevice->Clear(...)"? Try that, because it may work. I have had this problem before, and there can be a couple things, as far as I know. If taking that parameter out doesn't work, then let me know and I will try to help you out.
Matt U.
[edited by - SimDemon on February 7, 2004 10:05:38 AM]
Matt U.
[edited by - SimDemon on February 7, 2004 10:05:38 AM]
These values are set in D3DXMatrixPerspectiveFovLH. You have a near view plane and a far view plane. Also, what is your Z buffer depth type?
Chris
Chris
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement