Advertisement

Tricks of the Windows - Sample Problems

Started by January 01, 2003 05:56 PM
5 comments, last by Punx 21 years, 10 months ago
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]
~punx
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.
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
Advertisement
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.
~punx
yea, i have that problem too

have 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=8721

The 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.

C++: A Dialog | C++0x Features: Part1 (lambdas, auto, static_assert) , Part 2 (rvalue references) , Part 3 (decltype) | Write Games | Fix Your Timestep!

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.
"...and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces."----------Scott Meyers, "Effective C++"
Advertisement
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.
-YoshiXGXCX ''99

This topic is closed to new replies.

Advertisement