Changeset View
Changeset View
Standalone View
Standalone View
intern/ghost/intern/GHOST_SystemWin32.cpp
| Show First 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | |||||
| #include "GHOST_EventCursor.h" | #include "GHOST_EventCursor.h" | ||||
| #include "GHOST_EventKey.h" | #include "GHOST_EventKey.h" | ||||
| #include "GHOST_EventWheel.h" | #include "GHOST_EventWheel.h" | ||||
| #include "GHOST_TimerTask.h" | #include "GHOST_TimerTask.h" | ||||
| #include "GHOST_TimerManager.h" | #include "GHOST_TimerManager.h" | ||||
| #include "GHOST_WindowManager.h" | #include "GHOST_WindowManager.h" | ||||
| #include "GHOST_WindowWin32.h" | #include "GHOST_WindowWin32.h" | ||||
| #if defined(WITH_GL_EGL) | |||||
| # include "GHOST_ContextEGL.h" | |||||
| #else | |||||
| # include "GHOST_ContextWGL.h" | |||||
| #endif | |||||
| #ifdef WITH_INPUT_NDOF | #ifdef WITH_INPUT_NDOF | ||||
| #include "GHOST_NDOFManagerWin32.h" | #include "GHOST_NDOFManagerWin32.h" | ||||
| #endif | #endif | ||||
| // Key code values not found in winuser.h | // Key code values not found in winuser.h | ||||
| #ifndef VK_MINUS | #ifndef VK_MINUS | ||||
| #define VK_MINUS 0xBD | #define VK_MINUS 0xBD | ||||
| #endif // VK_MINUS | #endif // VK_MINUS | ||||
| ▲ Show 20 Lines • Show All 227 Lines • ▼ Show 20 Lines | else { | ||||
| delete window; | delete window; | ||||
| window = NULL; | window = NULL; | ||||
| } | } | ||||
| return window; | return window; | ||||
| } | } | ||||
| /** | |||||
| * Create a new offscreen context. | |||||
| * Never explicitly delete the window, use disposeContext() instead. | |||||
| * \return The new context (or 0 if creation failed). | |||||
| */ | |||||
| GHOST_IContext *GHOST_SystemWin32::createOffscreenContext() | |||||
| { | |||||
| bool debug_context = false; /* TODO: inform as a parameter */ | |||||
brecht: It would be good to have a comment explaining this, it's not obvious to me why an offscreen… | |||||
Not Done Inline ActionsSolving this will require passing GHOST_GLSettings to GHOST_CreateOpenGLContext(). Not sure how much you are relying on OpenGL debugging, but seems like keeping that could be somewhat important. brecht: Solving this will require passing `GHOST_GLSettings` to `GHOST_CreateOpenGLContext()`. Not… | |||||
| GHOST_Context *context; | |||||
| #if defined(WITH_GL_PROFILE_CORE) | |||||
| for (int minor = 5; minor >= 0; --minor) { | |||||
| context = new GHOST_ContextWGL( | |||||
| false, true, 0, | |||||
| NULL, NULL, | |||||
Not Done Inline ActionsIndentation seems too deep here. brecht: Indentation seems too deep here. | |||||
| WGL_CONTEXT_CORE_PROFILE_BIT_ARB, | |||||
| 4, minor, | |||||
| (debug_context ? WGL_CONTEXT_DEBUG_BIT_ARB : 0), | |||||
| GHOST_OPENGL_WGL_RESET_NOTIFICATION_STRATEGY); | |||||
| if (context->initializeDrawingContext()) { | |||||
| return context; | |||||
| } | |||||
Not Done Inline ActionsI guess this false will need to be replaced by some variables? brecht: I guess this `false` will need to be replaced by some variables? | |||||
| else { | |||||
| delete context; | |||||
| } | |||||
| } | |||||
| context = new GHOST_ContextWGL( | |||||
| false, true, 0, | |||||
| NULL, NULL, | |||||
| WGL_CONTEXT_CORE_PROFILE_BIT_ARB, | |||||
| 3, 3, | |||||
| (debug_context ? WGL_CONTEXT_DEBUG_BIT_ARB : 0), | |||||
| GHOST_OPENGL_WGL_RESET_NOTIFICATION_STRATEGY); | |||||
| if (context->initializeDrawingContext()) { | |||||
| return context; | |||||
| } | |||||
| else { | |||||
| MessageBox( | |||||
| NULL, | |||||
| "Blender requires a graphics driver with at least OpenGL 3.3 support.\n\n" | |||||
| "The program will now close.", | |||||
| "Blender - Unsupported Graphics Driver!", | |||||
| MB_OK | MB_ICONERROR); | |||||
| delete context; | |||||
| exit(); | |||||
| } | |||||
| #elif defined(WITH_GL_PROFILE_COMPAT) | |||||
| // ask for 2.1 context, driver gives any GL version >= 2.1 (hopefully the latest compatibility profile) | |||||
| // 2.1 ignores the profile bit & is incompatible with core profile | |||||
| context = new GHOST_ContextWGL( | |||||
| false, true, 0, | |||||
| NULL, NULL, | |||||
| 0, // no profile bit | |||||
| 2, 1, | |||||
| (debug_context ? WGL_CONTEXT_DEBUG_BIT_ARB : 0), | |||||
| GHOST_OPENGL_WGL_RESET_NOTIFICATION_STRATEGY); | |||||
| if (context->initializeDrawingContext()) { | |||||
| return context; | |||||
| } | |||||
| else { | |||||
| delete context; | |||||
| } | |||||
| #else | |||||
| # error // must specify either core or compat at build time | |||||
| #endif | |||||
| return NULL; | |||||
| } | |||||
| /** | |||||
| * Dispose of a context. | |||||
| * \param context Pointer to the context to be disposed. | |||||
| * \return Indication of success. | |||||
| */ | |||||
| GHOST_TSuccess GHOST_SystemWin32::disposeContext(GHOST_IContext *context) | |||||
| { | |||||
| delete context; | |||||
| return GHOST_kSuccess; | |||||
| } | |||||
| bool GHOST_SystemWin32::processEvents(bool waitForEvent) | bool GHOST_SystemWin32::processEvents(bool waitForEvent) | ||||
| { | { | ||||
| MSG msg; | MSG msg; | ||||
| bool anyProcessed = false; | bool anyProcessed = false; | ||||
| do { | do { | ||||
| GHOST_TimerManager *timerMgr = getTimerManager(); | GHOST_TimerManager *timerMgr = getTimerManager(); | ||||
| ▲ Show 20 Lines • Show All 1,336 Lines • Show Last 20 Lines | |||||
It would be good to have a comment explaining this, it's not obvious to me why an offscreen context would be tied to a window. Is it an API limitation? Maybe it determines with GPU is used if there are multiple GPUs used for different monitors?
It also seems problematic for background mode OpenGL render, but I'm not sure if this code would be reused for that.