bmap_rendertarget(BMAP*,var num,var
mode)
Specifies a bitmap as a render target for all subsequent objects and views. This way multiple render targets can be set and simultaneously rendered into through the COLOR1...COLORn pixel shader output semantics.
Parameters:
BMAP* - Bitmap pointer to be used as a render target, or NULL for disabling the render target. All render targets must have the same size.
num - Render target number,
1..3 for COLOR1..COLOR3.
For rendering into COLOR0, set the render target through view.bmap.
mode -
Face number for an environment map render target, 1=west, 2=north, 3=east, 4=south, 5=down, 6=up.
mode -
Mode for a normal render target bitmap, 1 = preserve previous content, 0 = clear previous content. A7.22
Returns:
0 if the given render target number is not supported by the hardware, otherwise nonzero.
Speed:
Medium
Edition:
A7.10 C
P
Remarks:
- The function can be called in a material event for switching render targets depending on a certain view.
- Render target 0 can only be set when the view has no own render target (view.bmap), and can be switched off through bmap_rendertarget(NULL,0,0) for resuming normal screen rendering.
-
All render targets active at the same time must have the same size and format. When you use render targets of different sizes in different views, make sure to enable and disable them by calling bmap_rendertarget in an ENABLE_VIEW event, so that only render targets of the same size are active at the same time. Globally enabled render targets that stay active all the time must have the same size as the screen.
-
The sky_color affects all render targets. Set it to (0,0,0) if you want to prevent that the render targets are cleared at the begin of every view rendering. Alternatively, disable the render targets trough an an ENABLE_VIEW event when a particular view must not write into them.
- Not all 3D cards support multiple render targets.
If they do, then normally four targets are supported.
Example (lite-C):
// example for switching view dependent render targets ///////////////////////////////
VIEW* viewTarget = { ... }
PANEL* panTarget1 = { pos_x = 0; bmap = "#200x200x24"; flags = SHOW; } // COLOR1 rendertarget
PANEL* panTarget2 = { pos_x = 200; bmap = "#200x200x24"; flags = SHOW; } // COLOR2 rendertarget
function eventTarget()
{
if (render_view == viewTarget) { // activate COLOR1 and COLOR2 rendertargets for this view only
bmap_rendertarget(panTarget1.bmap,1,0);
bmap_rendertarget(panTarget2.bmap,2,0);
} else {
bmap_rendertarget(NULL,1,0);
bmap_rendertarget(NULL,2,0);
}
}
MATERIAL* mtl_viewevent = {
event = eventTarget;
flags = ENABLE_VIEW;
}
See also:
view.bmap, bmap_zbuffer, material events,
render_view
► latest
version online