I've been using directX 10 for a few days. I use Visual Studio C++ 2010 express edition, directX June 2010 sdk with directX 10 on Windows 7.
The error I've been getting is this, whenever I load the texture using the function mentioned above, either the file name is wrong, or the compiler can't find the image (it is .bmp).
Here are the global variables:
HINSTANCE hInstance;
HWND hWnd;
ID3D10Device* pDevice = NULL;
IDXGISwapChain* pSwapChain = NULL;
ID3D10RenderTargetView* pView = NULL;
ID3D10Texture2D *pTexture;
These are the function declarations for the DirectX functions:
ID3D10Texture * SetTexture(LPCWSTR name);
void ShowTexture();
void Render();
The SetTexture function is as follows:
ID3D10Resource *TextureResource = NULL;
ID3D10Texture2D *pTexture;
HRESULT hr = D3DX10CreateTextureFromFile(pDevice, name, NULL, NULL, &TextureResource, NULL);
if (FAILED(hr)){
return NULL;
}
TextureResource->QueryInterface(__uuidof(ID3D10Texture2D), (LPVOID*)&pTexture);
TextureResource->Release();
return pTexture;
And finally, the ShowTexture function is as follows:
ID3D10Texture2D *pBackBuffer;
HRESULT hr = pSwapChain->GetBuffer(0, __uuidof(ID3D10Texture2D), (LPVOID*)&pBackBuffer);
if(FAILED(hr)){
return hr;
}
D3D10_BOX region;
region.left = 0;
region.right = 640;
region.top = 0;
region.bottom = 480;
region.front = 0;
region.back = 1;
pDevice->CopySubresourceRegion(pBackBuffer, 0, 0, 0, 0, pTexture, 0, ®ion);
return S_OK;
I literally have no idea where to put these functions in the code, seems wherever I put them, I only get a blank screen (color is white, not even the clear screen color I set it to).
I tried putting it in my message loop in WinMain, I tried putting it in the middle of WinMain but it still does not display any image. Any help would be appreciated.
Aucun commentaire:
Enregistrer un commentaire