bool MAIN_APP::Run() { Time.Signal(); Renderer::Render(Time.Delta()); return true; }
bool DEMO_APP::Run() { theTime.Signal(); float dt = (float)theTime.Delta(); devContext->OMSetRenderTargets(1, &anotherView, DepthStencilView); devContext->RSSetViewports(1, &viewPort); float ClearColor[4] = { 0.0f, 0.0f, 0.0f, 1.0f }; devContext->ClearRenderTargetView(anotherView, ClearColor); devContext->ClearDepthStencilView(DepthStencilView, D3D11_CLEAR_DEPTH, 1.0f, 0); scene[0] = Inverse4x4(secondCamera); D3D11_MAPPED_SUBRESOURCE sceneMap; ZeroMemory(&sceneMap, sizeof(sceneMap)); devContext->Map(sceneMatrixBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &sceneMap); memcpy(sceneMap.pData, scene, sizeof(scene)); devContext->Unmap(sceneMatrixBuffer, 0); devContext->VSSetConstantBuffers(1, 1, &sceneMatrixBuffer); devContext->PSSetConstantBuffers(0, 1, &lightBuff); devContext->PSSetConstantBuffers(1, 1, &ambientBuff); devContext->PSSetConstantBuffers(2, 1, &ptltBuff); devContext->PSSetConstantBuffers(3, 1, &spotBuff); devContext->GSSetConstantBuffers(1, 1, &sceneMatrixBuffer); //Pyramid.worldMatrices[0] = RotateY(50.0f * dt) * Pyramid.worldMatrices[0]; //Pyramid.worldMatrices[1] = RotateZ(50.0f * dt) * Pyramid.worldMatrices[1]; //Pyramid.worldMatrices[2] = RotateX(50.0f * dt) * Pyramid.worldMatrices[2]; //Pyramid.worldMatrices[3] = RotateY(200.0f * dt) * RotateZ(200.0f * dt) * RotateX(200.0f * dt) * Pyramid.worldMatrices[3]; //SKYBOX RENDERING///// devContext->RSSetState(pOtherState); //SkyBox.worldMatrix = viewMatrix; SkyBox.worldMatrix.M[3][0] = secondCamera.M[3][0]; SkyBox.worldMatrix.M[3][1] = secondCamera.M[3][1]; SkyBox.worldMatrix.M[3][2] = secondCamera.M[3][2]; SkyBox.Render(); devContext->ClearDepthStencilView(DepthStencilView, D3D11_CLEAR_DEPTH, 1.0f, 0); /////////////////////// devContext->RSSetState(pRasterState); Pyramid.Render(); Quad.Render(); Tree.Render(); Tree2.Render(); Tree1.Render(); devContext->ResolveSubresource(fixerTexture, D3D11CalcSubresource(0, 0, 1), renderTexture, D3D11CalcSubresource(0, 0, 1), DXGI_FORMAT_R8G8B8A8_UNORM_SRGB); QuadSeed.Render(); devContext->GenerateMips(QuadSeed.pShaderResource); ///////////////////////////////////////////////////////////////////////////////////////////////////////// devContext->OMSetRenderTargets(1, &postProcessView, DepthStencilView); devContext->RSSetViewports(1, &viewPort); //float ClearColor[4] = { 0.0f, 0.0f, 0.0f, 1.0f }; devContext->ClearRenderTargetView(postProcessView, ClearColor); devContext->ClearDepthStencilView(DepthStencilView, D3D11_CLEAR_DEPTH, 1.0f, 0); scene[0] = Inverse4x4(viewMatrix); //D3D11_MAPPED_SUBRESOURCE sceneMap; ZeroMemory(&sceneMap, sizeof(sceneMap)); devContext->Map(sceneMatrixBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &sceneMap); memcpy(sceneMap.pData, scene, sizeof(scene)); devContext->Unmap(sceneMatrixBuffer, 0); devContext->VSSetConstantBuffers(1, 1, &sceneMatrixBuffer); devContext->PSSetConstantBuffers(0, 1, &lightBuff); devContext->PSSetConstantBuffers(1, 1, &ambientBuff); devContext->PSSetConstantBuffers(2, 1, &ptltBuff); devContext->PSSetConstantBuffers(3, 1, &spotBuff); devContext->GSSetConstantBuffers(1, 1, &sceneMatrixBuffer); //Pyramid.worldMatrices[0] = RotateY(50.0f * dt) * Pyramid.worldMatrices[0]; //Pyramid.worldMatrices[1] = RotateZ(50.0f * dt) * Pyramid.worldMatrices[1]; //Pyramid.worldMatrices[2] = RotateX(50.0f * dt) * Pyramid.worldMatrices[2]; //Pyramid.worldMatrices[3] = RotateY(200.0f * dt) * RotateZ(200.0f * dt) * RotateX(200.0f * dt) * Pyramid.worldMatrices[3]; //SKYBOX RENDERING///// devContext->RSSetState(pOtherState); //SkyBox.worldMatrix = viewMatrix; SkyBox.worldMatrix.M[3][0] = viewMatrix.M[3][0]; SkyBox.worldMatrix.M[3][1] = viewMatrix.M[3][1]; SkyBox.worldMatrix.M[3][2] = viewMatrix.M[3][2]; SkyBox.Render(); devContext->ClearDepthStencilView(DepthStencilView, D3D11_CLEAR_DEPTH, 1.0f, 0); /////////////////////// devContext->RSSetState(pRasterState); Pyramid.Render(); Quad.Render(); Tree.Render(); Tree1.Render(); Tree2.Render(); devContext->ResolveSubresource(fixerTexture, D3D11CalcSubresource(0, 0, 1), renderTexture, D3D11CalcSubresource(0, 0, 1), DXGI_FORMAT_R8G8B8A8_UNORM_SRGB); QuadSeed.Render(); devContext->GenerateMips(QuadSeed.pShaderResource); devContext->ResolveSubresource(fixerTexture, D3D11CalcSubresource(0, 0, 1), postTexture, D3D11CalcSubresource(0, 0, 1), DXGI_FORMAT_R8G8B8A8_UNORM_SRGB); PostQuad.Render(); ///////////////////////////////////////////////////////////////// devContext->OMSetRenderTargets(1, &targetView, DepthStencilView); //devContext->RSSetViewports(1, &viewPort); //float ClearColor[4] = { 0.0f, 0.0f, 0.0f, 1.0f }; devContext->ClearRenderTargetView(targetView, ClearColor); devContext->ClearDepthStencilView(DepthStencilView, D3D11_CLEAR_DEPTH, 1.0f, 0); MoveCamera(5.0f, 200.0f, dt); D3D11_MAPPED_SUBRESOURCE ambMap; ZeroMemory(&ambMap, sizeof(ambMap)); devContext->Map(ambientBuff, 0, D3D11_MAP_WRITE_DISCARD, 0, &ambMap); memcpy(ambMap.pData, &ambientLight, sizeof(ambientLight)); devContext->Unmap(ambientBuff, 0); D3D11_MAPPED_SUBRESOURCE lightMap; ZeroMemory(&lightMap, sizeof(lightMap)); devContext->Map(lightBuff, 0, D3D11_MAP_WRITE_DISCARD, 0, &lightMap); memcpy(lightMap.pData, &theLight, sizeof(theLight)); devContext->Unmap(lightBuff, 0); D3D11_MAPPED_SUBRESOURCE ptLtMap; ZeroMemory(&ptLtMap, sizeof(ptLtMap)); devContext->Map(ptltBuff, 0, D3D11_MAP_WRITE_DISCARD, 0, &ptLtMap); memcpy(ptLtMap.pData, &thePtLight, sizeof(thePtLight)); devContext->Unmap(ptltBuff, 0); D3D11_MAPPED_SUBRESOURCE spotMap; ZeroMemory(&spotMap, sizeof(spotMap)); devContext->Map(spotBuff, 0, D3D11_MAP_WRITE_DISCARD, 0, &spotMap); memcpy(spotMap.pData, &theSpotLight, sizeof(theSpotLight)); devContext->Unmap(spotBuff, 0); scene[0] = Inverse4x4(viewMatrix); SkyBox.worldMatrix.M[3][0] = viewMatrix.M[3][0]; SkyBox.worldMatrix.M[3][1] = viewMatrix.M[3][1]; SkyBox.worldMatrix.M[3][2] = viewMatrix.M[3][2]; //D3D11_MAPPED_SUBRESOURCE sceneMap; ZeroMemory(&sceneMap, sizeof(sceneMap)); devContext->Map(sceneMatrixBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &sceneMap); memcpy(sceneMap.pData, scene, sizeof(scene)); devContext->Unmap(sceneMatrixBuffer, 0); devContext->VSSetConstantBuffers(1, 1, &sceneMatrixBuffer); devContext->PSSetConstantBuffers(0, 1, &lightBuff); devContext->PSSetConstantBuffers(1, 1, &ambientBuff); devContext->PSSetConstantBuffers(2, 1, &ptltBuff); devContext->PSSetConstantBuffers(3, 1, &spotBuff); devContext->GSSetConstantBuffers(1, 1, &sceneMatrixBuffer); //Pyramid.worldMatrices[0] = RotateY(50.0f * dt) * Pyramid.worldMatrices[0]; //Pyramid.worldMatrices[1] = RotateZ(50.0f * dt) * Pyramid.worldMatrices[1]; //Pyramid.worldMatrices[2] = RotateX(50.0f * dt) * Pyramid.worldMatrices[2]; //Pyramid.worldMatrices[3] = RotateY(200.0f * dt) * RotateZ(200.0f * dt) * RotateX(200.0f * dt) * Pyramid.worldMatrices[3]; //SKYBOX RENDERING///// devContext->RSSetState(pOtherState); //SkyBox.worldMatrix = viewMatrix; SkyBox.Render(); devContext->ClearDepthStencilView(DepthStencilView, D3D11_CLEAR_DEPTH, 1.0f, 0); /////////////////////// devContext->RSSetState(pRasterState); Pyramid.Render(); Quad.Render(); Tree.Render(); Tree1.Render(); Tree2.Render(); devContext->ResolveSubresource(fixerTexture, D3D11CalcSubresource(0, 0, 1), renderTexture, D3D11CalcSubresource(0, 0, 1), DXGI_FORMAT_R8G8B8A8_UNORM_SRGB); QuadSeed.Render(); devContext->GenerateMips(QuadSeed.pShaderResource); //WHY BROKEN? devContext->ResolveSubresource(fixerTexture, D3D11CalcSubresource(0, 0, 1), postTexture, D3D11CalcSubresource(0, 0, 1), DXGI_FORMAT_R8G8B8A8_UNORM_SRGB); PostQuad.Render(); /////////////////////2nd VIEWPORT///////////////////////////////////////////////////////////////////////////////////////////////// devContext->OMSetRenderTargets(1, &anotherView, DepthStencilView); devContext->RSSetViewports(1, &otherPort); //float ClearColor[4] = { 0.0f, 0.0f, 0.0f, 1.0f }; devContext->ClearRenderTargetView(anotherView, ClearColor); devContext->ClearDepthStencilView(DepthStencilView, D3D11_CLEAR_DEPTH, 1.0f, 0); scene[0] = secondCamera; //D3D11_MAPPED_SUBRESOURCE sceneMap; ZeroMemory(&sceneMap, sizeof(sceneMap)); devContext->Map(sceneMatrixBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &sceneMap); memcpy(sceneMap.pData, scene, sizeof(scene)); devContext->Unmap(sceneMatrixBuffer, 0); devContext->VSSetConstantBuffers(1, 1, &sceneMatrixBuffer); devContext->PSSetConstantBuffers(0, 1, &lightBuff); devContext->PSSetConstantBuffers(1, 1, &ambientBuff); devContext->PSSetConstantBuffers(2, 1, &ptltBuff); devContext->PSSetConstantBuffers(3, 1, &spotBuff); devContext->GSSetConstantBuffers(1, 1, &sceneMatrixBuffer); //Pyramid.worldMatrices[0] = RotateY(50.0f * dt) * Pyramid.worldMatrices[0]; //Pyramid.worldMatrices[1] = RotateZ(50.0f * dt) * Pyramid.worldMatrices[1]; //Pyramid.worldMatrices[2] = RotateX(50.0f * dt) * Pyramid.worldMatrices[2]; //Pyramid.worldMatrices[3] = RotateY(200.0f * dt) * RotateZ(200.0f * dt) * RotateX(200.0f * dt) * Pyramid.worldMatrices[3]; //SKYBOX RENDERING///// devContext->RSSetState(pOtherState); //SkyBox.worldMatrix = viewMatrix; SkyBox.worldMatrix.M[3][0] = secondCamera.M[3][0]; SkyBox.worldMatrix.M[3][1] = secondCamera.M[3][1]; SkyBox.worldMatrix.M[3][2] = secondCamera.M[3][2]; SkyBox.Render(); devContext->ClearDepthStencilView(DepthStencilView, D3D11_CLEAR_DEPTH, 1.0f, 0); /////////////////////// devContext->RSSetState(pRasterState); Pyramid.Render(); Quad.Render(); Tree.Render(); Tree1.Render(); Tree2.Render(); devContext->ResolveSubresource(fixerTexture, D3D11CalcSubresource(0, 0, 1), renderTexture, D3D11CalcSubresource(0, 0, 1), DXGI_FORMAT_R8G8B8A8_UNORM_SRGB); QuadSeed.Render(); devContext->GenerateMips(QuadSeed.pShaderResource); //PostQuad.Render(); ///////////////////////////////////////////////////////////////// devContext->OMSetRenderTargets(1, &targetView, DepthStencilView); //devContext->RSSetViewports(1, &viewPort); //float ClearColor[4] = { 0.0f, 0.0f, 0.0f, 1.0f }; //devContext->ClearRenderTargetView(targetView, ClearColor); devContext->ClearDepthStencilView(DepthStencilView, D3D11_CLEAR_DEPTH, 1.0f, 0); //MoveCamera(5.0f, 200.0f, dt); //D3D11_MAPPED_SUBRESOURCE ambMap; ZeroMemory(&ambMap, sizeof(ambMap)); devContext->Map(ambientBuff, 0, D3D11_MAP_WRITE_DISCARD, 0, &ambMap); memcpy(ambMap.pData, &ambientLight, sizeof(ambientLight)); devContext->Unmap(ambientBuff, 0); //D3D11_MAPPED_SUBRESOURCE lightMap; ZeroMemory(&lightMap, sizeof(lightMap)); devContext->Map(lightBuff, 0, D3D11_MAP_WRITE_DISCARD, 0, &lightMap); memcpy(lightMap.pData, &theLight, sizeof(theLight)); devContext->Unmap(lightBuff, 0); //D3D11_MAPPED_SUBRESOURCE ptLtMap; ZeroMemory(&ptLtMap, sizeof(ptLtMap)); devContext->Map(ptltBuff, 0, D3D11_MAP_WRITE_DISCARD, 0, &ptLtMap); memcpy(ptLtMap.pData, &thePtLight, sizeof(thePtLight)); devContext->Unmap(ptltBuff, 0); //D3D11_MAPPED_SUBRESOURCE spotMap; ZeroMemory(&spotMap, sizeof(spotMap)); devContext->Map(spotBuff, 0, D3D11_MAP_WRITE_DISCARD, 0, &spotMap); memcpy(spotMap.pData, &theSpotLight, sizeof(theSpotLight)); devContext->Unmap(spotBuff, 0); scene[0] = secondCamera;//Inverse4x4(viewMatrix); //D3D11_MAPPED_SUBRESOURCE sceneMap; ZeroMemory(&sceneMap, sizeof(sceneMap)); devContext->Map(sceneMatrixBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &sceneMap); memcpy(sceneMap.pData, scene, sizeof(scene)); devContext->Unmap(sceneMatrixBuffer, 0); devContext->VSSetConstantBuffers(1, 1, &sceneMatrixBuffer); devContext->PSSetConstantBuffers(0, 1, &lightBuff); devContext->PSSetConstantBuffers(1, 1, &ambientBuff); devContext->PSSetConstantBuffers(2, 1, &ptltBuff); devContext->PSSetConstantBuffers(3, 1, &spotBuff); devContext->GSSetConstantBuffers(1, 1, &sceneMatrixBuffer); Pyramid.worldMatrices[0] = RotateY(50.0f * dt) * Pyramid.worldMatrices[0]; Pyramid.worldMatrices[1] = RotateZ(50.0f * dt) * Pyramid.worldMatrices[1]; Pyramid.worldMatrices[2] = RotateX(50.0f * dt) * Pyramid.worldMatrices[2]; Pyramid.worldMatrices[3] = RotateY(200.0f * dt) * RotateZ(200.0f * dt) * RotateX(200.0f * dt) * Pyramid.worldMatrices[3]; //SKYBOX RENDERING///// devContext->RSSetState(pOtherState); //SkyBox.worldMatrix = viewMatrix; SkyBox.worldMatrix.M[3][0] = secondCamera.M[3][0]; SkyBox.worldMatrix.M[3][1] = secondCamera.M[3][1]; SkyBox.worldMatrix.M[3][2] = secondCamera.M[3][2]; SkyBox.Render(); devContext->ClearDepthStencilView(DepthStencilView, D3D11_CLEAR_DEPTH, 1.0f, 0); /////////////////////// devContext->RSSetState(pRasterState); Pyramid.Render(); Quad.Render(); Tree.Render(); Tree1.Render(); Tree2.Render(); devContext->ResolveSubresource(fixerTexture, D3D11CalcSubresource(0, 0, 1), renderTexture, D3D11CalcSubresource(0, 0, 1), DXGI_FORMAT_R8G8B8A8_UNORM_SRGB); QuadSeed.Render(); devContext->GenerateMips(QuadSeed.pShaderResource); swapChain->Present(0, 0); return true; }