Save viewport in GEVulkanCameraSceneNode

This commit is contained in:
Benau 2022-07-06 10:53:26 +08:00
parent 4351926137
commit 8ab63edd30
3 changed files with 21 additions and 1 deletions

View File

@ -24,6 +24,8 @@ private:
GEVulkanDynamicBuffer* m_buffer;
GEVulkanCameraUBO m_ubo_data;
irr::core::rect<irr::s32> m_viewport;
public:
// ------------------------------------------------------------------------
GEVulkanCameraSceneNode(irr::scene::ISceneNode* parent,
@ -36,6 +38,11 @@ public:
virtual void render();
// ------------------------------------------------------------------------
GEVulkanDynamicBuffer* getBuffer() const { return m_buffer; }
// ------------------------------------------------------------------------
void setViewPort(const irr::core::rect<irr::s32>& area)
{ m_viewport = area; }
// ------------------------------------------------------------------------
const irr::core::rect<irr::s32>& getViewPort() const { return m_viewport; }
}; // GEVulkanCameraSceneNode
}

View File

@ -3,11 +3,12 @@
#include "ge_main.hpp"
#include "ge_vulkan_2d_renderer.hpp"
#include "ge_vulkan_camera_scene_node.hpp"
#include "ge_vulkan_command_loader.hpp"
#include "ge_vulkan_features.hpp"
#include "ge_vulkan_mesh_cache.hpp"
#include "ge_vulkan_shader_manager.hpp"
#include "ge_vulkan_texture.hpp"
#include "ge_vulkan_command_loader.hpp"
#include "ICameraSceneNode.h"
#include "ISceneManager.h"
@ -1896,7 +1897,16 @@ void GEVulkanDriver::setViewPort(const core::rect<s32>& area)
core::rect<s32> rendert(0,0, getCurrentRenderTargetSize().Width, getCurrentRenderTargetSize().Height);
vp.clipAgainst(rendert);
if (vp.getHeight() > 0 && vp.getWidth() > 0)
{
m_viewport = vp;
if (m_irrlicht_device->getSceneManager() &&
m_irrlicht_device->getSceneManager()->getActiveCamera())
{
GEVulkanCameraSceneNode* cam = static_cast<GEVulkanCameraSceneNode*>
(m_irrlicht_device->getSceneManager()->getActiveCamera());
cam->setViewPort(area);
}
}
} // setViewPort
// ----------------------------------------------------------------------------

View File

@ -74,6 +74,9 @@ void FixedPipelineRenderer::render(float dt, bool is_loading)
Physics::get()->draw();
} // for i<world->getNumKarts()
// For GEVulkanDriver
irr_driver->getSceneManager()->setActiveCamera(NULL);
// Set the viewport back to the full screen for race gui
irr_driver->getVideoDriver()->setViewPort(core::recti(0, 0,
UserConfigParams::m_width,