This one is pretty trivial when using the default OpenGL rendering backend. Just create a GLViewport widget and set its renderingHandler to your custom rendering delegate.
Example:
GLViewport(`myGLViewport`).renderingHandler = (vec2i size, GL gl) {
gl.MatrixMode(GL_PROJECTION);
gl.LoadIdentity();
gl.gluPerspective(60.f, cast(float)size.x / size.y, 0.1f, 100.f);
gl.MatrixMode(GL_MODELVIEW);
gl.LoadIdentity();
// Rendering code
};
The default backend does not create a new OpenGL rendering context for GLViewports, but sets up a viewport, enables scissor testing and saves GL_ALL_ATTRIB_BITS (for its own state) between calling the custom rendering functions. The implication of this design choice is that GLViewport state such as projection matrices won't be retained between the custom rendering handler calls. Thus, the user has to call basic setup in run of the custom rendering handler, like in the example above.
If a custom rendering context is desired, it will have to be created using FBO or pbuffers.