FS2_Open
Open source remastering of the Freespace 2 engine
bmpman.h File Reference
#include "cfile/cfile.h"
#include "globalincs/pstypes.h"

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...
 

Enumerations

enum  BM_TYPE {
  BM_TYPE_NONE = 0, BM_TYPE_USER, BM_TYPE_PCX, BM_TYPE_TGA,
  BM_TYPE_DDS, BM_TYPE_PNG, BM_TYPE_JPG, BM_TYPE_ANI,
  BM_TYPE_EFF, BM_TYPE_RENDER_TARGET_STATIC, BM_TYPE_RENDER_TARGET_DYNAMIC, BM_TYPE_DXT1,
  BM_TYPE_DXT3, BM_TYPE_DXT5, BM_TYPE_CUBEMAP_DDS, BM_TYPE_CUBEMAP_DXT1,
  BM_TYPE_CUBEMAP_DXT3, BM_TYPE_CUBEMAP_DXT5
}
 

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...
 
voidbm_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...
 
bitmapbm_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...
 

Detailed Description

Header file for the bitmap manager (bmpman)

Definition in file bmpman.h.

Macro Definition Documentation

#define BMPMAN_NDEBUG

Enables BMPMAN debugging code.

Definition at line 26 of file bmpman.h.

Function Documentation

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.

int bm_create ( int  bpp,
int  w,
int  h,
void data = NULL,
int  flags = 0 
)

Loads a bitmap which exists somewhere in the RAM.

Parameters
bppThe bitdepth of the bitmap
wThe width of the bitmap
hThe height of the bitmap
[in]dataThe bitmap's data glob
flags
Note
The used RAM cannot be freed until bm_release is called on the created bitmap

Definition at line 469 of file bmpman.cpp.

int bm_get_cache_slot ( int  bitmap_id,
int  separate_ani_frames 
)

Gets the cache slot of the bitmap indexed by handle.

if the bitmap is an ani, gets the first frame

Returns
The cache slot index of the bitmap if handle is valid
Note
If the handle is invalid, an Assert() fails

Definition at line 669 of file bmpman.cpp.

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.

See also
BM_SELECT_SCREEN_FORMAT() BM_SELECT_TEX_FORMAT() BM_SELECT_ALPHA_TEX_FORMAT()

Definition at line 685 of file bmpman.cpp.

void bm_get_filename ( int  bitmapnum,
char *  filename 
)

Gets the filename of the bitmap indexed by handle.

Parameters
[out]filenameThe filename of the bitmap, if successful. Is set to an empty string if unseccessful
Todo:
z64 - maybe deprecate this in favor of an SCP_string version

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.

Returns
A const char* to the filename of the bitmap
Todo:

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.

void bm_get_frame_usage ( int ntotal,
int nnew 
)

(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.

Parameters
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
Note
This is a debug function, and is undefined within release builds

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.

Parameters
[out]wIf non-null, gets the width
[out]hIf non-null, gets the heigth
[out]flagsIf non-null, gets the flags
[out]nframsIf non-null, gets the nframes
[out]fpsIf non-null, gets the fps
Returns
The handle on success, or
The handle to the first frame on success, or
-1 on failure

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.

int bm_get_num_mipmaps ( int  handle)

Gets the number of mipmaps of the indexed texture.

Definition at line 838 of file bmpman.cpp.

void bm_get_palette ( int  handle,
ubyte pal,
char *  name 
)

Gets the palette for a given bitmap indexed by handle, and optionally the filename.

Parameters
[out]palIs set to reference the bitmap's palette
[out]name(optional) Is set to the bitmap's filename
Todo:
Maybe get rid of the optional filename and have the callers call bm_get_filename. Less efficient, however.

Definition at line 850 of file bmpman.cpp.

uint bm_get_signature ( int  handle)

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.

int bm_get_tcache_type ( int  handle)

Gets the correct TCACHE_TYPE for compressed graphics (uncompressed are assumed TCACHE_TYPE_NORMAL)

Definition at line 887 of file bmpman.cpp.

BM_TYPE bm_get_type ( int  handle)

Returns the image type of the given bitmap handle.

Definition at line 894 of file bmpman.cpp.

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.

only works good in 8bpp mode

Note
This function is not defined.
void bm_gfx_load_all ( )

Loads all data for all bitmaps that have been requested to be loaded.

Note
This function is not defined.
bool bm_has_alpha_channel ( int  handle)

Checks to see if the indexed bitmap has an alpha channel.

Note
Currently just checks if the bitmap is 32bpp and is not a .PCX

Definition at line 903 of file bmpman.cpp.

void bm_init ( )

Initilizes the bitmap manager.

Definition at line 916 of file bmpman.cpp.

int bm_is_compressed ( int  handle)

Returns the compression type of the bitmap indexed by handle.

Definition at line 952 of file bmpman.cpp.

int bm_is_render_target ( int  handle)

Checks to see if the given bitmap indexed by handle is a render target.

Returns
The render type (BM_TYPE) if it is a render target, or
0 if it is not

Definition at line 993 of file bmpman.cpp.

int bm_is_valid ( int  handle)

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.

Returns
Nonzero if valid, else
Zero otherwise
Todo:
z64 - Returned value is essentially a bool type, need to check all caller functions to see if it can safely be updated to reflect this

Definition at line 1006 of file bmpman.cpp.

int bm_load ( const char *  filename)

Loads a bitmap so we can draw with it later.

Parameters
filename
Returns
The bitmap number if successful, else
a negative value if not

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)

Parameters
filename
Returns
The bitmap number if successful, else
a negative value if not

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.

Parameters
[in]filenameThe 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
Returns
true If successful
false If not successful

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.

Parameters
[in]filename
[out]nframesIf non-null, set to the number of frames the animation has
[out]fpsIf non-null, set to the fps of this animation
[out]keyframeif non null, set to the keyframe index of this animation
[in]can_drop_framesIf set, allows dropped frames
[in]dir_typeDirectory type
Returns
The bm number of the first bitmap in the sequence if successful, or
A negative value if unsuccessful

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

Parameters
filename
Returns
The bitmap number if successful, else
a negative value if not

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)

Parameters
[in]filename
[out]nframesIf non-null and loading was successful, set to the number of frames the animation has
[out]fpsIf non-null and loading was successful, set to the fps of this animation
[out]keyframeif non null and loading was successful, set to the keyframe index of this animation
[in]can_drop_frames
[in]dir_type
Returns
The bm number of the first bitmap in the sequence if successful, or
A negative value if unsuccessful

Definition at line 1683 of file bmpman.cpp.

bitmap* bm_lock ( int  handle,
ubyte  bpp,
ubyte  flags,
bool  nodebug = false 
)

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!

Parameters
handleThe number indexing the desired bitmap
bppThe desired bpp of the bitmep
flagsThe desired bitmap format
nodebug
Returns
A pointer to the bitmap that's valid until bm_unlock is called if successful, or
NULL if unsuccessful

Definition at line 1754 of file bmpman.cpp.

int bm_make_render_target ( int  width,
int  height,
int  flags 
)

Creates a render target as close to the desired resolution as possible.

Returns
the handle of an avilable render target if successful, or
-1 if not successful
Note
BM_FLAG_RENDER_TARGET_STATIC are drawn once/infrequently, while BM_FLAG_RENDER_TARGET_DYNAMIC are drawn roughly once every frame

Definition at line 2267 of file bmpman.cpp.

void* bm_malloc ( int  handle,
int  size 
)

Allocates memory for the given handle.

Returns
A pointer to the allocated vm if successful,
Null, if unsuccessful
Note
z64 - This function looks fishy. Not only is handle not used in release builds, but bm_bitmaps[handle].size and bm_texture_size aren't modified unless this is a debug build

Definition at line 2339 of file bmpman.cpp.

void bm_page_in_aabitmap ( int  bitmapnum,
int  num_frames = 1 
)

Marks a texture as being used for this level, and is anti-aliased.

Parameters
[in]num_framesIf 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.

void bm_page_in_texture ( int  bitmapnum,
int  num_frames = 0 
)

Marks a texture as being used for this level.

Parameters
[in]num_framesIf specified, assumes this is an animated texture

Definition at line 2462 of file bmpman.cpp.

void bm_page_in_xparent_texture ( int  bitmapnum,
int  num_frames = 1 
)

Marks a textures as being used for level and is transparant.

Parameters
[in]num_framesIf 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.

Returns
0 If the bitmap had already been released, or
0 If the handle is invalid, or
1 If successful

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.

int bm_release ( int  handle,
int  clear_render_targets = 0 
)

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.

Parameters
handleThe index number of the bitmap to release
clear_render_targetsIf nonzero, also release render targets
Returns
1 on success,
0 otherwise
Note
If the passed handle is that of an ANI, it frees EVERY frame. Be sure to only pass the handle of the first frame!
Todo:
upgrade return type and clear_render_targets type to bools

Definition at line 2603 of file bmpman.cpp.

int bm_reload ( int  bitmap_handle,
const char *  filename 
)

Reloads an existing bmpman slot with different bitmap.

Parameters
[in]filenameThe filename of the image to load
Returns
The bitmap handle on success, or
A negative value on failure
Note
This should only be used if you are certain the new picture is the same type, has same dimensions, etc.

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.

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.

See also
bm_set_components

Definition at line 2757 of file bmpman.cpp.

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.

See also
bm_set_components

Definition at line 2768 of file bmpman.cpp.

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.

See also
bm_set_components

Definition at line 2780 of file bmpman.cpp.

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.

See also
bm_set_components

Definition at line 2791 of file bmpman.cpp.

void bm_set_low_mem ( int  mode)

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)

Todo:
This should use an enum, or instead allow an arbitrary number to drop frames (like 1/2, 1/3, etc.)

Definition at line 2803 of file bmpman.cpp.

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

Returns
true if successful, or
false if unsuccessful

Definition at line 2810 of file bmpman.cpp.

int bm_unload ( int  handle,
int  clear_render_targets = 0,
bool  nodebug = false 
)

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.

Parameters
handleThe index number of the bitmap to free
clear_render_targetsIf true, release a render target
nodebugIf true, exclude certain debug messages
Returns
0 if not successful,
1 if successful

Definition at line 2890 of file bmpman.cpp.

void bm_unload_all ( )

Unloads all used bitmaps, should only ever be called by game_shutdown()

Todo:
Maybe move this declaration into bmpman.cpp and then extern this function within game_shutdown() to ensure it only ever gets called there.

Definition at line 2952 of file bmpman.cpp.

int bm_unload_fast ( int  handle,
int  clear_render_targets = 0 
)

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

Parameters
handleThe bm number of the bitmap to free
clear_render_targetsIf true, release a render target
Note
bm_free_data_fast() is used here and NOT bm_free_data()

Definition at line 2968 of file bmpman.cpp.

void bm_unlock ( int  handle)

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.

void bm_update_memory_used ( int  n,
int  size 
)

(DEBUG) Similar to bm_malloc, but only updates how much memory is used

Note
z64 - Also fishy (see bm_malloc)

Definition at line 3028 of file bmpman.cpp.

Variable Documentation

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.

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.

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.

Parameters
[out]pixelThe pixel to set
[in]rRed value (may not be NULL)
[in]gGreen value (may not be NULL)
[in]bBlue value (may not be NULL)
[in]aAlpha value (currently ignored)
Note
z64 - These functions were made predating the introduction of C++ classes, and are basically the equivalent of Pixel::set(ubyte *r, ubyte *b, ubyte *g). The original comment mentions that any of the rgba params may be NULL, but this is by far NOT the case, as a NULL value will cause undefined behavior (really really bad chroma corruption)
These functions assume the incoming bitdepth will always be >= to the outgoing bitdepth of the pixel. Should the incoming bitdepth be lower, the outgoing values will appear darker than they should be

Definition at line 76 of file bmpman.cpp.

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.

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.

See also
bm_set_components

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.