Click here to Skip to main content
15,886,258 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I'm trying to render to an off-screen surface, so i do:


-------------------------------------------------
d3ddev->GetRenderTarget(0, &backbuffer);
d3ddev->CreateOffscreenPlainSurface(64, 64, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &surface, NULL);
...
d3ddev->SetRenderTarget(0, surface);
d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(70, 90, 0), 1.0f, 0);

RECT rect;
rect.left = 0;
rect.top = 0;
rect.right = 63;
rect.bottom = 63;

D3DXVECTOR2 spriteCenter(32.0f, 32.0f);
D3DXVECTOR2 trans(0, 0);
D3DXMATRIX matrix;
D3DXVECTOR2 scaling(1.0f, 1.0f);

D3DXMatrixTransformation2D(&matrix, &spriteCenter, 0.0f, &scaling, &spriteCenter, tank.rotation, &trans);
sprite->SetTransform(&matrix);
sprite->Draw(texture, &rect, NULL, NULL, 0xFFFFFFFF);

sprite->Flush();
...
d3ddev->SetRenderTarget(0, backbuffer);
-----------------------------------------

But it won't work, the sprites are blitted on the top-left corner of my screen. I tried adding dev->beginscene/endscene, sprite->begin/end, but nothing.

what's wrong?
Posted

D3DXVECTOR2 trans(0, 0);

Where trans(X,Y)
 
Share this answer
 
v2
Let's put it this way: is it even possible to D3DXSPRITE->Draw to an off-screen surface? or just to the backbuffer?

if somebody can link a tut or post complete code that'd rule
 
Share this answer
 
Comments
S Houghtelin 1-Jul-11 10:50am    
You should not ask a question by posting it as an answer. Rather update your question by clicking improve question.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900