Ejemplo n.º 1
0
    void VRender() override
    {
        // Set up the input assembler
        mRenderer->VSetPrimitiveType(GPU_PRIMITIVE_TYPE_TRIANGLE);

        DX3D11Renderer* dxRenderer = static_cast<DX3D11Renderer*>(mRenderer);
        ID3D11DeviceContext* deviceContext = dxRenderer->GetDeviceContext();
        deviceContext->RSSetViewports(1, &dxRenderer->GetViewport());

        switch (mBlurType)
        {
        case Rig3DSampleScene::BLUR_TYPE_NONE:
            RenderNoBlur();
            break;
        case Rig3DSampleScene::BLUR_TYPE_GAUSSIAN:
            RenderGuassianBlur();
            break;
        case Rig3DSampleScene::BLUR_TYPE_MOTION:
            RenderMotionBlur();
            break;
        default:
            break;
        }

        mRenderer->VSwapBuffers();
    }
Ejemplo n.º 2
0
	void VRender() override
	{
		float color[4] = { 0.2f, 0.2f, 0.2f, 1.0f };

		// Set up the input assembler
		mDeviceContext->IASetInputLayout(mInputLayout);
		mRenderer->VSetPrimitiveType(GPU_PRIMITIVE_TYPE_TRIANGLE);

		mDeviceContext->RSSetViewports(1, &mRenderer->GetViewport());
		mDeviceContext->OMSetRenderTargets(1, mRenderer->GetRenderTargetView(), mRenderer->GetDepthStencilView());
		mDeviceContext->ClearRenderTargetView(*mRenderer->GetRenderTargetView(), color);
		mDeviceContext->ClearDepthStencilView(
		mRenderer->GetDepthStencilView(),
			D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL,
			1.0f,
			0);

		mDeviceContext->VSSetShader(mVertexShader, NULL, 0);
		mDeviceContext->PSSetShader(mPixelShader, NULL, 0);

		mDeviceContext->UpdateSubresource(
			mConstantBuffer,
			0,
			NULL,
			&mMatrixBuffer,
			0,
			0); 

		mDeviceContext->VSSetConstantBuffers(
			0,
			1,
			&mConstantBuffer);

		// Bezier
		mDeviceContext->UpdateSubresource(static_cast<DX11Mesh*>(mBezierMesh)->mVertexBuffer, 0, NULL, &mBezierVertices, 0, 0);

		mRenderer->VSetPrimitiveType(GPU_PRIMITIVE_TYPE_LINE);
		mRenderer->VBindMesh(mBezierMesh);
		mRenderer->VDrawIndexed(0, mBezierMesh->GetIndexCount());

		// Handles
		mDeviceContext->UpdateSubresource(static_cast<DX11Mesh*>(mHandlesMesh)->mVertexBuffer, 0, NULL, &mHandlesVertices, 0, 0);

		mRenderer->VSetPrimitiveType(GPU_PRIMITIVE_TYPE_LINE);
		mRenderer->VBindMesh(mHandlesMesh);
		mRenderer->VDrawIndexed(0, mHandlesMesh->GetIndexCount());

		// Circles
		mRenderer->VSetPrimitiveType(GPU_PRIMITIVE_TYPE_TRIANGLE);
		for (size_t i = 0; i < 4; i++)
		{
			mMatrixBuffer.mWorld = (mat4f::scale(mCircleScale) * mat4f::translate(mBezier.p[i])).transpose();
			mDeviceContext->UpdateSubresource(mConstantBuffer, 0, NULL, &mMatrixBuffer, 0, 0);

			mRenderer->VBindMesh(mCircleMesh);
			mRenderer->VDrawIndexed(0, mCircleMesh->GetIndexCount());
		}


		mRenderer->VSwapBuffers();
	}