BRender Tutorial Guide:5 Adding Colour:The Program

The Program

Compile and run BRTUTOR5.C to display a revolving blue cube. Note the selected true colour mode. If you are running BRender under DOS, the following line in the hardware initialisation code selects 320 200, 15-bit true colour:

	screen_buffer = DOSGfxBegin("VESA,W:320,H:200,B:15");
The following three lines of code are used to apply the material described in cube.mat to our revolving cube:

	cube_material = BrFmtScriptMaterialLoad("cube.mat");
	cube->material = BrMaterialFind("BLUE MATERIAL");
BrFmtScriptMaterialLoad loads a material from a material script and returns a pointer to an initialised br_material structure. BrMaterialAdd adds the new material to the registry. All materials must be added to the registry before they can be used in rendering.

BrMaterialFind searches for a material by name in the registry. You will recall that BLUE MATERIAL was the name entered in the identifier field in the material script file cube.mat. BrMaterialFind returns a pointer to a br_material (or NULL if the search was unsuccessful).

Use your text editor to experiment with the properties of BLUE MATERIAL, or to create your own material script files.

Generated with CERN WebMaker