#pragma once
#ifdef BKSCRDLL_EXPORTS
#define BKSCRDLL_API __declspec(dllexport)
#else
#define BKSCRDLL_API __declspec(dllimport)
#endif

// Этот класс экспортирован из BKScreenOGL.dll
#include "Screen_Shared.h"

#include "gl/gl.h"
#include "gl/glu.h"


typedef struct
{
	GLdouble r;
	GLdouble g;
	GLdouble b;
} RGBCols;

BKEXTERN_C class BKSCRDLL_API CScreenOGL : public CBKScreen_Shared
{
		static const GLdouble m_cpTexcoords2[];
		static const GLdouble m_cpVertices2[];
		static const GLint    m_cpIndices1[];

	protected:
		bool                m_bScrParamChanged;
		bool                m_bScrSizeChanged;

		CPalette           *m_pPalette;
		CPalette           *m_pOldPalette;
		CClientDC          *m_pDC;
		CClientDC          *m_pDC_FullScreen;
		HDC                 m_HDC;
		HDC                 m_HDC_FullScreen;
		HDC                 m_HDC_Current;

		HGLRC               hGLRC;
		RECT                m_rectWndWnd;   //размеры viewporta в оконном режиме
		RECT                m_rectViewPort; //текущие размеры viewporta
		//left, top - координаты экрана, right, bottom - размеры, а не координаты!!!

		PIXELFORMATDESCRIPTOR m_pfd;

	public:
		CScreenOGL();
		virtual ~CScreenOGL() override;

		virtual HRESULT     BKSS_ScreenView_Init(ScrsParams &sspar, CWnd *pwndScr, CWnd *pwndFullScr) override;
		virtual void        BKSS_ScreenView_Done() override;
		virtual void        BKSS_DrawScreen() override;
		virtual bool        BKSS_SetFullScreenMode() override;
		virtual bool        BKSS_SetWindowMode() override;

		virtual void        BKSS_SetColorMode() override;
		virtual void        BKSS_OnSize(int cx, int cy) override;

	protected:
		void                CreateContext();
		void                CreateRGBPalette();
		bool                SetWindowPixelFormat();
		unsigned char       ComponentFromIndex(int i, UINT nbits, UINT shift);
		void                set_screen_param();
		void                clear();
};


