Thread: Direct Draw: Rotating a bitmap

  1. #1
    Registered User Diamonds's Avatar
    Join Date
    Oct 2002
    Posts
    68

    Direct Draw: Rotating a bitmap

    I'm looking for someone who might have wrote code or knows of a lib function within direct draw (8.0) that will rotate a bitmap. I am trying to get an arrow bitmap to rotate in 360 degree circle.

  2. #2
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916
    I thought that there wasn't DirectDraw in 8.0...?

    If you're doing it with D3D, you can use the world matrix to do it.
    Away.

  3. #3
    Registered User Diamonds's Avatar
    Join Date
    Oct 2002
    Posts
    68
    ok i've got this started..


    DirectDraw has a datastructure with a number of effects stored which is passed into the function blt

    i am having trouble getting the structure init'ed.

    Code:
    	LPDDBLTFX rotation;
    
    	ZeroMemory(&rotation,sizeof(rotation));
    	rotation->dwSize = sizeof(rotation);
    	rotation->dwRotationAngle = 90;
    	Sys_Printf("rotation int.");
    assuming the printf fucntion sends the text to a text file, it doesn't reach that point before the program crashes.


    btw, DirectDraw was last updated in DX7, but all verisions of DX are backward compatable (meaning 8.0 has it).

  4. #4
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    Well you can rotate it in hardware but it is not widely supported on older video cards. Make sure you check the hardware caps and see if it is supported and if it is not just do it in software.

    As far as you not getting to the printf, just step through it in the debugger. Make sure you are in windowed mode though.
    "...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers

  5. #5
    Registered User Diamonds's Avatar
    Join Date
    Oct 2002
    Posts
    68
    ok i was using the wrong type of structure now I am using DDBLTFX as a structure for the rotation variable, it init's fine, but now the blt is failing.

    Code:
        HRESULT h;
        RECT    rc = *pRect;
    	RECT    rc2 = *pRect;
    	DDBLTFX  rotation;
    	IDirectDrawSurface7 *holder;
    	DDSURFACEDESC2          ddsd;
    
    	ZeroMemory(&rotation,sizeof(rotation));
    	rotation.dwSize = sizeof(rotation); 
    	rotation.dwRotationAngle = 180;
    	Sys_Printf("rotation int.");
    
        ZeroMemory(&ddsd, sizeof(ddsd));
        ddsd.dwSize = sizeof(ddsd);
        ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
        ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
        ddsd.dwWidth = width;
        ddsd.dwHeight = height;
        if (g_pDD->CreateSurface(&ddsd, &holder, NULL) != DD_OK)
            Sys_Printf("CreateSurface, holder failed");
    
        h = holder->Blt(NULL, lpSurf, &rc2, dwFlags | DDBLT_ROTATIONANGLE, &rotation);

  6. #6
    Registered User Diamonds's Avatar
    Join Date
    Oct 2002
    Posts
    68
    OMFG, ok after killing myself I have found out that my hardware does not support rotations for direct draw and that DirectX which is suppost to emulate things, does emulate things, all things BUT rotation.

  7. #7
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916
    You can do it with D3D... (just don't ever do anything with the Z coordinates...)
    Away.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help with Bitmap Display
    By The Brain in forum Windows Programming
    Replies: 7
    Last Post: 03-23-2009, 05:33 AM
  2. OpenGL -- Bitmaps
    By HQSneaker in forum Game Programming
    Replies: 14
    Last Post: 09-06-2004, 04:04 PM
  3. Owner draw button with bitmap
    By Mithoric in forum Windows Programming
    Replies: 2
    Last Post: 11-30-2003, 03:14 PM
  4. Direct Draw weird stuff
    By Magos in forum C++ Programming
    Replies: 6
    Last Post: 04-24-2002, 04:39 AM