C4 Engine
C4 Engine API Documentation


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

void SetTextureRenderCallback(TextureRenderCallback *callback, void *cookie = nullptr);

callback A pointer to the texture rendering callback function.
cookie A user-defined pointer that is passed to the texture rendering callback function.
The SetTextureRenderCallback function installs a rendering callback function that is called to draw the contents of a viewport widget's texture map. This callback function is called only after a viewport's texture map has been established with a call to the ViewportWidget::EnableViewportTexture function, and it is called once per frame unless the viewport can cache a static texture (as indicated by the staticFlag parameter of the ViewportWidget::EnableViewportTexture function) and the texture map has not been invalidated with the ViewportWidget::InvalidateViewportTexture function.

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

typedef void TextureRenderCallback(ViewportWidget *, void *);

The first parameter passed to the rendering callback function is a pointer to the viewport that is being rendered. The last parameter receives the pointer specified by the cookie parameter.

Right before the rendering callback function is called, the viewport's camera is established as the current rendering camera, and the viewport's texture map is established as the current rendering target. The callback function may cause calls to the GraphicsMgr::ClearColorBuffer and GraphicsMgr::Draw functions to occur, and these affect only the viewport's texture map.

If the callback parameter is nullptr, then any currently installed texture rendering callback function is removed, but items can still be rendered in the viewport through the direct rendering callback function if one has been installed using the ViewportWidget::SetDirectRenderCallback function.
See Also