Goal of this patch is to stop the invocation of OpenGL calls via the bgl module
on a none OpenGL GPU backend, report this as a python deprecation warning
and report this to the user.
## Deprecation warning to developers
```
>>> import bgl
>>> bgl.glUseProgram(0)
<blender_console>:1: DeprecationWarning: 'bgl.glUseProgram' is deprecated and will be removed in Blender 3.7. Report or update your script to use 'gpu' module.
```
## Deprecation message to users
The message to the user is shown as part of the Info Space and as a message box.
{F14159203 width=100%}
{F14158674 width=100%}
During implementation we tried several ideas:
# Use python warning as errors: This isn't fine grained enough and can show incorrect information to the user.
# Throw deprecation as error and use sys.excepthook to report the user message.
This required a custom exception class to identify the bgl deprecation and a CPython handler function to
be set during python initialization. Although this is the most flexible there was a disconnect between the
exception class, exception function and the excepthook registration.
# A variant how we handle autoexec failures. A flag is stored in Global and when set the user message is reported.
Not that flexible, but code is more connected to the boolean stored in the Global struct.
Although using Global struct isn't nice I chose this solution due to its traceability. It is clear to developers
reading the code how the mechanism works by using search all functionality of your IDE.
Reviewed By: MichaelPW, campbellbarton
Maniphest Tasks: T103863
Differential Revision: https://developer.blender.org/D16996
41 lines
1.1 KiB
C
41 lines
1.1 KiB
C
/* SPDX-License-Identifier: GPL-2.0-or-later
|
|
* Copyright 2019 Blender Foundation. All rights reserved. */
|
|
|
|
/** \file
|
|
* \ingroup wm
|
|
*/
|
|
#pragma once
|
|
|
|
#include "BLI_sys_types.h"
|
|
|
|
#include "GHOST_Types.h"
|
|
|
|
#include "GPU_context.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
struct bContext;
|
|
|
|
/* *************** Message box *************** */
|
|
/* `WM_ghost_show_message_box` is implemented in `wm_windows.c` it is
|
|
* defined here as it was implemented to be used for showing
|
|
* a message to the user when the platform is not (fully) supported.
|
|
*
|
|
* In all other cases this message box should not be used. */
|
|
void WM_ghost_show_message_box(const char *title,
|
|
const char *message,
|
|
const char *help_label,
|
|
const char *continue_label,
|
|
const char *link,
|
|
GHOST_DialogOptions dialog_options);
|
|
|
|
GHOST_TDrawingContextType wm_ghost_drawing_context_type(const eGPUBackendType gpu_backend);
|
|
|
|
void wm_test_opengl_deprecation_warning(struct bContext *C);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|