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;
}
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only