diff --git a/src/graphics/2dutils.cpp b/src/graphics/2dutils.cpp index 03d5b80c2..ff7df8209 100644 --- a/src/graphics/2dutils.cpp +++ b/src/graphics/2dutils.cpp @@ -700,5 +700,14 @@ void GL32_draw2DRectangle(video::SColor color, const core::rect& position, glGetError(); } // GL32_draw2DRectangle +void preloadShaders() +{ + Primitive2DList::getInstance(); + UniformColoredTextureRectShader::getInstance(); + TextureRectShader::getInstance(); + ColoredRectShader::getInstance(); + ColoredTextureRectShader::getInstance(); +} // preloadShaders + #endif // !SERVER_ONLY diff --git a/src/graphics/2dutils.hpp b/src/graphics/2dutils.hpp index eebdbb9f1..081fe1f2c 100644 --- a/src/graphics/2dutils.hpp +++ b/src/graphics/2dutils.hpp @@ -28,6 +28,8 @@ #include #include +void preloadShaders(); + void draw2DImageFromRTT(GLuint texture, size_t texture_w, size_t texture_h, const irr::core::rect& destRect, const irr::core::rect& sourceRect, diff --git a/src/graphics/cpu_particle_manager.cpp b/src/graphics/cpu_particle_manager.cpp index 2316d5661..36f0905d9 100644 --- a/src/graphics/cpu_particle_manager.cpp +++ b/src/graphics/cpu_particle_manager.cpp @@ -134,6 +134,25 @@ CPUParticleManager::GLParticle::GLParticle(bool flips) glBindVertexArray(0); } // GLParticle +// ---------------------------------------------------------------------------- +CPUParticleManager::CPUParticleManager() +{ + const float vertices[] = + { + -0.5f, 0.5f, 0.0f, 0.0f, + 0.5f, 0.5f, 1.0f, 0.0f, + -0.5f, -0.5f, 0.0f, 1.0f, + 0.5f, -0.5f, 1.0f, 1.0f, + }; + glGenBuffers(1, &m_particle_quad); + glBindBuffer(GL_ARRAY_BUFFER, m_particle_quad); + glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW); + glBindBuffer(GL_ARRAY_BUFFER, 0); + // For preloading shaders + ParticleRenderer::getInstance(); + AlphaTestParticleRenderer::getInstance(); +} // CPUParticleManager + // ---------------------------------------------------------------------------- void CPUParticleManager::addBillboardNode(scene::IBillboardSceneNode* node) { diff --git a/src/graphics/cpu_particle_manager.hpp b/src/graphics/cpu_particle_manager.hpp index a228d8897..60af051ab 100644 --- a/src/graphics/cpu_particle_manager.hpp +++ b/src/graphics/cpu_particle_manager.hpp @@ -116,21 +116,7 @@ private: public: // ------------------------------------------------------------------------ - CPUParticleManager() - { - const float vertices[] = - { - -0.5f, 0.5f, 0.0f, 0.0f, - 0.5f, 0.5f, 1.0f, 0.0f, - -0.5f, -0.5f, 0.0f, 1.0f, - 0.5f, -0.5f, 1.0f, 1.0f, - }; - glGenBuffers(1, &m_particle_quad); - glBindBuffer(GL_ARRAY_BUFFER, m_particle_quad); - glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, - GL_STATIC_DRAW); - glBindBuffer(GL_ARRAY_BUFFER, 0); - } + CPUParticleManager(); // ------------------------------------------------------------------------ ~CPUParticleManager() { diff --git a/src/graphics/irr_driver.cpp b/src/graphics/irr_driver.cpp index 597be7ac3..23d39054d 100644 --- a/src/graphics/irr_driver.cpp +++ b/src/graphics/irr_driver.cpp @@ -638,8 +638,11 @@ void IrrDriver::initDevice() #endif #ifndef SERVER_ONLY - if(CVS->isGLSL()) + if (CVS->isGLSL()) + { m_renderer = new ShaderBasedRenderer(); + preloadShaders(); + } else m_renderer = new FixedPipelineRenderer(); #endif diff --git a/src/graphics/post_processing.cpp b/src/graphics/post_processing.cpp index d4efbb454..6be63bc03 100644 --- a/src/graphics/post_processing.cpp +++ b/src/graphics/post_processing.cpp @@ -758,6 +758,9 @@ PostProcessing::PostProcessing() STKTexManager::getInstance()->addTexture(m_areamap); areamap->drop(); + // For preloading shaders + MotionBlurShader::getInstance(); + LightningShader::getInstance(); } // PostProcessing // ----------------------------------------------------------------------------