Ok, so I try to follow the
Explosion example
First, I got all the file of this example
- explode.dds
- explode.hlsl
- explode_fp.glsl
- explode_vp.glsl
- explosion.material
- explosion.particle
put in the folder Data/Particle (load this folder with file resources2.cfg)
And in create scene function, I call setup setupParticles()
Code: Select all
/*--------Effect--------------*/
void EmptyProjectGameState::setupParticles()
{
/*Get scene manager*/
Ogre::SceneManager* pSceneMana;
pSceneMana = mGraphicsSystem->getSceneManager();
/*Create particle*/
Ogre::ParticleSystem* particleSystem = pSceneMana->createParticleSystem("explosionTemplate");
particleSystem->setName("explosions");
// fast forward 1 second to the point where the particle has been emitted
particleSystem->fastForward(1.0);
// attach the particle system to a scene node
pSceneMana->getRootSceneNode()->attachObject(particleSystem);
}
But I got an Exception break when render the first frame
Visual Studio wrote:Exception thrown: read access violation.
std::_Vector_alloc<std::_Vec_base_types<Ogre::Pass * __ptr64,Ogre::STLAllocator<Ogre::Pass * __ptr64,Ogre::CategorisedAllocPolicy<0> > > >::_Myfirst(...) returned 0x10.
If there is a handler for this exception, the program may be safely continued.
And the full callstack is:
Code: Select all
> OgreMain_d.dll!std::vector<Ogre::Pass * __ptr64,Ogre::STLAllocator<Ogre::Pass * __ptr64,Ogre::CategorisedAllocPolicy<0> > >::size() Line 1180 C++
OgreMain_d.dll!Ogre::Technique::getPass(unsigned short index) Line 382 C++
OgreMain_d.dll!Ogre::HlmsLowLevel::calculateHashFor(Ogre::Renderable * renderable, unsigned int & outHash, unsigned int & outCasterHash) Line 166 C++
OgreMain_d.dll!Ogre::Renderable::setDatablock(Ogre::HlmsDatablock * datablock) Line 100 C++
OgreMain_d.dll!Ogre::v1::BillboardSet::setDatablock(Ogre::HlmsDatablock * datablock) Line 918 C++
OgreMain_d.dll!Ogre::Renderable::setMaterial(const Ogre::SharedPtr<Ogre::Material> & material) Line 188 C++
OgreMain_d.dll!Ogre::v1::BillboardSet::setMaterial(const Ogre::SharedPtr<Ogre::Material> & material) Line 895 C++
OgreMain_d.dll!Ogre::Renderable::setMaterialName(const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & name, const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & groupName) Line 178 C++
OgreMain_d.dll!Ogre::v1::BillboardSet::_createBuffers() Line 867 C++
OgreMain_d.dll!Ogre::v1::BillboardSet::beginBillboards(unsigned __int64 numBillboards) Line 381 C++
OgreMain_d.dll!Ogre::v1::BillboardParticleRenderer::_updateRenderQueue(Ogre::RenderQueue * queue, Ogre::Camera * camera, const Ogre::Camera * lodCamera, std::list<Ogre::Particle *,Ogre::STLAllocator<Ogre::Particle *,Ogre::CategorisedAllocPolicy<0> > > & currentParticles, bool cullIndividually, Ogre::FastArray<Ogre::Renderable *> & outRenderables) Line 142 C++
OgreMain_d.dll!Ogre::ParticleSystem::_updateRenderQueue(Ogre::RenderQueue * queue, Ogre::Camera * camera, const Ogre::Camera * lodCamera) Line 732 C++
OgreMain_d.dll!Ogre::SceneManager::_renderPhase02(Ogre::Camera * camera, const Ogre::Camera * lodCamera, Ogre::Viewport * vp, unsigned char firstRq, unsigned char lastRq, bool includeOverlays) Line 1158 C++
OgreMain_d.dll!Ogre::Camera::_renderScenePhase02(const Ogre::Camera * lodCamera, Ogre::Viewport * vp, unsigned char firstRq, unsigned char lastRq, bool includeOverlays) Line 406 C++
OgreMain_d.dll!Ogre::Viewport::_updateRenderPhase02(Ogre::Camera * camera, const Ogre::Camera * lodCamera, unsigned char firstRq, unsigned char lastRq) Line 230 C++
OgreMain_d.dll!Ogre::RenderTarget::_updateViewportRenderPhase02(Ogre::Viewport * viewport, Ogre::Camera * camera, const Ogre::Camera * lodCamera, unsigned char firstRq, unsigned char lastRq, bool updateStatistics) Line 242 C++
OgreMain_d.dll!Ogre::CompositorPassScene::execute(const Ogre::Camera * lodCamera) Line 217 C++
OgreMain_d.dll!Ogre::CompositorNode::_update(const Ogre::Camera * lodCamera, Ogre::SceneManager * sceneManager) Line 1020 C++
OgreMain_d.dll!Ogre::CompositorWorkspace::_update() Line 752 C++
OgreMain_d.dll!Ogre::CompositorManager2::_updateImplementation(Ogre::SceneManagerEnumerator & sceneManagers, Ogre::HlmsManager * hlmsManager) Line 709 C++
OgreMain_d.dll!Ogre::RenderSystem::updateCompositorManager(Ogre::CompositorManager2 * compositorManager, Ogre::SceneManagerEnumerator & sceneManagers, Ogre::HlmsManager * hlmsManager) Line 1029 C++
OgreMain_d.dll!Ogre::CompositorManager2::_update(Ogre::SceneManagerEnumerator & sceneManagers, Ogre::HlmsManager * hlmsManager) Line 637 C++
OgreMain_d.dll!Ogre::Root::_updateAllRenderTargets() Line 1558 C++
OgreMain_d.dll!Ogre::Root::renderOneFrame() Line 1079 C++
PointAndClick.exe!Demo::GraphicsSystem::update(float timeSinceLast) Line 320 C++
PointAndClick.exe!Demo::MainEntryPoints::mainAppSingleThreaded(HINSTANCE__ * hInst, HINSTANCE__ * hPrevInstance, char * strCmdLine, int nCmdShow) Line 118 C++
PointAndClick.exe!WinMainApp(HINSTANCE__ * hInst, HINSTANCE__ * hPrevInstance, char * strCmdLine, int nCmdShow) Line 35 C++
PointAndClick.exe!WinMain(HINSTANCE__ * hInst, HINSTANCE__ * hInst2, char * strCmdLine, int intParam) Line 32 C++
[External Code]
Did I do something wrong
I see that the error cause by mSupportedTechniques.empty() == true
File
\ogre\OgreMain\src\OgreMaterial.cpp
Code: Select all
Technique* Material::getBestTechnique(unsigned short lodIndex, const Renderable* rend)
{
if (mSupportedTechniques.empty())
{
return NULL;
}
else
{
so the technique pointer is null, but the function getPass get called on this Null pointer, thus cause the error
File
\ogre\OgreMain\src\OgreHlmsLowLevel.cpp
Code: Select all
Technique *technique = mat->getBestTechnique( renderable->getCurrentMaterialLod(), renderable );
Pass *pass = technique->getPass( 0 );
And in Output window did print this
Output window wrote:
WARNING: material explosionMaterial has no supportable Techniques and will be blank. Explanation:
Pass 0: Vertex program explodeVertexProgram cannot be used - not supported.