Mercurial > mm7
changeset 2522:b71d0e7837ac
Слияние
author | a.parshin |
---|---|
date | Thu, 09 Oct 2014 19:31:55 +0300 |
parents | 8e2022a843d9 (diff) 9f7908a4d8e6 (current diff) |
children | c532d5242055 |
files | Engine/MMT.cpp |
diffstat | 3 files changed, 98 insertions(+), 45 deletions(-) [+] |
line wrap: on
line diff
--- a/Engine/Graphics/RenderD3D11.cpp Thu Oct 09 22:02:47 2014 +0600 +++ b/Engine/Graphics/RenderD3D11.cpp Thu Oct 09 19:31:55 2014 +0300 @@ -144,23 +144,13 @@ void RenderD3D11::DrawTextureNew(float u, float v, Texture *tex) { - d3dc->OMSetRenderTargets(1, &primary_srv, nullptr); - - d3dc->VSSetShader(vs_test, nullptr, 0); - d3dc->PSSetShader(ps_test, nullptr, 0); - - uint uOffset = 0; - uint uStride = 4 * sizeof(float); - d3dc->IASetVertexBuffers(0, 1, &vb_test, &uStride, &uOffset); - d3dc->IASetInputLayout(layout_test); - d3dc->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST); - d3dc->Draw(6, 0); - - pSwapChain->Present(0, 0); + __debugbreak(); } void RenderD3D11::DrawTextureNew(float u, float v, RGBTexture *tex) { + ClearTarget(0); + if (!tex->d3d11_srv) { auto desc = tex->d3d11_desc = new D3D11_TEXTURE2D_DESC; @@ -207,6 +197,25 @@ ErrD3D(d3dd->CreateShaderResourceView(vram_texture, nullptr, (ID3D11ShaderResourceView **)&tex->d3d11_srv)); vram_texture->Release(); } + + + float blendFactor[4] = { 0.0f, 0.0f, 0.0f, 0.0f }; + d3dc->OMSetRenderTargets(1, &primary_srv, depth_srv); + d3dc->OMSetBlendState(ui_blend, blendFactor, 0xFFFFFFFF); + d3dc->OMSetDepthStencilState(ui_depthstencil, 1); + + d3dc->VSSetShader(ui_vs, nullptr, 0); + d3dc->PSSetShader(ui_ps, nullptr, 0); + + uint uOffset = 0; + uint uStride = 4 * sizeof(float); + d3dc->IASetVertexBuffers(0, 1, &ui_vb, &uStride, &uOffset); + d3dc->IASetInputLayout(ui_layout); + d3dc->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST); + + d3dc->Draw(6, 0); + + pSwapChain->Present(0, 0); } bool RenderD3D11::IsGammaSupported() @@ -364,23 +373,24 @@ - D3D11_RASTERIZER_DESC d3drs_desc; - memset(&d3drs_desc, 0, sizeof(d3drs_desc)); - d3drs_desc.FillMode = D3D11_FILL_SOLID; - d3drs_desc.CullMode = D3D11_CULL_NONE; - //d3drs_desc.FrontCounterClockwise = false; - //d3drs_desc.DepthBias = 0; - //d3drs_desc.DepthBiasClamp = 0.0f; - //d3drs_desc.SlopeScaledDepthBias = 0.0f; - //d3drs_desc.DepthClipEnable = true; - //d3drs_desc.ScissorEnable = false; - //d3drs_desc.MultisampleEnable = false; - //d3drs_desc.AntialiasedLineEnable = false; + D3D11_RASTERIZER_DESC default_rasterizer_desc; + memset(&default_rasterizer_desc, 0, sizeof(default_rasterizer_desc)); + default_rasterizer_desc.FillMode = D3D11_FILL_SOLID; + default_rasterizer_desc.CullMode = D3D11_CULL_NONE; + //default_rasterizer_desc.FrontCounterClockwise = false; + //default_rasterizer_desc.DepthBias = 0; + //default_rasterizer_desc.DepthBiasClamp = 0.0f; + //default_rasterizer_desc.SlopeScaledDepthBias = 0.0f; + //default_rasterizer_desc.DepthClipEnable = true; + //default_rasterizer_desc.ScissorEnable = false; + //default_rasterizer_desc.MultisampleEnable = false; + //default_rasterizer_desc.AntialiasedLineEnable = false; - ID3D11RasterizerState *d3drs; - ErrorD3D(d3dd->CreateRasterizerState(&d3drs_desc, &d3drs)); - d3dc->RSSetState(d3drs); - d3drs->Release(); + ErrorD3D(d3dd->CreateRasterizerState(&default_rasterizer_desc, &default_rasterizer)); + d3dc->RSSetState(default_rasterizer); + + default_depthstencil = nullptr; + default_blend = nullptr; @@ -390,30 +400,30 @@ viewport.TopLeftY = game_viewport_y; viewport.Width = game_viewport_width; viewport.Height = game_viewport_height; - //viewport.MinDepth = 0; + viewport.MinDepth = 0; viewport.MaxDepth = 1; d3dc->RSSetViewports(1, &viewport); D3D11_INPUT_ELEMENT_DESC layout_desc[] = { - { "POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, - { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 16, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + //{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 16, D3D11_INPUT_PER_VERTEX_DATA, 0 }, }; - CompileShader(d3dd, L"data/shaders/SimpleTexture.shader", layout_desc, 2, &vs_test, &ps_test, &layout_test); + CompileShader(d3dd, L"data/shaders/UI.shader", layout_desc, 1/*2*/, &ui_vs, &ui_ps, &ui_layout); { uint uVertexSize = 4 * sizeof(float); float test_mesh[] = { - -1, 1, 0.5, 1, - 1, 1, 0.5, 1, - -1, -1, 0.5, 1, + -1, 1, 0.1, 1, + 1, 1, 0.1, 1, + -1, -1, 0.1, 1, - -1, -1, 0.5, 1, - 1, 1, 0.5, 1, - 1, -1, 0.5, 1 + -1, -1, 0.1, 1, + 1, 1, 0.1, 1, + 1, -1, 0.1, 1 }; D3D11_BUFFER_DESC vbdesc; @@ -429,9 +439,38 @@ vbdata.SysMemPitch = 0; vbdata.SysMemSlicePitch = 0; - d3dd->CreateBuffer(&vbdesc, &vbdata, &vb_test); + d3dd->CreateBuffer(&vbdesc, &vbdata, &ui_vb); } + + + D3D11_DEPTH_STENCIL_DESC ui_depthstencil_desc; + ui_depthstencil_desc.DepthEnable = true; + ui_depthstencil_desc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL; + ui_depthstencil_desc.DepthFunc = D3D11_COMPARISON_ALWAYS; + ui_depthstencil_desc.StencilEnable = false; + ui_depthstencil_desc.StencilReadMask = 0xFF; + ui_depthstencil_desc.StencilWriteMask = 0xFF; + // Stencil operations if pixel is front-facing + ui_depthstencil_desc.FrontFace.StencilFailOp = D3D11_STENCIL_OP_KEEP; + ui_depthstencil_desc.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_INCR; + ui_depthstencil_desc.FrontFace.StencilPassOp = D3D11_STENCIL_OP_KEEP; + ui_depthstencil_desc.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS; + // Stencil operations if pixel is back-facing + ui_depthstencil_desc.BackFace.StencilFailOp = D3D11_STENCIL_OP_KEEP; + ui_depthstencil_desc.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP_DECR; + ui_depthstencil_desc.BackFace.StencilPassOp = D3D11_STENCIL_OP_KEEP; + ui_depthstencil_desc.BackFace.StencilFunc = D3D11_COMPARISON_ALWAYS; + + ErrorD3D(d3dd->CreateDepthStencilState(&ui_depthstencil_desc, &ui_depthstencil)); + + + D3D11_BLEND_DESC ui_blend_desc; + memset(&ui_blend_desc, 0, sizeof(ui_blend_desc)); + ui_blend_desc.RenderTarget[0].BlendEnable = false; + ui_blend_desc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL; + ErrD3D(d3dd->CreateBlendState(&ui_blend_desc, &ui_blend)); + return true; }
--- a/Engine/Graphics/RenderD3D11.h Thu Oct 09 22:02:47 2014 +0600 +++ b/Engine/Graphics/RenderD3D11.h Thu Oct 09 19:31:55 2014 +0300 @@ -172,9 +172,14 @@ ID3D11DeviceContext *d3dc; ID3D11RenderTargetView *primary_srv; ID3D11DepthStencilView *depth_srv; + ID3D11RasterizerState *default_rasterizer; + ID3D11DepthStencilState *default_depthstencil; + ID3D11BlendState *default_blend; - ID3D11VertexShader *vs_test; - ID3D11PixelShader *ps_test; - ID3D11InputLayout *layout_test; - ID3D11Buffer *vb_test; + ID3D11VertexShader *ui_vs; + ID3D11PixelShader *ui_ps; + ID3D11InputLayout *ui_layout; + ID3D11Buffer *ui_vb; + ID3D11DepthStencilState *ui_depthstencil; + ID3D11BlendState *ui_blend; };
--- a/Engine/MMT.cpp Thu Oct 09 22:02:47 2014 +0600 +++ b/Engine/MMT.cpp Thu Oct 09 19:31:55 2014 +0300 @@ -61,9 +61,18 @@ else tex.Load("mm6title.pcx", 2); + //while (true) + //{ pRenderer->BeginScene(); pRenderer->DrawTextureNew(0, 0, &tex); - //Sleep(5000); + + //MSG msg; + //while (PeekMessageW(&msg, 0, 0, 0, PM_REMOVE)) + //{ + // TranslateMessage(&msg); + // DispatchMessageW(&msg); + //} + //} tex.Release();