int WIN_CreateWindow(_THIS, SDL_Window * window) { HWND hwnd; RECT rect; DWORD style = STYLE_BASIC; int x, y; int w, h; style |= GetWindowStyle(window); /* Figure out what the window area will be */ rect.left = window->x; rect.top = window->y; rect.right = window->x + window->w; rect.bottom = window->y + window->h; AdjustWindowRectEx(&rect, style, FALSE, 0); x = rect.left; y = rect.top; w = (rect.right - rect.left); h = (rect.bottom - rect.top); hwnd = CreateWindow(SDL_Appname, TEXT(""), style, x, y, w, h, NULL, NULL, SDL_Instance, NULL); if (!hwnd) { return WIN_SetError("Couldn't create window"); } WIN_PumpEvents(_this); if (SetupWindowData(_this, window, hwnd, SDL_TRUE) < 0) { DestroyWindow(hwnd); return -1; } #if SDL_VIDEO_OPENGL_WGL /* We need to initialize the extensions before deciding how to create ES profiles */ if (window->flags & SDL_WINDOW_OPENGL) { WIN_GL_InitExtensions(_this); } #endif #if SDL_VIDEO_OPENGL_ES2 if ((window->flags & SDL_WINDOW_OPENGL) && _this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES #if SDL_VIDEO_OPENGL_WGL && (!_this->gl_data || !_this->gl_data->HAS_WGL_EXT_create_context_es2_profile) #endif ) { #if SDL_VIDEO_OPENGL_EGL if (WIN_GLES_SetupWindow(_this, window) < 0) { WIN_DestroyWindow(_this, window); return -1; } #else return SDL_SetError("Could not create GLES window surface (no EGL support available)"); #endif /* SDL_VIDEO_OPENGL_EGL */ } else #endif /* SDL_VIDEO_OPENGL_ES2 */ #if SDL_VIDEO_OPENGL_WGL if (window->flags & SDL_WINDOW_OPENGL) { if (WIN_GL_SetupWindow(_this, window) < 0) { WIN_DestroyWindow(_this, window); return -1; } } #endif return 0; }
int WIN_CreateWindow(_THIS, SDL_Window * window) { HWND hwnd, parent = NULL; DWORD style = STYLE_BASIC; int x, y; int w, h; if (window->flags & SDL_WINDOW_SKIP_TASKBAR) { parent = CreateWindow(SDL_Appname, TEXT(""), STYLE_BASIC, 0, 0, 32, 32, NULL, NULL, SDL_Instance, NULL); } style |= GetWindowStyle(window); /* Figure out what the window area will be */ WIN_AdjustWindowRectWithStyle(window, style, FALSE, &x, &y, &w, &h, SDL_FALSE); hwnd = CreateWindow(SDL_Appname, TEXT(""), style, x, y, w, h, parent, NULL, SDL_Instance, NULL); if (!hwnd) { return WIN_SetError("Couldn't create window"); } WIN_PumpEvents(_this); if (SetupWindowData(_this, window, hwnd, parent, SDL_TRUE) < 0) { DestroyWindow(hwnd); if (parent) { DestroyWindow(parent); } return -1; } /* Inform Windows of the frame change so we can respond to WM_NCCALCSIZE */ SetWindowPos(hwnd, NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE); if (window->flags & SDL_WINDOW_MINIMIZED) { ShowWindow(hwnd, SW_SHOWMINNOACTIVE); } if (!(window->flags & SDL_WINDOW_OPENGL)) { return 0; } /* The rest of this macro mess is for OpenGL or OpenGL ES windows */ #if SDL_VIDEO_OPENGL_ES2 if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES #if SDL_VIDEO_OPENGL_WGL && (!_this->gl_data || WIN_GL_UseEGL(_this)) #endif /* SDL_VIDEO_OPENGL_WGL */ ) { #if SDL_VIDEO_OPENGL_EGL if (WIN_GLES_SetupWindow(_this, window) < 0) { WIN_DestroyWindow(_this, window); return -1; } return 0; #else return SDL_SetError("Could not create GLES window surface (EGL support not configured)"); #endif /* SDL_VIDEO_OPENGL_EGL */ } #endif /* SDL_VIDEO_OPENGL_ES2 */ #if SDL_VIDEO_OPENGL_WGL if (WIN_GL_SetupWindow(_this, window) < 0) { WIN_DestroyWindow(_this, window); return -1; } #else return SDL_SetError("Could not create GL window (WGL support not configured)"); #endif return 0; }