Hey there, Lenox here. I made this ( very ) simple application that uses Direct3D to...well, pop up a black window. The problem is this: When I start up the application, the window does popup but the background is invisible and some of the name in the start bar is shown ( See
Figure 1 ). I can fix the problem by minimizing it. ( The window should look as it does in
Figure 2 )
Here's some code to go along with all of this.
Direct3D.Cpp
HRESULT Direct3D::Go()
{
pD3D9 = Direct3DCreate9( D3D_SDK_VERSION );
if( !pD3D9 )
{
throw std::runtime_error( "Failed to initialize Direct3D." );
return E_FAIL;
}
D3DDISPLAYMODE d3ddm;
D3DPRESENT_PARAMETERS d3dpp;
ZeroMemory( &d3dpp, sizeof( D3DPRESENT_PARAMETERS ) );
pD3D9->GetAdapterDisplayMode( D3DADAPTER_DEFAULT, &d3ddm );
d3dpp.hDeviceWindow = GetInfo()->_hwnd;
d3dpp.BackBufferWidth = GetInfo()->_width;
d3dpp.BackBufferHeight = GetInfo()->_height;
d3dpp.Windowed = GetInfo()->_windowed;
d3dpp.BackBufferFormat = d3ddm.Format;
d3dpp.BackBufferCount = 1;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.EnableAutoDepthStencil = true;
d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
d3dpp.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
if( pD3D9->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, d3dpp.hDeviceWindow,
D3DCREATE_HARDWARE_VERTEXPROCESSING | D3DCREATE_MULTITHREADED,
&d3dpp, &pD3DDevice9 ) != D3D_OK )
{
iLogger.Write( "status", "Failed to create the Direct3D Device" );
throw std::runtime_error( "Failed to create the device." );
return E_FAIL;
};
iLogger.Write( "status","Direct3D Initialized" );
return S_OK;
};
Window.hpp
inline HRESULT Register( WindowInfo * x)
{
WNDCLASSEX _class;
_class.cbSize = sizeof( WNDCLASSEX );
_class.style = CS_HREDRAW | CS_VREDRAW;
_class.lpfnWndProc = x->_wndProc;
_class.cbClsExtra = NULL;
_class.cbWndExtra = NULL;
_class.hInstance = x->_hinstance;
_class.hIcon = LoadIcon( NULL, IDI_APPLICATION );
_class.hCursor = LoadCursor( NULL, IDC_ARROW );
_class.hbrBackground = (HBRUSH)GetStockObject( BLACK_BRUSH );
_class.lpszMenuName = NULL;
_class.lpszClassName = x->_winType.c_str();
_class.hIconSm = LoadIcon( NULL, IDI_WINLOGO );
if( !RegisterClassEx( &_class ) )
{
iLogger.Write( "status","Failed to register the window class." );
throw std::runtime_error( "Failed to register the window class." );
return E_FAIL;
};
iLogger.Write( "status","Window class registered successfully." );
return Create( _class , x);
};
HRESULT Create( WNDCLASSEX _class , WindowInfo *x)
{
HWND hWnd = NULL;
hWnd = CreateWindow( _class.lpszClassName,
x->_name.c_str(),
x->_style,
CW_USEDEFAULT,
x->_y,
x->_width,
x->_height,
NULL,
NULL,
x->_hinstance,
NULL );
if( !hWnd )
{
iLogger.Write( "status","Failed to create the window." );
throw std::runtime_error( "Failed to create the window." );
return E_FAIL;
};
iLogger.Write( "status","Window created successfully." );
_init->PassHWND( hWnd );
return _init->Go();
};
Any help would be appreciated, Thank you.
[Edited by - Lenox on November 20, 2005 2:28:03 PM]