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
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement