[SOLVED]ogre 2.0 HardwareVertexBuffer bug?????

Problems building or running the engine, queries about how to use features etc.
Post Reply
dummy_98
Kobold
Posts: 38
Joined: Sat Oct 31, 2015 7:12 pm
x 1

[SOLVED]ogre 2.0 HardwareVertexBuffer bug?????

Post by dummy_98 »

Code: Select all

mVertexData = std::make_unique<VertexData>();
	mRenderOp.vertexData = mVertexData.get();

	const int OneQuadVertexCount = 6;

	mRenderOp.indexData = nullptr;
	mRenderOp.vertexData->vertexStart = 0;
	mRenderOp.vertexData->vertexCount = OneQuadVertexCount;
	mRenderOp.operationType = RenderOperation::OT_TRIANGLE_LIST;
	mRenderOp.useIndexes = false;

	VertexDeclaration* decl = mRenderOp.vertexData->vertexDeclaration;
	VertexBufferBinding* bind = mRenderOp.vertexData->vertexBufferBinding;
	size_t offset = 0;

	// create/bind positions/tex.ccord. buffer
	if (!decl->findElementBySemantic(Ogre::VES_POSITION))
		decl->addElement(0, offset, Ogre::VET_FLOAT3, Ogre::VES_POSITION);

	offset += VertexElement::getTypeSize(Ogre::VET_FLOAT3);

	if (!decl->findElementBySemantic(Ogre::VES_TEXTURE_COORDINATES))
		decl->addElement(0, offset, Ogre::VET_FLOAT2, Ogre::VES_TEXTURE_COORDINATES, 0);

	offset += VertexElement::getTypeSize(Ogre::VET_FLOAT2);

	if (!decl->findElementBySemantic(Ogre::VES_DIFFUSE))
		decl->addElement(0, offset, Ogre::VET_COLOUR, Ogre::VES_DIFFUSE);


	HardwareVertexBufferSharedPtr ptbuf = HardwareBufferManager::getSingleton().createVertexBuffer(
		decl->getVertexSize(0), mRenderOp.vertexData->vertexCount, HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY);

	bind->setBinding(0, ptbuf);

i made many HardwareBuffer in above code.

but each HardwareBuffer's lock pointer is all same...

Code: Select all

char* const pStartBuf = static_cast<char*>(hardwareBufferPtr->lock(HardwareBuffer::HBL_DISCARD));
pStartBuf pointer all same......

Did I do something wrong?
Last edited by dummy_98 on Thu Dec 03, 2015 9:06 am, edited 1 time in total.
dummy_98
Kobold
Posts: 38
Joined: Sat Oct 31, 2015 7:12 pm
x 1

Re: ogre 2.0 HardwareVertexBuffer bug?????

Post by dummy_98 »

only i want to change UV value.... ,

These side effects occur because of previous vertex information remains......... (same pointer).....

:(
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: ogre 2.0 HardwareVertexBuffer bug?????

Post by dark_sylinc »

Not sure I understand.
What is the problem again?
dummy_98
Kobold
Posts: 38
Joined: Sat Oct 31, 2015 7:12 pm
x 1

Re: ogre 2.0 HardwareVertexBuffer bug?????

Post by dummy_98 »

because i only want to change UV value , i wrote the changed value in hardwarebuffer's UV area


but HardwareVertexBuffer's lock pointer was same , Just before other hardwarebuffer is used that pointer.

Nevertheless i only changed uv value , others was changed ( just before used hardwarebuffer's position,color )

after all , i only can't change uv , I had to update all(position,uv,color) hardwarebuffer's area
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: ogre 2.0 HardwareVertexBuffer bug?????

Post by dark_sylinc »

HBL_DISCARD means you reupload the entire buffer's contents. You can't perform partial modifications.

Either use HBL_NORMAL (slow), or use a 2nd vertex buffer to store the UVs only so that you can lock-discard them.
If two different HardwareVertexBuffer pointers return the same pointer with lock(), that's fine since you're just getting an address that is mapped and will be unmapped upon calling unlock. This address may be reused again.
dummy_98
Kobold
Posts: 38
Joined: Sat Oct 31, 2015 7:12 pm
x 1

Re: ogre 2.0 HardwareVertexBuffer bug?????

Post by dummy_98 »

i was confusing HardwareBuffer::Usage and HardwareBuffer::LockOptions

thanks for answer
Post Reply