[v1-10-10] createmanual texture dx9 renderer texture size incorrect?

Problems building or running the engine, queries about how to use features etc.
Post Reply
Nickak2003
Goblin
Posts: 272
Joined: Thu Jun 10, 2004 4:19 am
x 26

[v1-10-10] createmanual texture dx9 renderer texture size incorrect?

Post by Nickak2003 »

I create a manual texture. I fill the buffer data, then resize the window, recreate the texture with proper width/height, render to it, at some dimensions it works at most it is skewed. The textures srcWidth/Height is same as getWidth/height and the same as width/height. The following code is called whenever the window is resized, after a call to clear which resets and removes the renderTexture stuff.

Code: Select all

	renderTexture = Ogre::TextureManager::getSingleton().createManual(
		textureName,
		Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
		Ogre::TEX_TYPE_2D, width, height, 0, Ogre::PF_A8R8G8B8, Ogre::TU_DYNAMIC_WRITE_ONLY_DISCARDABLE);
Here is an example where I fill the texture with horizontal lines. Initially at specific startup resolutions it works, but when i resize, say, window width, then the image skews. Even though the above code is called again.

Code: Select all

	for (std::size_t x = 0; x < width; x++) {
		for (std::size_t y = 0; y < height; y++) {
			p = (y*width) + x;

			unsigned char r = 0;
			y % 2  ==0 || y%3 ==0 || y%4 ==0 ? r = 255 : r = 0;

			((char*)&image[p])[0] = 0;
			((char*)&image[p])[1] = 0;
			((char*)&image[p])[2] = r;
			((char*)&image[p])[3] = 255;
		}
			
	}
	std::size_t endP = p - (size-1); // == 0

	Ogre::HardwarePixelBufferSharedPtr texBuf = renderTexture->getBuffer();
	texBuf->lock(Ogre::HardwareBuffer::HBL_DISCARD);

	memcpy(texBuf->getCurrentLock().data, (char*)&image.at(0), size * sizeOfWord);

	texBuf->unlock();
Normally I copy an image into the buffer rather than doing the for-loops, same difference. Any ideas?
images:
https://postimg.org/gallery/1xis0owz6/
Post Reply