Allow RES_CHANGE_SAME without recreating device
This commit is contained in:
parent
29c79abc22
commit
8c5759821e
@ -100,6 +100,7 @@ public:
|
||||
*/
|
||||
virtual std::unique_ptr<RenderTarget> createRenderTarget(const irr::core::dimension2du &dimension,
|
||||
const std::string &name) = 0;
|
||||
virtual void createPostProcessing() {}
|
||||
};
|
||||
|
||||
#endif //HEADER_ABSTRACT_RENDERER_HPP
|
||||
|
@ -35,13 +35,16 @@
|
||||
#include "graphics/per_camera_node.hpp"
|
||||
#include "graphics/referee.hpp"
|
||||
#include "graphics/render_target.hpp"
|
||||
#include "graphics/shader.hpp"
|
||||
#include "graphics/shader_based_renderer.hpp"
|
||||
#include "graphics/shader_files_manager.hpp"
|
||||
#include "graphics/shared_gpu_objects.hpp"
|
||||
#include "graphics/sp_mesh_loader.hpp"
|
||||
#include "graphics/sp/sp_base.hpp"
|
||||
#include "graphics/sp/sp_dynamic_draw_call.hpp"
|
||||
#include "graphics/sp/sp_mesh.hpp"
|
||||
#include "graphics/sp/sp_mesh_node.hpp"
|
||||
#include "graphics/sp/sp_shader_manager.hpp"
|
||||
#include "graphics/sp/sp_texture_manager.hpp"
|
||||
#include "graphics/stk_tex_manager.hpp"
|
||||
#include "graphics/stk_texture.hpp"
|
||||
@ -939,17 +942,20 @@ void IrrDriver::changeResolution(const int w, const int h,
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void IrrDriver::applyResolutionSettings()
|
||||
void IrrDriver::applyResolutionSettings(bool recreate_device)
|
||||
{
|
||||
#ifndef SERVER_ONLY
|
||||
// show black before resolution switch so we don't see OpenGL's buffer
|
||||
// garbage during switch
|
||||
m_video_driver->beginScene(true, true, video::SColor(255,100,101,140));
|
||||
GL32_draw2DRectangle( video::SColor(255, 0, 0, 0),
|
||||
core::rect<s32>(0, 0,
|
||||
UserConfigParams::m_prev_width,
|
||||
UserConfigParams::m_prev_height) );
|
||||
m_video_driver->endScene();
|
||||
if (recreate_device)
|
||||
{
|
||||
m_video_driver->beginScene(true, true, video::SColor(255,100,101,140));
|
||||
GL32_draw2DRectangle( video::SColor(255, 0, 0, 0),
|
||||
core::rect<s32>(0, 0,
|
||||
UserConfigParams::m_prev_width,
|
||||
UserConfigParams::m_prev_height) );
|
||||
m_video_driver->endScene();
|
||||
}
|
||||
track_manager->removeAllCachedData();
|
||||
delete attachment_manager;
|
||||
attachment_manager = NULL;
|
||||
@ -967,10 +973,12 @@ void IrrDriver::applyResolutionSettings()
|
||||
GUIEngine::clear();
|
||||
GUIEngine::cleanUp();
|
||||
|
||||
m_device->closeDevice();
|
||||
m_device->clearSystemMessages();
|
||||
m_device->run();
|
||||
|
||||
if (recreate_device)
|
||||
{
|
||||
m_device->closeDevice();
|
||||
m_device->clearSystemMessages();
|
||||
m_device->run();
|
||||
}
|
||||
delete material_manager;
|
||||
material_manager = NULL;
|
||||
|
||||
@ -980,22 +988,38 @@ void IrrDriver::applyResolutionSettings()
|
||||
// (we're sure to update main.cpp at some point and forget this one...)
|
||||
STKTexManager::getInstance()->kill();
|
||||
#ifdef ENABLE_RECORDER
|
||||
ogrDestroy();
|
||||
m_recording = false;
|
||||
if (recreate_device)
|
||||
{
|
||||
ogrDestroy();
|
||||
m_recording = false;
|
||||
}
|
||||
#endif
|
||||
// initDevice will drop the current device.
|
||||
delete m_renderer;
|
||||
m_renderer = NULL;
|
||||
SharedGPUObjects::reset();
|
||||
|
||||
SP::setMaxTextureSize();
|
||||
initDevice();
|
||||
if (recreate_device)
|
||||
{
|
||||
delete m_renderer;
|
||||
m_renderer = NULL;
|
||||
SharedGPUObjects::reset();
|
||||
|
||||
SP::setMaxTextureSize();
|
||||
initDevice();
|
||||
}
|
||||
#ifndef SERVER_ONLY
|
||||
for (unsigned i = 0; i < Q_LAST; i++)
|
||||
{
|
||||
m_perf_query[i]->reset();
|
||||
}
|
||||
if (!recreate_device)
|
||||
{
|
||||
SP::SPTextureManager::get()->stopThreads();
|
||||
SP::SPShaderManager::destroy();
|
||||
SP::SPTextureManager::destroy();
|
||||
ShaderBase::killShaders();
|
||||
ShaderFilesManager::getInstance()->removeAllShaderFiles();
|
||||
unsetMaxTextureSize();
|
||||
SP::setMaxTextureSize();
|
||||
m_renderer->createPostProcessing();
|
||||
}
|
||||
if (CVS->isGLSL())
|
||||
SP::loadShaders();
|
||||
#endif
|
||||
@ -1964,7 +1988,7 @@ void IrrDriver::update(float dt, bool is_loading)
|
||||
// old device and create a new one.
|
||||
if (m_resolution_changing!=RES_CHANGE_NONE)
|
||||
{
|
||||
applyResolutionSettings();
|
||||
applyResolutionSettings(m_resolution_changing != RES_CHANGE_SAME);
|
||||
if(m_resolution_changing==RES_CHANGE_YES)
|
||||
new ConfirmResolutionDialog(false);
|
||||
else if(m_resolution_changing==RES_CHANGE_YES_WARN)
|
||||
|
@ -156,7 +156,7 @@ private:
|
||||
int m_scene_complexity;
|
||||
|
||||
/** Internal method that applies the resolution in user settings. */
|
||||
void applyResolutionSettings();
|
||||
void applyResolutionSettings(bool recreate_device);
|
||||
void createListOfVideoModes();
|
||||
|
||||
bool m_request_screenshot;
|
||||
|
@ -51,12 +51,8 @@ private:
|
||||
|
||||
public:
|
||||
PostProcessing();
|
||||
virtual ~PostProcessing() {}
|
||||
|
||||
void reset();
|
||||
/** Those should be called around the part where we render the scene to be
|
||||
* post-processed */
|
||||
void begin() {}
|
||||
void update(float dt);
|
||||
|
||||
void renderBloom(GLuint in);
|
||||
|
@ -302,7 +302,7 @@ void ShaderBasedRenderer::renderSceneDeferred(scene::ICameraSceneNode * const ca
|
||||
m_lighting_passes.renderLightsScatter(m_rtts->getDepthStencilTexture(),
|
||||
m_rtts->getFBO(FBO_HALF1),
|
||||
m_rtts->getFBO(FBO_HALF2),
|
||||
m_post_processing);
|
||||
m_post_processing.get());
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
}
|
||||
|
||||
@ -574,7 +574,7 @@ void ShaderBasedRenderer::renderPostProcessing(Camera * const camera,
|
||||
}
|
||||
else if (irr_driver->getShadowViz() && m_rtts->getShadowFrameBuffer())
|
||||
{
|
||||
m_shadow_matrices.renderShadowsDebug(m_rtts->getShadowFrameBuffer(), m_post_processing);
|
||||
m_shadow_matrices.renderShadowsDebug(m_rtts->getShadowFrameBuffer(), m_post_processing.get());
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -598,13 +598,12 @@ ShaderBasedRenderer::ShaderBasedRenderer()
|
||||
SharedGPUObjects::init();
|
||||
SP::init();
|
||||
SP::initSTKRenderer(this);
|
||||
m_post_processing = new PostProcessing();
|
||||
createPostProcessing();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
ShaderBasedRenderer::~ShaderBasedRenderer()
|
||||
{
|
||||
delete m_post_processing;
|
||||
delete m_spherical_harmonics;
|
||||
delete m_skybox;
|
||||
delete m_rtts;
|
||||
@ -613,6 +612,12 @@ ShaderBasedRenderer::~ShaderBasedRenderer()
|
||||
ShaderFilesManager::kill();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void ShaderBasedRenderer::createPostProcessing()
|
||||
{
|
||||
m_post_processing.reset(new PostProcessing());
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void ShaderBasedRenderer::onLoadWorld()
|
||||
{
|
||||
@ -702,11 +707,6 @@ void ShaderBasedRenderer::addSunLight(const core::vector3df &pos)
|
||||
// ----------------------------------------------------------------------------
|
||||
void ShaderBasedRenderer::render(float dt, bool is_loading)
|
||||
{
|
||||
// Start the RTT for post-processing.
|
||||
// We do this before beginScene() because we want to capture the glClear()
|
||||
// because of tracks that do not have skyboxes (generally add-on tracks)
|
||||
m_post_processing->begin();
|
||||
|
||||
World *world = World::getWorld(); // Never NULL.
|
||||
Track *track = Track::getCurrentTrack();
|
||||
|
||||
@ -859,7 +859,7 @@ void ShaderBasedRenderer::renderToTexture(GL3RenderTarget *render_target,
|
||||
if (CVS->isDeferredEnabled())
|
||||
{
|
||||
renderSceneDeferred(camera, dt, false, true);
|
||||
render_target->setFrameBuffer(m_post_processing
|
||||
render_target->setFrameBuffer(m_post_processing.get()
|
||||
->render(camera, false, m_rtts));
|
||||
}
|
||||
else
|
||||
|
@ -46,7 +46,7 @@ private:
|
||||
DrawCalls m_draw_calls;
|
||||
LightingPasses m_lighting_passes;
|
||||
ShadowMatrices m_shadow_matrices;
|
||||
PostProcessing *m_post_processing;
|
||||
std::unique_ptr<PostProcessing> m_post_processing;
|
||||
|
||||
void prepareForwardRenderer();
|
||||
|
||||
@ -111,7 +111,8 @@ public:
|
||||
|
||||
RTT* getRTTs() { return m_rtts; }
|
||||
ShadowMatrices* getShadowMatrices() { return &m_shadow_matrices; }
|
||||
PostProcessing* getPostProcessing() { return m_post_processing; }
|
||||
PostProcessing* getPostProcessing() { return m_post_processing.get(); }
|
||||
void createPostProcessing() OVERRIDE;
|
||||
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user