D3DXCreateTextureFromFileInMemoryEx()到底支不支持寻址模式?
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);}