bool GSWndWGL::Attach(void* handle, bool managed) { m_NativeWindow = (HWND)handle; m_managed = managed; OpenWGLDisplay(); CreateContext(3, 3); AttachContext(); m_swapinterval = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT"); PopulateGlFunction(); UpdateWindow(m_NativeWindow); return true; }
bool GSWndWGL::Attach(void* handle, bool managed) { m_NativeWindow = (HWND)handle; m_managed = managed; if (!OpenWGLDisplay()) return false; if (!CreateContext(3, 3)) return false; AttachContext(); CheckContext(); // TODO //m_swapinterval = (PFNGLXSWAPINTERVALMESAPROC)glXGetProcAddress((const GLubyte*) "glXSwapIntervalMESA"); //PFNGLXSWAPINTERVALMESAPROC m_swapinterval = (PFNGLXSWAPINTERVALMESAPROC)glXGetProcAddress((const GLubyte*) "glXSwapInterval"); PopulateGlFunction(); UpdateWindow(m_NativeWindow); return true; }
//TODO: GSopen 1 => Drop? // Used by GSReplay. At least for now. // More or less copy pasted from GSWndDX::Create and GSWndWGL::Attach with a few // modifications bool GSWndWGL::Create(const string& title, int w, int h) { if(m_NativeWindow) return false; m_managed = true; WNDCLASS wc; memset(&wc, 0, sizeof(wc)); wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS | CS_OWNDC; wc.lpfnWndProc = WndProc; wc.hInstance = theApp.GetModuleHandle(); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); wc.lpszClassName = "GSWndOGL"; if (!GetClassInfo(wc.hInstance, wc.lpszClassName, &wc)) { if (!RegisterClass(&wc)) { return false; } } DWORD style = WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_OVERLAPPEDWINDOW | WS_BORDER; GSVector4i r; GetWindowRect(GetDesktopWindow(), r); // Old GSOpen ModeWidth and ModeHeight are not necessary with this. bool remote = !!GetSystemMetrics(SM_REMOTESESSION); if (w <= 0 || h <= 0 || remote) { w = r.width() / 3; h = r.width() / 4; if (!remote) { w *= 2; h *= 2; } } r.left = (r.left + r.right - w) / 2; r.top = (r.top + r.bottom - h) / 2; r.right = r.left + w; r.bottom = r.top + h; AdjustWindowRect(r, style, FALSE); m_NativeWindow = CreateWindow(wc.lpszClassName, title.c_str(), style, r.left, r.top, r.width(), r.height(), NULL, NULL, wc.hInstance, (LPVOID)this); if (m_NativeWindow == NULL) return false; OpenWGLDisplay(); CreateContext(3, 3); AttachContext(); m_swapinterval = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT"); PopulateGlFunction(); return true; }