95 lines
2.3 KiB
C++
95 lines
2.3 KiB
C++
/**
|
|
This file is a part of our_dick
|
|
Copyright (C) 2022 rexy712
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU Affero General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU Affero General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#ifndef OUR_DICK_GRAPHICS_WIP_OGL_BASE_SHADER_HPP
|
|
#define OUR_DICK_GRAPHICS_WIP_OGL_BASE_SHADER_HPP
|
|
|
|
#include "shader_source.hpp"
|
|
#include "gfx/ogl/shader_stage.hpp"
|
|
|
|
#include "shader.hpp"
|
|
|
|
namespace wip::gfx::ogl{
|
|
|
|
class base_shader
|
|
{
|
|
public:
|
|
static inline constexpr shader_source sources[] = {
|
|
{
|
|
.text =
|
|
R"glsl(
|
|
#version 450 core
|
|
|
|
layout (location = 0) in vec3 position;
|
|
layout (location = 1) in vec2 tex_coords;
|
|
layout (location = 3) in vec4 fcolor;
|
|
|
|
layout (binding = 0, std140) uniform mvp_matrix{
|
|
mat4 vp_mat;
|
|
};
|
|
layout (binding = 1, std140) uniform model_matrix{
|
|
mat4 model_mat;
|
|
};
|
|
|
|
out VS_OUT{
|
|
vec2 tex_coords;
|
|
vec4 fcolor;
|
|
}vs_out;
|
|
|
|
const vec4 vertices[6] = vec4[](vec4(0,1,0,1), vec4(0,0,0,1), vec4(1,0,0,1), vec4(1,0,0,1), vec4(1,1,0,1), vec4(0,1,0,1));
|
|
|
|
void main(){
|
|
gl_Position = vp_mat * model_mat * vec4(position, 1);
|
|
vs_out.tex_coords = tex_coords;
|
|
}
|
|
)glsl",
|
|
.len = 0,
|
|
.type = shader_type::VERTEX
|
|
},
|
|
{
|
|
.text =
|
|
R"glsl(
|
|
#version 450 core
|
|
|
|
in VS_OUT{
|
|
vec2 tex_coords;
|
|
vec4 fcolor;
|
|
}fs_in;
|
|
|
|
out vec4 frag_color;
|
|
|
|
layout (binding = 0) uniform sampler2D diffuse_texture;
|
|
uniform vec4 diffuse;
|
|
|
|
void main(){
|
|
frag_color = mix(texture(diffuse_texture, fs_in.tex_coords), fs_in.fcolor, fs_in.fcolor.a);
|
|
}
|
|
)glsl",
|
|
.len = 0,
|
|
.type = shader_type::FRAGMENT
|
|
}
|
|
};
|
|
static inline constexpr const char* vertex_shader_text = sources[0].text;
|
|
static inline constexpr const char* fragment_shader_text = sources[1].text;
|
|
};
|
|
|
|
}
|
|
|
|
|
|
#endif
|