Anyway this is the result: http://data.fuskbugg...01/--sample.jpg
void DxManager::Render()
{
IDirect3DSurface9* pSurface;
RECT destRect;
if(!pd3dDevice)
return;
pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(255, 255, 255), 1.0f, 0);
pd3dDevice->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &BackBuffer);
textures.push_back(this->getSurfaceFromBitmap("./gfx/1001.bmp"));
textures.push_back(this->getSurfaceFromBitmap("./gfx/1002.bmp"));
textures.push_back(this->getSurfaceFromBitmap("./gfx/1003.bmp"));
textures.push_back(this->getSurfaceFromBitmap("./gfx/1004.bmp"));
pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, true);
pd3dDevice->SetRenderState(D3DRS_ALPHAREF, 10);
pd3dDevice->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL);
pd3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
pd3dDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
for(int x = 0; x != 24; ++x)
{
for(int y = 0; y != 24; ++y)
{
int index = groundMap[y][x];
destRect.left = x * S_WIDTH;
destRect.top = y * S_HEIGHT;
destRect.bottom = destRect.top + S_HEIGHT;
destRect.right = destRect.left + S_WIDTH;
pSurface = textures[index];
hResult = pd3dDevice->StretchRect(pSurface, NULL, BackBuffer, &destRect, D3DTEXF_NONE);
}
}
if(hResult != D3D_OK)
{
MessageBox(NULL, "D3D är hjuk fixa!", "Hjukling", MB_OK);
exit(1);
return;
}
pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, false);
pd3dDevice->Present(NULL, NULL, NULL, NULL);
}
IDirect3DSurface9* DxManager::getSurfaceFromBitmap(std::string filename)
{
surface = NULL;
hResult = D3DXGetImageInfoFromFile(filename.c_str(), &imageInfo);
if (FAILED(hResult))
return NULL;
hResult = pd3dDevice->CreateOffscreenPlainSurface(imageInfo.Width, imageInfo.Height, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &surface, NULL);
if (FAILED(hResult))
return NULL;
hResult = D3DXLoadSurfaceFromFile(surface, NULL, NULL, filename.c_str(), NULL, D3DX_DEFAULT, 0, NULL);
if (FAILED(hResult))
return NULL;
return surface;
}
What have I missed?

New Topic/Question
Reply




MultiQuote





|