#pragma once
#include "Device.h"
#include "Gui/3D/Surface.h"

#ifdef GUI_GTK

namespace gui {

	/**
	 * OpenGL surface.
	 */
	class GLSurface : public Surface3D {
		friend class GLDevice;
		friend class GLGraphics;
	public:
		// Create.
		GLSurface(Size size, Float scale, GLDevice::Context *context);

		// Destroy.
		~GLSurface();

		// Resize.
		virtual void resize(Size size, Float scale);

		// Present.
		virtual PresentStatus present(bool waitForVSync);

		// Paint.
		virtual void repaint(RepaintParams *params);

		// Create a graphics object.
		virtual Graphics3D *createGraphics(Engine &e);

		// Grab the surface as an image.
		virtual Image *grabImage(Engine &e);

		// Make the GL context here current.
		void makeCurrent();
		void forceMakeCurrent();

	private:
		// Context.
		GLDevice::Context *context;

		// The framebuffer.
		GLuint framebuffer;

		// Color buffer we are rendering to.
		GLuint colorbuffer;

		// Depth buffer.
		GLuint depthbuffer;
	};

}

#endif
