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
50 lines
744 B
CMake
50 lines
744 B
CMake
# SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
set(INC
|
|
.
|
|
../../blenkernel
|
|
../../blenlib
|
|
../../gpu
|
|
../../makesdna
|
|
../../makesrna
|
|
../../../../intern/guardedalloc
|
|
../../../../intern/clog
|
|
)
|
|
|
|
set(INC_SYS
|
|
${Epoxy_INCLUDE_DIRS}
|
|
${PYTHON_INCLUDE_DIRS}
|
|
)
|
|
|
|
set(SRC
|
|
bgl.c
|
|
bl_math_py_api.c
|
|
blf_py_api.c
|
|
bpy_threads.c
|
|
idprop_py_api.c
|
|
idprop_py_ui_api.c
|
|
imbuf_py_api.c
|
|
py_capi_rna.c
|
|
py_capi_utils.c
|
|
|
|
bgl.h
|
|
bl_math_py_api.h
|
|
blf_py_api.h
|
|
idprop_py_api.h
|
|
idprop_py_ui_api.h
|
|
imbuf_py_api.h
|
|
py_capi_rna.h
|
|
py_capi_utils.h
|
|
|
|
# header-only
|
|
python_utildefines.h
|
|
)
|
|
|
|
set(LIB
|
|
${Epoxy_LIBRARIES}
|
|
${PYTHON_LINKFLAGS}
|
|
${PYTHON_LIBRARIES}
|
|
)
|
|
|
|
blender_add_lib(bf_python_ext "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
|