Original Post
Hiya guys been a while, EDIT - Please scroll down... the nature of the problem has infact changed. Thank you. I just recently began to learn DirectX 10 after a long while without programming... and well it feels great. The problem is that I am... "stuck". Here's my current code: As you can see its not complete. The problem is that when I compile the program I get an error, but when I set the device type to D3D10_DRIVER_TYPE_REFERENCE my program compiles without a problem. What I don't understand is why that little change fixes everything... I mean you need to use the reference device type only if the hardware has some sort of bug or if your graphics card simply doesn't support DirectX 10. I'm sure that my graphics card does indeed support DirectX 10 because when I open up the DirectX Diagnostic Tool ("dxdiag" in "run") it reports "DirectX 10" and the DirectX version. Do any of you guys know what's causing this problem? Thank you. [Edited by - pcbrainbuster on July 22, 2009 6:03:34 PM]
#include <windows.h>
#include <d3d10.h>
#include <d3dx10.h>
#pragma comment (lib, "d3d10.lib")
#pragma comment (lib, "d3dx10.lib")
#define Screen_Width 640
#define Screen_Height 480
HINSTANCE hInstance = NULL;
HWND hWnd = NULL;
ID3D10Device* D3D = NULL;
IDXGISwapChain* SwapChain = NULL;
LRESULT CALLBACK MainWndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
VOID InitD3D();
VOID RenderD3D();
VOID CleanDX();
INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, INT nCmdShow)
{
MSG Msg;
WNDCLASSEX WndClass;
ZeroMemory(&WndClass, sizeof(WNDCLASSEX));
WndClass.cbSize = sizeof(WNDCLASSEX);
WndClass.hbrBackground = GetSysColorBrush(COLOR_WINDOW);
WndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
WndClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
WndClass.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
WndClass.hInstance = hInstance;
WndClass.lpfnWndProc = MainWndProc;
WndClass.lpszClassName = "MainWND-Class";
WndClass.style = CS_HREDRAW | CS_VREDRAW;
RegisterClassEx(&WndClass);
hWnd = CreateWindowEx(NULL, WndClass.lpszClassName, "Test", WS_VISIBLE | WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, Screen_Width, Screen_Height, NULL, NULL, hInstance, NULL);
UpdateWindow(hWnd);
InitD3D();
while(GetMessage(&Msg, NULL, NULL, NULL) > 0)
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
RenderD3D();
}
CleanDX();
return 0;
}
LRESULT CALLBACK MainWndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
switch(Msg)
{
case WM_DESTROY:
PostQuitMessage(WM_QUIT);
break;
default: DefWindowProc(hWnd, Msg, wParam, lParam);
}
return TRUE;
}
VOID InitD3D()
{
DXGI_SWAP_CHAIN_DESC SC_Desc;
ID3D10RenderTargetView* RenderTargetView;
ID3D10Texture2D* BackBufferT;
ZeroMemory(&SC_Desc, sizeof(SC_Desc));
SC_Desc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
SC_Desc.BufferDesc.Height = Screen_Height;
SC_Desc.BufferDesc.RefreshRate.Denominator = 1;
SC_Desc.BufferDesc.RefreshRate.Numerator = 60;
SC_Desc.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
SC_Desc.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
SC_Desc.BufferDesc.Width = Screen_Width;
SC_Desc.BufferCount = 1;
SC_Desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
SC_Desc.Flags = 0;
SC_Desc.OutputWindow = hWnd;
SC_Desc.SampleDesc.Count = 1;
SC_Desc.SampleDesc.Quality = 0;
SC_Desc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
SC_Desc.Windowed = TRUE;
D3D10CreateDeviceAndSwapChain(NULL, D3D10_DRIVER_TYPE_HARDWARE, NULL, NULL, D3D10_SDK_VERSION, &SC_Desc, &SwapChain, &D3D);
SwapChain->GetBuffer(0, __uuidof(ID3D10Texture2D), (LPVOID*)&BackBufferT);
D3D->CreateRenderTargetView(BackBufferT, NULL, &RenderTargetView);
BackBufferT->Release();
}
VOID RenderD3D()
{
}
VOID CleanDX()
{
}