Translating DirectDraw to DirectX 9.0c terminology

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Translating DirectDraw to DirectX 9.0c terminology

      From all the research I've done, "it's possible". Unfortunately, that's about as far as the research went. I found one function which is supposed to act as a blt() replacement:

      //----------------------------------------------------------------------------
      // Blt() : A replacement of the DirectDraw Blt() function for Direct3D8
      // Supports DDBLTFX_MIRRORLEFTRIGHT and DDBLTFX_MIRRORUPDOWN
      // If pDestRect is NULL, copies it to the same co-ord as src
      // If pSrcRect is NULL, copies the entire texture
      //----------------------------------------------------------------------------
      HRESULT Blt(RECT *pDestRect, LPDIRECT3DTEXTURE8 pSrcTexture, RECT *pSrcRect, DWORD dwFlags)
      {
      D3DXVECTOR2 scaling(1,1);
      D3DXVECTOR2 rcenter(0,0);
      D3DXVECTOR2 trans(0,0);

      // Set the parameters - translation (screen location)
      if (pDestRect)
      {
      trans.x = (float) pDestRect->left;
      trans.y = (float) pDestRect->top;
      }
      // Scaling - If Source & Destination are different size rects, then scale
      if (pDestRect && pSrcRect)
      {
      scaling.x = ((float) (pDestRect->right - pDestRect->left)) /
      ((float) (pSrcRect->right - pSrcRect->left));
      scaling.y = ((float) (pDestRect->bottom - pDestRect->top)) /
      ((float) (pSrcRect->bottom - pSrcRect->top));
      }
      // Handle the flags - need to change scaling & adjust translation
      if (pSrcRect && dwFlags)
      {
      if(dwFlags&DDBLTFX_MIRRORLEFTRIGHT)
      {
      scaling.x = -scaling.x;
      trans.x += (float) (pDestRect->right - pDestRect->left);
      }
      if(dwFlags&DDBLTFX_MIRRORUPDOWN)
      {
      scaling.y = -scaling.y;
      trans.y += (float) (pDestRect->bottom - pDestRect->top);
      }
      }

      // And here we go:
      return dx8.pd3dxSprite->Draw(pSrcTexture, pSrcRect, &scaling,
      &rcenter, 0, &trans, 0xFFFFFFFF);
      }

      ...but that in turn I need to translate up to DirectX 9. Now, you're probably all wondering - MrMike provided you with rendering code! The hell is all this rot? ..well, it turns out that while MrMike did provide rendering code, I had forgotten that the map/world system I'm using for my game requires DirectDraw - in short, I now have to translate that up to Dx9 to play nice with everything else.

      The map/world system is a tile-based-map system located at: tilemap.co.uk/
      and it's fairly simple to use, while offering most everything you'd need for a 2D tile-map-system.

      In short, I need help. I don't understand the differences between DirectX 7 and 9, and how to change them well at all.

      The code for the cpp and header needed to translate and load these maps from file have been attached - (those attached are the unmodified originals).

      My first step was to update all the calls by removing anything references to BltFast, and changing the calls to Blt to match those of the replacement function provided.

      After this, I removed the references to HRESULT != DD_OK, instead replacing them with HRESULT FAILED().

      However, that's about as far as I've been able to get.
      Please, any help would be greatly appreciated - I can't
      much continue work on the game without a working
      world system (it's an RPG, so it's rather important to have..)

      -HeavyBlade