load shader from resource
This commit is contained in:
parent
26eb97286d
commit
24c7faad4d
1
.gitignore
vendored
1
.gitignore
vendored
@ -5,3 +5,4 @@
|
|||||||
*.manifest
|
*.manifest
|
||||||
*.idb
|
*.idb
|
||||||
*.obj
|
*.obj
|
||||||
|
*.res
|
||||||
11
build.bat
11
build.bat
@ -1,8 +1,15 @@
|
|||||||
|
fxc /Od /Zi /T fx_4_0 /nologo /Fo main.fxo main.fx
|
||||||
|
|
||||||
|
rem build main resource
|
||||||
|
rc.exe /d "_UNICODE" /d "UNICODE" /fo"Debug\main.res" ".\main.rc"
|
||||||
|
|
||||||
|
rem compile
|
||||||
cl.exe @"compile.rsp" "main.cpp"
|
cl.exe @"compile.rsp" "main.cpp"
|
||||||
|
|
||||||
link.exe @"link.rsp" /OUT:"Debug\d3d10.exe" /PDB:"Debug\d3d10.pdb" ".\Debug\main.obj" /NOLOGO /ERRORREPORT:PROMPT
|
rem link
|
||||||
|
link.exe @"link.rsp" /NOLOGO /ERRORREPORT:PROMPT
|
||||||
|
|
||||||
fxc /Od /Zi /T fx_4_0 /nologo /Fo main.fxo main.fx
|
mt.exe -manifest d3d10.exe.manifest -outputresource:Debug\d3d10.exe;1
|
||||||
|
|
||||||
@if %errorlevel% neq 0 exit /b %errorlevel%
|
@if %errorlevel% neq 0 exit /b %errorlevel%
|
||||||
|
|
||||||
|
|||||||
7
link.rsp
7
link.rsp
@ -1,7 +1,10 @@
|
|||||||
/INCREMENTAL
|
/INCREMENTAL
|
||||||
/DEBUG
|
/DEBUG
|
||||||
/SUBSYSTEM:WINDOWS
|
/SUBSYSTEM:WINDOWS
|
||||||
|
/MANIFEST:NO
|
||||||
/MACHINE:X86
|
/MACHINE:X86
|
||||||
|
/OUT:"Debug\d3d10.exe"
|
||||||
|
/PDB:"Debug\d3d10.pdb"
|
||||||
d3d10.lib
|
d3d10.lib
|
||||||
d3dx10.lib
|
d3dx10.lib
|
||||||
kernel32.lib
|
kernel32.lib
|
||||||
@ -16,5 +19,5 @@ oleaut32.lib
|
|||||||
uuid.lib
|
uuid.lib
|
||||||
odbc32.lib
|
odbc32.lib
|
||||||
odbccp32.lib
|
odbccp32.lib
|
||||||
|
".\Debug\main.obj"
|
||||||
|
".\Debug\main.res"
|
||||||
30
main.cpp
30
main.cpp
@ -65,6 +65,7 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLi
|
|||||||
|
|
||||||
if (FAILED(InitDirect3DDevice())) {
|
if (FAILED(InitDirect3DDevice())) {
|
||||||
print("InitDirect3DDevice\n");
|
print("InitDirect3DDevice\n");
|
||||||
|
system("pause");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,6 +79,7 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
system("pause");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,19 +161,33 @@ HRESULT InitDirect3DDevice()
|
|||||||
sd.SampleDesc.Quality = 0;
|
sd.SampleDesc.Quality = 0;
|
||||||
sd.Windowed = TRUE;
|
sd.Windowed = TRUE;
|
||||||
|
|
||||||
HRESULT hr;
|
D3D10_DRIVER_TYPE driverTypes[] = {
|
||||||
hr = D3D10CreateDeviceAndSwapChain(NULL,
|
D3D10_DRIVER_TYPE_HARDWARE,
|
||||||
D3D10_DRIVER_TYPE_REFERENCE,
|
D3D10_DRIVER_TYPE_REFERENCE,
|
||||||
|
};
|
||||||
|
UINT numDriverTypes = (sizeof (driverTypes)) / (sizeof (driverTypes[0]));
|
||||||
|
|
||||||
|
HRESULT hr;
|
||||||
|
D3D10_DRIVER_TYPE driverType = D3D10_DRIVER_TYPE_NULL;
|
||||||
|
for (UINT i = 0; i < numDriverTypes; i++) {
|
||||||
|
driverType = driverTypes[i];
|
||||||
|
hr = D3D10CreateDeviceAndSwapChain(NULL,
|
||||||
|
driverType,
|
||||||
NULL,
|
NULL,
|
||||||
D3D10_CREATE_DEVICE_DEBUG,
|
0,
|
||||||
|
//D3D10_CREATE_DEVICE_DEBUG,
|
||||||
D3D10_SDK_VERSION,
|
D3D10_SDK_VERSION,
|
||||||
&sd,
|
&sd,
|
||||||
&g_pSwapChain,
|
&g_pSwapChain,
|
||||||
&g_pd3dDevice);
|
&g_pd3dDevice);
|
||||||
|
if (SUCCEEDED(hr))
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
print("D3D10CreateDeviceAndSwapChain\n");
|
print("D3D10CreateDeviceAndSwapChain\n");
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
print("driverType %d\n", driverType);
|
||||||
|
|
||||||
ID3D10Texture2D * pBackBuffer;
|
ID3D10Texture2D * pBackBuffer;
|
||||||
hr = g_pSwapChain->GetBuffer(0, __uuidof(ID3D10Texture2D), (LPVOID *)&pBackBuffer);
|
hr = g_pSwapChain->GetBuffer(0, __uuidof(ID3D10Texture2D), (LPVOID *)&pBackBuffer);
|
||||||
@ -202,7 +218,9 @@ HRESULT InitDirect3DDevice()
|
|||||||
|
|
||||||
ID3D10Blob * pBlobErrors = NULL;
|
ID3D10Blob * pBlobErrors = NULL;
|
||||||
DWORD dwShaderFlags = D3D10_SHADER_ENABLE_STRICTNESS | D3D10_SHADER_DEBUG;
|
DWORD dwShaderFlags = D3D10_SHADER_ENABLE_STRICTNESS | D3D10_SHADER_DEBUG;
|
||||||
hr = D3DX10CreateEffectFromFile(L"c:/Users/dot/d3d10/main.fx",
|
hr = D3DX10CreateEffectFromResource(NULL,
|
||||||
|
L"RES_MAIN_FXO",
|
||||||
|
L"main.fxo",
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
"fx_4_0",
|
"fx_4_0",
|
||||||
@ -216,8 +234,10 @@ HRESULT InitDirect3DDevice()
|
|||||||
NULL);
|
NULL);
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
print("D3DX10CreateEffectFromFile\n");
|
print("D3DX10CreateEffectFromFile\n");
|
||||||
|
if (pBlobErrors != NULL) {
|
||||||
const char * pError = (const char *)pBlobErrors->GetBufferPointer();
|
const char * pError = (const char *)pBlobErrors->GetBufferPointer();
|
||||||
(void)pError;
|
print("pError: %p\n", pError);
|
||||||
|
}
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user