Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
age_maker
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Marek Trtík
age_maker
Commits
f878b520
There was an error fetching the commit references. Please try again later.
Commit
f878b520
authored
10 months ago
by
Filip Vincze
Browse files
Options
Downloads
Patches
Plain Diff
Add new shaders
parent
fd220b20
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/handlers/button_handler.cpp
+2
-0
2 additions, 0 deletions
src/handlers/button_handler.cpp
src/presenter.cpp
+70
-27
70 additions, 27 deletions
src/presenter.cpp
with
72 additions
and
27 deletions
src/handlers/button_handler.cpp
+
2
−
0
View file @
f878b520
...
...
@@ -35,6 +35,8 @@ namespace mak {
}
// Set object color
// Figure out a way to change
//gfx::object_system()->get_material(object_folder)->set_uniform("color", color);
gfx
::
object_system
()
->
get_uniforms
(
object_folder
)
->
find
<
com
::
FileVec3
>
(
"material_ambient_color"
)
->
set
(
color
);
}
...
...
This diff is collapsed.
Click to expand it.
src/presenter.cpp
+
70
−
27
View file @
f878b520
...
...
@@ -2,17 +2,23 @@
#include
<maker/index.hpp>
#include
<maker/handlers/button_handler.hpp>
#include
<gfx/index.hpp>
#include
<gfx/ui/transform.hpp>
#include
<gfx/text_shader.hpp>
#include
<gfx/font.hpp>
#include
<gfx/buffer_generators.hpp>
#include
<osi/index.hpp>
#include
<com/math_files.hpp>
#include
<utils/context_utils.hpp>
#include
<gfx/ui/transform.hpp>
#include
<iostream>
#include
<sstream>
#include
<fstream>
#include
<gfx/text_generator.hpp>
namespace
mak
{
typedef
gfx
::
ShaderGraph
::
Node
::
DataType
::
ElementType
ElementType
;
typedef
gfx
::
ShaderGraph
Graph
;
typedef
gfx
::
ShaderGraph
::
Node
::
SlotDefinition
Slot
;
Presenter
::
Presenter
()
:
com
::
Runner
{
self_name
()
}
{}
...
...
@@ -20,37 +26,76 @@ Presenter::Presenter()
Presenter
::~
Presenter
()
{}
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.);
}
)"
;
void
Presenter
::
initialize
()
{
osi
::
presenters
()
->
push_back
<
com
::
Folder
>
(
"maker"
)
->
push_back
<
com
::
Link
>
(
self_name
()
+
".link"
,
this
);
gfx
::
Shader
*
forward_uniform_color_shader
=
gfx
::
shader_generators
()
->
insert_shader_forward_uniform_color
();
gfx
::
Shader
*
text_shader
=
gfx
::
shader_system
()
->
insert_shader
<
gfx
::
TextShader
>
({
"shaders"
}
,
"default_text_shader"
,
gfx
::
Shader
::
UNLIT
,
default_vertex_shader
,
default_fragment_shader
);
Graph
*
default_shader
=
dynamic_cast
<
Graph
*>
(
gfx
::
shader_system
()
->
default_shader
());
//auto tex_coords = default_shader->insert<Graph::NodeVaryingTexcoord>();
//auto specular = default_shader->insert<Graph::TextureNode>(
//com::ContextPath{ "age", "texture", "font", "Consolas_16.png" });
//default_shader->connect(specular, Graph::TextureNode::inputs::tex_coord, tex_coords, 0);
gfx
::
Material
*
tex_material
=
gfx
::
material_system
()
->
insert_material
(
"box_material"
,
text_shader
,
{
"materials"
});
gfx
::
Material
*
text_material
=
gfx
::
material_system
()
->
insert_material
(
"text_material"
,
default_shader
,
{
"materials"
});
gfx
::
MonoFontProps
font_props
;
gfx
::
load_font_mono_props
(
std
::
filesystem
::
canonical
(
osi
::
data
()
->
dir
())
/
"age"
/
"font"
/
"Consolas_16.txt"
,
font_props
);
gfx
::
object_system
()
->
push_frame_back
(
gfx
::
object_system
()
->
insert_object
(
{
"grid"
},
gfx
::
shader_generators
()
->
insert_shader_forward_varying_color
()
,
tex_material
,
gfx
::
buffer_generators
()
->
insert_procedural_grid
()
),
grid_frame
()
);
// --- BEGIN test_box ---
com
::
Folder
*
const
test_box
=
gfx
::
object_system
()
->
insert_object
(
{
"maker"
,
"test_box"
},
forward_uniform_color_shader
,
gfx
::
buffer_generators
()
->
insert_procedural_box_solid
({
0.5
f
,
0.5
f
,
0.5
f
}
,
"test_box"
,
{
"maker"
})
);
gfx
::
object_system
()
->
push_frame_back
(
test_box
,
root
()
->
push_back
<
com
::
Folder
>
(
"test_box"
)
->
push_back
<
com
::
Frame
>
()
);
gfx
::
object_system
()
->
get_uniforms
(
test_box
)
->
push_back
<
com
::
FileVec3
>
(
"material_ambient_color"
,
vec3
{
0.75
f
,
0.75
f
,
0
});
// The second instance
com
::
Frame
*
const
frame2
=
root
()
->
push_back
<
com
::
Folder
>
(
"test_box_2"
)
->
push_back
<
com
::
Frame
>
();
frame2
->
move_origin
({
0.5
f
,
0
,
1.5
f
});
gfx
::
object_system
()
->
push_frame_back
(
test_box
,
frame2
);
//
com::Folder* const test_box = gfx::object_system()->insert_object(
//
{ "maker", "test_box" },
//tex_material
,
//
gfx::buffer_generators()->insert_procedural_box_solid({ 0.5f, 0.5f, 0.5f } , "test_box", { "maker" })
//
);
//
gfx::object_system()->push_frame_back(
//
test_box ,
//
root()->push_back<com::Folder>("test_box")->push_back<com::Frame>()
//
);
//
gfx::object_system()->get_uniforms(test_box)->push_back<com::FileVec3>("material_ambient_color", vec3{ 0.75f, 0.75f, 0 });
//
//
The second instance
//
com::Frame* const frame2 = root()->push_back<com::Folder>("test_box_2")->push_back<com::Frame>();
//
frame2->move_origin({ 0.5f, 0, 1.5f });
//
gfx::object_system()->push_frame_back(test_box, frame2);
// --- END test_box ---
...
...
@@ -66,6 +111,7 @@ void Presenter::initialize()
// Create buffer
gfx
::
Buffer
*
ui_buffer
=
gfx
::
buffer_generators
()
->
insert_procedural_rectangle
({
1.0
f
,
1.0
f
},
"ui_buffer"
,
{
"ui"
});
gfx
::
Buffer
*
ui_text_buffer
=
gfx
::
buffer_generators
()
->
insert_procedural_text_rectangle
(
"01234"
,
font_props
,
10000.0
f
);
// Set variables
gfx
::
ui_system
()
->
get_transform
(
ui_elem1
)
->
set_position
(
vec2
{
0.03
f
,
0.02
f
});
...
...
@@ -75,8 +121,8 @@ void Presenter::initialize()
gfx
::
ui_system
()
->
get_transform
(
ui_elem2
)
->
set_scale
(
vec2
{
0.01
f
,
0.005
f
});
// Insert UI elements into object system
gfx
::
ui_system
()
->
insert_object
(
ui_elem1
,
ui_elem_folder1
,
forward_uniform_color_shader
,
ui_buffer
);
gfx
::
ui_system
()
->
insert_object
(
ui_elem2
,
ui_elem_folder2
,
forward_uniform_color_shader
,
ui_buffer
);
gfx
::
ui_system
()
->
insert_object
(
ui_elem1
,
ui_elem_folder1
,
text_material
,
ui_buffer
);
gfx
::
ui_system
()
->
insert_object
(
ui_elem2
,
ui_elem_folder2
,
text_material
,
ui_buffer
);
// --- BEGIN directional light ---
...
...
@@ -96,14 +142,11 @@ void Presenter::initialize()
// END handlers
gfx
::
object_system
()
->
insert_light
(
test_box
,
dir_light
);
gfx
::
light_system
()
->
insert_shadow_caster
(
dir_light
,
test_box
);
//
gfx::object_system()->insert_light(test_box, dir_light);
//
gfx::light_system()->insert_shadow_caster(dir_light, test_box);
print_tree
(
*
gfx
::
root
(),
std
::
cout
);
print_tree
(
*
mak
::
root
(),
std
::
cout
);
std
::
shared_ptr
<
gfx
::
font_mono_props
>
props
=
std
::
make_shared
<
gfx
::
font_mono_props
>
();
gfx
::
load_font_mono_props
(
std
::
filesystem
::
canonical
(
osi
::
data
()
->
dir
())
/
"age"
/
"font"
/
"Consolas_16.txt"
,
*
props
);
}
void
Presenter
::
release
()
...
...
@@ -119,7 +162,7 @@ void Presenter::release()
void
Presenter
::
next_round
()
{
gfx
::
renderer
()
->
clear_render_buffers
();
gfx
::
renderer
()
->
present_collection
(
gfx
::
object_system
()
->
objects
());
gfx
::
renderer
()
->
present_collection
(
gfx
::
object_system
()
->
objects
()
,
gfx
::
Renderer
::
pipeline
::
FORWARD
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment