FS2_Open
Open source remastering of the Freespace 2 engine
|
Go to the source code of this file.
Classes | |
struct | bitmap |
class | bitmap_lookup |
Macros | |
#define | BMPMAN_NDEBUG |
Enables BMPMAN debugging code. More... | |
#define | MAX_BITMAPS 4750 |
How many bitmaps the game can handle. More... | |
#define | BMP_AABITMAP (1<<0) |
antialiased bitmap More... | |
#define | BMP_TEX_XPARENT (1<<1) |
transparent texture More... | |
#define | BMP_TEX_OTHER (1<<2) |
so we can identify all "normal" textures More... | |
#define | BMP_TEX_DXT1 (1<<3) |
dxt1 compressed 8r8g8b1a (24bit) More... | |
#define | BMP_TEX_DXT3 (1<<4) |
dxt3 compressed 8r8g8b4a (32bit) More... | |
#define | BMP_TEX_DXT5 (1<<5) |
dxt5 compressed 8r8g8b8a (32bit) More... | |
#define | BMP_TEX_CUBEMAP (1<<6) |
a texture made for cubic environment map More... | |
#define | BMP_TEX_COMP ( BMP_TEX_DXT1 | BMP_TEX_DXT3 | BMP_TEX_DXT5 ) |
Compressed textures. More... | |
#define | BMP_TEX_NONCOMP ( BMP_TEX_XPARENT | BMP_TEX_OTHER ) |
Non-compressed textures. More... | |
#define | BMP_TEX_ANY ( BMP_TEX_COMP | BMP_TEX_NONCOMP ) |
Any texture. More... | |
#define | BMP_FLAG_RENDER_TARGET_STATIC (1<<0) |
Texture is a static type. More... | |
#define | BMP_FLAG_RENDER_TARGET_DYNAMIC (1<<1) |
Texture is a dynamic type (animation) More... | |
#define | BMP_FLAG_CUBEMAP (1<<2) |
Texture is a cubemap. More... | |
Functions | |
void | bm_init () |
Initilizes the bitmap manager. More... | |
void | bm_close () |
Closes the bitmap manager, freeing any allocated memory used by bitmaps. Is called at program close. More... | |
int | bm_get_cache_slot (int bitmap_id, int separate_ani_frames) |
int | bm_get_next_handle () |
Gets the next available bitmap slot. More... | |
void * | bm_malloc (int handle, int size) |
Allocates memory for the given handle. More... | |
void | bm_update_memory_used (int n, int size) |
(DEBUG) Similar to bm_malloc, but only updates how much memory is used More... | |
int | bm_load (const char *filename) |
Loads a bitmap so we can draw with it later. More... | |
int | bm_load (const SCP_string &filename) |
Loads a bitmap so we can draw with it later. (Preferred version) More... | |
int | bm_load_duplicate (const char *filename) |
Reloads a bitmap as a duplicate. More... | |
int | bm_create (int bpp, int w, int h, void *data=NULL, int flags=0) |
int | bm_unload (int handle, int clear_render_targets=0, bool nodebug=false) |
Unloads a bitmap's data, but not the bitmap info. More... | |
int | bm_unload_fast (int handle, int clear_render_targets=0) |
Quickly unloads a bitmap's data, ignoring the load_count. More... | |
int | bm_release (int handle, int clear_render_targets=0) |
Frees both a bitmap's data and it's associated slot. More... | |
int | bm_load_animation (const char *filename, int *nframes=NULL, int *fps=NULL, int *keyframe=NULL, int can_drop_frames=0, int dir_type=CF_TYPE_ANY) |
Loads a bitmap sequance so we can draw with it. More... | |
int | bm_load_either (const char *filename, int *nframes=NULL, int *fps=NULL, int *keyframe=NULL, int can_drop_frames=0, int dir_type=CF_TYPE_ANY) |
Loads either animation (bm_load_animation) or still image (bm_load) More... | |
bitmap * | bm_lock (int handle, ubyte bpp, ubyte flags, bool nodebug=false) |
Locks down the bitmap indexed by bitmapnum. More... | |
uint | bm_get_signature (int handle) |
Returns a unique signiature for the bitmap indexed by handle. More... | |
BM_TYPE | bm_get_type (int handle) |
Returns the image type of the given bitmap handle. More... | |
void | bm_unlock (int handle) |
Unlocks a bitmap. More... | |
int | bm_is_valid (int handle) |
Checks if the bitmap indexed by handle is valid. More... | |
int | bm_get_info (int handle, int *w=NULL, int *h=NULL, ubyte *flags=NULL, int *nframes=NULL, int *fps=NULL) |
Gets info on the bitmap indexed by handle. More... | |
void | bm_get_filename (int bitmapnum, char *filename) |
Gets the filename of the bitmap indexed by handle. More... | |
const char * | bm_get_filename (int handle) |
Gets the filename of the bitmap indexed by handle, which must exist. More... | |
void | bm_gfx_load_all () |
Loads all data for all bitmaps that have been requested to be loaded. More... | |
void | bm_unload_all () |
Unloads all used bitmaps, should only ever be called by game_shutdown() More... | |
void | bm_get_palette (int handle, ubyte *pal, char *name) |
Gets the palette for a given bitmap indexed by handle, and optionally the filename. More... | |
void | bm_gfx_get_pixel (int bitmap, float u, float v, ubyte *r, ubyte *g, ubyte *b) |
Hack to get a pixel from a bitmap. More... | |
void | bm_get_frame_usage (int *ntotal, int *nnew) |
(DEBUG) Gets memory size, in bytes, of the locked bitmaps More... | |
int | bm_reload (int bitmap_handle, const char *filename) |
Reloads an existing bmpman slot with different bitmap. More... | |
void | bm_page_in_start () |
Tells bmpman to start keeping track of what bitmaps are used where. More... | |
void | bm_page_in_stop () |
Tells bmpman to stop paging (?) More... | |
void | bm_page_in_texture (int bitmapnum, int num_frames=0) |
Marks a texture as being used for this level. More... | |
void | bm_page_in_xparent_texture (int bitmapnum, int num_frames=1) |
Marks a textures as being used for level and is transparant. More... | |
void | bm_page_in_aabitmap (int bitmapnum, int num_frames=1) |
Marks a texture as being used for this level, and is anti-aliased. More... | |
bool | bm_page_out (int handle) |
Unloads the bitmap indexed by handle that was previously paged-in. More... | |
void | bm_set_low_mem (int mode) |
Sets BMPMAN's memory mode. More... | |
void | BM_SELECT_SCREEN_FORMAT () |
Sets bm_set_components and bm_get_components to reference screen format functions. More... | |
void | BM_SELECT_TEX_FORMAT () |
Sets bm_set_components and bm_get_components to reference texture format functions. More... | |
void | BM_SELECT_ALPHA_TEX_FORMAT () |
Sets bm_set_components and bm_get_components to reference texture format functions (with alpha) More... | |
void | bm_set_components_argb_16_screen (ubyte *pixel, ubyte *r, ubyte *g, ubyte *b, ubyte *a) |
Sets the 16bpp screen pixel to the specified RGBA value. More... | |
void | bm_set_components_argb_32_screen (ubyte *pixel, ubyte *r, ubyte *g, ubyte *b, ubyte *a) |
Sets the 32bpp screen pixel to the specified RGBA value. More... | |
void | bm_set_components_argb_16_tex (ubyte *pixel, ubyte *r, ubyte *g, ubyte *b, ubyte *a) |
Sets the 16bpp texture pixel to the specified RGBA value. More... | |
void | bm_set_components_argb_32_tex (ubyte *pixel, ubyte *r, ubyte *g, ubyte *b, ubyte *a) |
Sets the 32bpp texture pixel to the specified RGBA value. More... | |
void | bm_get_components (ubyte *pixel, ubyte *r, ubyte *g, ubyte *b, ubyte *a) |
Gets the RGBA components of a pixel according to the selected mode. More... | |
int | bm_is_compressed (int handle) |
Returns the compression type of the bitmap indexed by handle. More... | |
int | bm_get_tcache_type (int handle) |
Gets the correct TCACHE_TYPE for compressed graphics (uncompressed are assumed TCACHE_TYPE_NORMAL) More... | |
size_t | bm_get_size (int handle) |
Gets the size, in bytes, taken up by the bitmap indexed by handle. More... | |
int | bm_get_num_mipmaps (int handle) |
Gets the number of mipmaps of the indexed texture. More... | |
bool | bm_has_alpha_channel (int handle) |
Checks to see if the indexed bitmap has an alpha channel. More... | |
void | bm_print_bitmaps () |
(DEBUG) Prints all loaded bitmaps to an outwindow More... | |
int | bm_make_render_target (int width, int height, int flags) |
Creates a render target as close to the desired resolution as possible. More... | |
int | bm_is_render_target (int handle) |
Checks to see if the given bitmap indexed by handle is a render target. More... | |
bool | bm_set_render_target (int handle, int face=-1) |
(GR function) Calls gr_bm_set_render target for the given bitmap indexed by handle More... | |
bool | bm_load_and_parse_eff (const char *filename, int dir_type, int *nframes, int *nfps, int *key, BM_TYPE *type) |
Loads and parses an .EFF. More... | |
Variables | |
int | bm_texture_ram |
how many bytes of textures are used. More... | |
int | Bm_paging |
Bool type that indicates if BMPMAN is currently paging. More... | |
const BM_TYPE | bm_type_list [] |
List of valid bitmap types. More... | |
const char * | bm_ext_list [] |
List of extensions for those types. More... | |
const int | BM_NUM_TYPES |
Calculated number of bitmap types. More... | |
const BM_TYPE | bm_ani_type_list [] |
List of valid bitmap animation types. More... | |
const char * | bm_ani_ext_list [] |
List of extensions for those types. More... | |
const int | BM_ANI_NUM_TYPES |
Calculated number of bitmap animation types. More... | |
int | GLOWMAP |
References a map that is a fully lit version of its index -Bobboau. More... | |
int | SPECMAP |
References a map that is for specular mapping -Bobboau. More... | |
int | ENVMAP |
References a map that is for environment mapping -Bobboau. More... | |
int | NORMMAP |
Normal mapping. More... | |
int | HEIGHTMAP |
Height map for normal mapping. More... | |
int | MISCMAP |
Utility map, to be utilized for various things shader authors can come up with. More... | |
void(* | bm_set_components )(ubyte *pixel, ubyte *r, ubyte *g, ubyte *b, ubyte *a) |
Functional pointer that references any of the bm_set_components functions. More... | |
void(* | bm_set_components_32 )(ubyte *pixel, ubyte *r, ubyte *g, ubyte *b, ubyte *a) |
Functional pointer that references any of the bm_set_components_32 functions. More... | |
Header file for the bitmap manager (bmpman)
Definition in file bmpman.h.
void bm_close | ( | ) |
Closes the bitmap manager, freeing any allocated memory used by bitmaps. Is called at program close.
Definition at line 459 of file bmpman.cpp.
Loads a bitmap which exists somewhere in the RAM.
bpp | The bitdepth of the bitmap | |
w | The width of the bitmap | |
h | The height of the bitmap | |
[in] | data | The bitmap's data glob |
flags |
Definition at line 469 of file bmpman.cpp.
Gets the cache slot of the bitmap indexed by handle.
if the bitmap is an ani, gets the first frame
Definition at line 669 of file bmpman.cpp.
Gets the RGBA components of a pixel according to the selected mode.
Definition at line 685 of file bmpman.cpp.
Gets the filename of the bitmap indexed by handle.
[out] | filename | The filename of the bitmap, if successful. Is set to an empty string if unseccessful |
Definition at line 735 of file bmpman.cpp.
const char* bm_get_filename | ( | int | handle | ) |
Gets the filename of the bitmap indexed by handle, which must exist.
If the bitmap does not exist (i.e. the handle is invalid), then an Assertion halts program execution.
z64 - maybe deprecate this in favor of an SCP_string version.
z64 - maybe combine this with the other bm_get_filename function like so: void bm_get_filename(int handle, SCP_string *filename, bool must_exist = false);
Definition at line 727 of file bmpman.cpp.
(DEBUG) Gets memory size, in bytes, of the locked bitmaps
Both params are non-optional, and must be non-null. There's currently no safety checks on either.
ntotal[out] | Memory size, in bytes, of the locked bitmaps |
nnew[out] | Memory size, in bytes, of the bitmaps that were locked since the last frame |
Definition at line 749 of file bmpman.cpp.
int bm_get_info | ( | int | handle, |
int * | w = NULL , |
||
int * | h = NULL , |
||
ubyte * | flags = NULL , |
||
int * | nframes = NULL , |
||
int * | fps = NULL |
||
) |
Gets info on the bitmap indexed by handle.
[out] | w | If non-null, gets the width |
[out] | h | If non-null, gets the heigth |
[out] | flags | If non-null, gets the flags |
[out] | nframs | If non-null, gets the nframes |
[out] | fps | If non-null, gets the fps |
Definition at line 769 of file bmpman.cpp.
int bm_get_next_handle | ( | ) |
Gets the next available bitmap slot.
Definition at line 820 of file bmpman.cpp.
Gets the number of mipmaps of the indexed texture.
Definition at line 838 of file bmpman.cpp.
Gets the palette for a given bitmap indexed by handle, and optionally the filename.
[out] | pal | Is set to reference the bitmap's palette |
[out] | name | (optional) Is set to the bitmap's filename |
Definition at line 850 of file bmpman.cpp.
Returns a unique signiature for the bitmap indexed by handle.
A signature will change when the bitmap's data changes
Definition at line 869 of file bmpman.cpp.
size_t bm_get_size | ( | int | handle | ) |
Gets the size, in bytes, taken up by the bitmap indexed by handle.
Definition at line 878 of file bmpman.cpp.
Gets the correct TCACHE_TYPE for compressed graphics (uncompressed are assumed TCACHE_TYPE_NORMAL)
Definition at line 887 of file bmpman.cpp.
Returns the image type of the given bitmap handle.
Definition at line 894 of file bmpman.cpp.
Hack to get a pixel from a bitmap.
only works good in 8bpp mode
void bm_gfx_load_all | ( | ) |
Loads all data for all bitmaps that have been requested to be loaded.
bool bm_has_alpha_channel | ( | int | handle | ) |
Checks to see if the indexed bitmap has an alpha channel.
Definition at line 903 of file bmpman.cpp.
void bm_init | ( | ) |
Initilizes the bitmap manager.
Definition at line 916 of file bmpman.cpp.
Returns the compression type of the bitmap indexed by handle.
Definition at line 952 of file bmpman.cpp.
Checks to see if the given bitmap indexed by handle is a render target.
Definition at line 993 of file bmpman.cpp.
Checks if the bitmap indexed by handle is valid.
Some early known false or out of range handles (such as negative) are checked within an initial routine pass, followed by a more thorough check routine to ensure the series of bitmaps within the bm_bitmaps[] structure have not become invalid.
Definition at line 1006 of file bmpman.cpp.
int bm_load | ( | const char * | filename | ) |
Loads a bitmap so we can draw with it later.
filename |
Definition at line 1119 of file bmpman.cpp.
int bm_load | ( | const SCP_string & | filename | ) |
Loads a bitmap so we can draw with it later. (Preferred version)
filename |
Definition at line 1235 of file bmpman.cpp.
bool bm_load_and_parse_eff | ( | const char * | filename, |
int | dir_type, | ||
int * | nframes, | ||
int * | nfps, | ||
int * | key, | ||
BM_TYPE * | type | ||
) |
Loads and parses an .EFF.
[in] | filename | The filename of the .EFF |
[in] | dir_type | |
[out] | nframes | (optional) If given, is set to the number of frames this .EFF has |
[out] | nfps | (optional) If given, is set to the fps of this .EFF |
[out] | key | (optional) If given, is set to the keyframe index of this .EFF |
[out] | type | (optional) If given, is set to the BM_TYPE of the .EFF |
Definition at line 1239 of file bmpman.cpp.
int bm_load_animation | ( | const char * | filename, |
int * | nframes = NULL , |
||
int * | fps = NULL , |
||
int * | keyframe = NULL , |
||
int | can_drop_frames = 0 , |
||
int | dir_type = CF_TYPE_ANY |
||
) |
Loads a bitmap sequance so we can draw with it.
[in] | filename | |
[out] | nframes | If non-null, set to the number of frames the animation has |
[out] | fps | If non-null, set to the fps of this animation |
[out] | keyframe | if non null, set to the keyframe index of this animation |
[in] | can_drop_frames | If set, allows dropped frames |
[in] | dir_type | Directory type |
Definition at line 1420 of file bmpman.cpp.
int bm_load_duplicate | ( | const char * | filename | ) |
Reloads a bitmap as a duplicate.
This function basically allows you to load a bitmap which already exists (by filename). This is useful because in some cases we need to have a bitmap which is locked in screen format and texture format, such as the pilot pics and squad logos
filename |
Definition at line 1668 of file bmpman.cpp.
int bm_load_either | ( | const char * | filename, |
int * | nframes = NULL , |
||
int * | fps = NULL , |
||
int * | keyframe = NULL , |
||
int | can_drop_frames = 0 , |
||
int | dir_type = CF_TYPE_ANY |
||
) |
Loads either animation (bm_load_animation) or still image (bm_load)
[in] | filename | |
[out] | nframes | If non-null and loading was successful, set to the number of frames the animation has |
[out] | fps | If non-null and loading was successful, set to the fps of this animation |
[out] | keyframe | if non null and loading was successful, set to the keyframe index of this animation |
[in] | can_drop_frames | |
[in] | dir_type |
Definition at line 1683 of file bmpman.cpp.
Locks down the bitmap indexed by bitmapnum.
Also converts the bitmap to the appropriate format specified by bpp and flags. Only lock a bitmap when you need it!
handle | The number indexing the desired bitmap |
bpp | The desired bpp of the bitmep |
flags | The desired bitmap format |
nodebug |
Definition at line 1754 of file bmpman.cpp.
Creates a render target as close to the desired resolution as possible.
Definition at line 2267 of file bmpman.cpp.
Allocates memory for the given handle.
Definition at line 2339 of file bmpman.cpp.
Marks a texture as being used for this level, and is anti-aliased.
[in] | num_frames | If specified, assumes this is an animated texture |
Definition at line 2354 of file bmpman.cpp.
void bm_page_in_start | ( | ) |
Tells bmpman to start keeping track of what bitmaps are used where.
Definition at line 2372 of file bmpman.cpp.
void bm_page_in_stop | ( | ) |
Tells bmpman to stop paging (?)
Definition at line 2393 of file bmpman.cpp.
Marks a texture as being used for this level.
[in] | num_frames | If specified, assumes this is an animated texture |
Definition at line 2462 of file bmpman.cpp.
Marks a textures as being used for level and is transparant.
[in] | num_frames | If specified, assumes this is an animated texture |
Definition at line 2514 of file bmpman.cpp.
bool bm_page_out | ( | int | handle | ) |
Unloads the bitmap indexed by handle that was previously paged-in.
Definition at line 2559 of file bmpman.cpp.
void bm_print_bitmaps | ( | ) |
(DEBUG) Prints all loaded bitmaps to an outwindow
Definition at line 2586 of file bmpman.cpp.
Frees both a bitmap's data and it's associated slot.
Once called, the bm number 'n' cannot be used until bm_load or bm_create is re-inits the slot.
handle | The index number of the bitmap to release |
clear_render_targets | If nonzero, also release render targets |
Definition at line 2603 of file bmpman.cpp.
Reloads an existing bmpman slot with different bitmap.
[in] | filename | The filename of the image to load |
Definition at line 2699 of file bmpman.cpp.
void BM_SELECT_ALPHA_TEX_FORMAT | ( | ) |
Sets bm_set_components and bm_get_components to reference texture format functions (with alpha)
Definition at line 2721 of file bmpman.cpp.
void BM_SELECT_SCREEN_FORMAT | ( | ) |
Sets bm_set_components and bm_get_components to reference screen format functions.
Definition at line 2733 of file bmpman.cpp.
void BM_SELECT_TEX_FORMAT | ( | ) |
Sets bm_set_components and bm_get_components to reference texture format functions.
Definition at line 2745 of file bmpman.cpp.
Sets the 16bpp screen pixel to the specified RGBA value.
Definition at line 2757 of file bmpman.cpp.
Sets the 16bpp texture pixel to the specified RGBA value.
Definition at line 2768 of file bmpman.cpp.
Sets the 32bpp screen pixel to the specified RGBA value.
Definition at line 2780 of file bmpman.cpp.
Sets the 32bpp texture pixel to the specified RGBA value.
Definition at line 2791 of file bmpman.cpp.
Sets BMPMAN's memory mode.
0 = High memory; 1 = Low memory (loads every other frame of ani's); 2 = Debug low memory (only use first frame of each ani)
Definition at line 2803 of file bmpman.cpp.
(GR function) Calls gr_bm_set_render target for the given bitmap indexed by handle
Definition at line 2810 of file bmpman.cpp.
Unloads a bitmap's data, but not the bitmap info.
The bm number (n) may be reused once this function has been called on it. However, it will have to be paged in the next time it is locked.
handle | The index number of the bitmap to free |
clear_render_targets | If true, release a render target |
nodebug | If true, exclude certain debug messages |
Definition at line 2890 of file bmpman.cpp.
void bm_unload_all | ( | ) |
Unloads all used bitmaps, should only ever be called by game_shutdown()
Definition at line 2952 of file bmpman.cpp.
Quickly unloads a bitmap's data, ignoring the load_count.
Similar to bm_unload(), except that it can be safely used to free data without worrying about load_count. It's safe to use in relation to bm_release() and in gr_*_texture functions
handle | The bm number of the bitmap to free |
clear_render_targets | If true, release a render target |
Definition at line 2968 of file bmpman.cpp.
Unlocks a bitmap.
Decrements the ref_count member of the bitmap_entry struct, A bitmap can only be unloaded when the ref_count is 0
Definition at line 3005 of file bmpman.cpp.
(DEBUG) Similar to bm_malloc, but only updates how much memory is used
Definition at line 3028 of file bmpman.cpp.
const char* bm_ani_ext_list[] |
List of extensions for those types.
Definition at line 73 of file bmpman.cpp.
const int BM_ANI_NUM_TYPES |
Calculated number of bitmap animation types.
Definition at line 74 of file bmpman.cpp.
const BM_TYPE bm_ani_type_list[] |
List of valid bitmap animation types.
Definition at line 72 of file bmpman.cpp.
const char* bm_ext_list[] |
List of extensions for those types.
Definition at line 69 of file bmpman.cpp.
const int BM_NUM_TYPES |
Calculated number of bitmap types.
Definition at line 70 of file bmpman.cpp.
int Bm_paging |
Bool type that indicates if BMPMAN is currently paging.
Definition at line 65 of file bmpman.cpp.
Functional pointer that references any of the bm_set_components functions.
The bm_set_components functions packs the RGBA values into the ubyte array referenced by pixel, whose format differs according to its bpp value and presence of an alpha channel. The RGBA values are scaled accordingly.
[out] | pixel | The pixel to set |
[in] | r | Red value (may not be NULL) |
[in] | g | Green value (may not be NULL) |
[in] | b | Blue value (may not be NULL) |
[in] | a | Alpha value (currently ignored) |
Definition at line 76 of file bmpman.cpp.
Functional pointer that references any of the bm_set_components_32 functions.
The bm_set_components functions packs the RGBA values into the ubyte array referenced by pixel, whose format differs according to its bpp value and presence of an alpha channel. The RGBA values are scaled accordingly.
Definition at line 77 of file bmpman.cpp.
int bm_texture_ram |
how many bytes of textures are used.
Definition at line 64 of file bmpman.cpp.
const BM_TYPE bm_type_list[] |
List of valid bitmap types.
Definition at line 68 of file bmpman.cpp.
int ENVMAP |
References a map that is for environment mapping -Bobboau.
Definition at line 59 of file bmpman.cpp.
int GLOWMAP |
References a map that is a fully lit version of its index -Bobboau.
Definition at line 57 of file bmpman.cpp.
int HEIGHTMAP |
Height map for normal mapping.
Definition at line 61 of file bmpman.cpp.
int MISCMAP |
Utility map, to be utilized for various things shader authors can come up with.
Definition at line 62 of file bmpman.cpp.
int NORMMAP |
Normal mapping.
Definition at line 60 of file bmpman.cpp.
int SPECMAP |
References a map that is for specular mapping -Bobboau.
Definition at line 58 of file bmpman.cpp.