C4 Engine
C4 Engine API Documentation

ViewportWidget::SetDirectRenderCallback

Defined in:  C4Viewports.h
Sets the direct rendering callback function for a viewport widget.
Prototype

void SetDirectRenderCallback(DirectRenderCallback *callback, void *cookie = nullptr);

Parameters
callback A pointer to the direct rendering callback function.
cookie A user-defined pointer that is passed to the direct rendering callback function.
Description
The SetDirectRenderCallback function installs a rendering callback function that is called once per frame to draw the contents of a viewport widget that are rendered directly to the frame buffer. If a texture rendering callback function is also installed (with the ViewportWidget::SetTextureRenderCallback function), then the direct rendering callback function is called after the contents of the texture map have been rendered, if necessary, and drawn to the frame buffer. Thus, the contents drawn with the direct rendering callback function appear on top of the viewport's texture image.

The callback parameter should point to a function having the following prototype.

typedef void DirectRenderCallback(List<Renderable> *, ViewportWidget *, void *);

The first parameter passed to the direct rendering callback function is a pointer to a list to which renderable objects can be added, and the second parameter is a pointer to the viewport that is being rendered. The last parameter receives the pointer specified by the cookie parameter.

When the direct rendering callback function is called, the viewport's camera has already been established as the current rendering camera. The direct rendering callback function may cause calls to the GraphicsMgr::Draw function to occur, and it may add renderable objects to the render list passed to it. If the render list contains any objects upon return from the direct rendering callback function, then they are immediately rendered with the DrawRenderList function and removed from the list.

The direct rendering callback function would normally call the GraphicsMgr::ClearColorBuffer function first to clear the area covered by the viewport widget.

If the callback parameter is nullptr, then any currently installed direct rendering callback function is removed.
See Also

ViewportWidget::SetTextureRenderCallback

ViewportWidget::SetMouseEventCallback

ViewportWidget::SetTrackTaskCallback

Renderable