H
Du allozierst Texturspeicher fuer 512x512 Pixel:
g_pD3DDevice->CreateTexture( 512, 512, 0, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &g_pTexture, NULL );
Und dann schreibst Du 512*512*128*128 Pixel (das sind 16 Gigabyte) rein:
int texcount = 512*512;
while (texcount--)
{
for(int x = 0; x < 128; x++)
{
for(int y = 0; y < 128; y++)
{
int c = x ^ y;
*pixel++ = D3DCOLOR_XRGB(c,c,255,c);
}
}
}
Da wuerd' ich auch crashen...
Versuch's mal so:
g_pTexture->LockRect(0, &lr, 0, 0);
unsigned char *scanline= (unsigned char*)lr.pBits;
for(int y = 0; y < 512; y++)
{
// 32bit zeiger auf die aktuelle scanline
unsigned int *pixel= (unsigned int*)scanline;
for(int x = 0; x < 512; x++)
{
int c = x ^ y;
*pixel++ = D3DCOLOR_XRGB(c,c,255,c);
}
// zeiger zur naechsten scanline
scanline+=lr.Pitch;
}
g_pTexture->UnlockRect(0);
Wenn Du Dir die Beispiele und die Dokumentation im DirectX-SDK genau anschaust, wirst Du es sicher selber hinkriegen, ein Polygon zu zeichnen.