BRender Technical Reference Manual:4 Data Structures (Alphabetical Reference):br_pixelmap
Next|Prev|Up
The Structure
Members
Operations
BrPixelmapFill()
BrPixelmapRectangleFill()
BrPixelmapLine()
BrPixelmapPixelSet()
BrPixelmapPixelGet()
BrPixelmapText()
BrPixelmapTextF()
BrPixelmapTextWidth()
BrPixelmapTextHeight()
Copy/Assign
BrPixelmapCopy()
BrPixelmapRectangleCopy()
Access & Maintenance
BrMapAdd()
BrMapAddMany()
BrMapUpdate()
BrMapRemove()
BrMapRemoveMany()
BrTableAdd()
BrTableAddMany()
BrTableUpdate()
BrTableRemove()
BrTableRemoveMany()
Referencing & Lifetime
Initialisation
Construction & Destruction
BrPixelmapAllocate()
BrPixelmapAllocateSub()
BrPixelmapMatch()
BrPixelmapClone()
BrPixelmapFree()
Supplementary
BrPixelmapPixelSize()
BrPixelmapChannels()
BrMapCount()
BrMapEnum()
BrMapFind()
BrMapFindMany()
BrMapFindHook()
BrMapFindFailedLoad()
BrTableCount()
BrTableEnum()
BrTableFind()
BrTableFindMany()
BrTableFindHook()
BrTableFindFailedLoad()
Import & Export
BrPixelmapFileCount()
BrPixelmapLoad()
BrPixelmapLoadMany()
BrFmtBMPLoad()
BrFmtGIFLoad()
BrFmtIFFLoad()
BrFmtTGALoad()
BrPixelmapSave()
BrPixelmapSaveMany()

br_pixelmap


The Structure

BRender's pixel map structure, used for texture maps, shade tables, blend tables, colour buffers and Z-buffers. See Image Support. Texture maps, shade tables, and blend tables being required for rendering materials should be maintained within the registry as necessary.

The typedef

(See pixelmap.h for precise declaration and ordering)

Behaviour

br_uint_8 type Individual pixel type

br_uint_8 flags

Size & Position

br_int_16 origin_x, origin_y Local origin (centre), relative to base_x, base_y

br_uint_16 width, height Size of pixel map (in pixels)

Data

void * pixels A pointer to raw pixel data

br_int_16 row_bytes The difference in bytes between pixels at the same column of adjacent rows

br_uint_16 base_x, base_y Co-ordinates of the region of pixels in use

br_pixelmap * map A pointer to a colour map, used when pixel colours are indexed

Supplementary

char * identifier An optional name for texture maps and tables

void * user User data (application dependent)

void * device A device pointer, used if the pixel map originated from a device

Related Functions

Scene Rendering

See BrZbSceneRenderBegin()
34, BrZbSceneRender()34.

Image Support

See BrPixelmapDoubleBuffer()44, BrPixelmapDirtyRectangleCopy()42, BrPixelmapDirtyRectangleFill()42, BrScenePick2D()84.

Related Structures

Scene Modelling

See br_material151.

Members

Behaviour

br_uint_8 type

This member defines the type of data stored for each pixel in the pixel map. The various types have values defined by the following symbols:



All values are written with the most significant bit to the left.

The Encoding column represents the 32 bit value to be supplied as colour to functions such as BrPixelmapPixelSet()277. The last column shows how the first pixel on a row will appear in the first four bytes indexed from pixels. The dots represent further pixels. The ordering of bytes pixel maps is independent of word byte order, except in the case of depth buffers, in which pixels are read and written as 32 bit values. This means that in a 16 bit depth buffer the least significant 16 bits are lost.

Note, with respect to pixel maps used as textures, that zero pixels (irrespective of any palette information) are not rendered, and so have the effect of transparency. This only applies to textures and not to pixel map operations such as BrPixelmapCopy()280.

br_uint_8 flags

This is a read-only member, set upon allocation, that contains various flag values. One of the flags that may be useful is BR_BMF_NO_ACCESS which will be set if the pixel data is stored at pixels. If not set then pixels is invalid and there is no direct access to pixel data.

Size & Position

br_int_16 origin_x, origin_y

These members define the position of the co-ordinate origin of the pixel map relative to the base origin (given by base_x, base_y). Thus a point plotted at (0,0) will be plotted at column origin_x from base_x. The co-ordinate origin also effectively defines the centre of projection when used as a rendering destination.

br_uint_16 width, height

These members contain the dimensions of the visible region of the pixel map.

Data

void * pixels

When pixel data is directly accessible (see flags), this member points to an area of memory containing the raw pixel data. It either points to the start of the memory occupied by the pixel map or the last row_bytes of it. However, it always points to the byte of the left hand pixel of the `first' row. For instance, in monochrome pixel maps it will point to the byte whose most significant bit represents the left hand pixel of the first row. In true colour pixel maps it will point to the least significant byte of the colour of the left hand pixel of the first row, which will be the blue component in BR_PMT_RGB_888 pixel maps and the alpha component in BR_PMT_RGBA_8888 pixel maps.

br_int_16 row_bytes

This member defines the physical row length of the pixel map in terms of the byte difference between pixels in the same column of adjacent rows. It will be negative if the pixel map memory is inverted.

br_uint_16 base_x, base_y

These members define the top left of the start of pixel map data in terms of base_y as a number of row_bytes, and base_x as a smaller offset from this.

br_pixelmap * map

For indexed pixel maps (of type BR_PMT_INDEX_?), this member points to a colour map. This is used to obtain the `true colour' corresponding to a particular index.

Supplementary

char * identifier

Pointer to unique, zero terminated, character string (or Null if not required).

If the pixel map is loaded or imported, the identifier will have been set using BrResStrDup()49.

void * user

This member may be used by the application for its own purposes. It is initialised to Null upon allocation (if allocated by BRender), and not accessed by BRender thereafter.

void * device

Some platform specific functions can return a pixel map structure corresponding to an area of video memory or other hardware. This member enables pixel map functions to determine whether the pixel map is in memory or not. It should not be used by the application.

Operations


BrPixelmapFill()

Description:
Fill a pixel map with a given value.

Declaration:
void BrPixelmapFill(br_pixelmap* dat, br_uint_32 colour)

Arguments:
br_pixelmap * dat

A pointer to the pixel map to be filled.

br_uint_32 colour

Value to set each pixel to.


BrPixelmapRectangleFill()

Description:
Fill a rectangular window in a pixel map with a given value.

Declaration:
void BrPixelmapRectangleFill(br_pixelmap* dst, br_int_16 x, br_int_16 y, br_uint_16 w, br_uint_16 h, br_uint_32 colour)

Arguments:
br_pixelmap * dst

A pointer to the destination pixel map.

br_int_16 x,y

Co-ordinates of the rectangle's top left corner.

br_uint_16 w,h

Rectangle width and height (in pixels).

br_uint_32 colour

Value to set each pixel to.

Example:
br_int_16 x,y;
br_uint_16 w,h;
br_pixelmap *offscreen;
...
BrPixelmapRectangleFill(offscreen,x,y,w,h,0);


BrPixelmapLine()

Description:
Draw a line in a pixel map between (x1,y1) and (x2,y2), clipping it to the edges of the pixel map if necessary.

Declaration:
void BrPixelmapLine(br_pixelmap* dst, br_int_16 x1, br_int_16 y1, br_int_16 x2, br_int_16 y2, br_uint_32 colour)

Arguments:
br_pixelmap * dst

A pointer to the destination pixel map.

br_int_16 x1,y1,x2,y2

Co-ordinates of the line's endpoints.

br_uint_32 colour

Value to set each pixel in the line to.


BrPixelmapPixelSet()

Description:
Set a pixel to a given value.

Declaration:
void BrPixelmapPixelSet(br_pixelmap* dst, br_int_16 x, br_int_16 y, br_uint_32 colour)

Arguments:
br_pixelmap * dst

A pointer to the destination pixel map.

br_int_16 x,y

Pixel co-ordinates.

br_uint_32 colour

Pixel value.


BrPixelmapPixelGet()

Description:
Get the value of a particular pixel

Declaration:
br_uint_32 BrPixelmapPixelGet(const br_pixelmap* src, br_int_16 x, br_int_16 y)

Arguments:
const br_pixelmap * src

A pointer to the source pixel map from which to read the pixel.

br_int_16 x,y

Pixel co-ordinates.

Result:
br_uint_32 colour

Pixel value. If the point is off-screen, zero will be returned.

Remarks:
Some device oriented pixel maps may not support read operations.


BrPixelmapText()

Description:
Write a string into a pixel map in a given font.

Declaration:
void BrPixelmapText(br_pixelmap* dst, br_int_16 x, br_int_16 y, br_uint_32 colour, const br_font* font, const char* text)

Arguments:
br_pixelmap * dst

A pointer to the destination pixel map.

br_int_16 x,y

Co-ordinates of text's top left corner.

br_uint_32 colour

Value to set each text pixel to.

const br_font * font

A pointer to a BRender font, or Null for the default font.

The following pointers are available:

BrFontFixed3x5

BrFontProp4x6

BrFontProp7x9

See brfont.h for precise declaration.

const char * text

A string.

Example:
br_uint_32 colour;
br_pixelmap *pmap;
...
BrPixelmapText(pmap,0,0,colour,BrFontProp7x9,"Example text...");


BrPixelmapTextF()

Description:
Write a `printf' formatted string into a pixel map in a given font. The function will accept format strings and arguments just as for the standard printf() function.

Declaration:
void BrPixelmapTextF(br_pixelmap* dst, br_int_16 x, br_int_16 y, br_uint_32 colour, const br_font* font, const char* fmt, ...)

Arguments:
br_pixelmap * dst

A pointer to the destination pixel map.

br_int_16 x, y

Co-ordinates of text's top left corner.

br_uint_32 colour

Value to set each text pixel to.

const br_font * font

A pointer to a BRender font, or Null for the default font.

The following pointers are available:

BrFontFixed3x5

BrFontProp4x6

BrFontProp7x9

See brfont.h for precise declaration.

const char * fmt

A format string (as for printf()).

Example:
br_uint_32 colour;
br_pixelmap *pmap;
...
BrPixelmapTextF
(	pmap,0,0,255,NULL,"Frames/Sec = %16g Polys/Sec = %16g"
,	TIMING_FRAMES/((end_time-start_time)/(double)CLOCK_RATE)
,	total_faces	/((end_time-start_time)/(double)CLOCK_RATE)
);


BrPixelmapTextWidth()

Description:
Find the width of a string for a given font and pixel map.

Declaration:
br_uint_16 BrPixelmapTextWidth(const br_pixelmap* dst, const br_font* font, const char* text)

Arguments:
const br_pixelmap * dst

A pointer to a pixel map.

const br_font * font

A pointer to a BRender font, or Null for the default font.

const char * text

A string.

Result:
br_uint_16

Returns the string width in pixels. If the text argument is Null, the width of one character is returned.

See Also:
BrPixelmapText()
277


BrPixelmapTextHeight()

Description:
Find the height of a font for a given pixel map.

Declaration:
br_uint_16 BrPixelmapTextHeight(const br_pixelmap* dst, const br_font* font)

Arguments:
const br_pixelmap * dst

A pointer to a pixel map.

const br_font * font

A pointer to a BRender font, or Null for the default font.

Result:
Returns the font height in pixels.

See Also:
BrPixelmapText()
277


Copy/Assign

The br_pixelmap
272 structure should not be copied by structure assignment. Copies should only be made via construction. However, the pixels may be copied, in whole or in part using the following functions.


BrPixelmapCopy()

Description:
Copy the data in one pixel map to another. The source and destination pixel maps must have the same type and dimensions.

Declaration:
void BrPixelmapCopy(br_pixelmap* dst, const br_pixelmap* src)

Arguments:
br_pixelmap * dst

A pointer to the destination pixel map.

const br_pixelmap * src

A pointer to the source pixel map.

Example:
br_pixelmap *offscreen, *backdrop;
...
BrPixelmapCopy(offscreen, backdrop);


BrPixelmapRectangleCopy()

Description:
Copy a rectangular window from one pixel map to another.

Declaration:
void BrPixelmapRectangleCopy (br_pixelmap* dst, br_int_16 dx, br_int_16 dy, const br_pixelmap* src, br_int_16 sx, br_int_16 sy, br_uint_16 w, br_uint_16 h)

Arguments:
br_pixelmap * dst

A pointer to the destination pixel map.

br_int_16 dx,dy

Co-ordinates of the destination rectangle's top left corner.

const br_pixelmap * src

A pointer to the source pixel map.

br_int_16 sx,sy

Co-ordinates of the source rectangle's top left corner.

br_uint_16 w,h

Rectangle width and height (in pixels).


Access & Maintenance

Colour or texture maps and shade tables must be added to the registry if they are involved in rendering a scene. They should not be modified during rendering.

Colour maps and shade tables that have been added to the registry may be accessed by BRender during rendering.

If any changes are made to colour maps or shade tables involved in rendering, they must be updated before the next rendering in which they are involved.

Note that while texture maps and shade tables are pixel maps, the reverse does not apply. A pixel map is only a texture map by virtue of being added to the registry as such. Similarly with a shade table. Most importantly, a pixel map cannot be both! A texture map must be removed from the registry for it to become just a pixel map, and only then could it be added as a shade table. The same applies with roles interchanged. Note that this just applies to the instance of the br_pixelmap272 data structure, not to the memory that holds the pixel data. Therefore it is quite valid to have a texture map and shade table sharing the same pixel memory (not that it is easy to envisage a useful effect of doing so).


BrMapAdd()

Description:
Add a texture map to the registry, updating it as necessary. All texture maps must be added to the registry before they are subsequently involved in rendering.

Declaration:
br_pixelmap* BrMapAdd(br_pixelmap* pixelmap)

Arguments:
br_pixelmap * pixelmap

A pointer to a texture map.

Result:
br_pixelmap *

Returns a pointer to the added texture map, else Null if unsuccessful.

See Also:
BrMapUpdate()
282, BrMapAddMany()282, BrPixelmapLoad()295, BrMapFind()289, BrMapRemove()282.


BrMapAddMany()

Description:
Add a number of texture maps to the registry, updating them as necessary.

Declaration:
br_uint_32 BrMapAddMany(br_pixelmap* const* pixelmaps, int n)

Arguments:
br_pixelmap * const * pixelmaps

A pointer to an array of pointers to texture maps.

int n

Number of texture maps to add to the registry.

Result:
br_uint_32

Returns the number of texture maps added successfully.

See Also:
BrMapUpdate()
282, BrMapAdd()281, BrMapRemove()282, BrMapRemoveMany()283


BrMapUpdate()

Description:
Update a texture map.

Declaration:
void BrMapUpdate(br_pixelmap* pixelmap, br_uint_16 flags)

Arguments:
br_pixelmap * pixelmap

A pointer to a texture map.

br_uint_16 flags

Texture map update flags. In general, BR_MAPU_ALL should be used.

See Also:
BrMapAdd()281.


BrMapRemove()

Description:
Remove a texture map from the registry.

Declaration:
br_pixelmap* BrMapRemove(br_pixelmap* pixelmap)

Arguments:
br_pixelmap * pixelmap

A pointer to a texture map.

Result:
br_pixelmap *

Returns a pointer to the item removed.

See Also:
BrMapAdd()
281


BrMapRemoveMany()

Description:
Remove a number of texture maps from the registry.

Declaration:
br_uint_32 BrMapRemoveMany(br_pixelmap* const* pixelmaps, int n)

Arguments:
br_pixelmap * const * pixelmaps

A pointer to an array of pointers to texture maps.

int n

Number of texture maps to remove from the registry.

Result:
br_uint_32

Returns the number of texture maps removed successfully.

See Also:
BrMapAddMany()
282


BrTableAdd()

Description:
Add a shade table to the registry, updating it as necessary. All shade tables must be added to the registry before they are used subsequently.

Declaration:
br_pixelmap* BrTableAdd(br_pixelmap* pixelmap)

Arguments:
br_pixelmap * pixelmap

A pointer to a shade table.

Result:
br_pixelmap *

Returns a pointer to the added shade table, else Null if unsuccessful.

See Also:
BrTableUpdate()
284, BrTableAddMany()283, BrPixelmapLoad()295, BrTableFind()292, BrTableRemove()284


BrTableAddMany()

Description:
Add a number of shade tables to the registry, updating them as necessary.

Declaration:
br_uint_32 BrTableAddMany(br_pixelmap* const* pixelmaps, int n)

Arguments:
br_pixelmap * const * pixelmaps

A pointer to an array of pointers to shade tables.

int n

Number of shade tables to add to the registry.

Result:
br_uint_32

Returns the number of shade tables added successfully.

See Also:
BrTableUpdate()
284, BrTableAdd()283, BrTableRemove()284, BrTableRemoveMany()284


BrTableUpdate()

Description:
Update a shade table.

Declaration:
void BrTableUpdate(br_pixelmap* pixelmap, br_uint_16 flags)

Arguments:
br_pixelmap * pixelmap

A pointer to a shade table.

br_uint_16 flags

Shade table update flags. In general, BR_TABU_ALL should be used.

See Also:
BrTableAdd()283.


BrTableRemove()

Description:
Remove a shade table from the registry.

Declaration:
br_pixelmap* BrTableRemove(br_pixelmap* pixelmap)

Arguments:
br_pixelmap * pixelmap

A pointer to a shade table.

Result:
br_pixelmap *

Returns a pointer to the shade table removed.

See Also:
BrTableAdd()
283


BrTableRemoveMany()

Description:
Remove a number of shade tables from the registry.

Declaration:
br_uint_32 BrTableRemoveMany(br_pixelmap* const* pixelmaps, int n)

Arguments:
br_pixelmap * const * pixelmaps

A pointer to an array of pointers to shade tables.

int n

Number of shade tables to remove from the registry.

Result:
br_uint_32

Returns the number of shade tables removed successfully.

See Also:
BrTableAddMany()
283


Referencing & Lifetime

Pixel maps may be freely and multiply referenced. Once added to the registry as a texture map or shade table, there are certain restrictions, but they may still be multiply referenced. Maps and tables must have been added to the registry if they will be involved in rendering. Texture maps and shade tables must be maintained while they are in the registry or being referenced.

Initialisation

The structure is initialised by the various construction functions. Pixel maps should not be created or initialised by any other means.

Construction & Destruction

Apart from platform specific functions, pixel maps should only be constructed by the following BRender functions. Destruction should naturally be performed by the corresponding `free' function, usually BrPixelmapFree()287. Note that texture maps and shade tables should be removed from the registry before destruction.


BrPixelmapAllocate()

Description:
Allocate a new pixel map.

Declaration:
br_pixelmap* BrPixelmapAllocate(br_uint_8 type, br_uint_16 w, br_uint_16 h, void* pixels, int flags)

Arguments:
br_uint_8 type

Pixel map type.

br_uint_16 w

Width in pixels.

br_uint_16 h

Height in pixels.

void * pixels

A pointer to an existing block of memory. If Null, the pixel memory is allocated automatically using BrResAllocate()48.

The calculation obtaining the minimum size required for the block of memory is non-obvious. It is row_bytes*h., and row_bytes is not simply w*bits-per-pixel/8. To determine row_bytes, it is probably simplest to call this function with a dummy, non-Null pointer (address of an automatic, say), and record the value of row_bytes returned in the br_pixelmap272 (free it immediately afterwards). The memory pointed to by pixels is not accessed by this function.

int flags

Supply either BR_PMAF_NORMAL or BR_PMAF_INVERTED. If the latter, the function will automatically set the pixels member of the returned pixel map (whether supplied or not) to be at the start of the final row of pixel map memory (row_bytes is negative).

Result:
br_pixelmap *

Returns a pointer to the new pixel map, or Null if unsuccessful.


BrPixelmapAllocateSub()

Description:
Allocate a pixel map as part of an existing pixel map. The new pixel map is clipped to the existing pixel map.

Declaration:
br_pixelmap* BrPixelmapAllocateSub(br_pixelmap* pm, br_uint_16 x, br_uint_16 y, br_uint_16 w, br_uint_16 h)

Arguments:
br_pixelmap * pm

A pointer to an existing pixel map.

br_uint_16 x,y

Co-ordinates of the top left of the new pixel map in the existing pixel map.

br_uint_16 w,h

Width and height of the new pixel map.

Result:
br_pixelmap *

Returns a pointer to the new pixel map, or Null if unsuccessful.

Remarks:
The effective origin is set that of the existing pixel map.


BrPixelmapMatch()

Description:
Given a pixel map, allocate either a depth buffer or an off-screen colour buffer with the same dimensions.

Declaration:
br_pixelmap* BrPixelmapMatch(const br_pixelmap* src, int match_type)

Arguments:
const br_pixelmap * src

A pointer to the source pixel map.

int match_type

The type of matching pixel map required.

Result:
br_pixelmap *

Returns a pointer to the matching pixel map.


BrPixelmapClone()

Description:
Create a pixel map of the same type and dimensions and copy the pixel data.

Declaration:
br_pixelmap* BrPixelmapClone(const br_pixelmap* src)

Arguments:
const br_pixelmap * src

A pointer to the source pixel map.

Result:
br_pixelmap *

Returns a pointer to the new pixel map.

Example:
br_pixelmap *image, *working_copy;
...
image = BrPixelmapLoad("backdrop.pix");
working_copy = BrPixelmapClone(image);


BrPixelmapFree()

Description:
Deallocate a pixel map and any associated memory.

Declaration:
void BrPixelmapFree(br_pixelmap* pmap)

Arguments:
br_pixelmap * pmap

A pointer to a pixel map.


Supplementary


BrPixelmapPixelSize()

Description:
Find the pixel size for a given pixel map.

Declaration:
br_uint_16 BrPixelmapPixelSize(const br_pixelmap* pm)

Arguments:
const br_pixelmap * pm

A pointer to a pixel map.

Result:
br_uint_16

Returns the size of each pixel, in bits.


BrPixelmapChannels()

Description:
Find the channels available for a given pixel map.

Declaration:
br_uint_16 BrPixelmapChannels(const br_pixelmap* pm)

Arguments:
const br_pixelmap * pm

A pointer to a pixel map.

Result:
br_uint_16

Returns a mask giving the available channels, being a combination of the following bit value symbols:

BR_PMCHAN_INDEX

BR_PMCHAN_RGB

BR_PMCHAN_DEPTH

BR_PMCHAN_ALPHA

BR_PMCHAN_YUV


BrMapCount()

Description:
Count the number of registered texture maps whose names match a given search pattern. The search pattern can include the standard wild cards `*' and `?'.

Declaration:
br_uint_32 BrMapCount(const char* pattern)

Arguments:
const char * pattern

Search pattern.

Result:
br_uint_32

Returns the number of texture maps matching the search pattern.

See Also:
BrMapEnum()
289, BrMapFind()289


BrMapEnum()

Description:
Calls a call-back function for every texture map matching a given search pattern. The call-back is passed a pointer to each matching item, and its second argument is an optional pointer supplied by the user. The search pattern can include the standard wild cards `*' and `?'. The call-back itself returns a br_uint_32
348 value. The enumeration will halt at any stage if the return value is non-zero.

Declaration:
br_uint_32 BrMapEnum(const char* pattern, br_map_enum_cbfn* callback, void* arg)

Arguments:
const char * pattern

Search pattern.

br_map_enum_cbfn * callback

A pointer to a call-back function.

void * arg

An optional argument to pass to the call-back function.

Result:
br_uint_32

Returns the first non-zero call-back return value, or zero if all matching texture maps are enumerated.

Example:
br_uint_32 BR_CALLBACK test_callback(br_pixelmap* map, void* arg)
{	br_uint_32 count;
...
	return(count);
}
...
{	br_uint_32 enum;
...
	enum = BrMapEnum("map",&test_callback,NULL);
}

BrMapFind()

Description:
Find a texture map in the registry by name. A call-back function can be setup to be called if the search is unsuccessful. The search pattern can include the standard wild cards `*' and `?'.

Declaration:
br_pixelmap* BrMapFind(const char* pattern)

Arguments:
const char * pattern

Search pattern.

Result:
br_pixelmap *

Returns a pointer to the texture map if found, otherwise Null. If a call-back exists and is called, the call-back's return value is returned.

See Also:
BrMapFindHook()
290, BrMapFindMany()290


BrMapFindMany()

Description:
Find a number of texture maps in the registry by name. The search pattern can include the standard wild cards `*' and `?'.

Declaration:
br_uint_32 BrMapFindMany(const char* pattern, br_pixelmap** pixelmaps, int max)

Arguments:
const char * pattern

Search pattern.

br_pixelmap ** pixelmaps

A pointer to an array of pointers to texture maps.

int max

Maximum number of texture maps to find.

Result:
br_uint_32

Returns the number of texture maps found. The pointer array is filled with pointers to the found texture maps.

See Also:
BrMapFind()
289, BrMapFindHook()290


BrMapFindHook()

Description:
Functions to set up a call-back.

Declaration:
br_map_find_cbfn* BrMapFindHook(br_map_find_cbfn* hook)

Arguments:
br_map_find_cbfn * hook

A pointer to a call-back function.

Effects:
If BrMapFind()
289 is unsuccessful and a call-back has been set up, the call-back is passed the search pattern as its only argument. The call-back should then return a pointer to a substitute or default texture map.

For example, a call-back could be set up to return a default texture map if the desired texture map cannot be found in the registry.

The function BrMapFindFailedLoad()291 is provided and will probably be sufficient in many cases.

Result:
br_map_find_cbfn *

Returns a pointer to the old call-back function.

Example:
br_map BR_CALLBACK * test_callback(char* pattern)
{	br_map* default_map;
...
	return(default_map);
}
...
{	br_map* map;
...
	BrMapFindHook(&test_callback);
	map = BrMapFind("non_existent_map");
}

See Also:
BrMapFindFailedLoad()291


BrMapFindFailedLoad()

Description:
This function is provided as a suitable function to supply to BrMapFindHook()
290.

Declaration:
br_pixelmap* BrMapFindFailedLoad(const char* name)

Arguments:
const char * name

The name supplied to BrMapFind()289.

Effects:
Attempts to load the texture map from the filing system using name as the filename. Searches in current directory, if not found tries, in order, the directories listed in BRENDER_PATH (if defined). If successful, sets this name as the identifier of the loaded texture map and adds the texture map to the registry.

Result:
br_pixelmap *

Returns a pointer to the texture map, if found, else Null.

Example:
BrMapFindHook(BrMapFindFailedLoad);

BrTableCount()

Description:
Count the number of registered shade tables whose names match a given search pattern. The search pattern can include the standard wild cards `*' and `?'.

Declaration:
br_uint_32 BrTableCount(const char* pattern)

Arguments:
const char * pattern

Search pattern.

Result:
br_uint_32

Returns the number of shade tables matching the search pattern.

See Also:
BrTableEnum()
292, BrTableFind()292


BrTableEnum()

Description:
Calls a call-back function for every shade table matching a given search pattern. The call-back is passed a pointer to each matching shade table, and its second argument is an optional pointer supplied by the user. The search pattern can include the standard wild cards `*' and `?'. The call-back itself returns a br_uint_32
348 value. The enumeration will halt at any stage if the return value is non-zero.

Declaration:
br_uint_32 BrTableEnum(const char* pattern, br_table_enum_cbfn* callback, void* arg)

Arguments:
const char * pattern

Search pattern.

br_table_enum_cbfn * callback

A pointer to a call-back function.

void * arg

An optional argument to pass to the call-back function.

Result:
br_uint_32

Returns the first non-zero call-back return value, or zero if all matching shade tables are enumerated.

Example:
br_uint_32 BR_CALLBACK test_callback(br_pixelmap* table, void* arg)
{	br_uint_32 count;
...
	return(count);
}
...
{	br_uint_32 enum;
...
	enum = BrTableEnum("Table",&test_callback,NULL);
}

BrTableFind()

Description:
Find a shade table in the registry by name. A call-back function can be setup to be called if the search is unsuccessful. The search pattern can include the standard wild cards `*' and `?'.

Declaration:
br_pixelmap* BrTableFind(const char* pattern)

Arguments:
const char * pattern

Search pattern.

Result:
br_pixelmap *

Returns a pointer to the shade table if found, otherwise Null. If a call-back exists and is called, the call-back's return value is returned.

See Also:
BrTableFindHook()
293, BrTableFindMany()293


BrTableFindMany()

Description:
Find a number of shade tables in the registry by name. The search pattern can include the standard wild cards `*' and `?'.

Declaration:
br_uint_32 BrTableFindMany(const char* pattern, br_pixelmap** pixelmaps, int max)

Arguments:
const char * pattern

Search pattern.

br_pixelmap ** pixelmaps

A pointer to an array of pointers to shade tables.

int max

Maximum number of shade tables to find.

Result:
br_uint_32

Returns the number of shade tables found. The pointer array is filled with pointers to the found shade tables.

See Also:
BrTableFind()
292, BrTableFindHook()293


BrTableFindHook()

Description:
Functions to set up a call-back. If BrTableFind()
292 is unsuccessful and a call-back has been set up, the call-back it is passed the search pattern as its only argument. The call-back should then return a pointer to a substitute or default shade table.

For example, a call-back could be set up to return a default shade table if the desired shade table cannot be found in the registry.

The function BrTableFindFailedLoad()294 is provided and will probably be sufficient in many cases.

Declaration:
br_table_find_cbfn* BrTableFindHook(br_table_find_cbfn* hook)

Arguments:
br_table_find_cbfn * hook

A pointer to a call-back function.

Result:
br_table_find_cbfn *

Returns a pointer to the old call-back function.

Example:
br_table BR_CALLBACK * test_callback(char* pattern)
{	br_table* default_table;
...
	return(default_table);
}
...
{	br_table* table;
...
	BrTableFindHook(&test_callback);
	table = BrTableFind("non_existent_table");
}
See Also:
BrTableFindFailedLoad()294


BrTableFindFailedLoad()

Description:
This function is provided as a suitable function to supply to BrTableFindHook()
293.

Declaration:
br_pixelmap* BrTableFindFailedLoad(const char* name)

Arguments:
const char * name

The name supplied to BrTableFind()292.

Effects:
Attempts to load the shade table from the filing system using name as the filename. Searches in current directory, if not found tries, in order, the directories listed in BRENDER_PATH (if defined). If successful, sets this name as the identifier of the loaded shade table and adds the shade table to the registry.

Result:
br_pixelmap *

Returns a pointer to the shade table, if found, else Null.

Example:
BrTableFindHook(BrTableFindFailedLoad);


Import & Export


BrPixelmapFileCount()

Description:
Locate a given file and count the number of pixel maps in it.

Declaration:
br_uint_32 BrPixelmapFileCount(const char* filename, br_uint_16* num)

Arguments:
const char * filename

Name of the file containing the pixel maps to count.

br_uint_16 * num

Pointer to the variable in which to store the number of pixel maps counted in the file. If Null, the file will still be located and appropriate success returned, but no count will be made.

Effects:
Searches for filename, if no path specified with file looks in current directory, if not found tries, in order, the directories listed in BRENDER_PATH (if defined). If a file is found, will count the number of pixel maps stored in it.

Result:
br_uint_32

Returns zero if the file was found (even if it is not a pixel map file), non-zero otherwise.


BrPixelmapLoad()

Description:
Load a pixel map. Note that they are not added to the registry.

Declaration:
br_pixelmap* BrPixelmapLoad(const char* filename)

Arguments:
const char * filename

Name of the file containing the pixel map to load.

Effects:
Searches for filename, if no path specified with file looks in current directory, if not found tries, in order, the directories listed in BRENDER_PATH (if defined).

Result:
br_pixelmap *

Returns a pointer to the loaded pixel map, or Null if unsuccessful.

See Also:
BrPixelmapLoadMany()
295, BrPixelmapSave()297, BrMapAdd()281, BrTableAdd()283.


BrPixelmapLoadMany()

Description:
Load a number of pixel maps. Note that they are not added to the registry.

Declaration:
br_uint_32 BrPixelmapLoadMany(const char* filename, br_pixelmap** pixelmaps, br_uint_16 num)

Arguments:
const char * filename

Name of the file containing the pixel maps to load.

br_pixelmap ** pixelmaps

A non-Null pointer to an array of pointers to pixel maps.

br_uint_16 num

Maximum number of pixel maps to load.

Effects:
Searches for filename, if no path specified with file looks in current directory, if not found tries, in order, the directories listed in BRENDER_PATH (if defined).

Result:
br_uint_32

Returns the number of pixel maps loaded successfully. The pointer array is filled with pointers to the loaded pixel maps.

See Also:
See BrPixelmapFileCount()
242 to determine the number of pixel maps in a file.


BrFmtBMPLoad()

Description:
Load a pixel map in the BMP format.

Declaration:
br_pixelmap* BrFmtBMPLoad(const char* name, br_uint_32 flags)

Arguments:
const char * name

Name of the file containing the pixel map.

br_uint_32 flags

Either BR_PMT_RGBX_888 or BR_PMT_RGBA_8888, when the source pixel map uses 32 bits per pixel. Zero otherwise.

Effects:
Searches for filename, if no path specified with file looks in current directory, if not found tries, in order, the directories listed in BRENDER_PATH (if defined).

Result:
br_pixelmap *

Returns a pointer to the loaded pixel map.


BrFmtGIFLoad()

Description:
Load a pixel map in the GIF format.

Declaration:
br_pixelmap* BrFmtGIFLoad(const char* name, br_uint_32 flags)

Arguments:
const char * name

Name of the file containing the pixel map.

br_uint_32 flags

Either BR_PMT_RGBX_888 or BR_PMT_RGBA_8888, when the source pixel map uses 32 bits per pixel. Zero otherwise.

Effects:
Searches for filename, if no path specified with file looks in current directory, if not found tries, in order, the directories listed in BRENDER_PATH (if defined).

Result:
br_pixelmap *

Returns a pointer to the loaded pixel map.


BrFmtIFFLoad()

Description:
Load a pixel map in the IFF format.

Declaration:
br_pixelmap* BrFmtIFFLoad(const char* name, br_uint_32 flags)

Arguments:
const char * name

Name of the file containing the pixel map.

br_uint_32 flags

Either BR_PMT_RGBX_888 or BR_PMT_RGBA_8888, when the source pixel map uses 32 bits per pixel. Zero otherwise.

Effects:
Searches for filename, if no path specified with file looks in current directory, if not found tries, in order, the directories listed in BRENDER_PATH (if defined).

Result:
br_pixelmap *

Returns a pointer to the loaded pixel map.


BrFmtTGALoad()

Description:
Load a pixel map in the TGA format.

Declaration:
br_pixelmap* BrFmtTGALoad(const char* name, br_uint_32 flags)

Arguments:
const char * name

Name of the file containing the pixel map.

br_uint_32 flags

Either BR_PMT_RGBX_888 or BR_PMT_RGBA_8888, when the source pixel map uses 32 bits per pixel. Zero otherwise.

Effects:
Searches for filename, if no path specified with file looks in current directory, if not found tries, in order, the directories listed in BRENDER_PATH (if defined).

Result:
br_pixelmap *

Returns a pointer to the loaded pixel map.


BrPixelmapSave()

Description:
Save a pixel map to a file.

Declaration:
br_uint_32 BrPixelmapSave(const char* filename, const br_pixelmap* pixelmap)

Arguments:
const char * filename

Name of the file to save the pixel map to.

const br_pixelmap * pixelmap

A pointer to a pixel map.

Effects:
Writes the pixel map to a file
*1.

Result:
br_uint_32

Returns Null if the pixel map could not be saved.


BrPixelmapSaveMany()

Description:
Save a number of pixel maps to a file.

Declaration:
br_uint_32 BrPixelmapSaveMany(const char* filename, const br_pixelmap* const* pixelmaps, br_uint_16 num)

Arguments:
const char * filename

Name of the file to save the pixel maps to.

const br_pixelmap * const * pixelmaps

A pointer to an array of pointers to pixel maps. If Null, all registered texture maps and shade tables are saved (irrespective of num).

br_uint_16 num

Number of pixel maps to save.

Effects:
Writes the pixel maps to a file
*2.

Result:
br_uint_32

Returns the number of pixel maps saved successfully.



Generated with CERN WebMaker