#pragma once
#include "Gui/BasicPainter.h"
#include "Graphics.h"

namespace gui {

	/**
	 * A painter capable of drawing 3D graphics.
	 */
	class Painter3D : public BasicPainter {
		STORM_CLASS;
	public:
		// Create.
		STORM_CTOR Painter3D();

		// Destroy.
		virtual ~Painter3D();

		// Called to render the contents of the window.
		// `size` is the drawing size in device independent units.
		// Return `true` to schedule a repaint for the next frame.
		virtual Bool STORM_FN render(Size size, Graphics3D *graphics);

		// Prepare the supplied resource for rendering on this painter. This is not necessary, but
		// can be done ahead of time to avoid stutter when rendering. This has to be done *after*
		// attaching the painter to a window. Returns 'true' if the resource was prepared.
		Bool STORM_FN prepare(Resource3D *resource);

	protected:
		// Surface type.
		virtual SurfaceType surfaceType() { return surface3D; }

		// Callback for rendering.
		virtual void render(Surface *surface, Bool &more, Bool &ok);

		// Attach, create WindowGraphics.
		virtual void onAttach(Surface *surface);

		// Destroy our WindowGraphics.
		virtual void onDestroy();

		// Called when the underlying surface was resized.
		virtual void onResize();

	private:
		// Graphics object.
		Graphics3D *graphics;
	};

}
