2020-05-27 09:21:20 +02:00
|
|
|
#include "framework.h"
|
2020-01-08 20:57:33 +01:00
|
|
|
#include "Renderer11.h"
|
2020-05-27 09:21:20 +02:00
|
|
|
#include "camera.h"
|
|
|
|
#include "spotcam.h"
|
2021-08-02 13:16:33 +02:00
|
|
|
#include "lara.h"
|
2021-08-28 13:27:58 +02:00
|
|
|
#include "control.h"
|
|
|
|
|
2021-08-30 18:03:21 +03:00
|
|
|
TEN::Renderer::RendererHUDBar* g_HealthBar;
|
|
|
|
TEN::Renderer::RendererHUDBar* g_AirBar;
|
|
|
|
TEN::Renderer::RendererHUDBar* g_DashBar;
|
|
|
|
TEN::Renderer::RendererHUDBar* g_MusicVolumeBar;
|
|
|
|
TEN::Renderer::RendererHUDBar* g_SFXVolumeBar;
|
2021-08-26 15:54:52 +03:00
|
|
|
|
2021-08-30 18:03:21 +03:00
|
|
|
namespace TEN::Renderer {
|
2020-01-12 23:10:38 +01:00
|
|
|
|
2020-08-09 15:25:56 +02:00
|
|
|
void Renderer11::initialiseBars()
|
2021-08-31 17:37:15 +02:00
|
|
|
{
|
2021-08-02 13:16:33 +02:00
|
|
|
std::array<Vector4, 5> healthColors = {
|
2020-06-21 14:27:12 +02:00
|
|
|
//top
|
|
|
|
Vector4(82 / 255.0f,0,0,1),
|
|
|
|
Vector4(0,82 / 255.0f,0,1),
|
|
|
|
//center
|
|
|
|
Vector4(78 / 255.0f,81 / 255.0f,0,1),
|
|
|
|
//bottom
|
|
|
|
Vector4(82 / 255.0f,0,0,1),
|
|
|
|
Vector4(0,82 / 255.0f,0,1),
|
|
|
|
};
|
|
|
|
|
2021-08-02 13:16:33 +02:00
|
|
|
std::array<Vector4, 5> airColors = {
|
2020-06-21 14:27:12 +02:00
|
|
|
//top
|
|
|
|
Vector4(0 ,0,90 / 255.0f,1),
|
|
|
|
Vector4(0 ,47 / 255.0f,96 / 255.0f,1),
|
|
|
|
//center
|
|
|
|
Vector4(0,39 / 255,155 / 255.0f,1),
|
|
|
|
//bottom
|
|
|
|
Vector4(0 ,0,90 / 255.0f,1),
|
|
|
|
Vector4(0 ,47 / 255.0f,96 / 255.0f,1),
|
|
|
|
};
|
|
|
|
|
2021-08-02 13:16:33 +02:00
|
|
|
std::array<Vector4, 5> dashColors = {
|
2020-06-21 14:27:12 +02:00
|
|
|
//top
|
|
|
|
Vector4(78 / 255.0f,4 / 255.0f,0,1),
|
|
|
|
Vector4(136 / 255.0f,117 / 255.0f,5 / 255.0f,1),
|
|
|
|
//center
|
|
|
|
Vector4(245 / 255.0f,119 / 255,24 / 255.0f,1),
|
|
|
|
//bottom
|
|
|
|
Vector4(78 / 255.0f,4 / 255.0f,0,1),
|
|
|
|
Vector4(136 / 255.0f,117 / 255.0f,5 / 255.0f,1),
|
|
|
|
};
|
2021-08-02 13:16:33 +02:00
|
|
|
std::array<Vector4, 5> soundSettingColors = {
|
2020-06-21 14:27:12 +02:00
|
|
|
//top
|
|
|
|
Vector4(0.18f,0.3f,0.72f,1),
|
|
|
|
Vector4(0.18f,0.3f,0.72f,1),
|
|
|
|
//center
|
|
|
|
Vector4(0.18f,0.3f,0.72f,1),
|
|
|
|
//bottom
|
|
|
|
Vector4(0.18f,0.3f,0.72f,1),
|
|
|
|
Vector4(0.18f,0.3f,0.72f,1),
|
|
|
|
};
|
2020-08-09 22:15:32 +02:00
|
|
|
g_HealthBar = new RendererHUDBar(m_device.Get(), 20, 32, 150, 8, 1, healthColors);
|
|
|
|
g_AirBar = new RendererHUDBar(m_device.Get(), 630, 32, 150, 8, 1, airColors);
|
|
|
|
g_DashBar = new RendererHUDBar(m_device.Get(), 630, 32 + 8 + 4, 150, 8, 1, dashColors);
|
2021-08-12 00:38:15 +01:00
|
|
|
g_MusicVolumeBar = new RendererHUDBar(m_device.Get(), 400, 194, 150, 8, 1, soundSettingColors);
|
|
|
|
g_SFXVolumeBar = new RendererHUDBar(m_device.Get(), 400, 212, 150, 8, 1, soundSettingColors);
|
2020-06-21 14:27:12 +02:00
|
|
|
}
|
2021-08-04 10:21:45 +02:00
|
|
|
void Renderer11::drawBar(float percent, const RendererHUDBar* const bar,GAME_OBJECT_ID textureSlot,int frame, bool poison) {
|
2020-06-21 14:27:12 +02:00
|
|
|
UINT strides = sizeof(RendererVertex);
|
|
|
|
UINT offset = 0;
|
|
|
|
float color[] = { 0,0,0,1.0f };
|
|
|
|
m_context->ClearDepthStencilView(m_depthStencilView, D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, 0.0f, 0xFF);
|
2020-08-09 22:15:32 +02:00
|
|
|
m_context->IASetInputLayout(m_inputLayout.Get());
|
2020-06-21 14:27:12 +02:00
|
|
|
m_context->IASetVertexBuffers(0, 1, bar->vertexBufferBorder.Buffer.GetAddressOf(), &strides, &offset);
|
|
|
|
m_context->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
|
|
|
|
m_context->IASetIndexBuffer(bar->indexBufferBorder.Buffer.Get(), DXGI_FORMAT_R32_UINT, 0);
|
2020-07-23 21:40:07 +02:00
|
|
|
m_context->VSSetConstantBuffers(0, 1, m_cbHUD.get());
|
2020-08-09 22:15:32 +02:00
|
|
|
m_context->VSSetShader(m_vsHUD.Get(), NULL, 0);
|
2021-08-04 10:21:45 +02:00
|
|
|
m_context->PSSetShaderResources(0, 1, m_sprites[Objects[ID_BAR_BORDER_GRAPHIC].meshIndex].Texture->ShaderResourceView.GetAddressOf());
|
2020-06-21 14:27:12 +02:00
|
|
|
ID3D11SamplerState* sampler = m_states->LinearClamp();
|
|
|
|
m_context->PSSetSamplers(0, 1, &sampler);
|
2020-08-09 22:15:32 +02:00
|
|
|
m_context->PSSetShader(m_psHUDTexture.Get(), NULL, 0);
|
2020-06-21 14:27:12 +02:00
|
|
|
m_context->OMSetBlendState(m_states->Opaque(), NULL, 0xFFFFFFFF);
|
|
|
|
m_context->OMSetDepthStencilState(m_states->DepthNone(), NULL);
|
|
|
|
m_context->RSSetState(m_states->CullNone());
|
|
|
|
m_context->DrawIndexed(56, 0, 0);
|
2021-08-04 10:21:45 +02:00
|
|
|
m_context->PSSetShaderResources(0, 1, m_sprites[Objects[textureSlot].meshIndex].Texture->ShaderResourceView.GetAddressOf());
|
2020-06-21 14:27:12 +02:00
|
|
|
|
|
|
|
|
|
|
|
m_context->ClearDepthStencilView(m_depthStencilView, D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, 0.0f, 0xFF);
|
2020-08-09 22:15:32 +02:00
|
|
|
m_context->IASetInputLayout(m_inputLayout.Get());
|
2020-06-21 14:27:12 +02:00
|
|
|
m_context->IASetVertexBuffers(0, 1, bar->vertexBuffer.Buffer.GetAddressOf(), &strides, &offset);
|
|
|
|
m_context->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
|
|
|
|
m_context->IASetIndexBuffer(bar->indexBuffer.Buffer.Get(), DXGI_FORMAT_R32_UINT, 0);
|
|
|
|
m_stHUDBar.Percent = percent;
|
2021-08-02 13:16:33 +02:00
|
|
|
m_stHUDBar.Poisoned = poison;
|
|
|
|
m_stHUDBar.Frame = frame;
|
2020-08-09 22:15:32 +02:00
|
|
|
m_cbHUDBar.updateData(m_stHUDBar, m_context.Get());
|
2020-07-23 21:40:07 +02:00
|
|
|
m_context->VSSetConstantBuffers(0, 1, m_cbHUD.get());
|
|
|
|
m_context->PSSetConstantBuffers(0, 1, m_cbHUDBar.get());
|
2020-08-09 22:15:32 +02:00
|
|
|
m_context->VSSetShader(m_vsHUD.Get(), NULL, 0);
|
|
|
|
m_context->PSSetShader(m_psHUDBarColor.Get(), NULL, 0);
|
2020-06-21 14:27:12 +02:00
|
|
|
m_context->OMSetBlendState(m_states->Opaque(), NULL, 0xFFFFFFFF);
|
|
|
|
m_context->OMSetDepthStencilState(m_states->DepthNone(), NULL);
|
|
|
|
m_context->RSSetState(m_states->CullNone());
|
2021-08-02 13:16:33 +02:00
|
|
|
m_context->DrawIndexed(12, 0, 0);
|
2020-06-21 14:27:12 +02:00
|
|
|
}
|
2020-01-08 20:57:33 +01:00
|
|
|
|
2020-08-09 15:25:56 +02:00
|
|
|
void Renderer11::addLine2D(int x1, int y1, int x2, int y2, byte r, byte g, byte b, byte a) {
|
2020-06-21 14:27:12 +02:00
|
|
|
RendererLine2D* line = &m_lines2DBuffer[m_nextLine2D++];
|
2020-01-08 20:57:33 +01:00
|
|
|
|
2020-06-21 14:27:12 +02:00
|
|
|
line->Vertices[0] = Vector2(x1, y1);
|
|
|
|
line->Vertices[1] = Vector2(x2, y2);
|
|
|
|
line->Color = Vector4(r, g, b, a);
|
2020-01-08 20:57:33 +01:00
|
|
|
|
2020-06-21 14:27:12 +02:00
|
|
|
m_lines2DToDraw.push_back(line);
|
|
|
|
}
|
2020-03-23 06:59:21 +01:00
|
|
|
|
2021-09-14 19:53:09 +03:00
|
|
|
void Renderer11::addQuad2D(RECT rect, byte r, byte g, byte b, byte a)
|
|
|
|
{
|
|
|
|
RendererRect2D* quad = &m_rects2DBuffer[m_nextRect2D++];
|
|
|
|
|
|
|
|
quad->Rectangle = rect;
|
|
|
|
quad->Color = Vector4(r, g, b, a);
|
|
|
|
|
|
|
|
m_rects2DToDraw.push_back(quad);
|
|
|
|
}
|
|
|
|
|
2020-10-11 16:47:36 +02:00
|
|
|
void Renderer11::drawOverlays(RenderView& view)
|
2021-08-06 11:06:43 +03:00
|
|
|
{
|
|
|
|
if (CurrentLevel == 0)
|
|
|
|
return;
|
|
|
|
|
2020-06-21 14:27:12 +02:00
|
|
|
if (!BinocularRange && !SpotcamOverlay)
|
2020-08-09 15:25:56 +02:00
|
|
|
return;
|
2020-06-21 14:27:12 +02:00
|
|
|
|
|
|
|
m_context->OMSetBlendState(m_states->AlphaBlend(), NULL, 0xFFFFFFFF);
|
|
|
|
|
2021-08-21 04:13:42 +03:00
|
|
|
if (BinocularRange && !LaserSight)
|
|
|
|
{
|
|
|
|
drawFullScreenQuad(m_sprites[Objects[ID_BINOCULAR_GRAPHIC].meshIndex].Texture->ShaderResourceView.Get(), Vector3::One, false);
|
|
|
|
}
|
|
|
|
else if (BinocularRange && LaserSight)
|
|
|
|
{
|
|
|
|
drawFullScreenQuad(m_sprites[Objects[ID_LASER_SIGHT_GRAPHIC].meshIndex].Texture->ShaderResourceView.Get(), Vector3::One, false);
|
|
|
|
|
|
|
|
m_context->OMSetBlendState(m_states->Opaque(), NULL, 0xFFFFFFFF);
|
|
|
|
|
2020-06-21 14:27:12 +02:00
|
|
|
// Draw the aiming point
|
|
|
|
RendererVertex vertices[4];
|
|
|
|
|
|
|
|
vertices[0].Position.x = -4.0f / ScreenWidth;
|
|
|
|
vertices[0].Position.y = 4.0f / ScreenHeight;
|
|
|
|
vertices[0].Position.z = 0.0f;
|
|
|
|
vertices[0].UV.x = 0.0f;
|
|
|
|
vertices[0].UV.y = 0.0f;
|
|
|
|
vertices[0].Color = Vector4(1.0f, 0.0f, 0.0f, 1.0f);
|
|
|
|
|
|
|
|
vertices[1].Position.x = 4.0f / ScreenWidth;
|
|
|
|
vertices[1].Position.y = 4.0f / ScreenHeight;
|
|
|
|
vertices[1].Position.z = 0.0f;
|
|
|
|
vertices[1].UV.x = 1.0f;
|
|
|
|
vertices[1].UV.y = 0.0f;
|
|
|
|
vertices[1].Color = Vector4(1.0f, 0.0f, 0.0f, 1.0f);
|
|
|
|
|
|
|
|
vertices[2].Position.x = 4.0f / ScreenWidth;
|
|
|
|
vertices[2].Position.y = -4.0f / ScreenHeight;
|
|
|
|
vertices[2].Position.z = 0.0f;
|
|
|
|
vertices[2].UV.x = 1.0f;
|
|
|
|
vertices[2].UV.y = 1.0f;
|
|
|
|
vertices[2].Color = Vector4(1.0f, 0.0f, 0.0f, 1.0f);
|
|
|
|
|
|
|
|
vertices[3].Position.x = -4.0f / ScreenWidth;
|
|
|
|
vertices[3].Position.y = -4.0f / ScreenHeight;
|
|
|
|
vertices[3].Position.z = 0.0f;
|
|
|
|
vertices[3].UV.x = 0.0f;
|
|
|
|
vertices[3].UV.y = 1.0f;
|
|
|
|
vertices[3].Color = Vector4(1.0f, 0.0f, 0.0f, 1.0f);
|
|
|
|
|
2020-08-09 22:15:32 +02:00
|
|
|
m_context->VSSetShader(m_vsFullScreenQuad.Get(), NULL, 0);
|
|
|
|
m_context->PSSetShader(m_psFullScreenQuad.Get(), NULL, 0);
|
2020-06-21 14:27:12 +02:00
|
|
|
|
|
|
|
m_context->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
|
2020-08-09 22:15:32 +02:00
|
|
|
m_context->IASetInputLayout(m_inputLayout.Get());
|
2020-06-21 14:27:12 +02:00
|
|
|
|
|
|
|
m_primitiveBatch->Begin();
|
|
|
|
m_primitiveBatch->DrawQuad(vertices[0], vertices[1], vertices[2], vertices[3]);
|
|
|
|
m_primitiveBatch->End();
|
|
|
|
}
|
2021-08-21 04:13:42 +03:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// TODO: Vignette goes here! -- Lwmte, 21.08.21
|
|
|
|
}
|
2020-03-23 06:59:21 +01:00
|
|
|
}
|
2020-01-08 20:57:33 +01:00
|
|
|
}
|