Who Do YOU Rotate A Bitmap In VB
I was wondering what the code would be to rotate a bitmap in in DirectX for VB.
Code would be helpful.
Thanks ALL.
In DirectX8? Direct3D or DDraw?
If its DirectDraw you cannot rotate in hardware, you will have to create your own blit routine, if you are using D3D you can use D3DXSprite and specify the rotation in ->Draw.
If its DirectDraw you cannot rotate in hardware, you will have to create your own blit routine, if you are using D3D you can use D3DXSprite and specify the rotation in ->Draw.
Game Download ZeroOne Realm
Although it may specify Rotation and alpha blending as a flag in LPDIRECTDRAWSURFACE7->Blt(), it does not work with the majority (if any) of video cards available
As I mentioned before you can implement your own rotation routine if you are good with asm, though the easy solution is to use 3D Hardware to do it for you. I have recently converted my 2D platform game from DDraw7 to D3DX8 with not much difficulty and great results, including as much scaling, rotation, and alpha blending I want
You may download the source for my D3DXWrapper via my site, click below:
As I mentioned before you can implement your own rotation routine if you are good with asm, though the easy solution is to use 3D Hardware to do it for you. I have recently converted my 2D platform game from DDraw7 to D3DX8 with not much difficulty and great results, including as much scaling, rotation, and alpha blending I want
You may download the source for my D3DXWrapper via my site, click below:
Game Download ZeroOne Realm
D3D is really your only choice. DirectDraw has an option for bitmap rotation in the Blt function, but it is hardware only, and very few video cards support it.
Heya,
D3D really your own choice? Why must anything be done by some layer, other software or API?
Can''t we make our own formula''s anymore? Can we just pump polygons into D3D and let D3D do_all_the_rest?
What if Curious_George does not want 3D hardware to be involved?
Maybe his target platform does not have an I_do_everything_for_you layer?
To get some resources about rotating a bitmap, search the internet on rotozoomer''s. A rotozoomer is a demoeffect that rotates a bitmap on screen and well..zooms in and out
Dunno if hornet.org is still up, but that one sure got one...
You should really check out, since programming is more than loading a .x file (with D3DX) and putting it on screen with 1 function call!
Gr,
BoRReL
D3D really your own choice? Why must anything be done by some layer, other software or API?
Can''t we make our own formula''s anymore? Can we just pump polygons into D3D and let D3D do_all_the_rest?
What if Curious_George does not want 3D hardware to be involved?
Maybe his target platform does not have an I_do_everything_for_you layer?
To get some resources about rotating a bitmap, search the internet on rotozoomer''s. A rotozoomer is a demoeffect that rotates a bitmap on screen and well..zooms in and out
Dunno if hornet.org is still up, but that one sure got one...
You should really check out, since programming is more than loading a .x file (with D3DX) and putting it on screen with 1 function call!
Gr,
BoRReL
Heya,
No offense, of course!
I know he asked for DirectX!
Still I think switching to D3D for this is ridiculous
Gr,
BoRReL
No offense, of course!
I know he asked for DirectX!
Still I think switching to D3D for this is ridiculous
Gr,
BoRReL
Here''s my rotation from my DX Wrapper for C++
/MindWipe
"If it doesn''t fit, force it; if it breaks, it needed replacement anyway."
RotateBlit(int x, int y, float alpha, SURFACEDATA Scr, bool ColorKey){ DDSURFACEDESC2 SurfaceDesc2; DDCOLORKEY ddck; int lPitch2; USHORT* Buffer2; int ux,uy,vv; float hw,hh,x1,y1,x2,y2,x3,y3,mx,my,mx2,my2,ty,ty2,rx,ry,alpha2,r; alpha = alpha * (2.0f*PI/360.0f); hw=Scr.Width/2.0f; hh=Scr.Height/2.0f; //ColorKey Scr.Surface->GetColorKey(DDCKEY_SRCBLT, &ddck); //Locks the destination surface INITDESC(SurfaceDesc2); SurfaceData.Surface->Lock(NULL, &SurfaceDesc2, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL); Buffer=(USHORT *)SurfaceDesc2.lpSurface; lPitch=(int)(SurfaceDesc2.lPitch >> 1); //Locks the source surface INITDESC(SurfaceDesc2); Scr.Surface->Lock(NULL, &SurfaceDesc2, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL); Buffer2=(USHORT *)SurfaceDesc2.lpSurface; lPitch2=(int)(SurfaceDesc2.lPitch >> 1); //radien r=sqrtf(hw*hw+hh*hh); // #1 /* ux=-hw; uy=-hh;*/ alpha2=-(acosf(-hw/r))+alpha; x1=(x+cosf(alpha2)*r); y1=(y+sinf(alpha2)*r); // #2 alpha2=-(acosf(-hw/r))+alpha; x2=(x+cosf(alpha2)*r); y2=(y+sinf(alpha2)*r); // #3 alpha2=acosf(hw/r)+alpha; x3=(x+cosf(alpha2)*r); y3=(y+sinf(alpha2)*r); mx=(x2-x1)/(Scr.Width); my=(y2-y1)/(Scr.Width); mx2=(x3-x2)/(Scr.Height); my2=(y3-y2)/(Scr.Height); for(uy=0;uy<Scr.Height;uy++){ ty=(uy*mx2); ty2=(uy*my2); rx=x1; ry=y1; for(ux=0;ux<Scr.Width;ux++){ rx+=mx; ry+=my; if(Buffer2[ux+uy*lPitch2] != ddck.dwColorSpaceLowValue) { vv=int(rx+ty)+int(ry+ty2)*lPitch; Buffer[vv]=Buffer2[ux+uy*lPitch2]; Buffer[vv+1]=Buffer2[ux+uy*lPitch2]; } }} Scr.Surface->Unlock(NULL); SurfaceData.Surface->Unlock(NULL);}
/MindWipe
"If it doesn''t fit, force it; if it breaks, it needed replacement anyway."
What I do is pre-rotate it during design time, and then just stick all of my rotated images in an array of surfaces or onto one big surface at runtime. This is much faster, and I can control the image quality more. Just another option...
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement