Exception during integration with existing project.


17-10-2008 08:33:59

Hi, I tried to integrate PagedGeomtery with my project but unfortunatly it did not work. Compiled demo works fine but when I move simple code (tutorial1) to my project there is an exception:

OGRE EXCEPTION(2:InvalidParametersException): Named constants have not been initialised, perhaps a compile error. in GpuProgramParameters::_findNamedConstatntDefinition at ...\ogregpuprogram.cpp (line 873)

I use Ogre 1.4.9. Can anyone help resolve this problem?


18-10-2008 00:23:41

I figured out that this strange behavior was because of Plugin_CgProgramManager lack. I think that if there is no such program group, in this case "cg", there should be an error raised somehow. But now I got "Debug Assertion Faild!" :(


18-10-2008 02:06:59

PagedGeometry doesn't work without the CG plugins, which explains your initial problems - Ogre didn't know how to compile the scripts so it crashed.

Regarding the assertion failure, it's impossible to tell what's causing it or how to fix it without more information, like where the failure is occurring and what the call stack looks like. It could be just as simple as a mismatched DLL (if you recently upgraded to a newer version of Ogre), or something like uninitialized memory, etc.


18-10-2008 11:29:53

Thanks for reply. My suggestion about raising the error was rather to Ogre team then you. I can be wrong about it but it is some idea. And here is the stack for debug assertion:

[Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]
> OgreHavocIntTest.exe!std::_Iterator_base::~_Iterator_base() Line 151 + 0x1e bytes C++
OgreHavocIntTest.exe!std::allocator<std::_List_nod<Ogre::VertexElement,std::allocator<Ogre::VertexElement> >::_Node>::deallocate(std::_List_nod<Ogre::VertexElement,std::allocator<Ogre::VertexElement> >::_Node * _Ptr=0x0217cad8, unsigned int __formal=1) Line 141 + 0x9 bytes C++
OgreHavocIntTest.exe!std::list<Ogre::VertexElement,std::allocator<Ogre::VertexElement> >::clear() Line 828 C++
OgreHavocIntTest.exe!std::list<Ogre::VertexElement,std::allocator<Ogre::VertexElement> >::_Tidy() Line 1185 C++
OgreHavocIntTest.exe!std::list<Ogre::VertexElement,std::allocator<Ogre::VertexElement> >::~list<Ogre::VertexElement,std::allocator<Ogre::VertexElement> >() Line 516 C++
OgreHavocIntTest.exe!Forests::BatchedGeometry::SubBatch::build() Line 378 C++
OgreHavocIntTest.exe!Forests::BatchedGeometry::build() Line 154 + 0x10 bytes C++
OgreHavocIntTest.exe!Forests::BatchPage::build() Line 71 C++
OgreHavocIntTest.exe!Forests::GeometryPageManager::_loadPage(Forests::GeometryPage * page=0x0665d638) Line 708 + 0xf bytes C++
OgreHavocIntTest.exe!Forests::GeometryPageManager::update(unsigned long deltaTime=11, Ogre::Vector3 & camPos={...}, Ogre::Vector3 & camSpeed={...}, bool & enableCache=true, Forests::GeometryPageManager * prevManager=0x00000000) Line 473 C++
OgreHavocIntTest.exe!Forests::PagedGeometry::update() Line 223 C++
OgreHavocIntTest.exe!OgreTerrainComponent::nextFrame(unsigned int timeSinceLastFrame=11) Line 80 C++
OgreHavocIntTest.exe!FrameListeners::nextFrame(unsigned int timeSinceLastFrame=11) Line 83 + 0x2c bytes C++
OgreHavocIntTest.exe!Application::Implementation::run() Line 194 C++
OgreHavocIntTest.exe!Application::run() Line 281 C++
OgreHavocIntTest.exe!WinMain(HINSTANCE__ * hInstance=0x00400000, HINSTANCE__ * hPrevInstance=0x00000000, char * lpCmdLine=0x001d5134, int nShowCmd=1) Line 64 + 0x8 bytes C++
OgreHavocIntTest.exe!__tmainCRTStartup() Line 324 + 0x35 bytes C
OgreHavocIntTest.exe!WinMainCRTStartup() Line 196 C
OgreHavocIntTest.exe!hkThreadMemory::allocateChunk(int nbytes=6619244, HK_MEMORY_CLASS cl=7340076) Line 259 + 0x1 bytes C++
OgreHavocIntTest.exe!hkThreadMemory::allocateChunk(int nbytes=, HK_MEMORY_CLASS cl=) Line 259 + 0x1 bytes C++

it looks like it happens on leaving scope of this loop (BatchedGeometry.cpp line 378):

for (Ogre::ushort i = 0; i < vertBinding->getBufferCount(); ++i)
HardwareVertexBufferSharedPtr buffer = HardwareBufferManager::getSingleton()
.createVertexBuffer(vertDecl->getVertexSize(i), vertexData->vertexCount, HardwareBuffer::HBU_STATIC_WRITE_ONLY);
vertBinding->setBinding(i, buffer);


and my code:

pagedGeometry = new PagedGeometry();

pagedGeometry->setCamera( e.getCamera() );
pagedGeometry->setPageSize( 50.0f );
pagedGeometry->addDetailLevel< BatchPage >( 150, 30 );
pagedGeometry->addDetailLevel< ImpostorPage >( 400, 50 );

treeLoader3D = new TreeLoader3D( pagedGeometry, TBounds( 0, 0, 1500, 1500 ) );

treeLoader3D->addTree( entity, Ogre::Vector3( 10.0f, 0.1f, 1.0f ) );

pagedGeometry->setPageLoader( treeLoader3D );

which is updated every frame:


entity is created in constructor earlier. If you need other information just write what is it.

Jules Robichaud Gagnon

18-10-2008 15:53:56

Does it do that with any entities ( including those in the demo )

Have you tried to reproduce the problem in one of the samples? Using the same parameters, meshes and creation / destruction order.

At first sight :
Sounds more like a mesh/material problem to me than a CG problem. Seems like there is a .program associated with the material used claiming there is a per mesh custom parameter for the shader but in fact the mesh when batched will use custom ones. Can you show me the .material/.program you are using please for the entity giving the problem?


18-10-2008 16:31:49

Model and material definitions are taken from demo. Model is tree2.mesh upgraded by OgreMeshUpgrade. Materials are:

material SOLID/TEX/wood7.jpg
ambient 0.4 0.4 0.4 1
diffuse 1 1 1 1

scene_blend alpha_blend

texture wood7.jpg

material SOLID/TEX/Leaves.png
ambient 0.5 0.5 0.5 1
diffuse 0.6 0.6 0.6 1

cull_hardware none
alpha_rejection greater_equal 128
//scene_blend alpha_blend

texture Leaves.png alpha

I think that programs are hard coded in PagedGeometry source.

I forgot to mention that I did not change Ogre version lately and all works fine in release compilation.


19-10-2008 18:12:57

I resolved my problem. When I was integrating PagedGeometry to my projcet I changed "Runtime Library" from "Multi-threaded Debug DLL" to "Multi-threaded Debug" because of symbols "already defined in LIBCMTD.lib" errors. When I changed it back to original value and made some changes to my project it started to work.