summaryrefslogtreecommitdiff
path: root/common/glwindow.h
blob: 6fc3432e3f008a84d4e881d072f468270c3ca381 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#ifndef _GLWINDOW_H_
#define _GLWINDOW_H_

class GLWindow
{
public:
	GLWindow(GLWindow *share);
	virtual ~GLWindow();

	void IncRef()
	{ m_nRef++; }
	void DecRef()
	{ m_nRef--; if (m_nRef == 0) delete this; }

	bool Create(void* data);
	void DestroyContext();

	bool MakeCurrent();
	void SwapBuffers();
	void Redraw();
	void CaptureMouse();
	void ReleaseMouse();

	int GetWidth() const
	{ return m_nWidth; }
	int GetHeight() const
	{ return m_nHeight; }
	void* GetData() const
	{ return m_pData; }

	virtual void OnDraw() { };
	virtual void OnSize(int cx, int cy)
	{ m_nWidth = cx; m_nHeight = cy; };
	virtual void OnInitialUpdate();
	virtual void OnLeftButtonDown(int x, int y, bool bControl, bool bShift) { };
	virtual void OnLeftButtonUp(int x, int y, bool bControl, bool bShift) { };
	virtual void OnLeftButtonDoubleClick(int x, int y, bool bControl, bool bShift) { };
	virtual void OnRightButtonDown(int x, int y, bool bControl, bool bShift) { };
	virtual void OnRightButtonUp(int x, int y, bool bControl, bool bShift) { };
	virtual void OnMouseMove(int x, int y, bool bControl, bool bShift) { };

protected:
	int m_nWidth;
	int m_nHeight;

private:
	void *m_pData;
	GLWindow *m_pShare;
	int m_nRef;
};

#endif // _GLWINDOW_H_