Skip to content

Commit

Permalink
++
Browse files Browse the repository at this point in the history
  • Loading branch information
tomcypher89 committed Jun 3, 2024
1 parent 5066644 commit 83fdf88
Show file tree
Hide file tree
Showing 12 changed files with 53 additions and 26 deletions.
43 changes: 31 additions & 12 deletions src/carcockpit/car_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,12 @@ car_widget::car_widget(utki::shared_ref<ruis::context> context, all_parameters p
LOG([&](auto& o) {
o << "Max texture size: " << *maxTextureSize << std::endl;
})

LOG([&](auto& o) {
o << "<< LOAD GLTF >>" << std::endl;
})
ruis::render::gltf_loader l(*this->context.get().renderer.get().factory, true);
demoscene = l.load(papki::fs_file("../res/samples_gltf/parent_and_children.glb")).to_shared_ptr();
}

void car_widget::update(uint32_t dt)
Expand Down Expand Up @@ -449,20 +455,33 @@ void car_widget::render(const ruis::matrix4& matrix) const
// modelview,
// this->tex_cube_env_hata->tex());

ruis::mat4 mtrx;

auto vaao1 = demoscene->nodes[0].get().mesh_.get()->primitives[0].get().vao.to_shared_ptr();
mtrx = demoscene->nodes[0].get().get_transformation_matrix();
phong_s->render(*vaao1, mvp * mtrx, modelview * mtrx, this->tex_test->tex(), light_pos_view, light_int);

auto vaao2 = demoscene->nodes[0].get().children[0].get().mesh_.get()->primitives[0].get().vao.to_shared_ptr();
mtrx *= demoscene->nodes[0].get().children[0].get().get_transformation_matrix();
phong_s->render(*vaao2, mvp * mtrx, modelview * mtrx, this->tex_test->tex(), light_pos_view, light_int);



phong_s->render(*this->light_vao, mvp_monkey, modelview_monkey, this->tex_test->tex(), light_pos_view, light_int);

advanced_s->render(
*this->car_vao,
mvp,
modelview,
projection,
this->tex_rust_diffuse->tex(),
this->tex_rust_normal->tex(),
this->tex_rust_roughness->tex(),
this->tex_cube_env_hata->tex(),
light_pos_view,
light_int
);
// advanced_s->render(
// *this->car_vao,
// mvp,
// modelview,
// projection,
// this->tex_rust_diffuse->tex(),
// this->tex_rust_normal->tex(),
// this->tex_rust_roughness->tex(),
// this->tex_cube_env_hata->tex(),
// light_pos_view,
// light_int
// );

// //advanced_s->render(*this->vao_lamba_r, mvp, modelview, projection,
// this->tex_car_diffuse->tex(),
// // this->tex_car_normal->tex(),
Expand Down
13 changes: 10 additions & 3 deletions src/carcockpit/car_widget.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,21 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <ruis/widgets/base/fraction_widget.hpp>
#include <ruis/widgets/widget.hpp>

#include "../ruis/render/scene/shaders/shader_adv.hpp"
#include "../ruis/render/scene/shaders/shader_phong.hpp"
#include "../ruis/render/scene/shaders/shader_skybox.hpp"
// #include "../ruis/render/scene/shaders/shader_adv.hpp"
// #include "../ruis/render/scene/shaders/shader_phong.hpp"
// #include "../ruis/render/scene/shaders/shader_skybox.hpp"
#include "shaders/shader_adv.hpp"
#include "shaders/shader_phong.hpp"
#include "shaders/shader_skybox.hpp"

#include "../ruis/render/scene/scene.hpp"

namespace carcockpit {

class car_widget : public ruis::fraction_widget, public ruis::updateable, virtual public ruis::widget
{
std::shared_ptr<ruis::render::scene> demoscene;

std::shared_ptr<ruis::res::texture_2d> tex;
std::shared_ptr<ruis::res::texture_2d> tex_test;

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions src/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ this_name := ruis_render
$(eval $(call prorab-config, ../config))

this_srcs += $(call prorab-src-dir, ruis)
#this_ldlibs += `pkg-config --libs glesv2`
#this_ldlibs += -lruisapp-opengles-xorg -l ruis-render-opengles

this_static_lib_only := true
this_no_install := true
Expand Down
3 changes: 1 addition & 2 deletions src/ruis/render/scene/mesh.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ class material

class primitive
{
utki::shared_ref<ruis::render::vertex_array> vao;

public:
utki::shared_ref<ruis::render::vertex_array> vao;
utki::shared_ref<material> material_;
primitive(utki::shared_ref<ruis::render::vertex_array> vao, utki::shared_ref<material> material_);
void render();
Expand Down
6 changes: 3 additions & 3 deletions src/ruis/render/scene/scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ void scene_renderer::render(utki::shared_ref<node> n, ruis::mat4 parent_model)

scene_renderer_regular::scene_renderer_regular()
{
skybox_shader = std::make_shared<shader_skybox>();
phong_shader = std::make_shared<shader_phong>();
advanced_shader = std::make_shared<shader_adv>();
// skybox_shader = std::make_shared<shader_skybox>();
// phong_shader = std::make_shared<shader_phong>();
// advanced_shader = std::make_shared<shader_adv>();
}

void scene_renderer_regular::render_node(utki::shared_ref<node> n, ruis::mat4 model)
Expand Down
12 changes: 6 additions & 6 deletions src/ruis/render/scene/scene.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <ruis/context.hpp>
#include <ruis/render/renderer.hpp>

#include "shaders/shader_adv.hpp"
#include "shaders/shader_phong.hpp"
#include "shaders/shader_skybox.hpp"
// #include "shaders/shader_adv.hpp"
// #include "shaders/shader_phong.hpp"
// #include "shaders/shader_skybox.hpp"

#include "node.hpp"
#include "scene.hpp"
Expand Down Expand Up @@ -60,9 +60,9 @@ class scene_renderer

class scene_renderer_regular : public scene_renderer
{
std::shared_ptr<shader_skybox> skybox_shader;
std::shared_ptr<shader_phong> phong_shader;
std::shared_ptr<shader_adv> advanced_shader;
// std::shared_ptr<shader_skybox> skybox_shader;
// std::shared_ptr<shader_phong> phong_shader;
// std::shared_ptr<shader_adv> advanced_shader;

public:
ruis::mat4 view_matrix;
Expand Down

0 comments on commit 83fdf88

Please sign in to comment.