bool WindowWin::Init(uint32 a_Width, uint32 a_Height) { m_Width = a_Width; m_Height = a_Height; m_Dim.x = (float)m_Width; m_Dim.y = (float)m_Height; WNDCLASS temp = { CS_HREDRAW | CS_VREDRAW | CS_OWNDC, // defines the class style Win32Messages, // pointer to the message handler function 0, // extra bytes following the window class structure 0, // extra bytes following the window instance m_Instance, // instance handle LoadIcon(NULL, IDI_APPLICATION), // icon handle LoadCursor(NULL, IDC_ARROW), // cursor NULL, // background brush NULL, // menu name "TmplQ" // window title }; if (!RegisterClass(&temp)) { return false; } // Bram fixed my stuff // Now with centered window! // Determine window position and dimensions const int x = GetSystemMetrics(SM_CXSCREEN) / 2 - m_Width / 2; const int y = GetSystemMetrics(SM_CYSCREEN) / 2 - m_Height / 2; m_Pos.x = (float)x; m_Pos.y = (float)y; m_Center.x = (float)(m_Width / 2); m_Center.y = (float)(m_Height / 2); const DWORD style = WS_OVERLAPPEDWINDOW; const DWORD ext_style = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE; RECT dim = { 0, 0, m_Width, m_Height }; AdjustWindowRect(&dim, style, FALSE); const int w = dim.right - dim.left; const int h = dim.bottom - dim.top; m_Window = CreateWindowEx ( ext_style, "TmplQ", // window class "TmplQ", // window title style, // visibility settings x, y, w, h, NULL, NULL, temp.hInstance, NULL ); if (!m_Window) { return false; } if (!(m_WindowContext = GetDC(m_Window))) { return false; } LOG("Context: %x", m_WindowContext); PIXELFORMATDESCRIPTOR pfd = { sizeof(PIXELFORMATDESCRIPTOR), // size 1, // version PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, // flags PFD_TYPE_RGBA, // pixel type 32, // color bits 0, 0, 0, 0, 0, 0, 0, 0, // color rgba 0, 0, 0, 0, 0, // accum bits, rgba 24, // depth bits 0, // stencil bits 0, // aux buffers PFD_MAIN_PLANE, // layer type 0, // reserved 0, 0, 0 // layer, visible, damage }; unsigned int format; if (!(format = ChoosePixelFormat(m_WindowContext, &pfd))) { return false; } if (!SetPixelFormat(m_WindowContext, format, &pfd)) { return false; } HGLRC hrc; if (!(hrc = wglCreateContext(m_WindowContext))) { return false; } if (!wglMakeCurrent(m_WindowContext, hrc)) { return false; } GLenum status = glewInit(); if (status != GLEW_OK) { char error[256]; sprintf(error, "%s", glewGetErrorString(status)); MessageBoxA(NULL, error, "GLEW error", MB_OK | MB_ICONEXCLAMATION); return false; } ShowWindow(m_Window, 1); UpdateWindow(m_Window); wglSwapIntervalEXT(0); s_WindowWin = this; return true; }