void draw(Image* image,int dx,int dy,int dw,int dh,int sx,int sy,int sw,int sh,unsigned int color,int cx,int cy,int rotation)
{
int scale = 10;
D3DXMATRIX newMat;
RECT srcRect={sx,sy,sx+sw,sy+sh};
D3DXVECTOR2 scaling((float)dw/(float)image->getImageWidth(),(float)dh/(float)image->getImageHeight());
D3DXMatrixTransformation2D(&newMat,NULL,0.0,&scaling,&D3DXVECTOR2(cx,cy),D3DXToRadian(rotation),&D3DXVECTOR2(dx,dy));
sprite->SetTransform(&newMat);
// zoom code
D3DXMATRIX matrix;
device->SetTransform(D3DTS_PROJECTION, D3DXMatrixOrthoRH(&matrix, 1024*scale, 768*scale, 1, 1000));
//end of zoom code
sprite->Draw(image->getTexture(),&srcRect,0,0,color);
}
Anyone know why my zoom wont work?
Hello, I have been using a 2D library written with DirectX 9. I have been trying to modify the draw() function to enable me to zoom in and out. After following a conclusion I have made the following edits to the draw() function:
but for some reason after I run it, everything goes black, and I cant continue to see what im working with. I am aware that scale is hardcoded, which will be changed after I figure this out, but does any DirectX guru have any idea as to why this happens?
I'm not sure if passing the address of a temporary to a parameter taking a pointer is valid. When you do this in D3DXMatrixTransformation2D:
I think it might destroy the temporary D3DXVECTOR2 before jumping in to the function so the function gets trash memory. Anyone know the actual spec for this?
Still you don't need to set the transform for both the sprite and device, just changing the device projection should do the trick. Or, if you're using a camera, move the camera further forwards :P
&D3DXVECTOR2(cx,cy)
I think it might destroy the temporary D3DXVECTOR2 before jumping in to the function so the function gets trash memory. Anyone know the actual spec for this?
Still you don't need to set the transform for both the sprite and device, just changing the device projection should do the trick. Or, if you're using a camera, move the camera further forwards :P
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement