Compare commits
No commits in common. "98804d9ee4598c47b6d359a86b04ede453113cef" and "24c7faad4db35cbc22affbb9736687b8e018dc68" have entirely different histories.
98804d9ee4
...
24c7faad4d
1
.gitignore
vendored
1
.gitignore
vendored
@ -6,4 +6,3 @@
|
|||||||
*.idb
|
*.idb
|
||||||
*.obj
|
*.obj
|
||||||
*.res
|
*.res
|
||||||
*.aps
|
|
||||||
10
build.bat
10
build.bat
@ -1,23 +1,15 @@
|
|||||||
fxc /Od /Zi /T fx_4_0 /nologo /Fo main.fxo main.fx
|
fxc /Od /Zi /T fx_4_0 /nologo /Fo main.fxo main.fx
|
||||||
|
|
||||||
@if %errorlevel% neq 0 exit /b %errorlevel%
|
|
||||||
|
|
||||||
rem build main resource
|
rem build main resource
|
||||||
rc.exe /d "_UNICODE" /d "UNICODE" /fo"Debug\main.res" ".\main.rc"
|
rc.exe /d "_UNICODE" /d "UNICODE" /fo"Debug\main.res" ".\main.rc"
|
||||||
|
|
||||||
@if %errorlevel% neq 0 exit /b %errorlevel%
|
|
||||||
|
|
||||||
rem compile
|
rem compile
|
||||||
cl.exe @"compile.rsp" "main.cpp"
|
cl.exe @"compile.rsp" "main.cpp"
|
||||||
|
|
||||||
@if %errorlevel% neq 0 exit /b %errorlevel%
|
|
||||||
|
|
||||||
rem link
|
rem link
|
||||||
link.exe @"link.rsp" /NOLOGO /ERRORREPORT:PROMPT
|
link.exe @"link.rsp" /NOLOGO /ERRORREPORT:PROMPT
|
||||||
|
|
||||||
@if %errorlevel% neq 0 exit /b %errorlevel%
|
mt.exe -manifest d3d10.exe.manifest -outputresource:Debug\d3d10.exe;1
|
||||||
|
|
||||||
mt.exe -manifest d3d10.exe.debug.manifest -outputresource:Debug\d3d10.exe;1
|
|
||||||
|
|
||||||
@if %errorlevel% neq 0 exit /b %errorlevel%
|
@if %errorlevel% neq 0 exit /b %errorlevel%
|
||||||
|
|
||||||
|
|||||||
@ -1,24 +0,0 @@
|
|||||||
fxc /Od /Zi /T fx_4_0 /nologo /Fo main.fxo main.fx
|
|
||||||
|
|
||||||
@if %errorlevel% neq 0 exit /b %errorlevel%
|
|
||||||
|
|
||||||
rem build main resource
|
|
||||||
rc.exe /d "_UNICODE" /d "UNICODE" /fo"Release\main.res" ".\main.rc"
|
|
||||||
|
|
||||||
@if %errorlevel% neq 0 exit /b %errorlevel%
|
|
||||||
|
|
||||||
rem compile
|
|
||||||
cl.exe @"compile_release.rsp" "main.cpp"
|
|
||||||
|
|
||||||
@if %errorlevel% neq 0 exit /b %errorlevel%
|
|
||||||
|
|
||||||
rem link
|
|
||||||
link.exe @"link_release.rsp" /NOLOGO /ERRORREPORT:PROMPT
|
|
||||||
|
|
||||||
@if %errorlevel% neq 0 exit /b %errorlevel%
|
|
||||||
|
|
||||||
mt.exe -manifest d3d10.exe.release.manifest -outputresource:Release\d3d10.exe;1
|
|
||||||
|
|
||||||
@if %errorlevel% neq 0 exit /b %errorlevel%
|
|
||||||
|
|
||||||
Release\d3d10.exe
|
|
||||||
@ -1,19 +0,0 @@
|
|||||||
/O2
|
|
||||||
/GL
|
|
||||||
/D "WIN32"
|
|
||||||
/D "NDEBUG"
|
|
||||||
/D "_WINDOWS"
|
|
||||||
/D "_UNICODE"
|
|
||||||
/D "UNICODE"
|
|
||||||
/FD
|
|
||||||
/EHsc
|
|
||||||
/MT
|
|
||||||
/Fo"Release\\"
|
|
||||||
/Fd"Release\vc80.pdb"
|
|
||||||
/W3
|
|
||||||
/c
|
|
||||||
/Wp64
|
|
||||||
/Zi
|
|
||||||
/TP
|
|
||||||
/nologo
|
|
||||||
/errorReport:prompt
|
|
||||||
@ -1,25 +0,0 @@
|
|||||||
/INCREMENTAL:NO
|
|
||||||
/SUBSYSTEM:WINDOWS
|
|
||||||
/OPT:REF
|
|
||||||
/OPT:ICF
|
|
||||||
/LTCG
|
|
||||||
/MANIFEST:NO
|
|
||||||
/MACHINE:X86
|
|
||||||
/OUT:"Release\d3d10.exe"
|
|
||||||
/PDB:"Release\d3d10.pdb"
|
|
||||||
d3d10.lib
|
|
||||||
d3dx10.lib
|
|
||||||
kernel32.lib
|
|
||||||
user32.lib
|
|
||||||
gdi32.lib
|
|
||||||
winspool.lib
|
|
||||||
comdlg32.lib
|
|
||||||
advapi32.lib
|
|
||||||
shell32.lib
|
|
||||||
ole32.lib
|
|
||||||
oleaut32.lib
|
|
||||||
uuid.lib
|
|
||||||
odbc32.lib
|
|
||||||
odbccp32.lib
|
|
||||||
".\Release\main.obj"
|
|
||||||
".\Release\main.res"
|
|
||||||
86
main.cpp
86
main.cpp
@ -8,9 +8,7 @@ HINSTANCE g_hInstance = NULL;
|
|||||||
HWND g_hWnd = NULL;
|
HWND g_hWnd = NULL;
|
||||||
ID3D10Device * g_pd3dDevice = NULL;
|
ID3D10Device * g_pd3dDevice = NULL;
|
||||||
IDXGISwapChain * g_pSwapChain = NULL;
|
IDXGISwapChain * g_pSwapChain = NULL;
|
||||||
ID3D10Texture2D * g_pDepthStencil = NULL;
|
|
||||||
ID3D10RenderTargetView * g_pRenderTargetView = NULL;
|
ID3D10RenderTargetView * g_pRenderTargetView = NULL;
|
||||||
ID3D10DepthStencilView * g_pDepthStencilView = NULL;
|
|
||||||
ID3D10Effect * g_pEffect = NULL;
|
ID3D10Effect * g_pEffect = NULL;
|
||||||
ID3D10EffectTechnique * g_pTechnique = NULL;
|
ID3D10EffectTechnique * g_pTechnique = NULL;
|
||||||
ID3D10InputLayout * g_pVertexLayout = NULL;
|
ID3D10InputLayout * g_pVertexLayout = NULL;
|
||||||
@ -20,8 +18,7 @@ ID3D10Buffer * g_pIndexBuffer = NULL;
|
|||||||
ID3D10EffectMatrixVariable * g_pWorldVariable = NULL;
|
ID3D10EffectMatrixVariable * g_pWorldVariable = NULL;
|
||||||
ID3D10EffectMatrixVariable * g_pViewVariable = NULL;
|
ID3D10EffectMatrixVariable * g_pViewVariable = NULL;
|
||||||
ID3D10EffectMatrixVariable * g_pProjectionVariable = NULL;
|
ID3D10EffectMatrixVariable * g_pProjectionVariable = NULL;
|
||||||
D3DXMATRIX g_World1;
|
D3DXMATRIX g_World;
|
||||||
D3DXMATRIX g_World2;
|
|
||||||
D3DXMATRIX g_View;
|
D3DXMATRIX g_View;
|
||||||
D3DXMATRIX g_Projection;
|
D3DXMATRIX g_Projection;
|
||||||
|
|
||||||
@ -153,8 +150,8 @@ HRESULT InitDirect3DDevice()
|
|||||||
|
|
||||||
DXGI_SWAP_CHAIN_DESC sd = {};
|
DXGI_SWAP_CHAIN_DESC sd = {};
|
||||||
sd.BufferCount = 1;
|
sd.BufferCount = 1;
|
||||||
sd.BufferDesc.Width = width;
|
sd.BufferDesc.Width = 640;
|
||||||
sd.BufferDesc.Height = height;
|
sd.BufferDesc.Height = 480;
|
||||||
sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||||
sd.BufferDesc.RefreshRate.Numerator = 60;
|
sd.BufferDesc.RefreshRate.Numerator = 60;
|
||||||
sd.BufferDesc.RefreshRate.Denominator = 1;
|
sd.BufferDesc.RefreshRate.Denominator = 1;
|
||||||
@ -192,7 +189,6 @@ HRESULT InitDirect3DDevice()
|
|||||||
}
|
}
|
||||||
print("driverType %d\n", driverType);
|
print("driverType %d\n", driverType);
|
||||||
|
|
||||||
// back buffer
|
|
||||||
ID3D10Texture2D * pBackBuffer;
|
ID3D10Texture2D * pBackBuffer;
|
||||||
hr = g_pSwapChain->GetBuffer(0, __uuidof(ID3D10Texture2D), (LPVOID *)&pBackBuffer);
|
hr = g_pSwapChain->GetBuffer(0, __uuidof(ID3D10Texture2D), (LPVOID *)&pBackBuffer);
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
@ -206,37 +202,12 @@ HRESULT InitDirect3DDevice()
|
|||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// depth buffer
|
g_pd3dDevice->OMSetRenderTargets(1, &g_pRenderTargetView, NULL);
|
||||||
D3D10_TEXTURE2D_DESC descDepth;
|
|
||||||
descDepth.Width = width;
|
|
||||||
descDepth.Height = height;
|
|
||||||
descDepth.MipLevels = 1;
|
|
||||||
descDepth.ArraySize = 1;
|
|
||||||
descDepth.Format = DXGI_FORMAT_D32_FLOAT;
|
|
||||||
descDepth.SampleDesc.Count = 1;
|
|
||||||
descDepth.SampleDesc.Quality = 0;
|
|
||||||
descDepth.Usage = D3D10_USAGE_DEFAULT;
|
|
||||||
descDepth.BindFlags = D3D10_BIND_DEPTH_STENCIL;
|
|
||||||
descDepth.CPUAccessFlags = 0;
|
|
||||||
descDepth.MiscFlags = 0;
|
|
||||||
hr = g_pd3dDevice->CreateTexture2D(&descDepth, NULL, &g_pDepthStencil);
|
|
||||||
if (FAILED(hr))
|
|
||||||
return hr;
|
|
||||||
|
|
||||||
D3D10_DEPTH_STENCIL_VIEW_DESC descDSV;
|
|
||||||
descDSV.Format = descDepth.Format;
|
|
||||||
descDSV.ViewDimension = D3D10_DSV_DIMENSION_TEXTURE2D;
|
|
||||||
descDSV.Texture2D.MipSlice = 0;
|
|
||||||
hr = g_pd3dDevice->CreateDepthStencilView(g_pDepthStencil, &descDSV, &g_pDepthStencilView);
|
|
||||||
if (FAILED(hr))
|
|
||||||
return hr;
|
|
||||||
|
|
||||||
g_pd3dDevice->OMSetRenderTargets(1, &g_pRenderTargetView, g_pDepthStencilView);
|
|
||||||
|
|
||||||
// viewport
|
// viewport
|
||||||
D3D10_VIEWPORT vp;
|
D3D10_VIEWPORT vp;
|
||||||
vp.Width = width;
|
vp.Width = 640;
|
||||||
vp.Height = height;
|
vp.Height = 480;
|
||||||
vp.MinDepth = 0.0f;
|
vp.MinDepth = 0.0f;
|
||||||
vp.MaxDepth = 1.0f;
|
vp.MaxDepth = 1.0f;
|
||||||
vp.TopLeftX = 0;
|
vp.TopLeftX = 0;
|
||||||
@ -262,7 +233,7 @@ HRESULT InitDirect3DDevice()
|
|||||||
&pBlobErrors,
|
&pBlobErrors,
|
||||||
NULL);
|
NULL);
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
print("D3DX10CreateEffectFromResource\n");
|
print("D3DX10CreateEffectFromFile\n");
|
||||||
if (pBlobErrors != NULL) {
|
if (pBlobErrors != NULL) {
|
||||||
const char * pError = (const char *)pBlobErrors->GetBufferPointer();
|
const char * pError = (const char *)pBlobErrors->GetBufferPointer();
|
||||||
print("pError: %p\n", pError);
|
print("pError: %p\n", pError);
|
||||||
@ -365,8 +336,7 @@ HRESULT InitDirect3DDevice()
|
|||||||
g_pd3dDevice->IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
|
g_pd3dDevice->IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
|
||||||
|
|
||||||
// transform matrices
|
// transform matrices
|
||||||
D3DXMatrixIdentity(&g_World1);
|
D3DXMatrixIdentity(&g_World);
|
||||||
D3DXMatrixIdentity(&g_World2);
|
|
||||||
|
|
||||||
D3DXVECTOR3 Eye(0.0f, 2.0f, -5.0f);
|
D3DXVECTOR3 Eye(0.0f, 2.0f, -5.0f);
|
||||||
D3DXVECTOR3 At(0.0f, 1.0f, 0.0f);
|
D3DXVECTOR3 At(0.0f, 1.0f, 0.0f);
|
||||||
@ -389,55 +359,21 @@ HRESULT InitDirect3DDevice()
|
|||||||
void Render()
|
void Render()
|
||||||
{
|
{
|
||||||
static float t = 0.0f;
|
static float t = 0.0f;
|
||||||
if (0) {
|
|
||||||
t += (float)D3DX_PI * 0.0125f;
|
t += (float)D3DX_PI * 0.0125f;
|
||||||
} else {
|
D3DXMatrixRotationY(&g_World, t);
|
||||||
static DWORD dwTimeStart = 0;
|
|
||||||
DWORD dwTimeCur = GetTickCount();
|
|
||||||
if (dwTimeStart == 0)
|
|
||||||
dwTimeStart = dwTimeCur;
|
|
||||||
t = (dwTimeCur - dwTimeStart) / 1000.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
// first cube
|
|
||||||
D3DXMatrixRotationY(&g_World1, t);
|
|
||||||
|
|
||||||
// second cube
|
|
||||||
D3DXMATRIX mTranslate;
|
|
||||||
D3DXMATRIX mOrbit;
|
|
||||||
D3DXMATRIX mSpin;
|
|
||||||
D3DXMATRIX mScale;
|
|
||||||
D3DXMatrixRotationZ(&mSpin, -t);
|
|
||||||
D3DXMatrixRotationY(&mOrbit, -t * 2.0f);
|
|
||||||
D3DXMatrixTranslation(&mTranslate, -4.0f, 0.0f, 0.0f);
|
|
||||||
D3DXMatrixScaling(&mScale, 0.3f, 0.3f, 0.3f);
|
|
||||||
|
|
||||||
D3DXMatrixMultiply(&g_World2, &mScale, &mSpin);
|
|
||||||
D3DXMatrixMultiply(&g_World2, &g_World2, &mTranslate);
|
|
||||||
D3DXMatrixMultiply(&g_World2, &g_World2, &mOrbit);
|
|
||||||
|
|
||||||
|
|
||||||
float ClearColor[4] = { 0.0f, 0.125f, 0.6f, 1.0f };
|
float ClearColor[4] = { 0.0f, 0.125f, 0.6f, 1.0f };
|
||||||
g_pd3dDevice->ClearRenderTargetView(g_pRenderTargetView, ClearColor);
|
g_pd3dDevice->ClearRenderTargetView(g_pRenderTargetView, ClearColor);
|
||||||
g_pd3dDevice->ClearDepthStencilView(g_pDepthStencilView, D3D10_CLEAR_DEPTH, 1.0f, 0);
|
|
||||||
|
|
||||||
|
g_pWorldVariable->SetMatrix((float *)&g_World);
|
||||||
g_pViewVariable->SetMatrix((float *)&g_View);
|
g_pViewVariable->SetMatrix((float *)&g_View);
|
||||||
g_pProjectionVariable->SetMatrix((float *)&g_Projection);
|
g_pProjectionVariable->SetMatrix((float *)&g_Projection);
|
||||||
|
|
||||||
D3D10_TECHNIQUE_DESC techDesc;
|
D3D10_TECHNIQUE_DESC techDesc;
|
||||||
g_pTechnique->GetDesc( &techDesc );
|
g_pTechnique->GetDesc( &techDesc );
|
||||||
|
|
||||||
// render first cube
|
|
||||||
g_pWorldVariable->SetMatrix((float *)&g_World1);
|
|
||||||
for(UINT p = 0; p < techDesc.Passes; p++) {
|
|
||||||
g_pTechnique->GetPassByIndex(p)->Apply(0);
|
|
||||||
g_pd3dDevice->DrawIndexed(36, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// render second cube
|
|
||||||
g_pWorldVariable->SetMatrix((float *)&g_World2);
|
|
||||||
for(UINT p = 0; p < techDesc.Passes; p++) {
|
for(UINT p = 0; p < techDesc.Passes; p++) {
|
||||||
g_pTechnique->GetPassByIndex(p)->Apply(0);
|
g_pTechnique->GetPassByIndex(p)->Apply(0);
|
||||||
|
//g_pd3dDevice->Draw(3, 0);
|
||||||
g_pd3dDevice->DrawIndexed(36, 0, 0);
|
g_pd3dDevice->DrawIndexed(36, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user