45LRESULT CALLBACK
WndProc(HWND, UINT, WPARAM, LPARAM);
78 ChangeDisplaySettings(NULL,0);
85 MessageBox(NULL,
"Release Device Context Failed.",
"SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
91 MessageBox(NULL,
"Could Not Release hWnd.",
"SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
97 MessageBox(NULL,
"Could Not Unregister Class.",
"SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
109BOOL
CreateGLWindow(
char* title,
int width,
int height,
int bits, BOOL fullscreenflag)
117 WindowRect.left=(long)0;
118 WindowRect.right=(long)width;
119 WindowRect.top=(long)0;
120 WindowRect.bottom=(long)height;
125 wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
126 wc.lpfnWndProc = (WNDPROC)
WndProc;
130 wc.hIcon = LoadIcon(NULL, IDI_WINLOGO);
131 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
132 wc.hbrBackground = NULL;
133 wc.lpszMenuName = NULL;
134 wc.lpszClassName =
"OpenGL";
136 if (!RegisterClass(&wc))
138 MessageBox(NULL,
"Failed To Register The Window Class.",
"ERROR",MB_OK|MB_ICONEXCLAMATION);
144 DEVMODE dmScreenSettings;
145 memset(&dmScreenSettings,0,
sizeof(dmScreenSettings));
146 dmScreenSettings.dmSize=
sizeof(dmScreenSettings);
147 dmScreenSettings.dmPelsWidth = width;
148 dmScreenSettings.dmPelsHeight = height;
149 dmScreenSettings.dmBitsPerPel = bits;
150 dmScreenSettings.dmFields=DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT;
153 if (ChangeDisplaySettings(&dmScreenSettings,CDS_FULLSCREEN)!=DISP_CHANGE_SUCCESSFUL)
156 if (MessageBox(NULL,
"The Requested Fullscreen Mode Is Not Supported By\nYour Video Card. Use Windowed Mode Instead?",
"NeHe GL",MB_YESNO|MB_ICONEXCLAMATION)==IDYES)
163 MessageBox(NULL,
"Program Will Now Close.",
"ERROR",MB_OK|MB_ICONSTOP);
171 dwExStyle=WS_EX_APPWINDOW;
177 dwExStyle=WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;
178 dwStyle=WS_OVERLAPPEDWINDOW;
181 AdjustWindowRectEx(&WindowRect, dwStyle, FALSE, dwExStyle);
184 if (!(
hWnd=CreateWindowEx( dwExStyle,
191 WindowRect.right-WindowRect.left,
192 WindowRect.bottom-WindowRect.top,
199 MessageBox(NULL,
"Window Creation Error.",
"ERROR",MB_OK|MB_ICONEXCLAMATION);
207 MessageBox(NULL,
"Can't Create A GL Device Context.",
"ERROR",MB_OK|MB_ICONEXCLAMATION);
214 MessageBox(NULL,
"Can't Create A GL Rendering Context.",
"ERROR",MB_OK|MB_ICONEXCLAMATION);
221 MessageBox(NULL,
"Can't Activate The GL Rendering Context.",
"ERROR",MB_OK|MB_ICONEXCLAMATION);
225 ShowWindow(
hWnd,SW_SHOW);
226 SetForegroundWindow(
hWnd);
233 MessageBox(NULL,
"Initialization Failed.",
"ERROR",MB_OK|MB_ICONEXCLAMATION);
268 case SC_MONITORPOWER:
289 keys[wParam] = FALSE;
301 return DefWindowProc(
hWnd,uMsg,wParam,lParam);
310int ui_loop(
int argc,
char **argv,
const char *name)
315 int width, height, k;
321 if (MessageBox(NULL,
"Would You Like To Run In Fullscreen Mode?",
"Start FullScreen?",MB_YESNO|MB_ICONQUESTION)==IDNO)
335 if (PeekMessage(&msg,NULL,0,0,PM_REMOVE))
337 if (msg.message==WM_QUIT)
343 TranslateMessage(&msg);
344 DispatchMessage(&msg);
void gdiDestroyContext(GDIContext ctx)
GDIContext gdiCreateContext(GDIContext shareList, int flags)
void gdiSwapBuffers(HWND drawable)
int gdiMakeCurrent(HWND drawable, GDIContext ctx, int width, int height)
void reshape(int width, int height)
int ui_loop(int argc, char **argv, const char *name)
GLvoid ReSizeGLScene(GLsizei width, GLsizei height)
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM)
BOOL CreateGLWindow(char *title, int width, int height, int bits, BOOL fullscreenflag)
GLvoid KillGLWindow(GLvoid)