Changeset View
Changeset View
Standalone View
Standalone View
intern/ghost/intern/GHOST_SystemWin32.cpp
| Show All 25 Lines | |||||
| #ifndef _WIN32_IE | #ifndef _WIN32_IE | ||||
| # define _WIN32_IE 0x0501 /* shipped before XP, so doesn't impose additional requirements */ | # define _WIN32_IE 0x0501 /* shipped before XP, so doesn't impose additional requirements */ | ||||
| #endif | #endif | ||||
| #include <shlobj.h> | #include <shlobj.h> | ||||
| #include <tlhelp32.h> | #include <tlhelp32.h> | ||||
| #include <psapi.h> | #include <psapi.h> | ||||
| #include <shellapi.h> | |||||
| #include <windowsx.h> | #include <windowsx.h> | ||||
| #include "utfconv.h" | #include "utfconv.h" | ||||
| #include "GHOST_DisplayManagerWin32.h" | #include "GHOST_DisplayManagerWin32.h" | ||||
| #include "GHOST_EventButton.h" | #include "GHOST_EventButton.h" | ||||
| #include "GHOST_EventCursor.h" | #include "GHOST_EventCursor.h" | ||||
| #include "GHOST_EventKey.h" | #include "GHOST_EventKey.h" | ||||
| ▲ Show 20 Lines • Show All 263 Lines • ▼ Show 20 Lines | |||||
| */ | */ | ||||
| GHOST_IContext *GHOST_SystemWin32::createOffscreenContext() | GHOST_IContext *GHOST_SystemWin32::createOffscreenContext() | ||||
| { | { | ||||
| bool debug_context = false; /* TODO: inform as a parameter */ | bool debug_context = false; /* TODO: inform as a parameter */ | ||||
| GHOST_Context *context; | GHOST_Context *context; | ||||
| HWND wnd = CreateWindowA("STATIC", | HWND wnd = CreateWindowA("STATIC", | ||||
| "BlenderGLEW", | "BlenderGLEW", | ||||
brecht: Define a constant for this rather than hardcoding 1024. | |||||
| WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, | WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, | ||||
| 0, | 0, | ||||
| 0, | 0, | ||||
| 64, | 64, | ||||
| 64, | 64, | ||||
| NULL, | NULL, | ||||
| NULL, | NULL, | ||||
| GetModuleHandle(NULL), | GetModuleHandle(NULL), | ||||
| Show All 31 Lines | context = new GHOST_ContextWGL(false, | ||||
| 3, | 3, | ||||
| (debug_context ? WGL_CONTEXT_DEBUG_BIT_ARB : 0), | (debug_context ? WGL_CONTEXT_DEBUG_BIT_ARB : 0), | ||||
| GHOST_OPENGL_WGL_RESET_NOTIFICATION_STRATEGY); | GHOST_OPENGL_WGL_RESET_NOTIFICATION_STRATEGY); | ||||
| if (context->initializeDrawingContext()) { | if (context->initializeDrawingContext()) { | ||||
| goto finished; | goto finished; | ||||
| } | } | ||||
| else { | else { | ||||
| MessageBox(NULL, | |||||
| "A graphics card and driver with support for OpenGL 3.3 or higher is required.\n" | |||||
| "Installing the latest driver for your graphics card may resolve the issue.\n\n" | |||||
| "The program will now close.", | |||||
| "Blender - Unsupported Graphics Card or Driver", | |||||
| MB_OK | MB_ICONERROR); | |||||
| delete context; | delete context; | ||||
| exit(); | return NULL; | ||||
| } | } | ||||
| #elif defined(WITH_GL_PROFILE_COMPAT) | #elif defined(WITH_GL_PROFILE_COMPAT) | ||||
| // ask for 2.1 context, driver gives any GL version >= 2.1 | // ask for 2.1 context, driver gives any GL version >= 2.1 | ||||
| // (hopefully the latest compatibility profile) | // (hopefully the latest compatibility profile) | ||||
| // 2.1 ignores the profile bit & is incompatible with core profile | // 2.1 ignores the profile bit & is incompatible with core profile | ||||
| context = new GHOST_ContextWGL(false, | context = new GHOST_ContextWGL(false, | ||||
| true, | true, | ||||
| ▲ Show 20 Lines • Show All 1,394 Lines • ▼ Show 20 Lines | if (OpenClipboard(NULL)) { | ||||
| } | } | ||||
| CloseClipboard(); | CloseClipboard(); | ||||
| } | } | ||||
| else { | else { | ||||
| return; | return; | ||||
| } | } | ||||
| } | } | ||||
| /** \name Message Box | |||||
| * \{ */ | |||||
| static const char *MESSAGE_BOX_HELP_LINK_PTR = NULL; | |||||
| VOID CALLBACK showMessageBoxCallBack(LPHELPINFO lpHelpInfo) | |||||
| { | |||||
| if (MESSAGE_BOX_HELP_LINK_PTR) { | |||||
| ShellExecute(NULL, "open", MESSAGE_BOX_HELP_LINK_PTR, NULL, NULL, SW_SHOWNORMAL); | |||||
| } | |||||
| } | |||||
| GHOST_TSuccess GHOST_SystemWin32::showMessageBox(const char *title, | |||||
| const char *message, | |||||
| const char *link, | |||||
| GHOST_DialogOptions dialog_options) const | |||||
| { | |||||
| uint style = MB_OK | | |||||
| (dialog_options & GHOST_DialogError ? | |||||
| MB_ICONERROR : | |||||
| dialog_options & GHOST_DialogWarning ? MB_ICONWARNING : MB_ICONINFORMATION); | |||||
| bool show_help = link && strlen(link); | |||||
| if (show_help) { | |||||
| GHOST_ASSERT(MESSAGE_BOX_HELP_LINK_PTR == NULL, | |||||
| "showMessageBox: MESSAGE_BOX_HELP_LINK_PTR is in use"); | |||||
| style |= MB_HELP; | |||||
| MESSAGE_BOX_HELP_LINK_PTR = link; | |||||
| } | |||||
| MSGBOXPARAMSA message_box_params = {0}; | |||||
| message_box_params.cbSize = sizeof(MSGBOXCALLBACK); | |||||
| message_box_params.lpszText = message; | |||||
| message_box_params.lpszCaption = title; | |||||
| message_box_params.dwStyle = style; | |||||
| message_box_params.lpszText = message; | |||||
| message_box_params.lpfnMsgBoxCallback = showMessageBoxCallBack; | |||||
| MessageBoxIndirectA(&message_box_params); | |||||
| MESSAGE_BOX_HELP_LINK_PTR = NULL; | |||||
| return GHOST_kSuccess; | |||||
| } | |||||
| /* \} */ | |||||
| static DWORD GetParentProcessID(void) | static DWORD GetParentProcessID(void) | ||||
| { | { | ||||
| HANDLE snapshot; | HANDLE snapshot; | ||||
| PROCESSENTRY32 pe32 = {0}; | PROCESSENTRY32 pe32 = {0}; | ||||
| DWORD ppid = 0, pid = GetCurrentProcessId(); | DWORD ppid = 0, pid = GetCurrentProcessId(); | ||||
| snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); | snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); | ||||
| if (snapshot == INVALID_HANDLE_VALUE) { | if (snapshot == INVALID_HANDLE_VALUE) { | ||||
| return -1; | return -1; | ||||
| ▲ Show 20 Lines • Show All 89 Lines • Show Last 20 Lines | |||||
Define a constant for this rather than hardcoding 1024.