-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathApplication.h
More file actions
169 lines (145 loc) · 6.03 KB
/
Application.h
File metadata and controls
169 lines (145 loc) · 6.03 KB
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/*
==========================================================================
contains win32 application class
class Application
==========================================================================
*/
#ifndef APPLICATION_WIN32_H
#define APPLICATION_WIN32_H
#pragma comment(lib, "opengl32.lib")
#pragma comment(lib, "glu32.lib")
#include <Windows.h>
#include <gl/gl.h>
#include <gl/glu.h>
#include "Client.h"
#include "Mouse.h"
#include "Console.h"
#include "KeyDefines.h"
namespace DifferentialArts
{
#define WIN32_LEAN_AND_MEAN // Trims down libraries.
#define VC_LEANMEAN // Trims even more libraries.
#ifndef WM_MOUSEWHEEL
#define WM_MOUSEWHEEL 522
#endif
#define CLASSNAME "SOMECLASSNAME_FOR_THIS_PRGRM"
/*
============================================================
Application class for win32
============================================================
*/
/*! \class Application
\brief Application layer class
\author Rajesh Peter Douglas D'Monte
This class is for maintaining most communication with the
operating system.
*/
class RX_API Application
{
public:
HWND createWindow(void); //!< Creates a window and returns a handle
void MsgBox(LPCTSTR text, LPCTSTR title); //!< Displays a message box
void MsgBoxAndQuit(LPCTSTR text, LPCTSTR title); //!< Displays a message box and quits
void init_app(Console* pLog); //!< Initialize the application with a pointer to a log object
void ChangeToFullScreen(); //!< Change to fullscreen \bug May not work if you started windowed
void end(void); //!< Ends the application
bool isRunning(); //!< Returns true if the application is running
int GetFrameRate(void); //!< Returns the frame rate
RECT getRect(void); //!< Returns the main rect
RECT getWindowRect(void);//!< Returns the window rect
bool isFullScreen(void); //!< Returns true if fullscreen
unsigned int getRefreshRate(void); //!< Returns the refresh rate
unsigned int getColorDepth(void); //!< Returns the color depth
unsigned int getDepthBits(void); //!< Returns the depth bits
unsigned int getStencilBits(void); //!< Returns the stencil bits
unsigned int getAlphaBits(void); //!< Returns the alpha bits
DIM getDimensions(); //!< Returns the dimensions of the application
DIM getSystemResolution(void); //!< Returns the system resolution
//Key Event handlers
bool keyPressed(unsigned int key); //!< Check if key is pressed
bool keyReleased_wParam(unsigned int key, WPARAM wParam); //!< \deprecated @see keyPressed
bool keyReleased(unsigned int key); //!< Check if key is released
unsigned int getLastKeyReleased(void); //!< Returns the last key released
void UpdateKeyReleased(void); //Not for the end user
void SetMouseSensitivity(float m); //!< Sets mouse sensitivity
void WindowRefresh(void); //!< Calls ShowWindow UpdateWindow and SetFocus
void CenterMouse(void); //!< Centers the mouse position
void ResetMouseRelease(void); //Not for the end user
DIM getCenter(void); //!< Returns the center
DIM getLastCenter(void); //!< Returns the last value calculated by getCenter()
float GetMouseSensitivity(void); //!< Returns the mouse sensitivity
bool useMouse; //!< For mouse status
void setHINSTANCE(HINSTANCE hInstance);
HDC getDC(void); //!< Returns the device context
HWND getHandle(void); //!< Returns the window handle
HINSTANCE getHInstance(void); //!< Returns the hInstance object
void ToggleFullScreen(void); //!< \bug Not yet functional
PIXELFORMATDESCRIPTOR getPixelFormatDescriptor(void); //! Returns the pixel format descriptor used by the engine
LPCTSTR getWindowName(void); //!< Returns the window name
HGLRC getGLRenderContext(void); //!< Returns the GL render context the engine is using
bool UpdateGameWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, float fov,
double zNear, double zFar); //Not for the end user
bool isActivated(void); //!< Returns true if application is activated
/*
Multisample Functions
*/
//WARNING: ONLY FOR SPECIAL EXTENSIONS ON WIGGLE
bool WGLisExtensionSupported(const char *extension); //!< Check to see if WGL extension is supported
void InitializeFromPixelFormatForMultiSample(const int pf); //Not for the end user
void DestroyWindowObject(void); //!< Destroys the window object
void OverrideDeviceSettings(int refreshRate = 60, unsigned char colorBits = 24,
unsigned char depthBits = 24, unsigned char stencilBits = 0,
unsigned char alphaBits = 0); //!< Overrides default device settings, call in your game object's constructor.
DWORD m_FrameInterval;
int m_FPS;
int tFPS;
float m_fFrameIntervalSeconds;
float m_ftRatio;
float m_fGameTime;
float m_fActualTime;
DWORD currentTick;
DWORD lastTick;
DWORD dwStyle;
float frLastTime;
//The log file Object
Mouse Mouse; //!< Mouse object. Access the mouse through this object.
MousePointInt windowPosition;
WPARAM mKeyWParam;
LPARAM mKeyLParam;
Console* mlog;
float volume; //!< \deprecated FMOD controls volume instead
bool mbCEGUIUpdateInputInjection;
private:
BOOL m_bFullScreen;
HWND m_hWnd; // This is the handle for the window
RECT m_rRect; // This holds the window dimensions
HDC m_hDC; // General HDC - (handle to device context)
HGLRC m_hRC; // General OpenGL_DC - Our Rendering Context for OpenGL
HINSTANCE m_hInstance; // This holds the global hInstance for UnregisterClass() in DeInit()
RECT m_rWindowRect;
unsigned int width;
unsigned int height;
//Bit plane values
unsigned int mColorBits;
unsigned int mStencilBits;
unsigned int mAlphaBits;
unsigned int mDepthBits;
unsigned int mRefreshRate;
float mouseSensitivity;
unsigned int characterReleased;
char getAlphaNumeric(void);
bool bSetupPixelFormat(HDC hdc);
void SizeOpenGLScreen(int w, int h, float fov, double zNear, double zFar);
DEVMODE m_dmOld;
bool winMessage;
DIM systemResolution;
DIM centerScreen;
LPCTSTR mWindowName;
PIXELFORMATDESCRIPTOR mPFD;
bool active;
bool pause;
//..Friends
friend class CoreEngine;
};
}
#endif