Mirrored Sprite
All my (2D) sprites are looking to the right. How do I Blt them so they will face to the left instead?
if you''re using direct3d then alter the texture coords.
eg. if you have a quad with vertices with texture coords like so:
vert1 (0,0) vert2 (1,0) vert3 (1,1) vert4 (0,1) then change these texture coords to:
vert1 (1,0) vert2 (0,0) vert3 (0,1) vert4 (1,1)
In DirectDraw I''m not so sure, you may have to mirror the sprite graphics in a graphic editor.
eg. if you have a quad with vertices with texture coords like so:
vert1 (0,0) vert2 (1,0) vert3 (1,1) vert4 (0,1) then change these texture coords to:
vert1 (1,0) vert2 (0,0) vert3 (0,1) vert4 (1,1)
In DirectDraw I''m not so sure, you may have to mirror the sprite graphics in a graphic editor.
If you are using DirectDraw then take a look at the DDBLTFX structure (which you can use with the DirectDraw Blt function). This allows you to mirror left-to-right and/or top-to-bottom. This may be what you are looking for. Most modern graphics hardware will do these blits using the hardware itself, but some of the older graphics cards revert to slower software methods when it comes to mirroring sprites... in this case it would be better to either pre-mirror your sprites or simply provide multiple mirrored sprites using your favourite art package.
Cheers,
Sharky
Cheers,
Sharky
er, can I have a sample code? I didn''t downloaded the directx help. I only took a small portion of the sdk.
I haven''t done this for a while but I believe it is something along these lines...
// source and destination rectanglesRECT srcRect;RECT destRect;// ptr to the [src and dest] directdraw surfacesLPDIRECTDRAWSURFACE lpSurfSrc;LPDIRECTDRAWSURFACE lpSurfSprite;// the effects structure (for mirroring)DDBLTFX ddBltFx;// set up the DDBLTFX structure in your codeddBltFx.dwSize = sizeof(DDBLTFX);ddBltFx.dwDDFX = DDBLTFX_MIRRORLEFTRIGHT;// you would call your blit routine along the lines of...lpSurfDest->Blt(&destRect,lpSurfSprite,&srcRect,DDBLT_DDFX,&ddBltFx);
Remember to set the relevant values in the RECT structures and set your parameters accordingly. The DDBLT_DDFX flag tells the blit to use the DDBLTFX structure, which tells the blit to perform the sprite mirror operation (DDBLTFX_MIRRORLEFTRIGHT).
I think this is more or less how it works, although you may have to read up on this as I have no reference material to hand...
Good luck,
Sharky
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement