| 194 | } |
| 195 | |
| 196 | void SpriteRenderer::Begin(ID3D11DeviceContext* deviceContext, FilterMode filterMode, BlendMode blendMode) |
| 197 | { |
| 198 | _ASSERT(initialized); |
| 199 | _ASSERT(!context); |
| 200 | context = deviceContext; |
| 201 | |
| 202 | D3DPERF_BeginEvent(0xFFFFFFFF, L"SpriteRenderer Begin/End"); |
| 203 | |
| 204 | // Set the index buffer |
| 205 | context->IASetIndexBuffer(indexBuffer, DXGI_FORMAT_R16_UINT, 0); |
| 206 | |
| 207 | // Set primitive topology |
| 208 | context->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); |
| 209 | |
| 210 | ID3D11BlendState* blendState = blendMode == OpaqueBlend ? opaqueBlendState : alphaBlendState; |
| 211 | ID3D11PixelShader* ps = blendMode == OpaqueBlend ? pixelShaderOpaque : pixelShader; |
| 212 | |
| 213 | // Set the states |
| 214 | float blendFactor[4] = {1, 1, 1, 1}; |
| 215 | context->RSSetState(rastState); |
| 216 | context->OMSetBlendState(blendState, blendFactor, 0xFFFFFFFF); |
| 217 | context->OMSetDepthStencilState(dsState, 0); |
| 218 | |
| 219 | if (filterMode == Linear) |
| 220 | context->PSSetSamplers(0, 1, &(linearSamplerState.GetInterfacePtr())); |
| 221 | else if (filterMode == Point) |
| 222 | context->PSSetSamplers(0, 1, &(pointSamplerState.GetInterfacePtr())); |
| 223 | |
| 224 | // Set the shaders |
| 225 | context->PSSetShader(ps, nullptr, 0); |
| 226 | context->GSSetShader(nullptr, nullptr, 0); |
| 227 | context->DSSetShader(nullptr, nullptr, 0); |
| 228 | context->HSSetShader(nullptr, nullptr, 0); |
| 229 | } |
| 230 | |
| 231 | D3D11_TEXTURE2D_DESC SpriteRenderer::SetPerBatchData(ID3D11ShaderResourceView* texture) |
| 232 | { |
no outgoing calls
no test coverage detected