// Copyright (c) 2023 Dominic Masters // // This software is released under the MIT License. // https://opensource.org/licenses/MIT #include "display/shader/UIShader.hpp" using namespace Dawn; void UIShader::getStages( const enum ShaderOpenGLVariant variant, const struct UIShaderData *rel, std::vector> &stages, std::vector ¶meters ) { // Stages std::shared_ptr vertex; std::shared_ptr fragment; switch(variant) { case ShaderOpenGLVariant::GLSL_330_CORE: vertex = std::make_shared( ShaderStageType::VERTEX, "#version 330 core\n" "layout (location = 0) in vec3 aPos;\n" "layout (location = 1) in vec2 aTexCoord;\n" "uniform mat4 u_Projection;\n" "uniform mat4 u_View;\n" "uniform mat4 u_Model;\n" "out vec2 o_TextCoord;\n" "void main() {\n" "gl_Position = u_Projection * u_View * u_Model * vec4(aPos, 1.0);\n" "o_TextCoord = vec2(aTexCoord.x, aTexCoord.y);\n" "}" ); fragment = std::make_shared( ShaderStageType::FRAGMENT, "#version 330 core\n" "in vec2 o_TextCoord;\n" "uniform vec4 u_Color[4];\n" "out vec4 o_Color;\n" "void main() {\n" "o_Color = u_Color[2];\n" "}\n" ); break; default: assertUnreachable("Unsupported ShaderOpenGLVariant"); } // Add stages stages.push_back(vertex); stages.push_back(fragment); // Parameters parameters.push_back(ShaderOpenGLParameter( "u_Projection", &rel->projection, ShaderParameterType::MAT4 )); parameters.push_back(ShaderOpenGLParameter( "u_View", &rel->view, ShaderParameterType::MAT4 )); parameters.push_back(ShaderOpenGLParameter( "u_Model", &rel->model, ShaderParameterType::MAT4 )); parameters.push_back(ShaderOpenGLParameter( "u_Color", &rel->colors, ShaderParameterType::COLOR, 4 )); // parameters.push_back(ShaderOpenGLParameter( // "u_Color", // &rel->color, // ShaderParameterType::COLOR // )); // parameters.push_back(ShaderOpenGLParameter( // "u_HasTexture", // &rel->hasTexture, // ShaderParameterType::BOOLEAN // )); // parameters.push_back(ShaderOpenGLParameter( // "u_Texture", // &rel->texture, // ShaderParameterType::TEXTURE // )); }