首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网络游戏 >

D3DXCreateTextureFromFileInMemoryEx()到底支不支持寻址模式?解决方案

2012-03-28 
D3DXCreateTextureFromFileInMemoryEx()到底支不支持寻址模式?C/C++ codebool InitializeObjects(){FILE*

D3DXCreateTextureFromFileInMemoryEx()到底支不支持寻址模式?

C/C++ code
bool InitializeObjects(){        FILE* pFile = fopen("窗体背景1.png", "rb");    fseek(pFile, 0, SEEK_END);    int FileLen = ftell(pFile);    fseek(pFile, 0, SEEK_SET);    char* pData = new char[FileLen];    fread(pData, FileLen, 1, pFile);    D3DXIMAGE_INFO info;    D3DCOLOR colorkey = 0x000000ff;    if (D3DXCreateTextureFromFileInMemoryEx(        g_D3DDevice,        pData,        FileLen,        0,        0,        0,        0,        D3DFMT_UNKNOWN,        D3DPOOL_MANAGED,        D3DX_DEFAULT,        D3DX_DEFAULT,        D3DCOLOR_XRGB(0,0,0),        &info,        NULL,        &g_Texture) != D3D_OK)    {        ::MessageBox(0, "检测到", "测试", MB_OK);        return false;    }    delete [] pData;// ...    return true;}void RenderScene(){    // set wrap address mode    if( ::GetAsyncKeyState('W') & 0x8000f )    {        g_D3DDevice->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP);        g_D3DDevice->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP);    }    // set border color address mode    if( ::GetAsyncKeyState('B') & 0x8000f )    {        g_D3DDevice->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_BORDER);        g_D3DDevice->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_BORDER);        g_D3DDevice->SetSamplerState(0,  D3DSAMP_BORDERCOLOR, 0x000000ff);    }    // set clamp address mode    if( ::GetAsyncKeyState('C') & 0x8000f )    {        g_D3DDevice->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);        g_D3DDevice->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);    }    // set mirror address mode    if( ::GetAsyncKeyState('M') & 0x8000f )    {        g_D3DDevice->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_MIRROR);        g_D3DDevice->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_MIRROR);    }        g_D3DDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(255,255,255), 1.0f, 0);    g_D3DDevice->BeginScene();    g_D3DDevice->SetTransform(D3DTS_VIEW, &g_ViewMatrix);    g_D3DDevice->SetTexture(0, g_Texture);    g_D3DDevice->SetFVF(D3DFVF_VERTEX);    g_D3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, 3, objData, sizeof(CustomVertex));    g_D3DDevice->EndScene();    g_D3DDevice->Present(NULL, NULL, NULL, NULL);}


运行后,所有寻址模式都不可用。

D3DXCreateTextureFromFileInMemoryEx()函数支不支持寻址模式??如果支持,你有实现过么?

[解决办法]
LZ 我来接分啦

BTW,何为寻址模式?
[解决办法]
HRESULT D3DXCreateTextureFromFileInMemoryEx


既然是HRESULT 你得到的返回值信息是什么?

热点排行