Jump to content
  • Advertisement

Archived

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

lpsoftware

16 bit mode blues

This topic is 6800 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!