OK, well this is an example of what i compiled (i got it from here:
http://wiki.directxers.com/index.php?title...ct3D_10_Device)C++
#include "windows.h"
#include "d3d10.h"
bool g_bContinue = true;
//Besides the main function, there must be a message processing function
LRESULT WINAPI MsgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
switch( msg )
{
case WM_DESTROY:
PostQuitMessage( 0 );
g_bContinue = false;
return 0;
}
return DefWindowProc( hWnd, msg, wParam, lParam );
}
//The entry point of a windows application is the WinMain function
INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR, INT )
{
//Create a window class.
WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, MsgProc, 0L, 0L,
GetModuleHandle(NULL), NULL, NULL, NULL, NULL,
"Direct3D Window", NULL };
//Register the window class.
RegisterClassEx( &wc );
//Create the application's window.
HWND hWnd = CreateWindow( "Direct3D Window", "DirectX Wiki - D3D10 Tutorial 1",
WS_OVERLAPPEDWINDOW, 100, 100, 400, 400,
GetDesktopWindow(), NULL, wc.hInstance, NULL );
ShowWindow(hWnd,SW_SHOW);
//Create the Direct3D Device and Swap Chain
DXGI_SWAP_CHAIN_DESC sd;
ZeroMemory( &sd, sizeof(sd) );
sd.BufferCount = 1;
sd.BufferDesc.Width = 640;
sd.BufferDesc.Height = 480;
sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
sd.BufferDesc.RefreshRate.Numerator = 60;
sd.BufferDesc.RefreshRate.Denominator = 1;
sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
sd.OutputWindow = hWnd;
sd.SampleDesc.Count = 1;
sd.SampleDesc.Quality = 0;
sd.Windowed = TRUE;
IDXGISwapChain* pSwapChain = NULL;
ID3D10Device* pd3dDevice = NULL;
if( FAILED( D3D10CreateDeviceAndSwapChain( NULL,
D3D10_DRIVER_TYPE_REFERENCE,
NULL,
0,
D3D10_SDK_VERSION,
&sd,
&pSwapChain,
&pd3dDevice ) ) )
{
return FALSE;
}
// Create a render target view(from Backbuffer)
ID3D10Texture2D *pBackBuffer = NULL;
ID3D10RenderTargetView *pRenderTargetView = NULL;
if( FAILED( pSwapChain->GetBuffer( 0, __uuidof( ID3D10Texture2D ), (LPVOID*)&pBackBuffer ) ) )
return FALSE;
HRESULT hr = pd3dDevice->CreateRenderTargetView( pBackBuffer, NULL, &pRenderTargetView );
pBackBuffer->Release();
if( FAILED( hr ) )
return FALSE;
pd3dDevice->OMSetRenderTargets( 1, &pRenderTargetView, NULL );
//In D3D10 this must be done, because there is no default Viewport
D3D10_VIEWPORT vp;
vp.Width = 640;
vp.Height = 480;
vp.MinDepth = 0.0f;
vp.MaxDepth = 1.0f;
vp.TopLeftX = 0;
vp.TopLeftY = 0;
pd3dDevice->RSSetViewports( 1, &vp );
MSG msg;
while( g_bContinue )
{
//Clear render region with blue
float ClearColor[4] = { 0.0f, 0.0f, 1.0f, 1.0f }; //red,green,blue,alpha
pd3dDevice->ClearRenderTargetView( pRenderTargetView, ClearColor );
pSwapChain->Present( 0, 0 );
// A window has to handle its messages.
TranslateMessage( &msg );
DispatchMessage( &msg );
PeekMessage(&msg, 0, 0, 0, PM_REMOVE);
}
//Do not forget to clean up here
pSwapChain->Release();
pSwapChain = NULL;
pRenderTargetView->Release();
pRenderTargetView = NULL;
pd3dDevice->Release();
pd3dDevice = NULL;
return 0;
}
Basically when i run that, it takes about 3-5 seconds to work, and i messed around with it, to no avail
hope ya can help