|
Why do we need this function
------------------------------
This function is used to group together many small bitmaps into several bigger bitmaps.
This is very useful in improving rendering frames per second and shortening loading
time of the world. One of the techniques used in today's leading games is to create
small lightmaps (second bitmaps) for every polygon in the world (This can be done using STATE 3D Webmaker\WorldBuilder)
This technique can drastically improve the graphics quality of the world though they create a huge number of small bitmaps
For example in one of Half-Life worlds there are about 4000 lightmaps each one at the average size of 5*9 pixels.
Loading 4000 bitmaps can take quite sometime. Using STATE_engine_reduce_number_of_bitmaps()
one can group those small bitmaps into bigger ones. For example 4000 5x9 bitmaps can be grouped to only 3 bitmaps of 256x256 !!!
Please note that bitmap that are transparent or that are used by a STATE 2D animation or that are tiled will not be grouped together.
How to use this function
-------------------------
Load your world in editor mode (Give the EDITOR_MODE flag when calling STATE_engine_load_world() )
Call STATE_engine_reduce_number_of_bitmaps()
Call STATE_engine_save()
This will save a new copy of your world with the small bitmaps grouped in big bitmaps.
Note that not always we would like to group all the small bitmaps in big bitmaps
For example if we have a bitmap that we use as a shooting mark (to put on walls after shooting at them)
then we would like this bitmap to stay separate in its own file so that we could easily
call STATE_polygon_set_bitmap_fill()
the include_filter and exclude_filter parameters are used in order to give
the programmer the freedom to group together only the bitmaps that he wants to
Example:
---------
The following example will group together all the bitmaps that are equal or smaller than 32x32 bitmap into bitmaps in the size of 256x256
STATE_engine_reduce_number_of_bitmaps(32, 256, "..\\bitmaps", NULL, NULL, YES);
Return Value
-------------
Returns the number of bitmaps that were replaced and group together in bigger bitmaps
Parameters:
replace_below_equal_this_width:
Only bitmaps equal or smaller than this size will be replaced
Here are some common values to use 32, 20 and so on.
a value of 32 means that only bitmaps that are smaller then a 32x32 bitmap will be included
a bitmap of 33x2 is not consider smaller since it does not fit in inside the 32x32 square.
big_bitmaps_width
The size of the bitmaps that will be created and will be filled with the small bitmaps
Values must be in the power of to (i.e 256, 512, 1024, 2048, 4096 etc.)
For example giving 256 means that the engine will use 256x256 bitmaps.
This bitmap is always square.
By giving a big value (such as 1024 or 2048) you can group all the bitmaps in your world into
one big bitmap !
So what is the right value to use ? We recommend using 256 since
there are some 3D card that can not display bitmaps larger than 256x256
One can test different values and check how it effect the rendering speed.
bitmaps_folder
The directory where the bitmaps can be found. Bitmaps that are not in this folder are not going to be grouped
inside big bitmaps.
include_filter
Only bitmaps with name that contains the "include filter" string will be grouped\replaced
If this parameter is NULL then all the bitmaps in the given folder will be included
Example: If the include_filter is "xx" then the following bitmaps will be included xx.bmp xx12345.bmp 123xx.bmp but not x123x.bmp
exclude_filter
Bitmaps with name that contains the "Exclude filter" string will NOT be grouped\replaced
create_8bit_bitmaps
Whether the group bitmaps are in 8 bit or 24 bit format.
Could be YES or NO. YES is recommended for faster loading time.
In some cases NO could give better graphics quality.
|