Fix #103978 Add deprecation warnings to GPUBatch program usage. #105295
|
@ -174,6 +174,12 @@ PyDoc_STRVAR(
|
|||
" :type program: :class:`gpu.types.GPUShader`\n");
|
||||
static PyObject *pygpu_batch_program_set(BPyGPUBatch *self, BPyGPUShader *py_shader)
|
||||
{
|
||||
|
||||
PyErr_WarnEx(PyExc_DeprecationWarning,
|
||||
"calls to 'gpu.types.GPUBatch.program_set' is deprecated'",
|
||||
1);
|
||||
|
||||
|
||||
if (!BPyGPUShader_Check(py_shader)) {
|
||||
PyErr_Format(PyExc_TypeError, "Expected a GPUShader, got %s", Py_TYPE(py_shader)->tp_name);
|
||||
return NULL;
|
||||
|
@ -227,6 +233,13 @@ static PyObject *pygpu_batch_draw(BPyGPUBatch *self, PyObject *args)
|
|||
GPU_batch_set_shader(self->batch, py_program->shader);
|
||||
}
|
||||
|
||||
if(args<2 || self<2)
|
||||
|
||||
{
|
||||
PyErr_WarnEx(PyExc_DeprecationWarning,
|
||||
"'GPU BATCH' program is deprecated. Please add a valid program parameter ",
|
||||
Jeroen Bakker
commented
Description of the message is confusing. Description of the message is confusing.
We also want to limit this message to be shown once as typically this function will be used many times per second and can overflood the console.
|
||||
1);
|
||||
}
|
||||
|
||||
GPU_batch_draw(self->batch);
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
@ -334,7 +347,7 @@ PyTypeObject BPyGPUBatch_Type = {
|
|||
PyObject *BPyGPUBatch_CreatePyObject(GPUBatch *batch)
|
||||
{
|
||||
BPyGPUBatch *self;
|
||||
|
||||
|
||||
#ifdef USE_GPU_PY_REFERENCES
|
||||
self = (BPyGPUBatch *)_PyObject_GC_New(&BPyGPUBatch_Type);
|
||||
self->references = NULL;
|
||||
|
|
Loading…
Reference in New Issue
Seems like an incorrect check. It could be added in the
if(py_program == NULL)
check.