📄 glesmodule.cpp
字号:
GLenum face;
GLenum pname;
GLfloat *params;
PyObject *paramsPy;
if ( !PyArg_ParseTuple(args, "iiO:glMaterialfv", &face, &pname, ¶msPy) ) {
return NULL;
}
params = (GLfloat*)gles_PySequence_AsGLfloatArray(paramsPy);
if(params == NULL) {
assert(PyErr_Occurred() != NULL);
return NULL;
}
glMaterialfv(face, pname, params);
gles_free(params);
RETURN_IF_GLERROR;
RETURN_PYNONE;
}
extern "C" PyObject *gles_glMaterialx (PyObject *self, PyObject *args) {
GLenum face;
GLenum pname;
GLfixed param;
if ( !PyArg_ParseTuple(args, "iii:glMaterialx", &face, &pname, ¶m) ) {
return NULL;
}
glMaterialx(face, pname, param);
RETURN_IF_GLERROR;
RETURN_PYNONE;
}
extern "C" PyObject *gles_glMaterialxv (PyObject *self, PyObject *args) {
GLenum face;
GLenum pname;
GLfixed *params;
PyObject *paramsPy;
if ( !PyArg_ParseTuple(args, "iiO:glMaterialxv", &face, &pname, ¶msPy) ) {
return NULL;
}
params = (GLfixed*)gles_PySequence_AsGLfixedArray(paramsPy);
if(params == NULL) {
assert(PyErr_Occurred() != NULL);
return NULL;
}
glMaterialxv(face, pname, params);
gles_free(params);
RETURN_IF_GLERROR;
RETURN_PYNONE;
}
extern "C" PyObject *gles_glMatrixMode (PyObject *self, PyObject *args) {
GLenum mode;
if ( !PyArg_ParseTuple(args, "i:glMatrixMode", &mode) ) {
return NULL;
}
glMatrixMode(mode);
RETURN_IF_GLERROR;
RETURN_PYNONE;
}
extern "C" PyObject *gles_glMultMatrixf(PyObject *self, PyObject *args) {
GLfloat *m;
PyObject *mPy;
if ( !PyArg_ParseTuple(args, "O:glMultMatrixf", &mPy) ) {
return NULL;
}
mPy = gles_PySequence_Collapse(GL_FLOAT, mPy, NULL);
if(mPy == NULL) {
assert(PyErr_Occurred() != NULL);
return NULL;
}
if(PySequence_Length(mPy) != 16) {
PyErr_SetString(PyExc_ValueError, "Expecting a sequence of 16 floats");
return NULL;
}
m = gles_PySequence_AsGLfloatArray(mPy);
if(m == NULL) {
assert(PyErr_Occurred() != NULL);
return NULL;
}
glMultMatrixf(m);
gles_free(m);
RETURN_IF_GLERROR;
RETURN_PYNONE;
}
extern "C" PyObject *gles_glMultMatrixx(PyObject *self, PyObject *args) {
GLfixed *m;
PyObject *mPy;
if ( !PyArg_ParseTuple(args, "O:glMultMatrixx", &mPy) ) {
return NULL;
}
mPy = gles_PySequence_Collapse(GL_FIXED, mPy, NULL);
if(mPy == NULL) {
assert(PyErr_Occurred() != NULL);
return NULL;
}
if(PySequence_Length(mPy) != 16) {
PyErr_SetString(PyExc_ValueError, "Expecting a sequence of 16 ints");
return NULL;
}
m = gles_PySequence_AsGLfixedArray(mPy);
if(m == NULL) {
assert(PyErr_Occurred() != NULL);
return NULL;
}
glMultMatrixx(m);
gles_free(m);
RETURN_IF_GLERROR;
RETURN_PYNONE;
}
extern "C" PyObject *gles_glMultiTexCoord4f(PyObject *self, PyObject *args) {
GLenum target;
GLfloat s;
GLfloat t;
GLfloat r;
GLfloat q;
if ( !PyArg_ParseTuple(args, "iffff:glMultiTexCoord4f", &target, &s, &t, &r, &q) ) {
return NULL;
}
glMultiTexCoord4f(target, s, t, r, q);
RETURN_IF_GLERROR;
RETURN_PYNONE;
}
extern "C" PyObject *gles_glMultiTexCoord4x(PyObject *self, PyObject *args) {
GLenum target;
GLfixed s;
GLfixed t;
GLfixed r;
GLfixed q;
if ( !PyArg_ParseTuple(args, "iiiii:glMultiTexCoord4x", &target, &s, &t, &r, &q) ) {
return NULL;
}
glMultiTexCoord4x(target, s, t, r, q);
RETURN_IF_GLERROR;
RETURN_PYNONE;
}
extern "C" PyObject *gles_glNormal3f(PyObject *self, PyObject *args) {
GLfloat nx;
GLfloat ny;
GLfloat nz;
if ( !PyArg_ParseTuple(args, "fff:glNormal3f", &nx, &ny, &nz) ) {
return NULL;
}
glNormal3f(nx, ny, nz);
RETURN_IF_GLERROR;
RETURN_PYNONE;
}
extern "C" PyObject *gles_glNormal3x(PyObject *self, PyObject *args) {
GLfixed nx;
GLfixed ny;
GLfixed nz;
if ( !PyArg_ParseTuple(args, "iii:glNormal3x", &nx, &ny, &nz) ) {
return NULL;
}
glNormal3x(nx, ny, nz);
RETURN_IF_GLERROR;
RETURN_PYNONE;
}
PyObject *gles_wrap_glNormalPointer(GLenum type, GLsizei stride, PyObject *pointerPy) {
void *nptr = NULL;
array_object *arrobj=NULL;
// We can use either the array type or a sequence
// Check the array type first
if(PyObject_TypeCheck(pointerPy, GLES_ARRAY_TYPE) ) {
arrobj = (array_object*)pointerPy;
nptr = arrobj->arrdata;
}
#ifdef GL_OES_VERSION_1_1
else if(pointerPy == Py_None) {
nptr = NULL;
}
#endif
// Try to convert it as a sequence
else {
pointerPy = gles_PySequence_Collapse(type, pointerPy, NULL);
if( pointerPy == NULL ) {
assert(PyErr_Occurred() != NULL);
return NULL;
}
// glNormalPointer accepts only GL_BYTE, GL_SHORT, GL_FIXED or GL_FLOAT types
switch(type) {
case GL_BYTE:
nptr = gles_PySequence_AsGLbyteArray(pointerPy);
break;
case GL_SHORT:
nptr = gles_PySequence_AsGLshortArray(pointerPy);
break;
case GL_FIXED:
nptr = gles_PySequence_AsGLfixedArray(pointerPy);
break;
case GL_FLOAT:
nptr = gles_PySequence_AsGLfloatArray(pointerPy);
break;
default:
PyErr_SetString(PyExc_ValueError, "Invalid array type");
return NULL;
}
if(nptr == NULL) {
assert(PyErr_Occurred() != NULL);
return NULL;
}
}
#ifndef GL_OES_VERSION_1_1
if(nptr == NULL) {
// Something went horribly wrong
// However, we should have an exception already
assert(PyErr_Occurred() != NULL);
return NULL;
}
#endif
gles_assign_array(GL_NORMAL_ARRAY, nptr, arrobj);
glNormalPointer(type, stride, nptr);
RETURN_IF_GLERROR;
RETURN_PYNONE;
}
extern "C" PyObject *gles_glNormalPointer(PyObject *self, PyObject *args) {
GLenum type;
GLsizei stride;
PyObject *pointerPy;
if ( !PyArg_ParseTuple(args, "iiO:glNormalPointer", &type, &stride, &pointerPy) ) {
return NULL;
}
if(pointerPy == Py_None) {
gles_free_array(GL_NORMAL_ARRAY);
RETURN_PYNONE;
}
return gles_wrap_glNormalPointer(type, stride, pointerPy);
}
extern "C" PyObject *gles_glNormalPointerb(PyObject *self, PyObject *args) {
PyObject *pointerPy;
if ( !PyArg_ParseTuple(args, "O:glNormalPointerb", &pointerPy) ) {
return NULL;
}
if(pointerPy == Py_None) {
gles_free_array(GL_NORMAL_ARRAY);
RETURN_PYNONE;
}
return gles_wrap_glNormalPointer(/*type*/GL_BYTE, /*stride*/0, pointerPy);
}
extern "C" PyObject *gles_glNormalPointers(PyObject *self, PyObject *args) {
PyObject *pointerPy;
if ( !PyArg_ParseTuple(args, "O:glNormalPointers", &pointerPy) ) {
return NULL;
}
if(pointerPy == Py_None) {
gles_free_array(GL_NORMAL_ARRAY);
RETURN_PYNONE;
}
return gles_wrap_glNormalPointer(/*type*/GL_SHORT, /*stride*/0, pointerPy);
}
extern "C" PyObject *gles_glNormalPointerf(PyObject *self, PyObject *args) {
PyObject *pointerPy;
if ( !PyArg_ParseTuple(args, "O:glNormalPointerf", &pointerPy) ) {
return NULL;
}
if(pointerPy == Py_None) {
gles_free_array(GL_NORMAL_ARRAY);
RETURN_PYNONE;
}
return gles_wrap_glNormalPointer(/*type*/GL_FLOAT, /*stride*/0, pointerPy);
}
extern "C" PyObject *gles_glNormalPointerx(PyObject *self, PyObject *args) {
PyObject *pointerPy;
if ( !PyArg_ParseTuple(args, "O:glNormalPointerx", &pointerPy) ) {
return NULL;
}
if(pointerPy == Py_None) {
gles_free_array(GL_NORMAL_ARRAY);
RETURN_PYNONE;
}
return gles_wrap_glNormalPointer(/*type*/GL_FIXED, /*stride*/0, pointerPy);
}
extern "C" PyObject *gles_glOrthof(PyObject *self, PyObject *args) {
GLfloat left;
GLfloat right;
GLfloat bottom;
GLfloat top;
GLfloat zNear;
GLfloat zFar;
if ( !PyArg_ParseTuple(args, "ffffff:glOrthof", &left, &right, &bottom, &top, &zNear, &zFar) ) {
return NULL;
}
glOrthof(left, right, bottom, top, zNear, zFar);
RETURN_IF_GLERROR;
RETURN_PYNONE;
}
extern "C" PyObject *gles_glOrthox(PyObject *self, PyObject *args) {
GLfixed left;
GLfixed right;
GLfixed bottom;
GLfixed top;
GLfixed zNear;
GLfixed zFar;
if ( !PyArg_ParseTuple(args, "iiiiii:glOrthox", &left, &right, &bottom, &top, &zNear, &zFar) ) {
return NULL;
}
glOrthox(left, right, bottom, top, zNear, zFar);
RETURN_IF_GLERROR;
RETURN_PYNONE;
}
extern "C" PyObject *gles_glPixelStorei(PyObject *self, PyObject *args) {
GLenum pname;
GLint param;
if ( !PyArg_ParseTuple(args, "ii:glPixelStorei", &pname, ¶m) ) {
return NULL;
}
glPixelStorei(pname, param);
RETURN_IF_GLERROR;
RETURN_PYNONE;
}
extern "C" PyObject *gles_glPointSize(PyObject *self, PyObject *args) {
GLfloat size;
if ( !PyArg_ParseTuple(args, "f:glPointSize", &size) ) {
return NULL;
}
glPointSize(size);
RETURN_IF_GLERROR;
RETURN_PYNONE;
}
extern "C" PyObject *gles_glPointSizex(PyObject *self, PyObject *args) {
GLfixed size;
if ( !PyArg_ParseTuple(args, "i:glPointSizex", &size) ) {
return NULL;
}
glPointSizex(size);
RETURN_IF_GLERROR;
RETURN_PYNONE;
}
extern "C" PyObject *gles_glPolygonOffset(PyObject *self, PyObject *args) {
GLfloat factor;
GLfloat units;
if ( !PyArg_ParseTuple(args, "ff:glPolygonOffset", &factor, &units) ) {
return NULL;
}
glPolygonOffset(factor, units);
RETURN_IF_GLERROR;
RETURN_PYNONE;
}
extern "C" PyObject *gles_glPolygonOffsetx(PyObject *self, PyObject *args) {
GLfixed factor;
GLfixed units;
if ( !PyArg_ParseTuple(args, "ii:glPolygonOffsetx", &factor, &units) ) {
return NULL;
}
glPolygonOffsetx(factor, units);
RETURN_IF_GLERROR;
RETURN_PYNONE;
}
extern "C" PyObject *gles_glPopMatrix(PyObject *self, PyObject */*args*/) {
glPopMatrix();
RETURN_IF_GLERROR;
RETURN_PYNONE;
}
extern "C" PyObject *gles_glPushMatrix(PyObject *self, PyObject */*args*/) {
glPushMatrix();
RETURN_IF_GLERROR;
RETURN_PYNONE;
}
extern "C" PyObject *gles_glReadPixels(PyObject *self, PyObject *args) {
GLint x;
GLint y;
GLsizei width;
GLsizei height;
GLenum format;
GLenum type;
GLvoid *pixels;
int len=0;
PyObject *pixelsPy=NULL;
if ( !PyArg_ParseTuple(args, "iiiiii:glReadPixels", &x, &y, &width, &height, &format, &type) ) {
return NULL;
}
// Determine the size of the result
switch(format) {
case GL_RGBA:
len = width*height*4;
break;
case GL_RGB:
len = width*height*3;
break;
case GL_LUMINANCE:
len = width*height;
break;
case GL_LUMINANCE_ALPHA:
len = width*height*2;
break;
case GL_ALPHA:
len = width*height;
break;
default:
PyErr_SetString(PyExc_ValueError, "Unsupported format");
return NULL;
}
pixels = gles_alloc( len*sizeof(GLubyte) );
if( pixels == NULL ) {
return PyErr_NoMemory();
}
glReadPixels(x, y, width, height, format, type, pixels);
// Make a string object out of the data
pixelsPy = PyString_FromStringAndSize( (char*)pixels, len);
gles_free(pixels);
RETURN_IF_GLERROR;
Py_INCREF(pixelsPy);
return pixelsPy;
}
extern "C" PyObject *gles_glRotatef(PyObject *self, PyObject *args) {
GLfloat angle;
GLfloat x;
GLfloat y;
GLfloat z;
if ( !PyArg_ParseTuple(args, "ffff:glRotatef", &angle, &x, &y, &z) ) {
return NULL;
}
glRotatef(angle, x, y, z);
RETURN_IF_GLERROR;
RETURN_PYNONE;
}
extern "C" PyObject *gles_glRotatex (PyObject *self, PyObject *args) {
GLfixed angle;
GLfixed x;
GLfixed y;
GLfixed z;
if ( !PyArg_ParseTuple(args, "iiii:glRotatex", &angle, &x, &y, &z) ) {
return NULL;
}
glRotatex(angle, x, y, z);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -