diff options
Diffstat (limited to 'xc/lib/GL/glx/single2.c')
-rw-r--r-- | xc/lib/GL/glx/single2.c | 124 |
1 files changed, 124 insertions, 0 deletions
diff --git a/xc/lib/GL/glx/single2.c b/xc/lib/GL/glx/single2.c index a027ff129..3c1fc939c 100644 --- a/xc/lib/GL/glx/single2.c +++ b/xc/lib/GL/glx/single2.c @@ -38,6 +38,58 @@ #include "glxclient.h" #include "packsingle.h" +/* Used for GL_ARB_transpose_matrix */ +static void TransposeMatrixf(GLfloat m[16]) +{ + int i, j; + for (i = 0; i < 4; i++) { + for (j = 0; j < i; j++) { + GLfloat tmp = m[i*4+j]; + m[i*4+j] = m[j*4+i]; + m[j*4+i] = tmp; + } + } +} + +/* Used for GL_ARB_transpose_matrix */ +static void TransposeMatrixb(GLboolean m[16]) +{ + int i, j; + for (i = 0; i < 4; i++) { + for (j = 0; j < i; j++) { + GLboolean tmp = m[i*4+j]; + m[i*4+j] = m[j*4+i]; + m[j*4+i] = tmp; + } + } +} + +/* Used for GL_ARB_transpose_matrix */ +static void TransposeMatrixd(GLdouble m[16]) +{ + int i, j; + for (i = 0; i < 4; i++) { + for (j = 0; j < i; j++) { + GLdouble tmp = m[i*4+j]; + m[i*4+j] = m[j*4+i]; + m[j*4+i] = tmp; + } + } +} + +/* Used for GL_ARB_transpose_matrix */ +static void TransposeMatrixi(GLint m[16]) +{ + int i, j; + for (i = 0; i < 4; i++) { + for (j = 0; j < i; j++) { + GLint tmp = m[i*4+j]; + m[i*4+j] = m[j*4+i]; + m[j*4+i] = tmp; + } + } +} + GLenum glGetError(void) { __GLX_SINGLE_DECLARE_VARIABLES(); @@ -76,9 +128,23 @@ void glGetClipPlane(GLenum plane, GLdouble *equation) void glGetBooleanv(GLenum val, GLboolean *b) { + const GLenum origVal = val; __GLX_SINGLE_DECLARE_VARIABLES(); xGLXSingleReply reply; + if (val == GL_TRANSPOSE_MODELVIEW_MATRIX_ARB) { + val = GL_MODELVIEW_MATRIX; + } + else if (val == GL_TRANSPOSE_PROJECTION_MATRIX_ARB) { + val = GL_PROJECTION_MATRIX; + } + else if (val == GL_TRANSPOSE_TEXTURE_MATRIX_ARB) { + val = GL_TEXTURE_MATRIX; + } + else if (val == GL_TRANSPOSE_COLOR_MATRIX_ARB) { + val = GL_COLOR_MATRIX; + } + __GLX_SINGLE_LOAD_VARIABLES(); __GLX_SINGLE_BEGIN(X_GLsop_GetBooleanv,4); __GLX_SINGLE_PUT_LONG(0,val); @@ -226,6 +292,10 @@ void glGetBooleanv(GLenum val, GLboolean *b) __GLX_SINGLE_GET_CHAR(b); } else { __GLX_SINGLE_GET_CHAR_ARRAY(b,compsize); + if (val != origVal) { + /* matrix transpose */ + TransposeMatrixb(b); + } } } } @@ -234,9 +304,23 @@ void glGetBooleanv(GLenum val, GLboolean *b) void glGetDoublev(GLenum val, GLdouble *d) { + const GLenum origVal = val; __GLX_SINGLE_DECLARE_VARIABLES(); xGLXSingleReply reply; + if (val == GL_TRANSPOSE_MODELVIEW_MATRIX_ARB) { + val = GL_MODELVIEW_MATRIX; + } + else if (val == GL_TRANSPOSE_PROJECTION_MATRIX_ARB) { + val = GL_PROJECTION_MATRIX; + } + else if (val == GL_TRANSPOSE_TEXTURE_MATRIX_ARB) { + val = GL_TEXTURE_MATRIX; + } + else if (val == GL_TRANSPOSE_COLOR_MATRIX_ARB) { + val = GL_COLOR_MATRIX; + } + __GLX_SINGLE_LOAD_VARIABLES(); __GLX_SINGLE_BEGIN(X_GLsop_GetDoublev,4); __GLX_SINGLE_PUT_LONG(0,val); @@ -384,6 +468,10 @@ void glGetDoublev(GLenum val, GLdouble *d) __GLX_SINGLE_GET_DOUBLE(d); } else { __GLX_SINGLE_GET_DOUBLE_ARRAY(d,compsize); + if (val != origVal) { + /* matrix transpose */ + TransposeMatrixd(d); + } } } } @@ -392,9 +480,23 @@ void glGetDoublev(GLenum val, GLdouble *d) void glGetFloatv(GLenum val, GLfloat *f) { + const GLenum origVal = val; __GLX_SINGLE_DECLARE_VARIABLES(); xGLXSingleReply reply; + if (val == GL_TRANSPOSE_MODELVIEW_MATRIX_ARB) { + val = GL_MODELVIEW_MATRIX; + } + else if (val == GL_TRANSPOSE_PROJECTION_MATRIX_ARB) { + val = GL_PROJECTION_MATRIX; + } + else if (val == GL_TRANSPOSE_TEXTURE_MATRIX_ARB) { + val = GL_TEXTURE_MATRIX; + } + else if (val == GL_TRANSPOSE_COLOR_MATRIX_ARB) { + val = GL_COLOR_MATRIX; + } + __GLX_SINGLE_LOAD_VARIABLES(); __GLX_SINGLE_BEGIN(X_GLsop_GetFloatv,4); __GLX_SINGLE_PUT_LONG(0,val); @@ -542,6 +644,10 @@ void glGetFloatv(GLenum val, GLfloat *f) __GLX_SINGLE_GET_FLOAT(f); } else { __GLX_SINGLE_GET_FLOAT_ARRAY(f,compsize); + if (val != origVal) { + /* matrix transpose */ + TransposeMatrixf(f); + } } } } @@ -550,9 +656,23 @@ void glGetFloatv(GLenum val, GLfloat *f) void glGetIntegerv(GLenum val, GLint *i) { + const GLenum origVal = val; __GLX_SINGLE_DECLARE_VARIABLES(); xGLXSingleReply reply; + if (val == GL_TRANSPOSE_MODELVIEW_MATRIX_ARB) { + val = GL_MODELVIEW_MATRIX; + } + else if (val == GL_TRANSPOSE_PROJECTION_MATRIX_ARB) { + val = GL_PROJECTION_MATRIX; + } + else if (val == GL_TRANSPOSE_TEXTURE_MATRIX_ARB) { + val = GL_TEXTURE_MATRIX; + } + else if (val == GL_TRANSPOSE_COLOR_MATRIX_ARB) { + val = GL_COLOR_MATRIX; + } + __GLX_SINGLE_LOAD_VARIABLES(); __GLX_SINGLE_BEGIN(X_GLsop_GetIntegerv,4); __GLX_SINGLE_PUT_LONG(0,val); @@ -700,6 +820,10 @@ void glGetIntegerv(GLenum val, GLint *i) __GLX_SINGLE_GET_LONG(i); } else { __GLX_SINGLE_GET_LONG_ARRAY(i,compsize); + if (val != origVal) { + /* matrix transpose */ + TransposeMatrixi(i); + } } } } |