Skip to content
Snippets Groups Projects
Commit d41d29ac authored by Petr Babic's avatar Petr Babic
Browse files

add basic TextShader test


Signed-off-by: default avatarPetr Babic <pbabic@redhat.com>
parent b4c01d2a
No related branches found
No related tags found
No related merge requests found
#include "gfx/text_shader.hpp"
#include "utils/context_utils.hpp"
#include <com/math_files.hpp> #include <com/math_files.hpp>
#include <gfx/index.hpp> #include <gfx/index.hpp>
#include <maker/index.hpp> #include <maker/index.hpp>
...@@ -20,6 +23,51 @@ static com::Folder *generate_grid() { ...@@ -20,6 +23,51 @@ static com::Folder *generate_grid() {
return grid; return grid;
} }
static const std::string default_vertex_shader = R"(
#version 330 core
layout(location = 0) in vec3 vertex_position;
uniform mat4 model;
uniform mat4 view;
uniform mat4 projection;
void main()
{
gl_Position = projection * view * model * vec4(vertex_position, 1.);
}
)";
static const std::string default_fragment_shader = R"(
#version 330 core
out vec4 fragColor;
void main()
{
fragColor = vec4(0.2, 0.8, 1., 1.);
}
)";
static com::Folder *default_text_material_box() {
auto material = gfx::material_system()->insert_material(
"default-text-material",
gfx::shader_system()->insert_shader<gfx::TextShader>(
{ "shaders" }, "default-text-shader",
default_vertex_shader, default_fragment_shader
),
{"materials"}
);
auto box = gfx::object_system()->insert_object(
{ "default-text-material-box" }, material,
gfx::buffer_generators()->insert_procedural_box_solid({1, 1, 1}, "default-text-material-box", { "maker" }));
auto frame = root()->push_back<com::Folder>("default-text-material-box")->push_back<com::Frame>();
frame->set_origin({4, 4, 4});
gfx::object_system()->push_frame_back(box, frame);
return box;
}
static com::Folder *generate_box(vec3 position, vec3 half_sizes_along_axes) { static com::Folder *generate_box(vec3 position, vec3 half_sizes_along_axes) {
auto shader = gfx::shader_system()->insert_shader("box_shader", gfx::Shader::Pipeline::FORWARD, gfx::Shader::LIT, auto shader = gfx::shader_system()->insert_shader("box_shader", gfx::Shader::Pipeline::FORWARD, gfx::Shader::LIT,
{ "shaders" }); { "shaders" });
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment