16 bit mode blues

Started by
4 comments, last by lpsoftware 24 years, 1 month ago
Hey, I''ve got a weird problem and I was hoping someone might be able to help me out. Ok, I set up ddraw, display mode to 8 bit 640 * 480, blit a random pixel to the screen, clear the memory, loop. Everything''s fine. Now when I switch to 16 bit (I''m using the 16bit rgb macro provided by Andre Lamothe in wgpfd), only about 1/4 of the screen is being cleared after a pixel is plotted on it and the rest of the screen stays tainted with millions of pixels. I fixed this in the crude way of doing a memset(video_buffer, 0, 2000 * 1000), for example, instead of doing 640 * 480. Any ideas of fixing this without doing this crazy call? Thanks, Martin
______________Martin EstevaolpSoftware
Advertisement
By the way, I forgot to add that I''m drawing the pixels to a secondary surface, and Flip()ing it to the primary.

And, just in case you were wondering, I did take a look at the 16bit pixel-plotting source from lamothe''s book, but he doesn''t clear the memory in his demo.
______________Martin EstevaolpSoftware
When using 16 bpp, each pixel takes up 2 bytes in memory instead of 1 for 8 bpp. So to use memset to clear the buffer you would use memset(video_buffer, 0, 640*480*2) or more generally, you should probably use something like lPitch*height for the size calculation. lPitch is the number of bytes per scanline and is in the DDSURFACEDESC structure, which is filled in when you lock a surface.
Lich
Thanks a lot

I forgot that each pixel takes up 2 bytes in 16bpp. I know I read it in the book, I just didn''t apply it. Also, I know about lPitch in the surface description structure, and you''re right, I should be using it.

Again, thanks,
Martin
______________Martin EstevaolpSoftware
Hello

Im not sure if you managed already to do the clearing, but an alternative is to do a colorfill Blt, with something like this :


DDBLTFX ddbltfx;
DDRAW_INIT_STRUCT (ddbltfx);
ddbltfx.dwFillColor = 0;

RECT full_screen = {0, 0, 640, 480};

lpddsback->Blt (&full_screen,
NULL,
NULL,
DDBLT_COLORFILL / DDBLT_WAIT,
&ddbltfx);

lpddsprimary->Blt (&full_screen,
NULL,
NULL,
DDBLT_COLORFILL / DDBLT_WAIT,
&ddbltfx);


Assuming lpddsback is your Back surface, and lpddsprimary is your Primary surface.
And remember to Blt while the surface is NOT locked, or Blt will fail!

----
Oh, if you are clearing in every frame/loop, clear only the back surface. If you clear only once, in the initialization, then keep drawing dots randomly, clear both surfaces. Sorry
----

Cya,
-RoTTer

Edited by - RoTTer on 3/10/00 7:39:26 AM
Hi RoTTer,

Thanks for the suggestion. I considered doing that as a clear before, and I might use it

Martin
______________Martin EstevaolpSoftware

This topic is closed to new replies.

Advertisement