| Код | //=============================================================================
#include "../inc/aOpenGL.h" #include "../inc/aLog.h"
//=============================================================================
extern HWND h_Wnd; extern HGLRC hRC; extern HDC hDC; extern aOpenGL wogl; extern aLog logo;
//=============================================================================
LRESULT CALLBACK WndProc(HWND hWnd, unsigned int message, WPARAM wParam, LPARAM lParam) { unsigned int pixelFormat; PIXELFORMATDESCRIPTOR pfd = { sizeof(PIXELFORMATDESCRIPTOR), 1, PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, PFD_TYPE_RGBA, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0, PFD_MAIN_PLANE, 0, 0, 0, 0 };
switch(message) { case WM_CREATE: h_Wnd = hWnd; hDC = GetDC(hWnd); pixelFormat = ChoosePixelFormat(hDC, &pfd); if (!pixelFormat) { logo.log("Can't Choose Pixel Format"); PostQuitMessage(0); break; } if (!SetPixelFormat(hDC, pixelFormat, &pfd)) { logo.log("Can't Set Pixel Format"); PostQuitMessage(0); break; } hRC = wglCreateContext(hDC); if (!hRC) { logo.log("Can't Create OpenGL Rendering Context"); PostQuitMessage(0); break; } if (!wglMakeCurrent(hDC, hRC)) { logo.log("Can't Call Thread Of Current Rendering Context"); PostQuitMessage(0); break; } wogl.initGL(); break; case WM_DESTROY: case WM_CLOSE: ChangeDisplaySettings(0, 0); wglMakeCurrent(hDC, 0); wglDeleteContext(hRC); ReleaseDC(hWnd, hDC); PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); break; } return 0; }
//=============================================================================
int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst, char* lpCmdLine, int cmdShow) { MSG msg; WNDCLASS wc; HWND hWnd;
wc.style = CS_HREDRAW|CS_VREDRAW|CS_OWNDC; wc.lpfnWndProc = (WNDPROC) WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = 0; wc.hCursor = LoadCursor(0, IDC_ARROW); wc.hbrBackground = 0; wc.lpszMenuName = 0; wc.lpszClassName = "wglClass";
if (!RegisterClass(&wc)) { logo.log("Can't Register Window Class"); return 0; }
hWnd = CreateWindow("wglClass", "Bsedian se le Nek", WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, 0, 0, 800, 600, 0, 0, hInstance, 0); if (!hWnd) { logo.log("Can't Create Window"); return 0; }
ShowWindow(hWnd, SW_SHOWNORMAL); UpdateWindow(hWnd); SetFocus(hWnd);
while (1) { while(PeekMessage(&msg, 0, 0, 0, PM_NOREMOVE)) { if (GetMessage(&msg, 0, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } else return 1; }
wogl.drawGLScene(); SwapBuffers(hDC); } }
|
В классе aOpenGL, соответственно идёт работа с OGL'ом. |