Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev-ndy' into dev-sge
Browse files Browse the repository at this point in the history
  • Loading branch information
sguionni committed Mar 13, 2024
2 parents dcb36d5 + 205c46f commit e548219
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions lib/ui/src/ui/qt/tool/render/widget/opengl_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
#include <QOpenGLContext>
#include <app/application/scene.hpp>
#include <app/component/render/camera.hpp>
#include <app/component/render/proxy_camera.hpp>
#include <app/component/scene/transform_component.hpp>
#include <app/vtx_app.hpp>
#include <core/chemdb/color.hpp>
#include <renderer/proxy/representations.hpp>
#include <util/logger.hpp>

namespace VTX::UI::QT::Tool::Render::Widget
Expand All @@ -18,6 +21,22 @@ namespace VTX::UI::QT::Tool::Render::Widget
format.setSwapBehavior( QSurfaceFormat::DoubleBuffer );
format.setSwapInterval( 0 );
QSurfaceFormat::setDefaultFormat( format );

// TO_REMOVE : Force update camera position
App::VTXApp::get().onUpdate().addCallback(
this,
[]( const float p_deltaTime )
{
const App::Component::Scene::Transform & transformComponent
= App::MAIN_REGISTRY().getComponent<App::Component::Scene::Transform>( App::SCENE().getCamera() );

const App::Component::Render::ProxyCamera & proxyComponent
= App::MAIN_REGISTRY().getComponent<App::Component::Render::ProxyCamera>( App::SCENE().getCamera()
);

proxyComponent.getProxy().onCameraPosition( transformComponent.getPosition() );
}
);
}

OpenGLWidget::~OpenGLWidget() {}
Expand All @@ -29,6 +48,7 @@ namespace VTX::UI::QT::Tool::Render::Widget
App::RENDERER().build( defaultFramebufferObject() );
App::VTXApp::get().onPostRender().addCallback( this, [ this ]( float p_deltaTime ) { update(); } );
App::RENDERER().setProxyColorLayout( VTX::Core::ChemDB::Color::COLOR_LAYOUT_JMOL );
App::RENDERER().setProxyRepresentations( { VTX::Renderer::Proxy::Representation() } );
}

void OpenGLWidget::paintGL() { VTX::App::VTXApp::get().getRenderer().render( 0.15f ); }
Expand Down

0 comments on commit e548219

Please sign in to comment.