Minimum count of irregular bitmap regions before multi-threading?

Minimum count of irregular bitmap regions before multi-threading?

Some conditions to set up the question:

If I have multiple irregular bitmap regions that I am moving around on a screen.

If the irregular bitmap regions change, like a game character turning in direction or looking like they are doing some activity.

If the irregular bitmap regions are all about 128x128 (BMP or jpg) and (128 million colors or 64K colors) then they are 48k in size.

The same irregular bitmap regions, using 256 colors "optimized" are not so nice looking, but it drops the size to 17K. I am using that as an average for this question.

Now the question:

How many of these individual irregular bitmap regions should I have before splitting them into different threads?

Given the following Examples:

Example: All as one continuous process
Create irregular Bitmap_45_degrees_right,
Create irregular Bitmap_90_degrees_right,
Create irregular Bitmap_135_degrees_right,
Create irregular Bitmap_480_degrees_right,
Create irregular Bitmap_225_degrees_right,
etc.
Then combine them all in a back buffer,
Then put them to the screen.

Or

Example: All as separate threads process
New thread Create irregular Bitmap_45_degrees_right,
New thread Create irregular Bitmap_90_degrees_right,
New thread Create irregular Bitmap_135_degrees_right,
New thread Create irregular Bitmap_480_degrees_right,
New thread Create irregular Bitmap_225_degrees_right,
etc.
Then combine them all in a back buffer,
Then put them to the screen.

If I have 3 of these, then I guess that one continuous process is ok.

If I have 300 of these then I guess that maybe I should be using some separate threads. What is an experienced opinion on this? There might be some programmers that view this site and have large game experience, and I am looking for experienced answers. Sending the whole thing to video cards and putting the burden on the end user does not work. I am learning C++11 and I want to learn it right.





Last edited on
What is an irregular bitmap?

How many of these individual irregular bitmap regions should I have before splitting them into different threads?
What are you doing with these bitmaps?

putting the burden on the end user
What could that mean?
Region ! It is called a "region." The shape of a cat or dog or horse, etc.

I guess that an irregular bitmap is a bitmap region that uses an original bitmap (like loaded from a file "horse.bmp") and then uses a bitmap mask (?) which is (I think) two color maybe and the bitmap mask is used to tell the software which areas of the bitmap to not include in the final bitblt (?). Example: A picture of a horse with a red background would be the starting bitmap loaded from a file. The bitmap mask would be everything in that picture except (?) the red area. WOW! This is a lot. I am barely keeping this process in my head. Then the original bitmap would be combined (or something) with(/without?) the mask to make an irregular bitmap. I looked at examples of bitmap stuff and found mostly shapes like circles, squares, etc. and they were difficult for me to understand how to use them. I found one example that used an irregular (?) bitmap all alone by itself and I have been trying to learn and understand from it.

Doing with these bitmaps... I want to write a game and to be able to have lots of things moving around. I want to learn, really learn, how that is done in C or C++ without ActiveX, etc.

I purchased some games years ago and they said that they required some special brand and version of a video card to be able to run. I did not have that. I shelved or threw away or returned the game. That game writer/publisher/people lost that customer. I had bought one video card and I thought that it was good quality, and if the game did not run using it, then I did not use that game. I do not want to put that burden of having to have a special video card on the end user, and I think that if I make a program that does not "require" such, then it is a good start.

Then, after that, I can maybe make options for various video cards. But, not a required exact card brand and model.

Thank you for asking.






Last edited on
Nowadays consumer software rarely has special requirements, because most of it is written to standards or known subsets of APIs supported on all mainstream systems.

Programmers wishing to specialize their software for the advanced features of particular hardware can do so if they wish, but when discussing consumer software this is often an optional "use-if-available" kind of arrangement, and not a hard requirement.

There are of course minimum requirements, but those are unavoidable, and can be made low enough that almost all users can satisfy them.
Last edited on
So, I researched a bit about 'irregular bitmaps'. It's sometimes referred to as bitmaps with transparent parts. Forget about regions. The exists but makes the system slow and are generally unnecessary.

So how to make a bitmap with transparent parts?
Lets assume you have an image where the white parts are supposed to be transparent.
Copy the bitmap and convert it with a drawing tool to black/white. Invert that b/w image.
Now you can use MaskBlt(...) with this two bitmaps to draw it transparent. See:

https://docs.microsoft.com/de-de/windows/win32/api/wingdi/nf-wingdi-maskblt

By the way: You can use the mask to determine whether or not it is hit withiin the transparent part or not.

how that is done in C or C++ without ActiveX, etc.
ActiveX (web) would be wrong here. I think you mean DirectX.

Then, after that, I can maybe make options for various video cards.
Today this is usuall not required anymore.


I guess you need double buffer. It works like this:
In WM_SIZE create a buffer bitmap using CreateDIBSection(...) or CreateCompatibleBitmap(...) (hdc = NULL should work):
https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-createdibsection
https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-createcompatiblebitmap

When you want to draw use CreateCompatibleDC(...) (with hdc = NULL) to get the dc to draw to, and select the previously created bitmap:
https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-createcompatibledc

In WM_PAINT you use BitBlt(...) to SRCCOPY to the screen dc.
Registered users can post here. Sign in or register to post.