Basic rendering

The most simple way to render inside the menus is to draw straight by calling drawBox or drawString. Inside the onRender function you can render text and boxes after you have created your instance like this:

return function()
	local instance = MenuClass ("Paint Menu")

	local properties =
	{
		paint = nil,
	}

	Mixin.CopyTo (instance, properties)
	Mixin.CopyToAndBackupParents (instance, c)

	return instance
end

After that you can use the rendering functions inside onRender like this:

function c:onRender ()
	dio.drawing.font.drawString (x, y, text, color) 
	dio.drawing.font.drawBox (x, y, size_x, size_y, color)
end

Keep in mind that the color must contain the alpha component.

Render to texture in game

As far as I know, it is not possible to use direct rendering outside menus. You'll have to use render to texture method. You'll have to create one with

local renderToTexture = dio.drawing.createRenderToTexture (size_w, size_h)

Keep the renderToTexture safe somewhere because we're going to need it later on.

You'll also have to bind your earlyRender and lateRender methods with

dio.drawing.addRenderPassBefore (priority, function () onEarlyRender () end)
dio.drawing.addRenderPassAfter (priority, function () onLateRender () end)

Now we can start rendering! On early render you can call drawString and drawBox just like in direct rendering. However, you'll have to place these calls between

dio.drawing.setRenderToTexture (renderToTexture) -- that's the one we initialized before

and

dio.drawing.setRenderToTexture (nil)

We set the render to texture to nil so we won't render to it accidentally.

On late render, you render the texture to the screen with

dio.drawing.drawTexture (renderToTexture, x, y, size_w, size_h, color)

Twitch | Twitter