chronozphere

Hi guys

I want to implement an easy-to-manipuate texture in my game-engine. therefore i've created a bitmap in memory and a D3D texture. the user can use GDI functions to draw on the bitmap and the bitmap must be updated to video memory. I wrote the following routine (It's pascal, but i think most of you will get the idea):

[code]
//create sysmem texture
HR := D3DXCreateTexture(Graphic.fD3DDevice,fWidth,fHeight,1,0,D3DFMT_A8R8G8B8,D3DPOOL_SYSTEMMEM,fSysTex);
if Failed(HR) then
begin
Result := E_TEX_CREATE_FAILED;
LastErrorDX(Result,HR);
Exit;
end;

{Get first surface}
HR := fSysTex.GetSurfaceLevel(0,Surf);
if Failed(HR) then
begin
Result := E_TEX_SURFACE_FAILED;
LastErrorDX(Result,HR);
Exit;
end;

//lock entire surface
HR := Surf.LockRect(D3DRect,nil,D3DLOCK_NOSYSLOCK);
if Failed(HR) then
begin
Result := E_TEX_LOCK_FAILED;
LastErrorDX(Result,HR);
Exit;
end;

//set alpha to 255 so every texel is visible (this is not done by default)
//scanline returns a pointer to a pixel row
for i:=0 to fbitmap.Height-1 do
for j:=0 to fBitmap.Width-1 do
(PChar(fBitmap.ScanLineIdea)+(j*4)+3)^ := Char(255);

{move the data from fBitmap to fTexture}
for i:=0 to fBitmap.Height-1 do Move((fBitmap.ScanlineIdea)^,(PChar(D3DRect.pBits)+(D3DRect.pitch*i))^,fBitmap.Width*4);

Surf.UnlockRect;

//update texture to VRAM
HR := Graphic.fD3DDevice.UpdateTexture(fsysTex,fTexture);
if Failed(HR) then
begin
Result := E_TEX_UPDATE_FAILED;
LastErrorDX(Result,HR);
Exit;
end;
Surf := nil;
[/code]

But i use mipmapping and that's where the problems begin.
The mipmap chain doesn't get updated somehow.
It looks like the changes applied on the bitmap slowly fade away in the smaller texture surfaces. I dont know this for sure, but it doesn't look good.

image 1
image 2

The red rectangle on the texture is the updated part. Even when i look with an almost 90 degree angle onto the texture, it still doesn't have a solid red color. :(

I think i need to make sure that the smaller texture surfaces (lower in mipmap chain) also contain valid data. So i need to regenerate the chain. Do i need to do this by hand or are there any tricks/methods available to let D3D do this for you.

I really hope someone (a very kind DirectX MPV) knows a simple sollution for this problem.
This stuff really bothers me... i just want to continue my project.

Does someone know a sollution for this any help would be greatly appreciated. ;)







Re: Game Technologies: Graphics sollution

chronozphere

I think i've found the sollution.... Just use D3DXFilterTexture.

Check link below:

Sollution

Happy mipmapping ;)