📄 glesmodule.cpp
字号:
RETURN_IF_GLERROR;
RETURN_PYNONE;
}
extern "C" PyObject *gles_glColorPointer(PyObject *self, PyObject *args) {
GLint size;
GLenum type;
GLsizei stride;
PyObject * pointerPy;
if ( !PyArg_ParseTuple(args, "iiiO:glColorPointer", &size, &type, &stride, &pointerPy) ) {
return NULL;
}
return gles_wrap_glColorPointer(size, type, stride, pointerPy);
}
extern "C" PyObject *gles_glColorPointerub(PyObject *self, PyObject *args) {
GLint size;
PyObject * pointerPy;
if ( !PyArg_ParseTuple(args, "O:glColorPointerub", &pointerPy) ) {
return NULL;
}
if(pointerPy == Py_None) {
gles_free_array(GL_COLOR_ARRAY);
RETURN_PYNONE;
}
if( PyObject_TypeCheck(pointerPy, GLES_ARRAY_TYPE) ) {
size = ((array_object*)pointerPy)->dimension;
} else {
size = gles_PySequence_Dimension(pointerPy);
}
return gles_wrap_glColorPointer(size, /*type*/ GL_UNSIGNED_BYTE, /*stride*/ 0, pointerPy);
}
extern "C" PyObject *gles_glColorPointerf(PyObject *self, PyObject *args) {
GLint size;
PyObject * pointerPy;
if ( !PyArg_ParseTuple(args, "O:glColorPointerf", &pointerPy) ) {
return NULL;
}
if(pointerPy == Py_None) {
gles_free_array(GL_COLOR_ARRAY);
RETURN_PYNONE;
}
if( PyObject_TypeCheck(pointerPy, GLES_ARRAY_TYPE) ) {
size = ((array_object*)pointerPy)->dimension;
} else {
size = gles_PySequence_Dimension(pointerPy);
}
return gles_wrap_glColorPointer(size, /*type*/ GL_FLOAT, /*stride*/ 0, pointerPy);
}
extern "C" PyObject *gles_glColorPointerx(PyObject *self, PyObject *args) {
GLint size;
PyObject * pointerPy;
if ( !PyArg_ParseTuple(args, "O:glColorPointerx", &pointerPy) ) {
return NULL;
}
if(pointerPy == Py_None) {
gles_free_array(GL_COLOR_ARRAY);
RETURN_PYNONE;
}
if( PyObject_TypeCheck(pointerPy, GLES_ARRAY_TYPE) ) {
size = ((array_object*)pointerPy)->dimension;
} else {
size = gles_PySequence_Dimension(pointerPy);
}
return gles_wrap_glColorPointer(size, /*type*/ GL_FIXED, /*stride*/ 0, pointerPy);
}
extern "C" PyObject *gles_glCompressedTexImage2D(PyObject *self, PyObject *args) {
GLenum target;
GLint level;
GLenum internalformat;
GLsizei width;
GLsizei height;
GLint border;
GLsizei imageSize;
GLvoid *data;
PyObject *pixelsPy;
if( !PyArg_ParseTuple(args, "iiiiiiiO:glCompressedTexImage2D", &target, &level, &internalformat, &width, &height, &border, &imageSize, &pixelsPy) ) {
return NULL;
}
// Only accepting array or string objects
if( PyObject_TypeCheck(pixelsPy, GLES_ARRAY_TYPE) ) {
array_object *arr = (array_object*)pixelsPy;
data = arr->arrdata;
} else if( PyString_Check(pixelsPy) ) {
// "Convert" the string object into an array.
// The returned pointer points to the raw C string
// data held by the object, so no actual conversion needed.
data = PyString_AsString(pixelsPy);
if(data == NULL) {
assert(PyErr_Occurred() != NULL);
return NULL;
}
} else {
PyErr_SetString(PyExc_TypeError,"Only strings and gles.array objects supported");
return NULL;
}
glCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data);
RETURN_PYNONE;
}
extern "C" PyObject *gles_glCompressedTexSubImage2D(PyObject *self, PyObject *args) {
GLenum target;
GLint level;
GLint xoffset;
GLint yoffset;
GLsizei width;
GLsizei height;
GLenum format;
GLsizei imageSize;
GLvoid *data;
PyObject *pixelsPy;
if( !PyArg_ParseTuple(args, "iiiiiiiiO:glCompressedTexSubImage2D", &target, &level, &xoffset, &yoffset, &width, &height, &format, &imageSize, &pixelsPy) ) {
return NULL;
}
if( PyObject_TypeCheck(pixelsPy, GLES_ARRAY_TYPE) ) {
array_object *arr = (array_object*)pixelsPy;
data = arr->arrdata;
} else if( PyString_Check(pixelsPy) ) {
// "Convert" the string object into an array.
// The returned pointer points to the raw C string
// data held by the object, so no actual conversion needed.
data = PyString_AsString(pixelsPy);
if(data == NULL) {
assert(PyErr_Occurred() != NULL);
return NULL;
}
} // The last resort is to check if the given object is an Image object
else {
PyErr_SetString(PyExc_TypeError,"Only strings and gles.array objects supported");
return NULL;
}
glCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, data);
RETURN_PYNONE;
}
extern "C" PyObject *gles_glCopyTexImage2D(PyObject *self, PyObject *args) {
GLenum target;
GLint level;
GLenum internalformat;
GLint x;
GLint y;
GLsizei width;
GLsizei height;
GLint border;
if ( !PyArg_ParseTuple(args, "iiiiiiii:glCopyTexImage2D", &target, &level, &internalformat, &x, &y, &width, &height, &border) ) {
return NULL;
}
glCopyTexImage2D(target, level, internalformat, x, y, width, height, border);
RETURN_IF_GLERROR;
RETURN_PYNONE;
}
extern "C" PyObject *gles_glCopyTexSubImage2D(PyObject *self, PyObject *args) {
GLenum target;
GLint level;
GLint xoffset;
GLint yoffset;
GLint x;
GLint y;
GLsizei width;
GLsizei height;
if ( !PyArg_ParseTuple(args, "iiiiiiii:glCopyTexSubImage2D", &target, &level, &xoffset, &yoffset, &x, &y, &width, &height) ) {
return NULL;
}
glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
RETURN_IF_GLERROR;
RETURN_PYNONE;
}
extern "C" PyObject *gles_glCullFace(PyObject *self, PyObject *args) {
GLenum mode;
if ( !PyArg_ParseTuple(args, "i:glCullFace", &mode) ) {
return NULL;
}
glCullFace(mode);
RETURN_IF_GLERROR;
RETURN_PYNONE;
}
extern "C" PyObject *gles_glDeleteTextures(PyObject *self, PyObject *args) {
GLsizei n;
GLuint *textures = NULL;
PyObject *texturesPy = NULL;
if( !PyArg_ParseTuple(args, "O:glDeleteTextures", &texturesPy) ) {
return NULL;
}
if(! PySequence_Check(texturesPy) ) {
PyErr_SetString(PyExc_TypeError, "Expecting a sequence");
return NULL;
}
textures = gles_PySequence_AsGLuintArray(texturesPy);
if( textures == NULL ) {
assert(PyErr_Occurred() != NULL);
return NULL;
}
n = PySequence_Length(texturesPy);
glDeleteTextures(n, textures);
gles_free(textures);
RETURN_IF_GLERROR;
RETURN_PYNONE;
}
extern "C" PyObject *gles_glDepthFunc(PyObject *self, PyObject *args) {
GLenum func;
if ( !PyArg_ParseTuple(args, "i:glDepthFunc", &func) ) {
return NULL;
}
glDepthFunc(func);
RETURN_IF_GLERROR;
RETURN_PYNONE;
}
extern "C" PyObject *gles_glDepthMask(PyObject *self, PyObject *args) {
GLboolean flag;
if ( !PyArg_ParseTuple(args, "i:glDepthMask", &flag) ) {
return NULL;
}
glDepthMask(flag);
RETURN_IF_GLERROR;
RETURN_PYNONE;
}
extern "C" PyObject *gles_glDepthRangef(PyObject *self, PyObject *args) {
GLclampf zNear;
GLclampf zFar;
if ( !PyArg_ParseTuple(args, "ff:glDepthRangef", &zNear, &zFar) ) {
return NULL;
}
glDepthRangef(zNear, zFar);
RETURN_IF_GLERROR;
RETURN_PYNONE;
}
extern "C" PyObject *gles_glDepthRangex(PyObject *self, PyObject *args) {
GLclampx zNear;
GLclampx zFar;
if ( !PyArg_ParseTuple(args, "ii:glDepthRangex", &zNear, &zFar) ) {
return NULL;
}
glDepthRangex(zNear, zFar);
RETURN_IF_GLERROR;
RETURN_PYNONE;
}
extern "C" PyObject *gles_glDisable(PyObject *self, PyObject *args) {
GLenum cap;
if ( !PyArg_ParseTuple(args, "i:glDisable", &cap) ) {
return NULL;
}
glDisable(cap);
RETURN_IF_GLERROR;
RETURN_PYNONE;
}
extern "C" PyObject *gles_glDisableClientState(PyObject *self, PyObject *args) {
GLenum array;
if ( !PyArg_ParseTuple(args, "i:glDisableClientState", &array) ) {
return NULL;
}
glDisableClientState(array);
RETURN_IF_GLERROR;
RETURN_PYNONE;
}
extern "C" PyObject *gles_glDrawArrays(PyObject *self, PyObject *args) {
GLenum mode;
GLint first;
GLsizei count;
if ( !PyArg_ParseTuple(args, "iii:glDrawArrays", &mode, &first, &count) ) {
return NULL;
}
glDrawArrays(mode, first, count);
RETURN_IF_GLERROR;
RETURN_PYNONE;
}
extern "C" PyObject *gles_glDrawElements(PyObject *self, PyObject *args) {
GLenum mode;
GLsizei count = 0;
GLenum type;
void *eptr = NULL;
array_object *arrobj = NULL;
PyObject *indicesPy;
if ( !PyArg_ParseTuple(args, "iiiO:glDrawElements", &mode, &count, &type, &indicesPy) ) {
return NULL;
}
// We can use either the array type or a sequence.
// Check for gles.array type first.
if(PyObject_TypeCheck(indicesPy, GLES_ARRAY_TYPE) ) {
arrobj=(array_object*)indicesPy;
eptr = (GLubyte*)arrobj->arrdata;
} // We can also use None as an argument.
else if(indicesPy == Py_None) {
eptr = NULL;
} // Try to feed the object as a sequence.
else {
indicesPy = gles_PySequence_Collapse(type, indicesPy, NULL);
if(indicesPy == NULL) {
// We should have an exception from PySequence_Collapse if something went wrong
assert(PyErr_Occurred() != NULL);
return NULL;
}
// glDrawElements accepts only GL_UNSIGNED_BYTE or GL_UNSIGNED_SHORT types
switch(type) {
case GL_UNSIGNED_BYTE:
eptr = gles_PySequence_AsGLubyteArray(indicesPy);
break;
case GL_UNSIGNED_SHORT:
eptr = gles_PySequence_AsGLushortArray(indicesPy);
break;
default:
PyErr_SetString(PyExc_ValueError, "Invalid array type");
return NULL;
}
if(eptr == NULL) {
assert(PyErr_Occurred() != NULL);
return NULL;
}
}
glDrawElements(mode, count, type, eptr);
if(arrobj == NULL && eptr != NULL) {
gles_free(eptr);
}
RETURN_IF_GLERROR;
RETURN_PYNONE;
}
extern "C" PyObject *gles_glDrawElementsub(PyObject *self, PyObject *args) {
GLenum mode;
GLsizei count = 0;
GLenum type = GL_UNSIGNED_BYTE;
GLubyte *eptr;
array_object *arrobj = NULL;
PyObject *indicesPy;
if ( !PyArg_ParseTuple(args, "iO:glDrawElementsub", &mode, &indicesPy) ) {
return NULL;
}
// We can use either the array type or a sequence.
// Check for gles.array type first.
if(PyObject_TypeCheck(indicesPy, GLES_ARRAY_TYPE) ) {
arrobj=(array_object*)indicesPy;
if(arrobj->arrtype != type) {
PyErr_SetString(PyExc_TypeError, "Invalid type; expected GL_UNSIGNED_BYTE");
return NULL;
}
eptr = (GLubyte*)arrobj->arrdata;
count = arrobj->len;
} // We can also use None as an argument.
else if(indicesPy == Py_None) {
eptr = NULL;
} // Try to feed the object as a sequence.
else {
indicesPy = gles_PySequence_Collapse(type, indicesPy, NULL);
if(indicesPy == NULL) {
// We should have an exception from PySequence_Collapse if something went wrong
assert(PyErr_Occurred() != NULL);
return NULL;
}
eptr = gles_PySequence_AsGLubyteArray(indicesPy);
if(eptr == NULL) {
assert(PyErr_Occurred() != NULL);
return NULL;
}
count = PySequence_Length(indicesPy);
}
glDrawElements(mode, count, type, eptr);
if(arrobj == NULL && eptr != NULL) {
gles_free(eptr);
}
RETURN_IF_GLERROR;
RETURN_PYNONE;
}
extern "C" PyObject *gles_glDrawElementsus (PyObject *self, PyObject *args) {
GLenum mode;
GLsizei count = 0;
GLenum type = GL_UNSIGNED_SHORT;
GLushort *eptr;
array_object *arrobj = NULL;
PyObject *indicesPy;
if ( !PyArg_ParseTuple(args, "iO:glDrawElementsus", &mode, &indicesPy) ) {
return NULL;
}
// We can use either the array type or a sequence.
// Check for gles.array type first.
if(PyObject_TypeCheck(indicesPy, GLES_ARRAY_TYPE) ) {
arrobj = (array_object*)indicesPy;
if(arrobj->arrtype != type) {
PyErr_SetString(PyExc_TypeError, "Invalid type; expected GL_UNSIGNED_SHORT");
return NULL;
}
eptr = (GLushort*)arrobj->arrdata;
count = arrobj->len;
} // We can also use None as an argument.
else if(indicesPy == Py_None) {
eptr = NULL;
} // Try to feed the object as a sequence.
else {
indicesPy = gles_PySequence_Collapse(type, indicesPy, NULL);
if(indicesPy == NULL) {
// We should have an exception from PySequence_Collapse if something went wrong
assert(PyErr_Occurred() != NULL);
return NULL;
}
eptr = gles_PySequence_AsGLushortArray(indicesPy);
if(eptr == NULL) {
assert(PyErr_Occurred() != NULL);
return NULL;
}
count = PySequence_Length(indicesPy);
}
glDrawElements(mode, count, type, eptr);
if(arrobj == NULL && eptr != NULL) {
gles_free(eptr);
}
RETURN_IF_GLERROR;
RETURN_PYNONE;
}
extern "C" PyObject *gles_glEnable (PyObject *self, PyObject *args) {
GLenum cap;
if ( !PyArg_ParseTuple(args, "i:glEnable", &cap) ) {
return NULL;
}
glEnable(cap);
RETURN_IF_GLERROR;
RETURN_PYNONE;
}
extern "C" PyObject *gles_glEnableClientState(PyObject *self, PyObject *args) {
GLenum array;
if ( !PyArg_ParseTuple(args, "i:glEnableClientState", &array) ) {
return NULL;
}
glEnableClientState(array);
RETURN_IF_GLERROR;
RETURN_PYNONE;
}
extern "C" PyObject *gles_glFinish(PyObject *self, PyObject */*args*/) {
glFinish();
RETURN_IF_GLERROR;
RETURN_PYNONE;
}
extern "C" PyObject *gles_glFlush(PyObject *self, PyObject */*args*/) {
glFlush();
RETURN_IF_GLERROR;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -