Hi, I played around with surfaces and stuzmbled upon 2 problems.
What I want to do is in short the following:
1) Put a picture on surface1
2) Put a picture on surface2
3) Put a part the picture on surface 1 on surface 2
4) Create a texture and use surface 2 to fill it
5) Paint this texture on a sprite
6) Paint this sprite on the screen
So well, some steps may seem strange but there is a bit learning involved for me here and I think this are some things I just have to know.
Now my source:
Preperation, only executed once:
//1.) Put a picure on Surface1
Device.CreateOffscreenPlainSurface(500, 500, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, Surface1, nil);
D3dXLoadSurfaceFromFile(Surface1, nil, nil, 'd:\fish.png', nil, D3DX_DEFAULT, 0, nil);
//2.) Put a picure on Surface1
Device.CreateOffscreenPlainSurface(500, 500, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, Surface2, nil);
D3dXLoadSurfaceFromFile(Surface1, nil, nil, 'd:\house.bmp', nil, D3DX_DEFAULT, 0, nil);
//Create Picture 3 which I need later for drawing to the screen (I think)
Device.CreateOffscreenPlainSurface(500, 500, D3DFMT_X8R8G8B8, D3DPOOL_SYSTEMMEM, Surface3, nil);
Render Loop:
Clear(D3DCOLOR_XRGB(0, 0, 0));
BeginScene;
//3) Put a part the picture on surface 1 on surface 2
rect.Left := 0;
rect.Top := 0;
rect.Right := 100;
rect.Bottom := 100;
Device.StretchRect(Surface11, @rect, Surface2, @rect, D3DTEXF_NONE);
//4) Create a texture and use surface 2 to fill it
D3DXCreateTexture(Device, 500, 500, D3DX_DEFAULT, D3DUSAGE_RENDERTARGET, D3DFMT_X8R8G8B8,D3DPOOL_DEFAULT, Texture1);
Texture1.GetSurfaceLevel(0, Surface3);
//5) Paint this texture on a sprite
D3DXLoadSurfaceFromSurface(Surface3, nil, nil, Surface2, nil, nil, D3DX_DEFAULT, 0);
D3DXCreateSprite(Device, Sprite1);
//6) Paint this sprite on the screen
Sprite.Draw(Texture1, nil, nil, nil, 0, nil, 0);
//Well, this doesn't work.
EndScene;
Pressent(nil, nil, 0, nil);
My 2 problems are:
1) Nr. 5 is awfully slow, so damn slow I can't believe it's in anyway hardware-enhanced. Do I do anything wrong?
2) How do I paint this Sprite now to the screen?
Well, I hope this questions aren't to hard to understand. Maybe someone can help me. Pleeeeaaase.
Thanks in advance.
Edited by Coder: Use source tags. Check
GDNet Forums FAQ
[Edited by - Coder on August 20, 2004 6:38:13 AM]