| 4572 | } |
| 4573 | |
| 4574 | void TextureViewer::on_customCreate_clicked() |
| 4575 | { |
| 4576 | QString filename = ui->customShader->currentText(); |
| 4577 | |
| 4578 | if(filename.isEmpty()) |
| 4579 | { |
| 4580 | RDDialog::critical(this, tr("Error Creating Shader"), |
| 4581 | tr("No shader name specified.\nEnter a new name in the textbox")); |
| 4582 | return; |
| 4583 | } |
| 4584 | |
| 4585 | if(m_CustomShaders.contains(filename.toUpper())) |
| 4586 | { |
| 4587 | RDDialog::critical(this, tr("Error Creating Shader"), |
| 4588 | tr("Selected shader already exists.\nEnter a new name in the textbox.")); |
| 4589 | ui->customShader->setCurrentText(QString()); |
| 4590 | UI_UpdateChannels(); |
| 4591 | return; |
| 4592 | } |
| 4593 | |
| 4594 | ShaderEncoding enc = encodingExtensions[QFileInfo(filename).completeSuffix()]; |
| 4595 | |
| 4596 | if(enc == ShaderEncoding::Unknown) |
| 4597 | { |
| 4598 | QString extString; |
| 4599 | |
| 4600 | for(auto it = encodingExtensions.begin(); it != encodingExtensions.end(); ++it) |
| 4601 | { |
| 4602 | if(!canCompileCustomShader(it.value())) |
| 4603 | continue; |
| 4604 | |
| 4605 | if(!extString.isEmpty()) |
| 4606 | extString += lit(", "); |
| 4607 | extString += it.key(); |
| 4608 | } |
| 4609 | |
| 4610 | RDDialog::critical(this, tr("Error Creating Shader"), |
| 4611 | tr("No file extension specified, unknown shading language.\n" |
| 4612 | "Filename must contain one of: %1") |
| 4613 | .arg(extString)); |
| 4614 | return; |
| 4615 | } |
| 4616 | |
| 4617 | QString src; |
| 4618 | |
| 4619 | if(enc == ShaderEncoding::HLSL || enc == ShaderEncoding::Slang) |
| 4620 | { |
| 4621 | src = |
| 4622 | lit("float4 main(float4 pos : SV_Position, float4 uv : TEXCOORD0) : SV_Target0\n" |
| 4623 | "{\n" |
| 4624 | " return float4(0,0,0,1);\n" |
| 4625 | "}\n"); |
| 4626 | } |
| 4627 | else if(enc == ShaderEncoding::GLSL) |
| 4628 | { |
| 4629 | src = |
| 4630 | lit("#version 420 core\n\n" |
| 4631 | "layout (location = 0) in vec2 uv;\n\n" |
nothing calls this directly
no test coverage detected