M
Marco Bubke
Hi
If I understand the code right then there will be mset called if buffer is
NULL. Why?
I want only a empty array, why not a malloc? The data section after that
will be overwritten by me. Maybe I'm wrong.
static PyArrayObject *
NA_NewAll(int ndim, maybelong *shape, NumarrayType type,
void *buffer, maybelong byteoffset, maybelong bytestride,
int byteorder, int aligned, int writeable)
{
PyArrayObject *result = NA_NewAllFromBuffer(
ndim, shape, type, Py_None, byteoffset, bytestride,
byteorder, aligned, writeable);
if (result) {
if (!NA_NumArrayCheck((PyObject *) result)) {
PyErr_Format( PyExc_TypeError,
"NA_NewAll: non-NumArray result");
result = NULL;
} else {
if (buffer) {
memcpy(result->data, buffer,
PyArray_NBYTES(result));
} else {
memset(result->data, 0,
PyArray_NBYTES(result)); <-- ??????????????????
}
}
}
return result;
}
def get_polygon_stipple():
"""Return the polygon stipple pattern"""
cdef maybelong lenght
cdef void** data
lenght = 128
new_array = NA_NewArray(NULL, tUInt32, 1, lenght)
glGetPolygonStipple(<GLubyte*>NA_OFFSETDATA(new_array))
assert glGetError() != INVALID_OPERATION,\
"can't be called between gl.begin() and gl.end()"
return new_array
Here my code. I'm not sure if this is possible? I have also found
NA_getBufferPtrAndSize? Should I use this?
regards
Marco
If I understand the code right then there will be mset called if buffer is
NULL. Why?
I want only a empty array, why not a malloc? The data section after that
will be overwritten by me. Maybe I'm wrong.
static PyArrayObject *
NA_NewAll(int ndim, maybelong *shape, NumarrayType type,
void *buffer, maybelong byteoffset, maybelong bytestride,
int byteorder, int aligned, int writeable)
{
PyArrayObject *result = NA_NewAllFromBuffer(
ndim, shape, type, Py_None, byteoffset, bytestride,
byteorder, aligned, writeable);
if (result) {
if (!NA_NumArrayCheck((PyObject *) result)) {
PyErr_Format( PyExc_TypeError,
"NA_NewAll: non-NumArray result");
result = NULL;
} else {
if (buffer) {
memcpy(result->data, buffer,
PyArray_NBYTES(result));
} else {
memset(result->data, 0,
PyArray_NBYTES(result)); <-- ??????????????????
}
}
}
return result;
}
def get_polygon_stipple():
"""Return the polygon stipple pattern"""
cdef maybelong lenght
cdef void** data
lenght = 128
new_array = NA_NewArray(NULL, tUInt32, 1, lenght)
glGetPolygonStipple(<GLubyte*>NA_OFFSETDATA(new_array))
assert glGetError() != INVALID_OPERATION,\
"can't be called between gl.begin() and gl.end()"
return new_array
Here my code. I'm not sure if this is possible? I have also found
NA_getBufferPtrAndSize? Should I use this?
regards
Marco