summaryrefslogtreecommitdiff
path: root/src/wgl/rtotex/window.h
blob: ce30d439c40e3e8e94d4d67c4c94285b65b9a67b (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
//////////////////////////////////////////////////////////////////////////////////////////
//	window.h
//	class to setup opengl capable window
//	Downloaded from: www.paulsprojects.net
//	Created:	21st June 2002
//
//	Copyright (c) 2006, Paul Baker
//	Distributed under the New BSD Licence. (See accompanying file License.txt or copy at
//	http://www.paulsprojects.net/NewBSDLicense.txt)
//////////////////////////////////////////////////////////////////////////////////////////	

#ifndef WINDOW_H
#define WINDOW_H

class WINDOW
{
public:
	HGLRC hRC;													//Permanent rendering context
	HDC hDC;													//Private GDI device context
	HWND hWnd;													//Holds window handle
	HINSTANCE hInstance;										//Holds application instance
	MSG msg;								//message structure, to see if any pending messages
	const char * title;												//Window Title
	int width, height;											//window size
	int colorBits, depthBits, stencilBits;						//window bpp
	bool fullscreen;											//fullscreen?
	
	bool Init(const char * windowTitle,
				int newWidth, int newHeight,
				int newColorBits, int newDepthBits, int newStencilBits,
				int fullscreenflag);
																//Create Window
	void Shutdown(void);										//Properly kill window

	bool MakeCurrent(void);

	bool HandleMessages(void);
	static LRESULT CALLBACK WndProc(	HWND	hWnd,
										UINT	uMsg,
										WPARAM	wParam,
										LPARAM	lParam);		//DEAL WITH ALL WINDOW MESSAGES
																//static needed for CALLBACK
	void SwapBuffers();
	void CheckGLError(void);									//check for an OpenGL error

	void SaveScreenshot(void);


	//Text writing functions
	void StartTextMode(void);
	void Print(int x, int y, const char * string, ...);
	void EndTextMode(void);

	protected:
	GLuint base;					//display list base for font
	GLuint startTextModeList;



	//INPUT FUNCTIONS
	public:
	void Update();

	//KEYBOARD
	void SetKeyPressed(int keyNumber)
	{	keyPressed[keyNumber]=true;		}
	
	void SetKeyReleased(int keyNumber)
	{	keyPressed[keyNumber]=false;	}

	bool isKeyPressed(int keyNumber)
	{	return keyPressed[keyNumber];	}

	protected:
	bool keyPressed[256];
	
	//MOUSE
	public:
	void SetLeftButtonPressed()
	{	mouseLDown=true;	}
	
	void SetRightButtonPressed()
	{	mouseRDown=true;	}
	
	bool isLeftButtonPressed()
	{	return mouseLDown;	}

	bool isRightButtonPressed()
	{	return mouseRDown;	}

	int GetMouseX()
	{	return mouseX;		}

	int GetMouseY()
	{	return mouseY;		}

	int GetMouseXMovement()
	{	return mouseX-oldMouseX;	}

	int GetMouseYMovement()
	{	return mouseY-oldMouseY;	}

	protected:
	int oldMouseX, oldMouseY;
	int mouseX, mouseY;
	bool mouseLDown, mouseRDown;




	public:
	WINDOW() : title("Paul's Projects"), fullscreen(TRUE)
	{}
	~WINDOW()	{}
};

//#defines for window or fullscreen
#define WINDOWED_SCREEN		0
#define FULL_SCREEN			1
#define CHOOSE_SCREEN		2

#endif	//WINDOW_H