   Tricks of the Windows - Sample Problems    
  I've recently started reading Tricks of the Windows Programming Gurus (first edition) and I've stumbled upon a problem with one of the samples included on the cd-rom.When I run the .exe for sample demo7_13 the background is fine but the sprites which are supposed to animate are all garbled. I didn't change any code just ran the program. Could someone who owns the book help me with this problem? [edited by - Punx on January 1, 2003 7:00:33 PM]
  Does that particular program run in full-screen or windowed mode?If it''s windowed, you probably have to be in color depth that the program wants (LaMonthe seems to like 8bpp/256 in that book).Also, if it loads file, maybe it couldn''t find the texture files, but pressed on anyway.  ;  It''s a full screen app. What''s weird is it loaded the background image fine its just the animating sprites which are all garbled. I don''t think its a file loading error because the appropriate .bmps are in the right place.  ;  yea, i have that problem toohave problems w/lots of the sample code actually, the final project, the complete game, won''t run at all... crashs back to desktop  ;  I had this problem awhile back too.  I even bookmarked the thread!  www.gamedev.net/community/forums/topic.asp?topic_id=8721The thread says you''re supposed to change line 499 from whatever is there to = ddsd.lPitch    It was a mistake in the code.  During that secton of the book, LaMothe actually says to use lPitch, so who knows why it''s not right in the code.  ;  I solved that problem in the past, but i don''t know where i put those codes.The fact is that when u create a surface, let''s say the width is iWidth. But the real width of your surface is sometimes different from iWidth, it''s quite often greater than it. U can retrieve the real width when u lock the surface,the DDSURFACEDESC structure that u pass to the function has a member corresponding. I just don''t remember which member. It might be easy to find it out.Hope it helps.  ;  Video memory isn''t always linear, so using the width of the image as apposed to the pitch will cause that distortion.  Andre just made that mistake in the code, and most video cards will "smash" the image because the bytes won''t be properly aligned.  This also depends on the width of the image - certainly graphics cards will store certain widths (usually powers of 2) linearly (is that a word) and will buffer other sizes.  