/**
** This file is owned by VisualGear Technology Co., Ltd.
** Unauthorized copying of this file, via any medium is strictly prohibited
** Otherwise VisualGear Technology Co., Ltd. will have the right to pursue
** maximum responsibilities within scope of legal.
**
** Copyright 2018-2020 VisualGear All rights reserved.
**/

#ifndef OPENGLWIDGET_H
#define OPENGLWIDGET_H 

#include "UIGearsQtLib.h"
#include "openglfunctions.h"
#include <QOpenGLWidget>

class OpenGLUpdateEvent;
class OpenGLError;
class OpenGLFrameResults;
class QEvent;
class QGestureEvent;
class QKeyEvent;
class QMouseEvent;
class QMoveEvent;
class QOpenGLDebugMessage;
class QTouchEvent;
class QWheelEvent;

class UIGQOpenGLWidgetPrivate;

namespace UIGQtLib {

	class UIGEARSQTLIB_EXPORT UIGQOpenGLWidget : public QOpenGLWidget, public OpenGLFunctions
	{
		Q_OBJECT

	public:
		// Constructors / Destructors
		UIGQOpenGLWidget(QWidget *parent = 0);
		~UIGQOpenGLWidget();

		// Public Methods
		void printVersionInformation();
		void setProfilerVisible(bool visible);
		bool profilerVisible() const;

		// Static Widget functions
		static void sMakeCurrent();
		static QString openFileName(char const *title, char const *dir, char const *fileTypes);

	protected:

		// OpenGL Protected Methods
		virtual void initializeGL();
		virtual void resizeGL(int width, int height);
		virtual void paintGL();
		virtual void teardownGL();

		// Event Methods
		virtual bool event(QEvent *event);
		virtual void errorEventGL(OpenGLError *event);
		virtual void keyPressEvent(QKeyEvent *event);
		virtual void keyReleaseEvent(QKeyEvent *event);
		virtual void mousePressEvent(QMouseEvent *event);
		virtual void mouseReleaseEvent(QMouseEvent *event);
		virtual void mouseMoveEvent(QMouseEvent *event);
		virtual void moveEvent(QMoveEvent *event);
		virtual void touchEvent(QTouchEvent *event);
		virtual void gestureEvent(QGestureEvent *event);
		virtual void updateEvent(OpenGLUpdateEvent *event);

		public slots:
		void update();
		void frameTimeout(float fps);
		void messageLogged(const QOpenGLDebugMessage &msg);
		void frameResultAvailable(const OpenGLFrameResults &result);

	private:
		UIGQOpenGLWidgetPrivate *m_private;
	};


}


#endif // OPENGLWIDGET_H
