Changeset View
Standalone View
source/blender/python/generic/bgl.c
| Show All 9 Lines | |||||
| * This module is very similar to 'PyOpenGL' which could replace 'bgl' one day. | * This module is very similar to 'PyOpenGL' which could replace 'bgl' one day. | ||||
| */ | */ | ||||
| #include <Python.h> | #include <Python.h> | ||||
| #include "BLI_utildefines.h" | #include "BLI_utildefines.h" | ||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| #include "GPU_context.h" | |||||
| #include "GPU_state.h" | #include "GPU_state.h" | ||||
| #include "../generic/py_capi_utils.h" | #include "../generic/py_capi_utils.h" | ||||
| #include <epoxy/gl.h> | #include <epoxy/gl.h> | ||||
| #include "bgl.h" | #include "bgl.h" | ||||
| Show All 11 Lines | |||||
| #define void_str "" | #define void_str "" | ||||
| #define void_var(num) | #define void_var(num) | ||||
| #define void_ref(num) &bgl_var##num | #define void_ref(num) &bgl_var##num | ||||
| #define void_def(num) char bgl_var##num | #define void_def(num) char bgl_var##num | ||||
| #if 0 | #if 0 | ||||
| # define buffer_str "O!" | # define buffer_str "O!" | ||||
| # define buffer_var(number) (bgl_buffer##number)->buf.asvoid | # define buffer_var(number) (bgl_buffer##number)->buf.asvoid | ||||
| # define buffer_ref(number) &BGL_bufferType, &bgl_buffer##number | # define buffer_ref(number) &BGL_bufferType, &bgl_buffer##number | ||||
campbellbarton: Use `(void)`, to prevent `-Wstrict-prototypes` warning. | |||||
| # define buffer_def(number) Buffer *bgl_buffer##number | # define buffer_def(number) Buffer *bgl_buffer##number | ||||
| #endif | #endif | ||||
| /* GL Pointer fields, handled by buffer type */ | /* GL Pointer fields, handled by buffer type */ | ||||
| /* GLdoubleP, GLfloatP, GLintP, GLuintP, GLshortP, GLsizeiP, GLcharP */ | /* GLdoubleP, GLfloatP, GLintP, GLuintP, GLshortP, GLsizeiP, GLcharP */ | ||||
| #define GLbooleanP_str "O!" | #define GLbooleanP_str "O!" | ||||
| #define GLbooleanP_var(number) (bgl_buffer##number)->buf.asvoid | #define GLbooleanP_var(number) (bgl_buffer##number)->buf.asvoid | ||||
| ▲ Show 20 Lines • Show All 1,012 Lines • ▼ Show 20 Lines | |||||
| * \{ */ | * \{ */ | ||||
| #ifdef WITH_OPENGL | #ifdef WITH_OPENGL | ||||
| # define BGL_Wrap(funcname, ret, arg_list) \ | # define BGL_Wrap(funcname, ret, arg_list) \ | ||||
| static PyObject *Method_##funcname(PyObject *UNUSED(self), PyObject *args) \ | static PyObject *Method_##funcname(PyObject *UNUSED(self), PyObject *args) \ | ||||
| { \ | { \ | ||||
| arg_def arg_list; \ | arg_def arg_list; \ | ||||
| ret_def_##ret; \ | ret_def_##ret; \ | ||||
| if (GPU_backend_get_type() != GPU_BACKEND_OPENGL) { \ | |||||
| PyErr_SetString(PyExc_NotImplementedError, \ | |||||
| "`bgl` calls are only supported when using an OpenGL backend."); \ | |||||
Done Inline ActionsThe deprecated warning is often overlooked. mano-wii: The deprecated warning is often overlooked.
The error message cannot be ignored.
If we wanted… | |||||
Done Inline ActionsThis would still not show to the user on a mac. I believe the best option is to load sys.excepthook with a custom callback that reports back to the user. Still investigating how to do this via CPython jbakker: This would still not show to the user on a mac. I believe the best option is to load sys. | |||||
| return NULL; \ | |||||
| } \ | |||||
Done Inline ActionsIs it possible to continue with the functions logic (even if the BGL call does nothing), as any function that is expected to return a non None value will error (although admittedly there aren't too many of these). campbellbarton: Is it possible to continue with the functions logic (even if the BGL call does nothing), as any… | |||||
Done Inline ActionsThe biggest issue is that on metal the opengl library isn't loaded, that will crash when continuing the logic. Adding logic to use the correct return type might be doable, For example -1 for integer types. Will have a look how to do this jbakker: The biggest issue is that on metal the opengl library isn't loaded, that will crash when… | |||||
| if (!PyArg_ParseTuple(args, arg_str arg_list, arg_ref arg_list)) { \ | if (!PyArg_ParseTuple(args, arg_str arg_list, arg_ref arg_list)) { \ | ||||
| return NULL; \ | return NULL; \ | ||||
| } \ | } \ | ||||
| GPU_bgl_start(); \ | GPU_bgl_start(); \ | ||||
| ret_set_##ret gl##funcname(arg_var arg_list); \ | ret_set_##ret gl##funcname(arg_var arg_list); \ | ||||
| ret_ret_##ret; \ | ret_ret_##ret; \ | ||||
| } | } | ||||
| #else | #else | ||||
| ▲ Show 20 Lines • Show All 1,560 Lines • Show Last 20 Lines | |||||
Use (void), to prevent -Wstrict-prototypes warning.