mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Improve ImGui shader string literals
Remove all useless indentation characters, change to static char array, use sizeof operator instead of strlen.
This commit is contained in:
parent
f6e6f834ce
commit
2ad72b9f8f
@ -383,37 +383,35 @@ bool ImGui_ImplDX11_CreateDeviceObjects()
|
||||
// Create the vertex shader
|
||||
// Shader taken from https://github.com/ocornut/imgui/issues/1724
|
||||
{
|
||||
static const char* vertexShader =
|
||||
"cbuffer vertexBuffer : register(b0) \
|
||||
{\
|
||||
float4x4 ProjectionMatrix; \
|
||||
};\
|
||||
struct VS_INPUT\
|
||||
{\
|
||||
float2 pos : POSITION;\
|
||||
float4 col : COLOR0;\
|
||||
float2 uv : TEXCOORD0;\
|
||||
};\
|
||||
\
|
||||
struct PS_INPUT\
|
||||
{\
|
||||
float4 pos : SV_POSITION;\
|
||||
float4 col : COLOR0;\
|
||||
float2 uv : TEXCOORD0;\
|
||||
};\
|
||||
\
|
||||
PS_INPUT main(VS_INPUT input)\
|
||||
{\
|
||||
PS_INPUT output;\
|
||||
output.pos = mul( ProjectionMatrix, float4(input.pos.xy, 0.f, 1.f));\
|
||||
output.col.xyz = pow(abs(input.col.xyz), 2.2f);\
|
||||
output.col.w = input.col.w;\
|
||||
output.uv = input.uv;\
|
||||
return output;\
|
||||
}";
|
||||
static const char vertexShader[] =
|
||||
"cbuffer vertexBuffer : register(b0)\n"
|
||||
"{\n"
|
||||
" float4x4 ProjectionMatrix;\n"
|
||||
"};\n"
|
||||
"struct VS_INPUT\n"
|
||||
"{\n"
|
||||
" float2 pos : POSITION;\n"
|
||||
" float4 col : COLOR0;\n"
|
||||
" float2 uv : TEXCOORD0;\n"
|
||||
"};\n"
|
||||
"struct PS_INPUT\n"
|
||||
"{\n"
|
||||
" float4 pos : SV_POSITION;\n"
|
||||
" float4 col : COLOR0;\n"
|
||||
" float2 uv : TEXCOORD0;\n"
|
||||
"};\n"
|
||||
"PS_INPUT main(VS_INPUT input)\n"
|
||||
"{\n"
|
||||
" PS_INPUT output;\n"
|
||||
" output.pos = mul(ProjectionMatrix, float4(input.pos.xy, 0.0f, 1.0f));\n"
|
||||
" output.col.xyz = pow(abs(input.col.xyz), 2.2f);\n"
|
||||
" output.col.w = input.col.w;\n"
|
||||
" output.uv = input.uv;\n"
|
||||
" return output;\n"
|
||||
"}\n";
|
||||
|
||||
ID3DBlob* vertexShaderBlob;
|
||||
if (FAILED(D3DCompile(vertexShader, strlen(vertexShader), nullptr, nullptr, nullptr, "main", "vs_4_0", 0, 0, &vertexShaderBlob, nullptr)))
|
||||
if (FAILED(D3DCompile(vertexShader, sizeof(vertexShader)-1, nullptr, nullptr, nullptr, "main", "vs_4_0", 0, 0, &vertexShaderBlob, nullptr)))
|
||||
return false; // NB: Pass ID3DBlob* pErrorBlob to D3DCompile() to get error showing in (const char*)pErrorBlob->GetBufferPointer(). Make sure to Release() the blob!
|
||||
if (bd->pd3dDevice->CreateVertexShader(vertexShaderBlob->GetBufferPointer(), vertexShaderBlob->GetBufferSize(), nullptr, &bd->pVertexShader) != S_OK)
|
||||
{
|
||||
@ -449,24 +447,23 @@ bool ImGui_ImplDX11_CreateDeviceObjects()
|
||||
|
||||
// Create the pixel shader
|
||||
{
|
||||
static const char* pixelShader =
|
||||
"struct PS_INPUT\
|
||||
{\
|
||||
float4 pos : SV_POSITION;\
|
||||
float4 col : COLOR0;\
|
||||
float2 uv : TEXCOORD0;\
|
||||
};\
|
||||
sampler sampler0;\
|
||||
Texture2D texture0;\
|
||||
\
|
||||
float4 main(PS_INPUT input) : SV_Target\
|
||||
{\
|
||||
float4 out_col = input.col * texture0.Sample(sampler0, input.uv); \
|
||||
return out_col; \
|
||||
}";
|
||||
static const char pixelShader[] =
|
||||
"struct PS_INPUT\n"
|
||||
"{\n"
|
||||
" float4 pos : SV_POSITION;\n"
|
||||
" float4 col : COLOR0;\n"
|
||||
" float2 uv : TEXCOORD0;\n"
|
||||
"};\n"
|
||||
"sampler sampler0;\n"
|
||||
"Texture2D texture0;\n"
|
||||
"float4 main(PS_INPUT input) : SV_Target\n"
|
||||
"{\n"
|
||||
" float4 output = input.col * texture0.Sample(sampler0, input.uv);\n"
|
||||
" return output;\n"
|
||||
"}\n";
|
||||
|
||||
ID3DBlob* pixelShaderBlob;
|
||||
if (FAILED(D3DCompile(pixelShader, strlen(pixelShader), nullptr, nullptr, nullptr, "main", "ps_4_0", 0, 0, &pixelShaderBlob, nullptr)))
|
||||
if (FAILED(D3DCompile(pixelShader, sizeof(pixelShader)-1, nullptr, nullptr, nullptr, "main", "ps_4_0", 0, 0, &pixelShaderBlob, nullptr)))
|
||||
return false; // NB: Pass ID3DBlob* pErrorBlob to D3DCompile() to get error showing in (const char*)pErrorBlob->GetBufferPointer(). Make sure to Release() the blob!
|
||||
if (bd->pd3dDevice->CreatePixelShader(pixelShaderBlob->GetBufferPointer(), pixelShaderBlob->GetBufferSize(), nullptr, &bd->pPixelShader) != S_OK)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user