vertex buffer crash in GL3+ with ATI graphics card

Discussion area about developing or extending OGRE, adding plugins for it or building applications on it. No newbie questions please, use the Help forum for that.
Post Reply
User avatar
Kinfoin
Gnoblar
Posts: 19
Joined: Sun Jul 05, 2015 3:16 am

vertex buffer crash in GL3+ with ATI graphics card

Post by Kinfoin »

hellow everyone,i have a problem with Ogre version 1.10 with GL3+ render system.
i want to change the vertex of a mesh.
and i wrote code:

Code: Select all

Ogre::Entity* tE = mSceneMgr->getEntity("Head");
			Ogre::MeshPtr headM = tE->getMesh();
			for (int i = 0; i < headM->getNumSubMeshes(); i++)
			{
				Ogre::SubMesh* submesh = headM->getSubMesh(i);
				Ogre::VertexData* vertex_data = submesh->useSharedVertices ? headM->sharedVertexData :
					submesh->vertexData;

				bool added_shared = false;
				size_t current_offset = 0;
				size_t shared_offset = 0;
				size_t next_offset = 0;

				if ((!submesh->useSharedVertices) || (submesh->useSharedVertices && !added_shared))
				{
					if (submesh->useSharedVertices)
					{
						added_shared = true;
						shared_offset = current_offset;
					}
					// the real vertex data is wrapped into lots of classes
					const Ogre::VertexElement* Elem = vertex_data->vertexDeclaration->findElementBySemantic(Ogre::VES_POSITION);
					Ogre::HardwareVertexBufferSharedPtr vbuf = vertex_data->vertexBufferBinding->getBuffer(Elem->getSource());

					unsigned char* vertex = static_cast<unsigned char*>(vbuf->lock(Ogre::HardwareBuffer::HBL_NORMAL));

					float* pReal;
					for (size_t j = 0; j < vertex_data->vertexCount; ++j, vertex += vbuf->getVertexSize())
					{
						// get vertex data
						Elem->baseVertexPointerToElement(vertex, &pReal);
						// translate to world space and scale, rota

						pReal[0] = pReal[0] - 10;
						pReal[1] = pReal[1] + 10;
						pReal[2] = pReal[2] - 5;
					}
					vbuf->unlock();
					next_offset += vertex_data->vertexCount;
				}
			}
just a little move...
it works well with NVIDIA graphics card.but crash in ATI graphics card.
and i found if i use mouse ray to pick up entity,it well crash too.
if somebody knows what happan,please tell me, thanks a lot!
Post Reply