Jump to content

  • Log In with Google      Sign In   
  • Create Account


#Actualmhagain

Posted 09 October 2012 - 03:20 PM

Do you have sample code, I don't want to tread in the dark atm?


Untested, but should work:
HRESULT LoadRGBAFromDXT (LPDIRECT3DTEXTURE9 dst, LPDIRECT3DTEXTURE9 src)
{
    assert (dst);
    assert (src);

    HRESULT ret = E_FAIL;
    LPDIRECT3DSURFACE9 dstsurf = NULL;
    LPDIRECT3DSURFACE9 srcsurf = NULL;

    if (SUCCEEDED (dst->GetSurfaceLevel (0, &dstsurf)))
    {
	    if (SUCCEEDED (src->GetSurfaceLevel (0, &srcsurf)))
	    {
		    ret = D3DXLoadSurfaceFromSurface (
			    dstsurf,
			    NULL,
			    NULL,
			    srcsurf,
			    NULL,
			    NULL,
			    D3DX_DEFAULT,
			    0
		    );
	    }
    }

    if (dstsurf) dstsurf->Release ();
    if (srcsurf) srcsurf->Release ();

    return ret;
}

Despite the name this isn't restricted to just DXT to RGBA but can be used to convert between any formats (and sizes).

I think I might get away with using D3DXLoadSurfaceFromMemory directly. Would this work? LPCVOID pSrcMemory is the pointer to the Raw Compressed DXTn data. I guess I can just create a texture in ARGB and copy DXTn data directly into it using D3DXLoadSurfaceFromMemory?


That would also do it, yes.

#1mhagain

Posted 09 October 2012 - 03:17 PM

Do you have sample code, I don't want to tread in the dark atm?


Untested, but should work:
HRESULT LoadRGBAFromDXT (LPDIRECT3DTEXTURE9 dst, LPDIRECT3DTEXTURE9 src)
{
HRESULT ret = E_FAIL;
assert (dst);
assert (src);
LPDIRECT3DSURFACE9 dstsurf = NULL;
LPDIRECT3DSURFACE9 srcsurf = NULL;
if (SUCCEEDED (dst->GetSurfaceLevel (0, &dstsurf)))
{
  if (SUCCEEDED (src->GetSurfaceLevel (0, &srcsurf)))
  {
   ret = D3DXLoadSurfaceFromSurface (
    dstsurf,
    NULL,
    NULL,
    srcsurf,
    NULL,
    NULL,
    D3DX_DEFAULT,
    0
   );
  }
}
if (dstsurf) dstsurf->Release ();
if (srcsurf) srcsurf->Release ();
return ret;
}

Despite the name this isn't restricted to just DXT to RGBA but can be used to convert between any formats (and sizes).

I think I might get away with using D3DXLoadSurfaceFromMemory directly. Would this work? LPCVOID pSrcMemory is the pointer to the Raw Compressed DXTn data. I guess I can just create a texture in ARGB and copy DXTn data directly into it using D3DXLoadSurfaceFromMemory?


That would also do it, yes.

PARTNERS