Archived

This topic is now archived and is closed to further replies.

athlon

Locking surfaces in DX7

Recommended Posts

What should I do, if I want to lock an offscreen surface, write some color values on it and disaply the result on the primary surface (NOT FULLSCREEN) (32bit) I have already done most of this, but I''m having problems with lock. I don''t exactly know how to write some color values on the offscreen surface. I calculated the memory address where the color should go like this: ((LPDWORD)((LPBYTE)lpsurface + (y * lpitch) + x)) = color; But that formula does''nt seem to work, if all colors are 0x00000000 only a small left part of the image is white and the other part is full of strange colors. I need a right formula to pu the colors on the image, and a formula to make a DWORD color value from r, g and b colors.

Share this post


Link to post
Share on other sites
Try this :

//...

DDSURFACEDESC2 DDsd;

//...

UINT* lpSurface = (UINT*)DDsD.lpSurface;
UINT lPitch = DDsd.lPitch >> 2; // divide by 4

//...

lpSurface[y*lPitch + x] = color;

// ...

Share this post


Link to post
Share on other sites