   Pixel Plotting
  I am just beginning DirectDraw, so help me out!I have read all the GameDev articles, every book I own, and still I cannot figure out how to lock/unlock the surfaces! I use the DirectX 8.1 SDK, and the ''ddutil.h'' and ''ddutil.cpp'' files that it comes with to do the basic DD init. 
  You won''t get much help on DirectDraw here. It''s been a very long time since I used that. Can''t you just use Direct3D 8/9? It''s much easier, believe me If you''re locked on DDraw, your only hope is google, then. Search for "pixel plotting direct draw", and "direct draw tutorials", ...etcGood luck.   Muhammad Haggag;  if you want to use directdraw you should switch to manageddx and c#. it is really easy.   [edited by - rupertk on February 5, 2004 6:38:57 AM];  What''s exactly your problem with locking?You have the interface of your surface, than call Lock () to get a pointer to your pixel data, do what ever you want, then call unlock, done.However, DirectDraw is not meant to acces per pixel data, you have to handle all the different pixel formats by yourself. ;  I''d say DirectDraw is more meant to access per-pixel data than DirectXGraphics is, even if you have to do it the hard way ;  Yeah, I did use DirectX 8 for 2D drawing a while back, but it doesn''t give per-pixel control. Pixel formats aren''t hard, anyways. However, all the resources I can get about DirectDraw work with older versions, and somehow, the locking function has changed for the IDirectDrawSurface7 (I think). ;  Post some code, and what errors are you getting?  Chris ;  This is my experimental pixel-plotting function (I''ll move the lock somewhere else later):void WritePixel( int posx, int posy, WORD color ){// Write a pixelint offset;DDSURFACEDESC2 LockedSurface;WORD *LockedSurfaceMemory;// Check the positionif ( posx < 0 || posx > 639 ){return;}if ( posy < 0 || posy > 479 ){return;}// Lock the backbuffer(ScrDisplay->GetBackBuffer())->Lock( NULL, &LockedSurface, DDLOCK_WAIT | DDLOCK_NOSYSLOCK, NULL ); // Get the memoryLockedSurfaceMemory = (WORD *)LockedSurface.lpSurface;// Get the offsetoffset = ( posx ) + ( LockedSurface.lPitch * posy );// Write the pixelLockedSurfaceMemory[offset] = color;// Unlock backbuffer(ScrDisplay->GetBackBuffer())->Unlock( LockedSurfaceMemory );}This will be in 16-bit color.I''m getting syntax errors that say that ''Unlock'' cannot convert ''LockedSurfaceMemory'' to the correct type. Also, even if I explicitly convert the data, the program crashes. ;  You have a problem with your offset line.  You use it to index a WORD array, but you use the y-position as "lpitch * posy".  lpitch is in BYTES however, so you need to change this to "lpitch * posy / 2", or just when you lock, make a lpitch16 variable:lpitch16 = lpitch >> 1; ;  Okay, I fixed my problem (incorrect use of Unlock())! Thanks guys! 