satikcz
13-07-2009 14:53:10
Hi all, i have following code (i rewrote it from OGRE):
the texture itself is created sooner by this code
In texture "MapObject" is in the begining stored some picture of green tree (with alpha) and lets say I wanted to change all pixels of the texture to pink, but when this code runned, the result was like this:
[/url]
(the picture is very dark)
material script:
[code]
material Map
{
technique
{
pass
{
texture_unit
{
texture tree.png
}
}
}
}
[/code]
any ideas whats wrong? I am trying everything what I get idea to for more than 5hrs, but havent found any solution yet
TexturePtr texture = TextureManager.Singleton.GetByName("MapObjects");
HardwarePixelBufferSharedPtr pixelBuffer = texture.GetBuffer();
pixelBuffer.Lock(HardwareBuffer.LockOptions.HBL_DISCARD); // for best performance use HBL_DISCARD!
PixelBox pixelBox = pixelBuffer.CurrentLock;
Byte* pDest = (Byte*)pixelBox.data;
for (int j = 0; j < 256; j++)
for (int i = 0; i < 256; i++)
{
*pDest++ = 255;
*pDest++ = 0;
*pDest++ = 255;
*pDest++ = 255;
}
pixelBuffer.Unlock();
MaterialPtr material = MaterialManager.Singleton.GetByName("Map");
material.GetTechnique(0).GetPass(0).CreateTextureUnitState("MapObjects");
material.GetTechnique(0).GetPass(0).SetSceneBlending(SceneBlendType.SBT_TRANSPARENT_ALPHA);
the texture itself is created sooner by this code
TexturePtr texture2 = TextureManager.Singleton.CreateManual(
"MapObjects", // name
ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME,
TextureType.TEX_TYPE_2D, // type
256, 256, // width & height
0, // number of mipmaps
PixelFormat.PF_A8R8G8B8,
261);
In texture "MapObject" is in the begining stored some picture of green tree (with alpha) and lets say I wanted to change all pixels of the texture to pink, but when this code runned, the result was like this:

(the picture is very dark)
material script:
[code]
material Map
{
technique
{
pass
{
texture_unit
{
texture tree.png
}
}
}
}
[/code]
any ideas whats wrong? I am trying everything what I get idea to for more than 5hrs, but havent found any solution yet
