Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Animate Palette
Message
De
08/08/2000 09:46:32
 
Information générale
Forum:
Visual C++
Catégorie:
Autre
Titre:
Divers
Thread ID:
00402135
Message ID:
00402191
Vues:
14
You don't want much :-) seriously though, this is a huge subject and the following DirectX sample leaves out a LARGE amounts of detail. I would suggest you buy a copy of DirectX for Dummies by Andre Le'Mothe from Amazon. Great book and will teach you a lot about DirectX and Windows. This is an example of pixel plotting and has been removed from a larger project, so lots of setup detail is missing:-


int PlotPixel(LPDIRECTDRAWSURFACE pDDS, int x, int y, int r, int g, int b, int BPP)
{
DDSURFACEDESC ddsd;
unsigned int pixel;
int offset;
unsigned char * szSurface;
HRESULT hr;
int pixelwidth;

ddsd.dwSize = sizeof(ddsd);

pixel = EncodeRGB(r, g, b);

hr = pDDS->Lock( NULL, &ddsd, DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR, NULL );

if (FAILED(hr))
return -1;

szSurface = (unsigned char*)ddsd.lpSurface;

switch(BPP)
{
case 16: pixelwidth = 2; break;
case 24: pixelwidth = 3; break;
case 32: pixelwidth = 4; break;
default: pixelwidth = 1;
}

offset = (y * ddsd.lPitch + x * pixelwidth);
memcpy( szSurface + offset, &pixel, pixelwidth );

hr = pDDS->Unlock( NULL );

if (FAILED(hr))
return -2;

return 0;
}
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform