#include <math.h>
#include <stdio.h>
#include <stdlib.h>
-//#include "gluP.h"
#endif
/*
* Compute ceiling of integer quotient of A divided by B:
*/
-#define CEILING( A, B ) ( (A) % (B) == 0 ? (A)/(B) : (A)/(B)+1 )
+#define CEILING(A, B) ((A) % (B) == 0 ? (A) / (B) : (A) / (B) + 1)
/* To work around optimizer bug in MSVC4.1 */
#if defined(__WIN32__) && !defined(OPENSTEP)
-void
-dummy(GLuint j, GLuint k)
+void dummy(GLuint j, GLuint k)
{
}
#else
#endif
-static GLint GLAPIENTRY
-mesa_gluScaleImage(GLenum format,
- GLsizei widthin, GLsizei heightin,
- GLenum typein, const void *datain,
- GLsizei widthout, GLsizei heightout,
- GLenum typeout, void *dataout)
+static GLint GLAPIENTRY mesa_gluScaleImage(GLenum format,
+ GLsizei widthin, GLsizei heightin,
+ GLenum typein, const void *datain,
+ GLsizei widthout, GLsizei heightout,
+ GLenum typeout, void *dataout)
{
- GLint components, i, j, k;
- GLfloat *tempin, *tempout;
- GLfloat sx, sy;
- GLint unpackrowlength, unpackalignment, unpackskiprows, unpackskippixels;
- GLint packrowlength, packalignment, packskiprows, packskippixels;
- GLint sizein, sizeout;
- GLint rowstride, rowlen;
-
-
- /* Determine number of components per pixel */
- switch (format) {
- case GL_COLOR_INDEX:
- case GL_STENCIL_INDEX:
- case GL_DEPTH_COMPONENT:
- case GL_RED:
- case GL_GREEN:
- case GL_BLUE:
- case GL_ALPHA:
- case GL_LUMINANCE:
- components = 1;
- break;
- case GL_LUMINANCE_ALPHA:
- components = 2;
- break;
- case GL_RGB:
- case GL_BGR:
- components = 3;
- break;
- case GL_RGBA:
- case GL_BGRA:
+ GLint components, i, j, k;
+ GLfloat *tempin, *tempout;
+ GLfloat sx, sy;
+ GLint unpackrowlength, unpackalignment, unpackskiprows, unpackskippixels;
+ GLint packrowlength, packalignment, packskiprows, packskippixels;
+ GLint sizein, sizeout;
+ GLint rowstride, rowlen;
+
+ /* Determine number of components per pixel */
+ switch (format) {
+ case GL_COLOR_INDEX:
+ case GL_STENCIL_INDEX:
+ case GL_DEPTH_COMPONENT:
+ case GL_RED:
+ case GL_GREEN:
+ case GL_BLUE:
+ case GL_ALPHA:
+ case GL_LUMINANCE:
+ components = 1;
+ break;
+ case GL_LUMINANCE_ALPHA:
+ components = 2;
+ break;
+ case GL_RGB:
+ case GL_BGR:
+ components = 3;
+ break;
+ case GL_RGBA:
+ case GL_BGRA:
#ifdef GL_EXT_abgr
- case GL_ABGR_EXT:
+ case GL_ABGR_EXT:
#endif
- components = 4;
- break;
- default:
- return GLU_INVALID_ENUM;
- }
-
- /* Determine bytes per input datum */
- switch (typein) {
- case GL_UNSIGNED_BYTE:
- sizein = sizeof(GLubyte);
- break;
- case GL_BYTE:
- sizein = sizeof(GLbyte);
- break;
- case GL_UNSIGNED_SHORT:
- sizein = sizeof(GLushort);
- break;
- case GL_SHORT:
- sizein = sizeof(GLshort);
- break;
- case GL_UNSIGNED_INT:
- sizein = sizeof(GLuint);
- break;
- case GL_INT:
- sizein = sizeof(GLint);
- break;
- case GL_FLOAT:
- sizein = sizeof(GLfloat);
- break;
- case GL_BITMAP:
- /* not implemented yet */
- default:
- return GL_INVALID_ENUM;
- }
-
- /* Determine bytes per output datum */
- switch (typeout) {
- case GL_UNSIGNED_BYTE:
- sizeout = sizeof(GLubyte);
- break;
- case GL_BYTE:
- sizeout = sizeof(GLbyte);
- break;
- case GL_UNSIGNED_SHORT:
- sizeout = sizeof(GLushort);
- break;
- case GL_SHORT:
- sizeout = sizeof(GLshort);
- break;
- case GL_UNSIGNED_INT:
- sizeout = sizeof(GLuint);
- break;
- case GL_INT:
- sizeout = sizeof(GLint);
- break;
- case GL_FLOAT:
- sizeout = sizeof(GLfloat);
- break;
- case GL_BITMAP:
- /* not implemented yet */
- default:
- return GL_INVALID_ENUM;
- }
-
- /* Get glPixelStore state */
- glGetIntegerv(GL_UNPACK_ROW_LENGTH, &unpackrowlength);
- glGetIntegerv(GL_UNPACK_ALIGNMENT, &unpackalignment);
- glGetIntegerv(GL_UNPACK_SKIP_ROWS, &unpackskiprows);
- glGetIntegerv(GL_UNPACK_SKIP_PIXELS, &unpackskippixels);
- glGetIntegerv(GL_PACK_ROW_LENGTH, &packrowlength);
- glGetIntegerv(GL_PACK_ALIGNMENT, &packalignment);
- glGetIntegerv(GL_PACK_SKIP_ROWS, &packskiprows);
- glGetIntegerv(GL_PACK_SKIP_PIXELS, &packskippixels);
-
- /* Allocate storage for intermediate images */
- tempin = (GLfloat *) malloc(widthin * heightin
- * components * sizeof(GLfloat));
- if (!tempin) {
- return GLU_OUT_OF_MEMORY;
- }
- tempout = (GLfloat *) malloc(widthout * heightout
- * components * sizeof(GLfloat));
- if (!tempout) {
- free(tempin);
- return GLU_OUT_OF_MEMORY;
- }
-
-
- /*
- * Unpack the pixel data and convert to floating point
- */
-
- if (unpackrowlength > 0) {
- rowlen = unpackrowlength;
- }
- else {
- rowlen = widthin;
- }
- if (sizein >= unpackalignment) {
- rowstride = components * rowlen;
- }
- else {
- rowstride = unpackalignment / sizein
- * CEILING(components * rowlen * sizein, unpackalignment);
- }
-
- switch (typein) {
- case GL_UNSIGNED_BYTE:
- k = 0;
- for (i = 0; i < heightin; i++) {
- GLubyte *ubptr = (GLubyte *) datain
- + i * rowstride
- + unpackskiprows * rowstride + unpackskippixels * components;
- for (j = 0; j < widthin * components; j++) {
- dummy(j, k);
- tempin[k++] = (GLfloat) * ubptr++;
- }
- }
- break;
- case GL_BYTE:
- k = 0;
- for (i = 0; i < heightin; i++) {
- GLbyte *bptr = (GLbyte *) datain
- + i * rowstride
- + unpackskiprows * rowstride + unpackskippixels * components;
- for (j = 0; j < widthin * components; j++) {
- dummy(j, k);
- tempin[k++] = (GLfloat) * bptr++;
- }
- }
- break;
- case GL_UNSIGNED_SHORT:
- k = 0;
- for (i = 0; i < heightin; i++) {
- GLushort *usptr = (GLushort *) datain
- + i * rowstride
- + unpackskiprows * rowstride + unpackskippixels * components;
- for (j = 0; j < widthin * components; j++) {
- dummy(j, k);
- tempin[k++] = (GLfloat) * usptr++;
- }
- }
- break;
- case GL_SHORT:
- k = 0;
- for (i = 0; i < heightin; i++) {
- GLshort *sptr = (GLshort *) datain
- + i * rowstride
- + unpackskiprows * rowstride + unpackskippixels * components;
- for (j = 0; j < widthin * components; j++) {
- dummy(j, k);
- tempin[k++] = (GLfloat) * sptr++;
- }
- }
- break;
- case GL_UNSIGNED_INT:
- k = 0;
- for (i = 0; i < heightin; i++) {
- GLuint *uiptr = (GLuint *) datain
- + i * rowstride
- + unpackskiprows * rowstride + unpackskippixels * components;
- for (j = 0; j < widthin * components; j++) {
- dummy(j, k);
- tempin[k++] = (GLfloat) * uiptr++;
- }
- }
- break;
- case GL_INT:
- k = 0;
- for (i = 0; i < heightin; i++) {
- GLint *iptr = (GLint *) datain
- + i * rowstride
- + unpackskiprows * rowstride + unpackskippixels * components;
- for (j = 0; j < widthin * components; j++) {
- dummy(j, k);
- tempin[k++] = (GLfloat) * iptr++;
- }
- }
- break;
- case GL_FLOAT:
- k = 0;
- for (i = 0; i < heightin; i++) {
- GLfloat *fptr = (GLfloat *) datain
- + i * rowstride
- + unpackskiprows * rowstride + unpackskippixels * components;
- for (j = 0; j < widthin * components; j++) {
- dummy(j, k);
- tempin[k++] = *fptr++;
- }
- }
- break;
- default:
- return GLU_INVALID_ENUM;
- }
-
-
- /*
- * Scale the image!
- */
-
- if (widthout > 1)
- sx = (GLfloat) (widthin - 1) / (GLfloat) (widthout - 1);
- else
- sx = (GLfloat) (widthin - 1);
- if (heightout > 1)
- sy = (GLfloat) (heightin - 1) / (GLfloat) (heightout - 1);
- else
- sy = (GLfloat) (heightin - 1);
+ components = 4;
+ break;
+ default:
+ return GLU_INVALID_ENUM;
+ }
+
+ /* Determine bytes per input datum */
+ switch (typein) {
+ case GL_UNSIGNED_BYTE:
+ sizein = sizeof(GLubyte);
+ break;
+ case GL_BYTE:
+ sizein = sizeof(GLbyte);
+ break;
+ case GL_UNSIGNED_SHORT:
+ sizein = sizeof(GLushort);
+ break;
+ case GL_SHORT:
+ sizein = sizeof(GLshort);
+ break;
+ case GL_UNSIGNED_INT:
+ sizein = sizeof(GLuint);
+ break;
+ case GL_INT:
+ sizein = sizeof(GLint);
+ break;
+ case GL_FLOAT:
+ sizein = sizeof(GLfloat);
+ break;
+ case GL_BITMAP:
+ /* not implemented yet */
+ default:
+ return GL_INVALID_ENUM;
+ }
+
+ /* Determine bytes per output datum */
+ switch (typeout) {
+ case GL_UNSIGNED_BYTE:
+ sizeout = sizeof(GLubyte);
+ break;
+ case GL_BYTE:
+ sizeout = sizeof(GLbyte);
+ break;
+ case GL_UNSIGNED_SHORT:
+ sizeout = sizeof(GLushort);
+ break;
+ case GL_SHORT:
+ sizeout = sizeof(GLshort);
+ break;
+ case GL_UNSIGNED_INT:
+ sizeout = sizeof(GLuint);
+ break;
+ case GL_INT:
+ sizeout = sizeof(GLint);
+ break;
+ case GL_FLOAT:
+ sizeout = sizeof(GLfloat);
+ break;
+ case GL_BITMAP:
+ /* not implemented yet */
+ default:
+ return GL_INVALID_ENUM;
+ }
+
+ /* Get glPixelStore state */
+ glGetIntegerv(GL_UNPACK_ROW_LENGTH, &unpackrowlength);
+ glGetIntegerv(GL_UNPACK_ALIGNMENT, &unpackalignment);
+ glGetIntegerv(GL_UNPACK_SKIP_ROWS, &unpackskiprows);
+ glGetIntegerv(GL_UNPACK_SKIP_PIXELS, &unpackskippixels);
+ glGetIntegerv(GL_PACK_ROW_LENGTH, &packrowlength);
+ glGetIntegerv(GL_PACK_ALIGNMENT, &packalignment);
+ glGetIntegerv(GL_PACK_SKIP_ROWS, &packskiprows);
+ glGetIntegerv(GL_PACK_SKIP_PIXELS, &packskippixels);
+
+ /* Allocate storage for intermediate images */
+ tempin = (GLfloat *)malloc(widthin * heightin * components *
+ sizeof(GLfloat));
+ if (!tempin) {
+ return GLU_OUT_OF_MEMORY;
+ }
+ tempout = (GLfloat *)malloc(widthout * heightout * components *
+ sizeof(GLfloat));
+ if (!tempout) {
+ free(tempin);
+ return GLU_OUT_OF_MEMORY;
+ }
+
+
+ /*
+ * Unpack the pixel data and convert to floating point
+ */
+
+ if (unpackrowlength > 0) {
+ rowlen = unpackrowlength;
+ } else {
+ rowlen = widthin;
+ }
+ if (sizein >= unpackalignment) {
+ rowstride = components * rowlen;
+ } else {
+ rowstride = unpackalignment / sizein * CEILING(components *
+ rowlen * sizein,
+ unpackalignment);
+ }
+
+ switch (typein) {
+ case GL_UNSIGNED_BYTE:
+ k = 0;
+ for (i = 0; i < heightin; i++) {
+ GLubyte *ubptr = (GLubyte *)datain + i * rowstride
+ + unpackskiprows * rowstride
+ + unpackskippixels * components;
+ for (j = 0; j < widthin * components; j++) {
+ dummy(j, k);
+ tempin[k++] = (GLfloat)*ubptr++;
+ }
+ }
+ break;
+ case GL_BYTE:
+ k = 0;
+ for (i = 0; i < heightin; i++) {
+ GLbyte *bptr = (GLbyte *)datain + i * rowstride
+ + unpackskiprows * rowstride
+ + unpackskippixels * components;
+ for (j = 0; j < widthin * components; j++) {
+ dummy(j, k);
+ tempin[k++] = (GLfloat)*bptr++;
+ }
+ }
+ break;
+ case GL_UNSIGNED_SHORT:
+ k = 0;
+ for (i = 0; i < heightin; i++) {
+ GLushort *usptr = (GLushort *)datain + i * rowstride
+ + unpackskiprows * rowstride
+ + unpackskippixels * components;
+ for (j = 0; j < widthin * components; j++) {
+ dummy(j, k);
+ tempin[k++] = (GLfloat)*usptr++;
+ }
+ }
+ break;
+ case GL_SHORT:
+ k = 0;
+ for (i = 0; i < heightin; i++) {
+ GLshort *sptr = (GLshort *)datain + i * rowstride
+ + unpackskiprows * rowstride
+ + unpackskippixels * components;
+ for (j = 0; j < widthin * components; j++) {
+ dummy(j, k);
+ tempin[k++] = (GLfloat)*sptr++;
+ }
+ }
+ break;
+ case GL_UNSIGNED_INT:
+ k = 0;
+ for (i = 0; i < heightin; i++) {
+ GLuint *uiptr = (GLuint *)datain + i * rowstride
+ + unpackskiprows * rowstride
+ + unpackskippixels * components;
+ for (j = 0; j < widthin * components; j++) {
+ dummy(j, k);
+ tempin[k++] = (GLfloat)*uiptr++;
+ }
+ }
+ break;
+ case GL_INT:
+ k = 0;
+ for (i = 0; i < heightin; i++) {
+ GLint *iptr = (GLint *)datain + i * rowstride
+ + unpackskiprows * rowstride
+ + unpackskippixels * components;
+ for (j = 0; j < widthin * components; j++) {
+ dummy(j, k);
+ tempin[k++] = (GLfloat)*iptr++;
+ }
+ }
+ break;
+ case GL_FLOAT:
+ k = 0;
+ for (i = 0; i < heightin; i++) {
+ GLfloat *fptr = (GLfloat *)datain + i * rowstride
+ + unpackskiprows * rowstride
+ + unpackskippixels * components;
+ for (j = 0; j < widthin * components; j++) {
+ dummy(j, k);
+ tempin[k++] = *fptr++;
+ }
+ }
+ break;
+ default:
+ return GLU_INVALID_ENUM;
+ }
+
+ /*
+ * Scale the image!
+ */
+
+ if (widthout > 1) {
+ sx = (GLfloat) (widthin - 1) / (GLfloat) (widthout - 1);
+ } else {
+ sx = (GLfloat) (widthin - 1);
+ }
+ if (heightout > 1) {
+ sy = (GLfloat) (heightin - 1) / (GLfloat) (heightout - 1);
+ } else {
+ sy = (GLfloat) (heightin - 1);
+ }
/*#define POINT_SAMPLE*/
#ifdef POINT_SAMPLE
- for (i = 0; i < heightout; i++) {
- GLint ii = i * sy;
- for (j = 0; j < widthout; j++) {
- GLint jj = j * sx;
-
- GLfloat *src = tempin + (ii * widthin + jj) * components;
- GLfloat *dst = tempout + (i * widthout + j) * components;
-
- for (k = 0; k < components; k++) {
- *dst++ = *src++;
- }
- }
- }
+ for (i = 0; i < heightout; i++) {
+ GLint ii = i * sy;
+ for (j = 0; j < widthout; j++) {
+ GLint jj = j * sx;
+
+ GLfloat *src = tempin + (ii * widthin + jj) * components;
+ GLfloat *dst = tempout + (i * widthout + j) * components;
+
+ for (k = 0; k < components; k++) {
+ *dst++ = *src++;
+ }
+ }
+ }
#else
- if (sx < 1.0 && sy < 1.0) {
- /* magnify both width and height: use weighted sample of 4 pixels */
- GLint i0, i1, j0, j1;
- GLfloat alpha, beta;
- GLfloat *src00, *src01, *src10, *src11;
- GLfloat s1, s2;
- GLfloat *dst;
-
- for (i = 0; i < heightout; i++) {
- i0 = i * sy;
- i1 = i0 + 1;
- if (i1 >= heightin)
- i1 = heightin - 1;
-/* i1 = (i+1) * sy - EPSILON;*/
- alpha = i * sy - i0;
- for (j = 0; j < widthout; j++) {
- j0 = j * sx;
- j1 = j0 + 1;
- if (j1 >= widthin)
- j1 = widthin - 1;
-/* j1 = (j+1) * sx - EPSILON; */
- beta = j * sx - j0;
-
- /* compute weighted average of pixels in rect (i0,j0)-(i1,j1) */
- src00 = tempin + (i0 * widthin + j0) * components;
- src01 = tempin + (i0 * widthin + j1) * components;
- src10 = tempin + (i1 * widthin + j0) * components;
- src11 = tempin + (i1 * widthin + j1) * components;
-
- dst = tempout + (i * widthout + j) * components;
-
- for (k = 0; k < components; k++) {
- s1 = *src00++ * (1.0 - beta) + *src01++ * beta;
- s2 = *src10++ * (1.0 - beta) + *src11++ * beta;
- *dst++ = s1 * (1.0 - alpha) + s2 * alpha;
- }
- }
- }
- }
- else {
- /* shrink width and/or height: use an unweighted box filter */
- GLint i0, i1;
- GLint j0, j1;
- GLint ii, jj;
- GLfloat sum, *dst;
-
- for (i = 0; i < heightout; i++) {
- i0 = i * sy;
- i1 = i0 + 1;
- if (i1 >= heightin)
- i1 = heightin - 1;
-/* i1 = (i+1) * sy - EPSILON; */
- for (j = 0; j < widthout; j++) {
- j0 = j * sx;
- j1 = j0 + 1;
- if (j1 >= widthin)
- j1 = widthin - 1;
-/* j1 = (j+1) * sx - EPSILON; */
-
- dst = tempout + (i * widthout + j) * components;
-
- /* compute average of pixels in the rectangle (i0,j0)-(i1,j1) */
- for (k = 0; k < components; k++) {
- sum = 0.0;
- for (ii = i0; ii <= i1; ii++) {
- for (jj = j0; jj <= j1; jj++) {
- sum += *(tempin + (ii * widthin + jj) * components + k);
- }
- }
- sum /= (j1 - j0 + 1) * (i1 - i0 + 1);
- *dst++ = sum;
- }
- }
- }
- }
+ if (sx < 1.0 && sy < 1.0) {
+ /* magnify both width and height: use weighted sample of 4 pixels */
+ GLint i0, i1, j0, j1;
+ GLfloat alpha, beta;
+ GLfloat *src00, *src01, *src10, *src11;
+ GLfloat s1, s2;
+ GLfloat *dst;
+
+ for (i = 0; i < heightout; i++) {
+ i0 = i * sy;
+ i1 = i0 + 1;
+ if (i1 >= heightin) {
+ i1 = heightin - 1;
+ }
+ /* i1 = (i+1) * sy - EPSILON; */
+ alpha = i * sy - i0;
+ for (j = 0; j < widthout; j++) {
+ j0 = j * sx;
+ j1 = j0 + 1;
+ if (j1 >= widthin) {
+ j1 = widthin - 1;
+ }
+ /* j1 = (j+1) * sx - EPSILON; */
+ beta = j * sx - j0;
+
+ /* compute weighted average of pixels
+ in rect (i0, j0) - (i1, j1) */
+ src00 = tempin + (i0 * widthin + j0) * components;
+ src01 = tempin + (i0 * widthin + j1) * components;
+ src10 = tempin + (i1 * widthin + j0) * components;
+ src11 = tempin + (i1 * widthin + j1) * components;
+
+ dst = tempout + (i * widthout + j) * components;
+
+ for (k = 0; k < components; k++) {
+ s1 = *src00++ * (1.0 - beta) + *src01++ * beta;
+ s2 = *src10++ * (1.0 - beta) + *src11++ * beta;
+ *dst++ = s1 * (1.0 - alpha) + s2 * alpha;
+ }
+ }
+ }
+ } else {
+ /* shrink width and/or height: use an unweighted box filter */
+ GLint i0, i1;
+ GLint j0, j1;
+ GLint ii, jj;
+ GLfloat sum, *dst;
+
+ for (i = 0; i < heightout; i++) {
+ i0 = i * sy;
+ i1 = i0 + 1;
+ if (i1 >= heightin) {
+ i1 = heightin - 1;
+ }
+ /* i1 = (i+1) * sy - EPSILON; */
+ for (j = 0; j < widthout; j++) {
+ j0 = j * sx;
+ j1 = j0 + 1;
+ if (j1 >= widthin) {
+ j1 = widthin - 1;
+ }
+ /* j1 = (j+1) * sx - EPSILON; */
+
+ dst = tempout + (i * widthout + j) * components;
+
+ /* compute average of pixels
+ in the rectangle (i0, j0) - (i1, j1) */
+ for (k = 0; k < components; k++) {
+ sum = 0.0;
+ for (ii = i0; ii <= i1; ii++) {
+ for (jj = j0; jj <= j1; jj++) {
+ sum += *(tempin + (ii * widthin + jj) *
+ components + k);
+ }
+ }
+ sum /= (j1 - j0 + 1) * (i1 - i0 + 1);
+ *dst++ = sum;
+ }
+ }
+ }
+ }
#endif
- /*
- * Return output image
- */
-
- if (packrowlength > 0) {
- rowlen = packrowlength;
- }
- else {
- rowlen = widthout;
- }
- if (sizeout >= packalignment) {
- rowstride = components * rowlen;
- }
- else {
- rowstride = packalignment / sizeout
- * CEILING(components * rowlen * sizeout, packalignment);
- }
-
- switch (typeout) {
- case GL_UNSIGNED_BYTE:
- k = 0;
- for (i = 0; i < heightout; i++) {
- GLubyte *ubptr = (GLubyte *) dataout
- + i * rowstride
- + packskiprows * rowstride + packskippixels * components;
- for (j = 0; j < widthout * components; j++) {
- dummy(j, k + i);
- *ubptr++ = (GLubyte) tempout[k++];
- }
- }
- break;
- case GL_BYTE:
- k = 0;
- for (i = 0; i < heightout; i++) {
- GLbyte *bptr = (GLbyte *) dataout
- + i * rowstride
- + packskiprows * rowstride + packskippixels * components;
- for (j = 0; j < widthout * components; j++) {
- dummy(j, k + i);
- *bptr++ = (GLbyte) tempout[k++];
- }
- }
- break;
- case GL_UNSIGNED_SHORT:
- k = 0;
- for (i = 0; i < heightout; i++) {
- GLushort *usptr = (GLushort *) dataout
- + i * rowstride
- + packskiprows * rowstride + packskippixels * components;
- for (j = 0; j < widthout * components; j++) {
- dummy(j, k + i);
- *usptr++ = (GLushort) tempout[k++];
- }
- }
- break;
- case GL_SHORT:
- k = 0;
- for (i = 0; i < heightout; i++) {
- GLshort *sptr = (GLshort *) dataout
- + i * rowstride
- + packskiprows * rowstride + packskippixels * components;
- for (j = 0; j < widthout * components; j++) {
- dummy(j, k + i);
- *sptr++ = (GLshort) tempout[k++];
- }
- }
- break;
- case GL_UNSIGNED_INT:
- k = 0;
- for (i = 0; i < heightout; i++) {
- GLuint *uiptr = (GLuint *) dataout
- + i * rowstride
- + packskiprows * rowstride + packskippixels * components;
- for (j = 0; j < widthout * components; j++) {
- dummy(j, k + i);
- *uiptr++ = (GLuint) tempout[k++];
- }
- }
- break;
- case GL_INT:
- k = 0;
- for (i = 0; i < heightout; i++) {
- GLint *iptr = (GLint *) dataout
- + i * rowstride
- + packskiprows * rowstride + packskippixels * components;
- for (j = 0; j < widthout * components; j++) {
- dummy(j, k + i);
- *iptr++ = (GLint) tempout[k++];
- }
- }
- break;
- case GL_FLOAT:
- k = 0;
- for (i = 0; i < heightout; i++) {
- GLfloat *fptr = (GLfloat *) dataout
- + i * rowstride
- + packskiprows * rowstride + packskippixels * components;
- for (j = 0; j < widthout * components; j++) {
- dummy(j, k + i);
- *fptr++ = tempout[k++];
- }
- }
- break;
- default:
- return GLU_INVALID_ENUM;
- }
-
-
- /* free temporary image storage */
- free(tempin);
- free(tempout);
-
- return 0;
+ /*
+ * Return output image
+ */
+
+ if (packrowlength > 0) {
+ rowlen = packrowlength;
+ } else {
+ rowlen = widthout;
+ }
+ if (sizeout >= packalignment) {
+ rowstride = components * rowlen;
+ } else {
+ rowstride = packalignment / sizeout * CEILING(components * rowlen *
+ sizeout, packalignment);
+ }
+
+ switch (typeout) {
+ case GL_UNSIGNED_BYTE:
+ k = 0;
+ for (i = 0; i < heightout; i++) {
+ GLubyte *ubptr = (GLubyte *)dataout + i * rowstride
+ + packskiprows * rowstride
+ + packskippixels * components;
+ for (j = 0; j < widthout * components; j++) {
+ dummy(j, k + i);
+ *ubptr++ = (GLubyte)tempout[k++];
+ }
+ }
+ break;
+ case GL_BYTE:
+ k = 0;
+ for (i = 0; i < heightout; i++) {
+ GLbyte *bptr = (GLbyte *)dataout + i * rowstride
+ + packskiprows * rowstride
+ + packskippixels * components;
+ for (j = 0; j < widthout * components; j++) {
+ dummy(j, k + i);
+ *bptr++ = (GLbyte)tempout[k++];
+ }
+ }
+ break;
+ case GL_UNSIGNED_SHORT:
+ k = 0;
+ for (i = 0; i < heightout; i++) {
+ GLushort *usptr = (GLushort *)dataout + i * rowstride
+ + packskiprows * rowstride
+ + packskippixels * components;
+ for (j = 0; j < widthout * components; j++) {
+ dummy(j, k + i);
+ *usptr++ = (GLushort)tempout[k++];
+ }
+ }
+ break;
+ case GL_SHORT:
+ k = 0;
+ for (i = 0; i < heightout; i++) {
+ GLshort *sptr = (GLshort *)dataout + i * rowstride
+ + packskiprows * rowstride
+ + packskippixels * components;
+ for (j = 0; j < widthout * components; j++) {
+ dummy(j, k + i);
+ *sptr++ = (GLshort)tempout[k++];
+ }
+ }
+ break;
+ case GL_UNSIGNED_INT:
+ k = 0;
+ for (i = 0; i < heightout; i++) {
+ GLuint *uiptr = (GLuint *)dataout + i * rowstride
+ + packskiprows * rowstride
+ + packskippixels * components;
+ for (j = 0; j < widthout * components; j++) {
+ dummy(j, k + i);
+ *uiptr++ = (GLuint)tempout[k++];
+ }
+ }
+ break;
+ case GL_INT:
+ k = 0;
+ for (i = 0; i < heightout; i++) {
+ GLint *iptr = (GLint *)dataout + i * rowstride
+ + packskiprows * rowstride
+ + packskippixels * components;
+ for (j = 0; j < widthout * components; j++) {
+ dummy(j, k + i);
+ *iptr++ = (GLint)tempout[k++];
+ }
+ }
+ break;
+ case GL_FLOAT:
+ k = 0;
+ for (i = 0; i < heightout; i++) {
+ GLfloat *fptr = (GLfloat *)dataout + i * rowstride
+ + packskiprows * rowstride + packskippixels
+ * components;
+ for (j = 0; j < widthout * components; j++) {
+ dummy(j, k + i);
+ *fptr++ = tempout[k++];
+ }
+ }
+ break;
+ default:
+ return GLU_INVALID_ENUM;
+ }
+
+
+ /* free temporary image storage */
+ free(tempin);
+ free(tempout);
+
+ return 0;
}
/*
* Return the largest k such that 2^k <= n.
*/
-static GLint
-ilog2(GLint n)
+static GLint ilog2(GLint n)
{
- GLint k;
-
- if (n <= 0)
- return 0;
- for (k = 0; n >>= 1; k++);
- return k;
+ GLint k;
+
+ if (n <= 0) {
+ return 0;
+ }
+ for (k = 0; n >>= 1; k++) {
+ ;
+ }
+ return k;
}
/*
* Find the value nearest to n which is also a power of two.
*/
-static GLint
-round2(GLint n)
+static GLint round2(GLint n)
{
- GLint m;
-
- for (m = 1; m < n; m *= 2);
-
- /* m>=n */
- if (m - n <= n - m / 2) {
- return m;
- }
- else {
- return m / 2;
- }
+ GLint m;
+
+ for (m = 1; m < n; m *= 2) {
+ ;
+ }
+
+ /* m>=n */
+ if (m - n <= n - m / 2) {
+ return m;
+ } else {
+ return m / 2;
+ }
}
* Given an pixel format and datatype, return the number of bytes to
* store one pixel.
*/
-static GLint
-bytes_per_pixel(GLenum format, GLenum type)
+static GLint bytes_per_pixel(GLenum format, GLenum type)
{
- GLint n, m;
-
- switch (format) {
- case GL_COLOR_INDEX:
- case GL_STENCIL_INDEX:
- case GL_DEPTH_COMPONENT:
- case GL_RED:
- case GL_GREEN:
- case GL_BLUE:
- case GL_ALPHA:
- case GL_LUMINANCE:
- n = 1;
- break;
- case GL_LUMINANCE_ALPHA:
- n = 2;
- break;
- case GL_RGB:
- case GL_BGR:
- n = 3;
- break;
- case GL_RGBA:
- case GL_BGRA:
+ GLint n, m;
+
+ switch (format) {
+ case GL_COLOR_INDEX:
+ case GL_STENCIL_INDEX:
+ case GL_DEPTH_COMPONENT:
+ case GL_RED:
+ case GL_GREEN:
+ case GL_BLUE:
+ case GL_ALPHA:
+ case GL_LUMINANCE:
+ n = 1;
+ break;
+ case GL_LUMINANCE_ALPHA:
+ n = 2;
+ break;
+ case GL_RGB:
+ case GL_BGR:
+ n = 3;
+ break;
+ case GL_RGBA:
+ case GL_BGRA:
#ifdef GL_EXT_abgr
- case GL_ABGR_EXT:
+ case GL_ABGR_EXT:
#endif
- n = 4;
- break;
- default:
- n = 0;
- }
-
- switch (type) {
- case GL_UNSIGNED_BYTE:
- m = sizeof(GLubyte);
- break;
- case GL_BYTE:
- m = sizeof(GLbyte);
- break;
- case GL_BITMAP:
- m = 1;
- break;
- case GL_UNSIGNED_SHORT:
- m = sizeof(GLushort);
- break;
- case GL_SHORT:
- m = sizeof(GLshort);
- break;
- case GL_UNSIGNED_INT:
- m = sizeof(GLuint);
- break;
- case GL_INT:
- m = sizeof(GLint);
- break;
- case GL_FLOAT:
- m = sizeof(GLfloat);
- break;
- default:
- m = 0;
- }
-
- return n * m;
+ n = 4;
+ break;
+ default:
+ n = 0;
+ }
+
+ switch (type) {
+ case GL_UNSIGNED_BYTE:
+ m = sizeof(GLubyte);
+ break;
+ case GL_BYTE:
+ m = sizeof(GLbyte);
+ break;
+ case GL_BITMAP:
+ m = 1;
+ break;
+ case GL_UNSIGNED_SHORT:
+ m = sizeof(GLushort);
+ break;
+ case GL_SHORT:
+ m = sizeof(GLshort);
+ break;
+ case GL_UNSIGNED_INT:
+ m = sizeof(GLuint);
+ break;
+ case GL_INT:
+ m = sizeof(GLint);
+ break;
+ case GL_FLOAT:
+ m = sizeof(GLfloat);
+ break;
+ default:
+ m = 0;
+ }
+
+ return n * m;
}
/*
* WARNING: This function isn't finished and has never been tested!!!!
*/
-GLint GLAPIENTRY
-mesa_gluBuild1DMipmaps(GLenum target, GLint components,
- GLsizei width, GLenum format, GLenum type, const void *data)
+GLint GLAPIENTRY mesa_gluBuild1DMipmaps(GLenum target, GLint components,
+ GLsizei width, GLenum format,
+ GLenum type, const void *data)
{
- GLubyte *texture;
- GLint levels, max_levels;
- GLint new_width, max_width;
- GLint i, j, k, l;
-
- if (width < 1)
- return GLU_INVALID_VALUE;
-
- glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max_width);
- max_levels = ilog2(max_width) + 1;
-
- /* Compute how many mipmap images to make */
- levels = ilog2(width) + 1;
- if (levels > max_levels) {
- levels = max_levels;
- }
-
- new_width = 1 << (levels - 1);
-
- texture = (GLubyte *) malloc(new_width * components);
- if (!texture) {
- return GLU_OUT_OF_MEMORY;
- }
-
- if (width != new_width) {
- /* initial rescaling */
- switch (type) {
- case GL_UNSIGNED_BYTE:
- {
- GLubyte *ub_data = (GLubyte *) data;
- for (i = 0; i < new_width; i++) {
- j = i * width / new_width;
- for (k = 0; k < components; k++) {
- texture[i * components + k] = ub_data[j * components + k];
- }
- }
- }
- break;
- default:
- /* Not implemented */
- return GLU_ERROR;
- }
- }
-
- /* generate and load mipmap images */
- for (l = 0; l < levels; l++) {
- glTexImage1D(GL_TEXTURE_1D, l, components, new_width, 0,
- format, GL_UNSIGNED_BYTE, texture);
-
- /* Scale image down to 1/2 size */
- new_width = new_width / 2;
- for (i = 0; i < new_width; i++) {
- for (k = 0; k < components; k++) {
- GLint sample1, sample2;
- sample1 = (GLint) texture[i * 2 * components + k];
- sample2 = (GLint) texture[(i * 2 + 1) * components + k];
- texture[i * components + k] = (GLubyte) ((sample1 + sample2) / 2);
- }
- }
- }
-
- free(texture);
-
- return 0;
+ GLubyte *texture;
+ GLint levels, max_levels;
+ GLint new_width, max_width;
+ GLint i, j, k, l;
+
+ if (width < 1) {
+ return GLU_INVALID_VALUE;
+ }
+
+ glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max_width);
+ max_levels = ilog2(max_width) + 1;
+
+ /* Compute how many mipmap images to make */
+ levels = ilog2(width) + 1;
+ if (levels > max_levels) {
+ levels = max_levels;
+ }
+
+ new_width = 1 << (levels - 1);
+
+ texture = (GLubyte *)malloc(new_width * components);
+ if (!texture) {
+ return GLU_OUT_OF_MEMORY;
+ }
+
+ if (width != new_width) {
+ /* initial rescaling */
+ switch (type) {
+ case GL_UNSIGNED_BYTE:
+ {
+ GLubyte *ub_data = (GLubyte *)data;
+ for (i = 0; i < new_width; i++) {
+ j = i * width / new_width;
+ for (k = 0; k < components; k++) {
+ texture[i * components + k] =
+ ub_data[j * components + k];
+ }
+ }
+ }
+ break;
+ default:
+ /* Not implemented */
+ free(texture);
+ return GLU_ERROR;
+ }
+ }
+
+ /* generate and load mipmap images */
+ for (l = 0; l < levels; l++) {
+ glTexImage1D(GL_TEXTURE_1D, l, components, new_width, 0,
+ format, GL_UNSIGNED_BYTE, texture);
+
+ /* Scale image down to 1/2 size */
+ new_width = new_width / 2;
+ for (i = 0; i < new_width; i++) {
+ for (k = 0; k < components; k++) {
+ GLint sample1, sample2;
+ sample1 = (GLint)texture[i * 2 * components + k];
+ sample2 = (GLint)texture[(i * 2 + 1) * components + k];
+ texture[i * components + k] =
+ (GLubyte)((sample1 + sample2) / 2);
+ }
+ }
+ }
+
+ free(texture);
+
+ return 0;
}
-GLint GLAPIENTRY
-mesa_gluBuild2DMipmaps(GLenum target, GLint components,
- GLsizei width, GLsizei height, GLenum format,
- GLenum type, const void *data)
+GLint GLAPIENTRY mesa_gluBuild2DMipmaps(GLenum target, GLint components,
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const void *data)
{
- GLint w, h, maxsize;
- void *image, *newimage;
- GLint neww, newh, level, bpp;
- int error;
- GLboolean done;
- GLint retval = 0;
- GLint unpackrowlength, unpackalignment, unpackskiprows, unpackskippixels;
- GLint packrowlength, packalignment, packskiprows, packskippixels;
-
- if (width < 1 || height < 1)
- return GLU_INVALID_VALUE;
-
- glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxsize);
-
- w = round2(width);
- if (w > maxsize) {
- w = maxsize;
- }
- h = round2(height);
- if (h > maxsize) {
- h = maxsize;
- }
-
- bpp = bytes_per_pixel(format, type);
- if (bpp == 0) {
- /* probably a bad format or type enum */
- return GLU_INVALID_ENUM;
- }
-
- /* Get current glPixelStore values */
- glGetIntegerv(GL_UNPACK_ROW_LENGTH, &unpackrowlength);
- glGetIntegerv(GL_UNPACK_ALIGNMENT, &unpackalignment);
- glGetIntegerv(GL_UNPACK_SKIP_ROWS, &unpackskiprows);
- glGetIntegerv(GL_UNPACK_SKIP_PIXELS, &unpackskippixels);
- glGetIntegerv(GL_PACK_ROW_LENGTH, &packrowlength);
- glGetIntegerv(GL_PACK_ALIGNMENT, &packalignment);
- glGetIntegerv(GL_PACK_SKIP_ROWS, &packskiprows);
- glGetIntegerv(GL_PACK_SKIP_PIXELS, &packskippixels);
-
- /* set pixel packing */
- glPixelStorei(GL_PACK_ROW_LENGTH, 0);
- glPixelStorei(GL_PACK_ALIGNMENT, 1);
- glPixelStorei(GL_PACK_SKIP_ROWS, 0);
- glPixelStorei(GL_PACK_SKIP_PIXELS, 0);
-
- done = GL_FALSE;
-
- if (w != width || h != height) {
- /* must rescale image to get "top" mipmap texture image */
- image = malloc((w + 4) * h * bpp);
- if (!image) {
- return GLU_OUT_OF_MEMORY;
- }
- error = mesa_gluScaleImage(format, width, height, type, data,
- w, h, type, image);
- if (error) {
- retval = error;
- done = GL_TRUE;
- }
- }
- else {
- image = (void *) data;
- }
-
- level = 0;
- while (!done) {
- if (image != data) {
- /* set pixel unpacking */
- glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
- glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
- glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
- glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
- }
-
- glTexImage2D(target, level, components, w, h, 0, format, type, image);
-
- if (w == 1 && h == 1)
- break;
-
- neww = (w < 2) ? 1 : w / 2;
- newh = (h < 2) ? 1 : h / 2;
- newimage = malloc((neww + 4) * newh * bpp);
- if (!newimage) {
- return GLU_OUT_OF_MEMORY;
- }
-
- error = mesa_gluScaleImage(format, w, h, type, image,
- neww, newh, type, newimage);
- if (error) {
- retval = error;
- done = GL_TRUE;
- }
-
- if (image != data) {
- free(image);
- }
- image = newimage;
-
- w = neww;
- h = newh;
- level++;
- }
-
- if (image != data) {
- free(image);
- }
-
- /* Restore original glPixelStore state */
- glPixelStorei(GL_UNPACK_ROW_LENGTH, unpackrowlength);
- glPixelStorei(GL_UNPACK_ALIGNMENT, unpackalignment);
- glPixelStorei(GL_UNPACK_SKIP_ROWS, unpackskiprows);
- glPixelStorei(GL_UNPACK_SKIP_PIXELS, unpackskippixels);
- glPixelStorei(GL_PACK_ROW_LENGTH, packrowlength);
- glPixelStorei(GL_PACK_ALIGNMENT, packalignment);
- glPixelStorei(GL_PACK_SKIP_ROWS, packskiprows);
- glPixelStorei(GL_PACK_SKIP_PIXELS, packskippixels);
-
- return retval;
+ GLint w, h, maxsize;
+ void *image, *newimage;
+ GLint neww, newh, level, bpp;
+ int error;
+ GLboolean done;
+ GLint retval = 0;
+ GLint unpackrowlength, unpackalignment, unpackskiprows, unpackskippixels;
+ GLint packrowlength, packalignment, packskiprows, packskippixels;
+
+ if (width < 1 || height < 1) {
+ return GLU_INVALID_VALUE;
+ }
+
+ glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxsize);
+
+ w = round2(width);
+ if (w > maxsize) {
+ w = maxsize;
+ }
+ h = round2(height);
+ if (h > maxsize) {
+ h = maxsize;
+ }
+
+ bpp = bytes_per_pixel(format, type);
+ if (bpp == 0) {
+ /* probably a bad format or type enum */
+ return GLU_INVALID_ENUM;
+ }
+
+ /* Get current glPixelStore values */
+ glGetIntegerv(GL_UNPACK_ROW_LENGTH, &unpackrowlength);
+ glGetIntegerv(GL_UNPACK_ALIGNMENT, &unpackalignment);
+ glGetIntegerv(GL_UNPACK_SKIP_ROWS, &unpackskiprows);
+ glGetIntegerv(GL_UNPACK_SKIP_PIXELS, &unpackskippixels);
+ glGetIntegerv(GL_PACK_ROW_LENGTH, &packrowlength);
+ glGetIntegerv(GL_PACK_ALIGNMENT, &packalignment);
+ glGetIntegerv(GL_PACK_SKIP_ROWS, &packskiprows);
+ glGetIntegerv(GL_PACK_SKIP_PIXELS, &packskippixels);
+
+ /* set pixel packing */
+ glPixelStorei(GL_PACK_ROW_LENGTH, 0);
+ glPixelStorei(GL_PACK_ALIGNMENT, 1);
+ glPixelStorei(GL_PACK_SKIP_ROWS, 0);
+ glPixelStorei(GL_PACK_SKIP_PIXELS, 0);
+
+ done = GL_FALSE;
+
+ if (w != width || h != height) {
+ /* must rescale image to get "top" mipmap texture image */
+ image = malloc((w + 4) * h * bpp);
+ if (!image) {
+ return GLU_OUT_OF_MEMORY;
+ }
+ error = mesa_gluScaleImage(format, width, height, type, data,
+ w, h, type, image);
+ if (error) {
+ retval = error;
+ done = GL_TRUE;
+ }
+ } else {
+ image = (void *) data;
+ }
+
+ level = 0;
+ while (!done) {
+ if (image != data) {
+ /* set pixel unpacking */
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+ glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
+ glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
+ }
+
+ glTexImage2D(target, level, components, w, h, 0, format, type, image);
+
+ if (w == 1 && h == 1) {
+ break;
+ }
+
+ neww = (w < 2) ? 1 : w / 2;
+ newh = (h < 2) ? 1 : h / 2;
+ newimage = malloc((neww + 4) * newh * bpp);
+ if (!newimage) {
+ return GLU_OUT_OF_MEMORY;
+ }
+
+ error = mesa_gluScaleImage(format, w, h, type, image,
+ neww, newh, type, newimage);
+ if (error) {
+ retval = error;
+ done = GL_TRUE;
+ }
+
+ if (image != data) {
+ free(image);
+ }
+ image = newimage;
+
+ w = neww;
+ h = newh;
+ level++;
+ }
+
+ if (image != data) {
+ free(image);
+ }
+
+ /* Restore original glPixelStore state */
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, unpackrowlength);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, unpackalignment);
+ glPixelStorei(GL_UNPACK_SKIP_ROWS, unpackskiprows);
+ glPixelStorei(GL_UNPACK_SKIP_PIXELS, unpackskippixels);
+ glPixelStorei(GL_PACK_ROW_LENGTH, packrowlength);
+ glPixelStorei(GL_PACK_ALIGNMENT, packalignment);
+ glPixelStorei(GL_PACK_SKIP_ROWS, packskiprows);
+ glPixelStorei(GL_PACK_SKIP_PIXELS, packskippixels);
+
+ return retval;
}
#include <assert.h>
#include <string.h>
#include <stdint.h>
-#include <sys/types.h> // for pid_t
+#include <sys/types.h> /* for pid_t */
#include "qemu-common.h"
-/* GW: dyngen-exec.h defines its own version of stuff that is in stdio.h -
+/* GW: dyngen-exec.h defines its own version of stuff that is in stdio.h -
only it misses things and is mildly different to stdio \o/. Hence
don't include stdio and make our own defines. */
*/
#include "tizen/src/debug_ch.h"
MULTI_DEBUG_CHANNEL(qemu, opengl);
-#define DEBUGF TRACE
+#define DEBUGF TRACE
#define GL_GLEXT_PROTOTYPES
#define GLX_GLXEXT_PROTOTYPES
#include <mesa_gl.h>
-//#include "qemu-queue.h"
#include "opengl_func.h"
#include "mesa_mipmap.h"
#include "opengl_process.h"
* as we need them on Windows too */
typedef int Bool;
const Bool True = 1;
-const Bool False = 0;
+const Bool False;
typedef struct __GLXFBConfigRec GLXFBConfig;
struct __GLXFBConfigRec {
- int formatFlags;
+ int formatFlags;
};
-// #defines from glx.h
#define GLX_VENDOR 1
#define GLX_VERSION 2
#define GLX_EXTENSIONS 3
{GLO_FF_BITS_16|GLO_FF_DEPTH_24|GLO_FF_STENCIL_8},*/
};
-#define FAKE_GL_VENDOR "Qemu"
+#define FAKE_GL_VENDOR "QEMU"
#define FAKE_GL_RENDERER "VMGL Passthrough"
#define FAKE_GL_VERSION "1.4"
#define FAKE_GL_MAJOR 1
-#define FAKE_GLX_VENDOR "Qemu"
+#define FAKE_GLX_VENDOR "QEMU"
#define FAKE_GLX_VERSION_STRING "1.2"
#define FAKE_GLX_VERSION_MAJOR 1
#define FAKE_GLX_VERSION_MINOR 2
/*#define glGetError() 0*/
#ifdef WIN32
-# define CCONV _stdcall /* DLL entry points are WINAPI */
+# define CCONV _stdcall /* DLL entry points are WINAPI */
#else
-# define CCONV
+# define CCONV
#endif
#define GET_EXT_PTR(type, funcname, args_decl) \
- static int detect_##funcname = 0; \
- static type CCONV (*ptr_func_##funcname)args_decl = NULL; \
- if (detect_##funcname == 0) \
- { \
+ static int detect_##funcname; \
+ static type CCONV (*ptr_func_##funcname)args_decl; \
+ if (detect_##funcname == 0) { \
detect_##funcname = 1; \
- ptr_func_##funcname = (type CCONV (*)args_decl)glo_getprocaddress((const char*)#funcname); \
- assert (ptr_func_##funcname); \
+ ptr_func_##funcname = \
+ (type CCONV (*)args_decl)glo_getprocaddress( \
+ (const char *)#funcname); \
+ assert(ptr_func_##funcname); \
}
#define GET_EXT_PTR_NO_FAIL(type, funcname, args_decl) \
- static int detect_##funcname = 0; \
- static type CCONV (*ptr_func_##funcname)args_decl = NULL; \
- if (detect_##funcname == 0) \
- { \
+ static int detect_##funcname; \
+ static type CCONV (*ptr_func_##funcname)args_decl; \
+ if (detect_##funcname == 0) { \
detect_##funcname = 1; \
- ptr_func_##funcname = (type CCONV (*)args_decl)glo_getprocaddress((const char*)#funcname); \
+ ptr_func_##funcname = \
+ (type CCONV (*)args_decl)glo_getprocaddress( \
+ (const char *)#funcname); \
}
#ifndef WIN32
if (handle == (void *) -1) {
#ifndef WIN32
handle = dlopen("libGLU.so", RTLD_LAZY);
- if (!handle)
+ if (!handle) {
DEBUGF("can't load libGLU.so : %s\n", dlerror());
+ }
#else
- handle = (void *) LoadLibrary("glu32.dll");
- if (!handle)
+ handle = (void *)LoadLibrary("glu32.dll");
+ if (!handle) {
DEBUGF("can't load glu32.dll\n");
+ }
#endif
}
if (handle) {
}
#define GET_GLU_PTR(type, funcname, args_decl) \
- static int detect_##funcname = 0; \
- static type CCONV (*ptr_func_##funcname)args_decl = NULL; \
- if (detect_##funcname == 0) \
- { \
+ static int detect_##funcname; \
+ static type CCONV (*ptr_func_##funcname)args_decl; \
+ if (detect_##funcname == 0) { \
detect_##funcname = 1; \
- ptr_func_##funcname = (type CCONV (*)args_decl)get_glu_ptr(#funcname); \
+ ptr_func_##funcname = \
+ (type CCONV (*)args_decl)get_glu_ptr(#funcname); \
}
-int display_function_call = 0;
+int display_function_call;
extern int kill_process;
typedef struct {
};
enum {
- SURFACE_PENDING, /* Created with light-weight context */
- SURFACE_ACTIVE, /* Ready after MakeCurrent */
+ SURFACE_PENDING, /* Created with light-weight context */
+ SURFACE_ACTIVE, /* Ready after MakeCurrent */
};
typedef struct QGloSurface {
ClientGLXDrawable client_drawable;
int type; /* window, pixmap or pbuffer */
int ready;
- int status;
+ int status;
int ref;
QTAILQ_ENTRY(QGloSurface) next;
} QGloSurface;
int fake_ctxt;
int fake_shareList;
- GloContext *context; // context (owned by this)
- QGloSurface *current_qsurface; // current rendering surface/drawable
- QTAILQ_HEAD(, QGloSurface) qsurfaces; // list of surfaces/drawables for
- // this context
+ GloContext *context; /* context (owned by this) */
+ QGloSurface *current_qsurface; /* current rendering surface/drawable */
+ QTAILQ_HEAD(, QGloSurface) qsurfaces; /* list of surfaces/drawables for */
+ /* this context */
void *vertexPointer;
void *normalPointer;
int nb_qsurf;
/* Number of FB configs sets allocated on behalf of this process */
- int nfbconfig;
-
- /* Array of FB configs sets */
+ int nfbconfig;
+
+ /* Array of FB configs sets */
const GLXFBConfig *fbconfigs[MAX_FBCONFIG];
-
- /* Number of FB configs per set */
+
+ /* Number of FB configs per set */
int fbconfigs_max[MAX_FBCONFIG];
-
- /* Total number of FB configs allocated on behalf of this process */
+
+ /* Total number of FB configs allocated on behalf of this process */
int nfbconfig_total;
int primitive;
supported = (char *)g_malloc(strlen(avail) + 2);
pos = supported;
- while(*ext) {
- srcp = (char*)avail;
- while((srcp = strstr(srcp, *ext))) {
+ while (*ext) {
+ srcp = (char *)avail;
+ while ((srcp = strstr(srcp, *ext))) {
int len = strlen(*ext);
- if(*(srcp+len) == ' ' || *(srcp+len) == '\0') {
+ if (*(srcp + len) == ' ' || *(srcp + len) == '\0') {
strcpy(pos, *ext);
pos += len;
- if(*(srcp+len) == ' ') {
+ if (*(srcp + len) == ' ') {
*pos = ' ';
pos++;
}
return supported;
}
-extern void vmgl_context_switch(ProcessStruct *p, int switch_gl_context);
+extern void vmgl_context_switch(ProcessStruct *p,
+ int switch_gl_context);
extern ProcessStruct *vmgl_get_process(pid_t pid);
extern void gl_disconnect(ProcessState *process);
-extern int do_function_call(ProcessState *process, int func_number, unsigned long *args, char *ret_string);
+extern int do_function_call(ProcessState *process,
+ int func_number,
+ unsigned long *args,
+ char *ret_string);
static const char *glx_ext_supported[] = {
"GLX_ARB_multisample",
{
static char *supported;
- if(!supported)
- supported = strip_extensions(glo_glXQueryExtensionsString(),
+ if (!supported) {
+ supported = strip_extensions(glo_glXQueryExtensionsString(),
glx_ext_supported);
+ }
return supported;
}
static const char *gl_ext_supported[] = {
-// Mandatory OpenGL 1.4 Extensions
+/* Mandatory OpenGL 1.4 Extensions */
"GL_ARB_depth_texture",
"GL_ARB_multisample",
"GL_ARB_multitexture",
"GL_SGIS_texture_border_clamp",
"GL_SGIS_texture_edge_clamp",
"GL_SGIS_texture_lod",
-// Optional extensions. If you get problems try disabling the below.
+/* Optional extensions. If you get problems try disabling the below. */
"GL_EXT_compiled_vertex_array",
"GL_ARB_copy_buffer",
"GL_ARB_depth_clamp",
"GL_ARB_fragment_shader",
"GL_ARB_framebuffer_object",
"GL_ARB_half_float_pixel",
- "GL_ARB_map_buffer_range",
+ "GL_ARB_map_buffer_range",
"GL_ARB_occlusion_query",
"GL_ARB_pixel_buffer_object",
"GL_ARB_point_sprite",
"GL_ARB_shader_objects",
"GL_ARB_shading_language_100",
"GL_ARB_shading_language_120",
- "GL_ARB_sync",
+ "GL_ARB_sync",
"GL_ARB_texture_non_power_of_two",
"GL_ARB_texture_rectangle",
- "GL_ARB_vertex_array_bgra",
+ "GL_ARB_vertex_array_bgra",
"GL_ARB_vertex_array_object",
"GL_ARB_vertex_buffer_object",
"GL_ARB_vertex_program",
"GL_EXT_cull_vertex",
"GL_EXT_framebuffer_blit",
"GL_EXT_framebuffer_object",
- "GL_EXT_gpu_program_parameters",
- "GL_EXT_packed_depth_stencil",
+ "GL_EXT_gpu_program_parameters",
+ "GL_EXT_packed_depth_stencil",
"GL_EXT_pixel_buffer_object",
"GL_EXT_provoking_vertex",
"GL_EXT_shadow_funcs",
"GL_EXT_stencil_two_side",
- "GL_EXT_texture_cube_map",
- "GL_EXT_texture_env_dot3",
+ "GL_EXT_texture_cube_map",
+ "GL_EXT_texture_env_dot3",
"GL_EXT_texture_filter_anisotropic",
"GL_EXT_texture_rectangle",
"GL_EXT_texture_sRGB",
"GL_EXT_vertex_array_bgra",
"GL_3DFX_texture_compression_FXT1",
"GL_APPLE_client_storage",
- "GL_APPLE_vertex_array_object",
+ "GL_APPLE_vertex_array_object",
"GL_ATI_blend_equation_separate",
"GL_ATI_envmap_bumpmap",
"GL_ATI_texture_env_combine3",
"GL_IBM_multimode_draw_arrays",
"GL_IBM_rasterpos_clip",
"GL_IBM_texture_mirrored_repeat",
- "GL_INGR_blend_func_separate",
+ "GL_INGR_blend_func_separate",
"GL_MESA_pack_invert",
"GL_MESA_texture_signed_rgba",
"GL_MESA_ycbcr_texture",
{
static char *supported;
- if(!supported)
+ if (!supported) {
supported = strip_extensions((const char *)glGetString(GL_EXTENSIONS),
gl_ext_supported);
+ }
return supported;
}
-static inline QGloSurface *get_qsurface_from_client_drawable(GLState *state, ClientGLXDrawable client_drawable) {
+static inline QGloSurface *get_qsurface_from_client_drawable(GLState *state,
+ ClientGLXDrawable client_drawable)
+{
QGloSurface *qsurface;
- if (state->current_qsurface && state->current_qsurface->client_drawable == client_drawable)
+ if (state->current_qsurface &&
+ state->current_qsurface->client_drawable == client_drawable) {
return state->current_qsurface;
+ }
QTAILQ_FOREACH(qsurface, &state->qsurfaces, next) {
- if (qsurface->client_drawable == client_drawable)
+ if (qsurface->client_drawable == client_drawable) {
return qsurface;
+ }
}
return NULL;
}
-// This must always be called only on surfaces belonging to the current context
-static inline void render_surface(QGloSurface *qsurface, int bpp, int stride, char *buffer)
+/* This must always be called only on surfaces
+ belonging to the current context */
+static inline void render_surface(QGloSurface *qsurface,
+ int bpp, int stride, char *buffer)
{
int w, h;
- if(!qsurface->ready)
- return;
+ if (!qsurface->ready) {
+ return;
+ }
glo_surface_get_size(qsurface->surface, &w, &h);
static void qsurface_pixmap_ref(QGloSurface *qsurface)
{
if (!qsurface) {
- DEBUGF( "%s %p\n", __FUNCTION__, qsurface);
+ DEBUGF("%s %p\n", __func__, qsurface);
return;
}
if (qsurface->type != SURFACE_PIXMAP) {
- DEBUGF( "%s %p is not a pixmap\n", __FUNCTION__, qsurface);
+ DEBUGF("%s %p is not a pixmap\n", __func__, qsurface);
return;
}
qsurface->ref++;
- DEBUGF("%s %p references increased to %d\n", __FUNCTION__, qsurface, qsurface->ref);
+ DEBUGF("%s %p references increased to %d\n",
+ __func__, qsurface, qsurface->ref);
}
static void qsurface_pixmap_unref(QGloSurface *qsurface)
{
if (!qsurface) {
- DEBUGF( "%s %p\n", __FUNCTION__, qsurface);
+ DEBUGF("%s %p\n", __func__, qsurface);
return;
}
if (qsurface->type != SURFACE_PIXMAP) {
- DEBUGF( "%s %p is not a pixmap\n", __FUNCTION__, qsurface);
+ DEBUGF("%s %p is not a pixmap\n", __func__, qsurface);
return;
}
qsurface->ref--;
- DEBUGF("%s %p references decreased to %d\n", __FUNCTION__, qsurface, qsurface->ref);
+ DEBUGF("%s %p references decreased to %d\n",
+ __func__, qsurface, qsurface->ref);
- if (qsurface->ref == 0)
- {
+ if (qsurface->ref == 0) {
glo_surface_destroy(qsurface->surface);
g_free(qsurface);
- DEBUGF( "%s freed: %p\n", __FUNCTION__, qsurface);
+ DEBUGF("%s freed: %p\n", __func__, qsurface);
}
}
static void state_set_current_surface(GLState *state, QGloSurface *qsurface)
{
- if (state->current_qsurface != NULL)
+ if (state->current_qsurface != NULL) {
qsurface_pixmap_unref(state->current_qsurface);
+ }
- if (qsurface != NULL)
+ if (qsurface != NULL) {
qsurface_pixmap_ref(qsurface);
+ }
state->current_qsurface = qsurface;
}
-// This must always be called only on surfaces belonging to the current context
-static inline void resize_surface(ProcessState *process, QGloSurface *qsurface,
- int w, int h) {
+/* This must always be called only on surfaces
+ belonging to the current context */
+static inline void resize_surface(ProcessState *process,
+ QGloSurface *qsurface,
+ int w,
+ int h)
+{
GLState *glstate = qsurface->glstate;
GloSurface *old_surface = qsurface->surface;
GloSurface *surface;
surface = glo_surface_create(w, h, glstate->context);
qsurface->surface = surface;
- // Client doesnt know surface is new - need to MakeCurrent
- if(process->current_state == qsurface->glstate) {
+ /* Client doesnt know surface is new - need to MakeCurrent */
+ if (process->current_state == qsurface->glstate) {
glo_surface_makecurrent(qsurface->surface);
- // set the viewport while the window size is changed. It is needed
- // especially for the case that glViewport is not explicitly called
- // in program. In this case, the viewport is set to incorrectly
- // in the first MakeCurrent when the window size is not known.
- // It will not impact normal GL programs with glViewport set as
- // programmers want.
- glViewport (0, 0, w, h);
- }
- else {
+ /* set the viewport while the window size is changed. It is needed
+ especially for the case that glViewport is not explicitly called
+ in program. In this case, the viewport is set to incorrectly
+ in the first MakeCurrent when the window size is not known.
+ It will not impact normal GL programs with glViewport set as
+ programmers want. */
+ glViewport(0, 0, w, h);
+ } else {
DEBUGF("Error: Surface is not current! %p %p\n",
process->current_state,
process->current_state->current_qsurface);
}
glstate->current_qsurface->ready = 1;
- DEBUGF( "resize_done\n");
+ DEBUGF("resize_done\n");
}
#define ARG_TO_UNSIGNED_SHORT(x) (unsigned short)(long)(x)
#define ARG_TO_INT(x) (int)(long)(x)
#define ARG_TO_UNSIGNED_INT(x) (unsigned int)(long)(x)
-#define ARG_TO_FLOAT(x) (*(float*)&(x))
-#define ARG_TO_DOUBLE(x) (*(double*)(x))
+#define ARG_TO_FLOAT(x) (*(float *)&(x))
+#define ARG_TO_DOUBLE(x) (*(double *)(x))
#include "server_stub.c"
{
#ifdef TARGET_X86_64
if (arg > (unsigned long) -1) {
- DEBUGF( "GLXDrawable too big for this implementation\n");
+ DEBUGF("GLXDrawable too big for this implementation\n");
exit(-1);
}
#endif
static void bind_qsurface(GLState *state,
QGloSurface *qsurface)
{
- DEBUGF("%s qsurface %p qsurface->glstate %p new state %p\n", __FUNCTION__, qsurface, qsurface->glstate, state);
+ DEBUGF("%s qsurface %p qsurface->glstate %p new state %p\n",
+ __func__, qsurface, qsurface->glstate, state);
qsurface->glstate = state;
- if ( qsurface->type == SURFACE_WINDOW )
- QTAILQ_INSERT_HEAD(&state->qsurfaces, qsurface, next);
+ if (qsurface->type == SURFACE_WINDOW) {
+ QTAILQ_INSERT_HEAD(&state->qsurfaces, qsurface, next);
+ }
state_set_current_surface(state, qsurface);
}
QGloSurface *qsurface)
{
if (!state || !qsurface) {
- DEBUGF("%s invalid parameter, state %p, qsurface %p\n", __FUNCTION__, state, qsurface);
+ DEBUGF("%s invalid parameter, state %p, qsurface %p\n",
+ __func__, state, qsurface);
return;
}
- DEBUGF("%s qsurface %p qsurface->glstate %p old state %p\n", __FUNCTION__, qsurface, qsurface->glstate, state);
+ DEBUGF("%s qsurface %p qsurface->glstate %p old state %p\n",
+ __func__, qsurface, qsurface->glstate, state);
qsurface->glstate = NULL;
- if ( qsurface->type == SURFACE_WINDOW )
- QTAILQ_REMOVE(&state->qsurfaces, qsurface, next);
+ if (qsurface->type == SURFACE_WINDOW) {
+ QTAILQ_REMOVE(&state->qsurfaces, qsurface, next);
+ }
- if ( state->current_qsurface == qsurface )
- state_set_current_surface(state, NULL);
+ if (state->current_qsurface == qsurface) {
+ state_set_current_surface(state, NULL);
+ }
}
/* Find the qsurface with required drawable in all pixmap/pbuffer surfaces */
-static QGloSurface* find_qsurface_from_client_drawable(ProcessState *process, ClientGLXDrawable client_drawable)
+static QGloSurface *find_qsurface_from_client_drawable(ProcessState *process,
+ ClientGLXDrawable client_drawable)
{
int i;
QGloSurface *qsurface;
- for ( i = 0; i < process->nb_qsurf; i++ )
- {
+ for (i = 0; i < process->nb_qsurf; i++) {
qsurface = process->pending_qsurfaces[i];
- if ( qsurface && qsurface->client_drawable == client_drawable )
+ if (qsurface && qsurface->client_drawable == client_drawable) {
return qsurface;
+ }
}
return NULL;
{
QGloSurface *qsurface;
- if(state->current_qsurface && state->current_qsurface->client_drawable == client_drawable)
+ if (state->current_qsurface
+ && state->current_qsurface->client_drawable == client_drawable) {
return 1;
+ }
QTAILQ_FOREACH(qsurface, &state->qsurfaces, next) {
- if(qsurface->client_drawable == client_drawable) {
+ if (qsurface->client_drawable == client_drawable) {
state_set_current_surface(state, qsurface);
qsurface->glstate = state;
return 1;
static int keep_drawable(ProcessState *process, ClientGLXDrawable drawable)
{
int i;
- for ( i = 0; i < MAX_PENDING_DRAWABLE; i++)
- {
- if ( process->pending_drawables[i] == 0 )
- {
+ for (i = 0; i < MAX_PENDING_DRAWABLE; i++) {
+ if (process->pending_drawables[i] == 0) {
process->pending_drawables[i] = drawable;
return 1;
}
static int link_drawable(ProcessState *process, ClientGLXDrawable drawable)
{
int i;
- for ( i = 0; i < MAX_PENDING_DRAWABLE; i++ )
- {
- if ( process->pending_drawables[i] == drawable )
- {
+ for (i = 0; i < MAX_PENDING_DRAWABLE; i++) {
+ if (process->pending_drawables[i] == drawable) {
process->pending_drawables[i] = 0;
return 1;
}
{
process->pending_qsurfaces =
g_realloc(process->pending_qsurfaces,
- (process->nb_qsurf + 1) * sizeof(QGloSurface*));
+ (process->nb_qsurf + 1) * sizeof(QGloSurface *));
process->pending_qsurfaces[process->nb_qsurf] = qsurface;
process->nb_qsurf++;
}
-static int link_qsurface(ProcessState *process, GLState *glstate, ClientGLXDrawable client_drawable)
+static int link_qsurface(ProcessState *process,
+ GLState *glstate,
+ ClientGLXDrawable client_drawable)
{
int i;
QGloSurface *qsurface;
- for ( i = 0; i < process->nb_qsurf; i++ )
- {
+ for (i = 0; i < process->nb_qsurf; i++) {
qsurface = process->pending_qsurfaces[i];
- if ( qsurface && qsurface->client_drawable == client_drawable )
- {
+ if (qsurface && qsurface->client_drawable == client_drawable) {
/* XXX:Current limitation is that each surface is binded to one
* context, and not accessible from another context. It's hard for
* glEGLImageTargetTexture2DOES implementation, in which we need
#if 0
memmove(&process->pending_qsurfaces[i],
&process->pending_qsurfaces[i+1],
- (process->nb_qsurf - i - 1) * sizeof(QGloSurface*));
+ (process->nb_qsurf - i - 1) * sizeof(QGloSurface *));
#endif
if (qsurface->type != SURFACE_PIXMAP) {
- DEBUGF("%s Forcing non pixmap qsurface->ref to 1 (type %d, ref %d)\n", __FUNCTION__, qsurface->type, qsurface->ref);
+ DEBUGF("%s Forcing non pixmap qsurface->ref to 1"
+ " (type %d, ref %d)\n",
+ __func__, qsurface->type, qsurface->ref);
qsurface->ref = 1;
}
- if(qsurface->status == SURFACE_PENDING)
- {
- glo_surface_update_context(qsurface->surface, glstate->context, 1);
- qsurface->status = SURFACE_ACTIVE;
- }
- else
- {
- unbind_qsurface(qsurface->glstate, qsurface);
- glo_surface_update_context(qsurface->surface, glstate->context, 0);
- }
+ if (qsurface->status == SURFACE_PENDING) {
+ glo_surface_update_context(qsurface->surface,
+ glstate->context, 1);
+ qsurface->status = SURFACE_ACTIVE;
+ } else {
+ unbind_qsurface(qsurface->glstate, qsurface);
+ glo_surface_update_context(qsurface->surface,
+ glstate->context, 0);
+ }
bind_qsurface(glstate, qsurface);
return 1;
unsigned int texture)
{
int i;
- for ( i = 0; i < MAX_PIXMAP_TEXTURE; i++ )
- {
- if ( state->pixmapTextures[i].used &&
- state->pixmapTextures[i].texture == texture )
- {
+ for (i = 0; i < MAX_PIXMAP_TEXTURE; i++) {
+ if (state->pixmapTextures[i].used &&
+ state->pixmapTextures[i].texture == texture) {
state->pixmapTextures[i].used = 0;
state->pixmapTextures[i].texture = 0;
state->pixmapTextures[i].drawable = 0;
ClientGLXDrawable drawable)
{
int i;
- for ( i = 0; i < MAX_PIXMAP_TEXTURE; i++ )
- {
- if ( state->pixmapTextures[i].used &&
- state->pixmapTextures[i].drawable == drawable )
- {
+ for (i = 0; i < MAX_PIXMAP_TEXTURE; i++) {
+ if (state->pixmapTextures[i].used &&
+ state->pixmapTextures[i].drawable == drawable) {
state->pixmapTextures[i].used = 0;
state->pixmapTextures[i].texture = 0;
state->pixmapTextures[i].drawable = 0;
unsigned int texture, ClientGLXDrawable drawable)
{
int i;
- for ( i = 0; i < MAX_PIXMAP_TEXTURE; i++ )
- {
- if ( state->pixmapTextures[i].texture == texture ||
- !state->pixmapTextures[i].used )
- {
+ for (i = 0; i < MAX_PIXMAP_TEXTURE; i++) {
+ if (state->pixmapTextures[i].texture == texture ||
+ !state->pixmapTextures[i].used) {
state->pixmapTextures[i].used = 1;
state->pixmapTextures[i].texture = texture;
state->pixmapTextures[i].drawable = drawable;
unsigned int texture)
{
int i;
- for ( i = 0; i < MAX_PIXMAP_TEXTURE; i++ )
- {
- if ( state->pixmapTextures[i].used &&
- state->pixmapTextures[i].texture == texture )
+ for (i = 0; i < MAX_PIXMAP_TEXTURE; i++) {
+ if (state->pixmapTextures[i].used &&
+ state->pixmapTextures[i].texture == texture) {
return state->pixmapTextures[i].drawable;
+ }
}
return 0;
if (client_texture < 32768) {
server_texture = process->current_state->tabTextures[client_texture];
} else {
- DEBUGF( "invalid texture name %d\n", client_texture);
+ DEBUGF("invalid texture name %d\n", client_texture);
}
return server_texture;
}
if (client_buffer < 32768) {
server_buffer = process->current_state->tabBuffers[client_buffer];
} else {
- DEBUGF( "invalid buffer name %d\n", client_buffer);
+ DEBUGF("invalid buffer name %d\n", client_buffer);
}
return server_buffer;
}
if (client_list < 32768) {
server_list = process->current_state->tabLists[client_list];
} else {
- DEBUGF( "invalid list name %d\n", client_list);
+ DEBUGF("invalid list name %d\n", client_list);
}
return server_list;
}
-static const GLXFBConfig *get_fbconfig(ProcessState *process, int client_fbconfig)
+static const GLXFBConfig *get_fbconfig(ProcessState *process,
+ int client_fbconfig)
{
int i;
-
- /* The client_fbconfig returned to upper layers is 1 + the index of the
- * fb config in the set that contains it, + the number of fb configs
- * store in previously allocated sets. */
+
+ /* The client_fbconfig returned to upper layers is 1 + the index of the
+ * fb config in the set that contains it, + the number of fb configs
+ * store in previously allocated sets. */
int nbtotal = 0;
/* For each set */
- for (i = 0; i < process->nfbconfig; i++) {
- /* If the fb config is stored within this set, return it */
+ for (i = 0; i < process->nfbconfig; i++) {
+ /* If the fb config is stored within this set, return it */
if (client_fbconfig <= nbtotal + process->fbconfigs_max[i]) {
return &process->fbconfigs[i][client_fbconfig - 1 - nbtotal];
}
/* Otherwise proceed to next set */
- nbtotal += process->fbconfigs_max[i];
+ nbtotal += process->fbconfigs_max[i];
}
return 0;
}
static int glXChooseVisualFunc(const int *attrib_list)
{
- if (attrib_list == NULL)
+ if (attrib_list == NULL) {
return 0;
+ }
int formatFlags = glo_flags_get_from_glx(attrib_list, True);
int i;
int bestConfig = 0;
int bestScore = -1;
- for (i=0;i<DIM(FBCONFIGS);i++) {
+ for (i = 0; i < DIM(FBCONFIGS); i++) {
int score = glo_flags_score(formatFlags, FBCONFIGS[i].formatFlags);
- if (bestScore < 0 || score<=bestScore) {
+ if (bestScore < 0 || score <= bestScore) {
bestScore = score;
bestConfig = i;
}
}
- if (bestScore > 0)
- DEBUGF( "Got format flags %d but we couldn't find an exactly matching config, chose %d\n", formatFlags, bestConfig);
+ if (bestScore > 0) {
+ DEBUGF("Got format flags %d but we couldn't find "
+ "an exactly matching config, chose %d\n",
+ formatFlags, bestConfig);
+ }
return bestConfig;
}
-static int glXGetConfigFunc(int visualid, int attrib, int *value) {
- const GLXFBConfig *config = &FBCONFIGS[0]; // default
+static int glXGetConfigFunc(int visualid, int attrib, int *value)
+{
+ const GLXFBConfig *config = &FBCONFIGS[0]; /* default */
int v;
- if (visualid>=0 && visualid<DIM(FBCONFIGS))
+ if (visualid >= 0 && visualid < DIM(FBCONFIGS)) {
config = &FBCONFIGS[visualid];
- else
- DEBUGF( "Unknown visual ID %d\n", visualid);
+ } else {
+ DEBUGF("Unknown visual ID %d\n", visualid);
+ }
v = glo_get_glx_from_flags(config->formatFlags, attrib);
- if (value)
- *value = v;
+ if (value) {
+ *value = v;
+ }
return 0;
}
-static const GLXFBConfig * glXGetFBConfigsFunc(int screen, int *nelements) {
+static const GLXFBConfig *glXGetFBConfigsFunc(int screen, int *nelements)
+{
*nelements = DIM(FBCONFIGS);
return &FBCONFIGS[0];
}
-static int glXGetFBConfigAttribFunc(const GLXFBConfig *fbconfig, int attrib, int *value) {
- // TODO other enums - see http://www.opengl.org/sdk/docs/man/xhtml/glXGetFBConfigAttrib.xml
+static int glXGetFBConfigAttribFunc(const GLXFBConfig *fbconfig,
+ int attrib, int *value)
+{
+ /* TODO other enums -
+ * see http://www.opengl.org/sdk/docs/man/xhtml/glXGetFBConfigAttrib.xml
+ */
int v = glo_get_glx_from_flags(fbconfig->formatFlags, attrib);
- if (value) *value = v;
+ if (value) {
+ *value = v;
+ }
return 0;
}
-static const GLXFBConfig *glXChooseFBConfigFunc(int screen, const int *attrib_list, int *nelements) {
+static const GLXFBConfig *glXChooseFBConfigFunc(int screen,
+ const int *attrib_list,
+ int *nelements)
+{
if (attrib_list != NULL) {
int formatFlags = glo_flags_get_from_glx(attrib_list, False);
int i;
int bestConfig = 0;
int bestScore = -1;
- for (i=0;i<DIM(FBCONFIGS);i++) {
+ for (i = 0; i < DIM(FBCONFIGS); i++) {
int score = glo_flags_score(formatFlags, FBCONFIGS[i].formatFlags);
- if (bestScore < 0 || score<=bestScore) {
+ if (bestScore < 0 || score <= bestScore) {
bestScore = score;
bestConfig = i;
}
}
if (bestScore > 0) {
- DEBUGF( "Got format flags %d but we couldn't find an exactly matching config, chose %d\n", formatFlags, bestConfig);
+ DEBUGF("Got format flags %d but we couldn't find "
+ "an exactly matching config, chose %d\n",
+ formatFlags, bestConfig);
}
- if (nelements)
- *nelements=1;
+ if (nelements) {
+ *nelements = 1;
+ }
return &FBCONFIGS[bestConfig];
}
- if (nelements)
- *nelements=0;
+ if (nelements) {
+ *nelements = 0;
+ }
return 0;
}
QGloSurface *qsurface, *tmp;
- DEBUGF("%s state %p\n", __FUNCTION__, state);
+ DEBUGF("%s state %p\n", __func__, state);
QTAILQ_FOREACH_SAFE(qsurface, &state->qsurfaces, next, tmp) {
glo_surface_destroy(qsurface->surface);
QTAILQ_REMOVE(&state->qsurfaces, qsurface, next);
g_free(qsurface);
}
-
- if (state->context)
- glo_context_destroy(state->context);
- if (state->vertexPointer)
+ if (state->context) {
+ glo_context_destroy(state->context);
+ }
+
+ if (state->vertexPointer) {
g_free(state->vertexPointer);
- if (state->normalPointer)
+ }
+ if (state->normalPointer) {
g_free(state->normalPointer);
- if (state->indexPointer)
+ }
+ if (state->indexPointer) {
g_free(state->indexPointer);
- if (state->colorPointer)
+ }
+ if (state->colorPointer) {
g_free(state->colorPointer);
- if (state->secondaryColorPointer)
+ }
+ if (state->secondaryColorPointer) {
g_free(state->secondaryColorPointer);
+ }
for (i = 0; i < NB_MAX_TEXTURES; i++) {
- if (state->texCoordPointer[i])
+ if (state->texCoordPointer[i]) {
g_free(state->texCoordPointer[i]);
+ }
}
for (i = 0; i < MY_GL_MAX_VERTEX_ATTRIBS_ARB; i++) {
- if (state->vertexAttribPointer[i])
+ if (state->vertexAttribPointer[i]) {
g_free(state->vertexAttribPointer[i]);
+ }
}
for (i = 0; i < MY_GL_MAX_VERTEX_ATTRIBS_NV; i++) {
- if (state->vertexAttribPointerNV[i])
+ if (state->vertexAttribPointerNV[i]) {
g_free(state->vertexAttribPointerNV[i]);
+ }
}
- if (state->weightPointer)
+ if (state->weightPointer) {
g_free(state->weightPointer);
- if (state->matrixIndexPointer)
+ }
+ if (state->matrixIndexPointer) {
g_free(state->matrixIndexPointer);
- if (state->fogCoordPointer)
+ }
+ if (state->fogCoordPointer) {
g_free(state->fogCoordPointer);
+ }
for (i = 0; i < MY_GL_MAX_VARIANT_POINTER_EXT; i++) {
- if (state->variantPointerEXT[i])
+ if (state->variantPointerEXT[i]) {
g_free(state->variantPointerEXT[i]);
+ }
}
- if (state->interleavedArrays)
+ if (state->interleavedArrays) {
g_free(state->interleavedArrays);
- if (state->elementPointerATI)
+ }
+ if (state->elementPointerATI) {
g_free(state->elementPointerATI);
+ }
}
static void init_gl_state(GLState *state)
switch (type) {
case GL_BYTE:
- bptr = (GLbyte *) list;
+ bptr = (GLbyte *)list;
return (GLuint) *(bptr + n);
case GL_UNSIGNED_BYTE:
- ubptr = (GLubyte *) list;
+ ubptr = (GLubyte *)list;
return (GLuint) *(ubptr + n);
case GL_SHORT:
- sptr = (GLshort *) list;
+ sptr = (GLshort *)list;
return (GLuint) *(sptr + n);
case GL_UNSIGNED_SHORT:
- usptr = (GLushort *) list;
+ usptr = (GLushort *)list;
return (GLuint) *(usptr + n);
case GL_INT:
- iptr = (GLint *) list;
+ iptr = (GLint *)list;
return (GLuint) *(iptr + n);
case GL_UNSIGNED_INT:
- uiptr = (GLuint *) list;
+ uiptr = (GLuint *)list;
return (GLuint) *(uiptr + n);
case GL_FLOAT:
- fptr = (GLfloat *) list;
+ fptr = (GLfloat *)list;
return (GLuint) *(fptr + n);
case GL_2_BYTES:
- ubptr = ((GLubyte *) list) + 2 * n;
+ ubptr = ((GLubyte *)list) + 2 * n;
return (GLuint) (*ubptr << 8) + (GLuint) *(ubptr + 1);
case GL_3_BYTES:
- ubptr = ((GLubyte *) list) + 3 * n;
+ ubptr = ((GLubyte *)list) + 3 * n;
return (GLuint) (*ubptr << 16) + (GLuint) (*(ubptr + 1) << 8) +
(GLuint) *(ubptr + 2);
case GL_4_BYTES:
- ubptr = ((GLubyte *) list) + 4 * n;
+ ubptr = ((GLubyte *)list) + 4 * n;
return (GLuint) (*ubptr << 24) + (GLuint) (*(ubptr + 1) << 16) +
(GLuint) (*(ubptr + 2) << 8) + (GLuint) *(ubptr + 3);
default:
state->fake_ctxt = fake_ctxt;
init_gl_state(state);
- // FIXMEIM - realloc? really?
+ /* FIXMEIM - realloc? really? */
process->glstates = g_realloc(process->glstates,
(process->nb_states + 1) * sizeof(GLState *));
process->nb_states++;
}
- DEBUGF("state %p fake_ctxt %08x process->nb_states %d\n", state, fake_ctxt, process->nb_states);
+ DEBUGF("state %p fake_ctxt %08x process->nb_states %d\n",
+ state, fake_ctxt, process->nb_states);
return state;
}
-static void set_context_sharelist(ProcessState *process, GLState *state, int fake_shareList)
+static void set_context_sharelist(ProcessState *process,
+ GLState *state,
+ int fake_shareList)
{
state->fake_shareList = fake_shareList;
for (i = 0; i < process->nb_states; i++) {
if (process->glstates[i]->fake_ctxt == fake_shareList) {
process->glstates[i]->ref++;
- state->textureAllocator = process->glstates[i]->textureAllocator;
+ state->textureAllocator =
+ process->glstates[i]->textureAllocator;
state->tabTextures = process->glstates[i]->tabTextures;
- state->bufferAllocator = process->glstates[i]->bufferAllocator;
+ state->bufferAllocator =
+ process->glstates[i]->bufferAllocator;
state->tabBuffers = process->glstates[i]->tabBuffers;
state->listAllocator = process->glstates[i]->listAllocator;
state->tabLists = process->glstates[i]->tabLists;
}
}
-static GLState *get_glstate_for_fake_ctxt(ProcessState *process, int fake_ctxt)
+static GLState *get_glstate_for_fake_ctxt(ProcessState *process,
+ int fake_ctxt)
{
int i;
for (i = 0; i < process->nb_states; i++) {
- if (process->glstates[i]->fake_ctxt == fake_ctxt)
+ if (process->glstates[i]->fake_ctxt == fake_ctxt) {
return process->glstates[i];
- }
+ }
+ }
return 0;
}
destroy_gl_state(&process->default_state);
g_free(process->glstates);
- if (process->cmdbuf)
+ if (process->cmdbuf) {
g_free(process->cmdbuf);
+ }
- for (i = 0; &processes[i] != process; i ++) {
- ; // do nothing
- }
+ for (i = 0; &processes[i] != process; i++) {
+ /* do nothing */
+ ;
+ }
- memmove(&processes[i], &processes[i + 1],
- (MAX_HANDLED_PROCESS - 1 - i) * sizeof(ProcessState));
+ memmove(&processes[i], &processes[i + 1],
+ (MAX_HANDLED_PROCESS - 1 - i) * sizeof(ProcessState));
}
static const int beginend_allowed[GL_N_CALLS] = {
#undef MAGIC_MACRO
-#define MAGIC_MACRO(name) [name ## _func] = 1,
+#define MAGIC_MACRO(name) [name##_func] = 1,
#include "gl_beginend.h"
};
static int first;
int i;
- if(!first) {
+ if (!first) {
first = 1;
init_process_tab();
}
* process->current_state contains info on which of the guests contexts is
* current.
*/
- for (i = 0; i < MAX_HANDLED_PROCESS; i ++) {
+ for (i = 0; i < MAX_HANDLED_PROCESS; i++) {
if (processes[i].p.process_id == pid) {
process = &processes[i];
break;
process->current_state = &process->default_state;
break;
}
- }
+ }
if (process == NULL) {
- DEBUGF( "Too many processes !\n");
+ DEBUGF("Too many processes !\n");
exit(-1);
}
- return (ProcessStruct *)process; // Cast is ok due to struct defn.
+ return (ProcessStruct *)process; /* Cast is ok due to struct defn. */
}
void vmgl_context_switch(ProcessStruct *p, int switch_gl_context)
{
ProcessState *process = (ProcessState *)p;
- if(switch_gl_context) {
- if(process->current_state->current_qsurface)
- glo_surface_makecurrent(process->current_state->current_qsurface->surface);
- else
- glo_surface_makecurrent(0); // should never happen
+ if (switch_gl_context) {
+ if (process->current_state->current_qsurface) {
+ glo_surface_makecurrent(process->current_state->
+ current_qsurface->surface);
+ } else {
+ glo_surface_makecurrent(0); /* should never happen */
+ }
}
}
-static char *opengl_strtok(const char *s, int *n, char const **saveptr, char *prevbuf)
+static char *opengl_strtok(const char *s, int *n,
+ char const **saveptr, char *prevbuf)
{
- const char *start;
- char *ret;
- char *p;
- int retlen;
+ const char *start;
+ char *ret;
+ char *p;
+ int retlen;
static const char *delim = " \t\n\r/";
- if (prevbuf)
- free(prevbuf);
+ if (prevbuf) {
+ free(prevbuf);
+ }
if (s) {
*saveptr = s;
} else {
- if (!(*saveptr) || !(*n))
+ if (!(*saveptr) || !(*n)) {
return NULL;
+ }
s = *saveptr;
}
s++, (*n)--;
} while (*n > 2 && (s[1] != '*' || s[2] != '/'));
s++, (*n)--;
- s++, (*n)--;
- if (*n == 0) {
- break;
- }
- } else {
- break;
+ s++, (*n)--;
+ if (*n == 0) {
+ break;
+ }
+ } else {
+ break;
}
}
}
- start = s;
+ start = s;
for (; *n && *s && !strchr(delim, *s); s++, (*n)--) {
- ; // do nothing
- }
+ /* do nothing */
+ ;
+ }
- if (*n > 0)
- s++, (*n)--;
+ if (*n > 0) {
+ s++, (*n)--;
+ }
- *saveptr = s;
+ *saveptr = s;
- retlen = s - start;
- ret = malloc(retlen + 1);
- p = ret;
+ retlen = s - start;
+ ret = malloc(retlen + 1);
+ p = ret;
- if (retlen == 0) {
- *p = 0;
- return ret;
- }
+ if (retlen == 0) {
+ *p = 0;
+ return ret;
+ }
- while (retlen > 0) {
+ while (retlen > 0) {
if (*start == '/' && retlen > 1) {
if (start[1] == '/') {
do {
start++, retlen--;
} while (retlen > 1 && start[1] != '\n' && start[1] != '\r');
- start++, retlen--;
- continue;
+ start++, retlen--;
+ continue;
} else if (start[1] == '*') {
do {
start++, retlen--;
} while (retlen > 2 && (start[1] != '*' || start[2] != '/'));
start += 3, retlen -= 3;
- continue;
+ continue;
}
}
- *(p++) = *(start++), retlen--;
- }
-
- *p = 0;
- return ret;
+ *(p++) = *(start++), retlen--;
+ }
+
+ *p = 0;
+ return ret;
}
static char *do_eglShaderPatch(const char *source, int length, int *patched_len)
{
- const char *saveptr = NULL;
- char *sp;
- char *p = NULL;
+ const char *saveptr = NULL;
+ char *sp;
+ char *p = NULL;
- if (!length)
+ if (!length) {
length = strlen(source);
-
+ }
+
*patched_len = 0;
int patched_size = length;
char *patched = malloc(patched_size + 1);
- if (!patched)
+ if (!patched) {
return NULL;
+ }
p = opengl_strtok(source, &length, &saveptr, NULL);
for (; p; p = opengl_strtok(0, &length, &saveptr, p)) {
- if (!strncmp(p, "lowp", 4) || !strncmp(p, "mediump", 7) || !strncmp(p, "highp", 5)) {
+ if (!strncmp(p, "lowp", 4) ||
+ !strncmp(p, "mediump", 7) ||
+ !strncmp(p, "highp", 5)) {
continue;
} else if (!strncmp(p, "precision", 9)) {
- while ((p = opengl_strtok(0, &length, &saveptr, p)) && !strchr(p, ';')) {
- // do nothing
- ;
- }
+ while ((p = opengl_strtok(0, &length, &saveptr, p)) &&
+ !strchr(p, ';')) {
+ /* do nothing */
+ ;
+ }
} else {
const char *p2;
if (!strncmp(p, "gl_MaxVertexUniformVectors", 26)) {
patched_size *= 2;
patched = realloc(patched, patched_size + 1);
- if (!patched)
+ if (!patched) {
return NULL;
+ }
}
memcpy(patched + *patched_len, p2, new_len);
*patched_len += new_len;
- }
+ }
}
patched[*patched_len] = 0;
/* check that we don't leave dummy preprocessor lines */
for (sp = patched; *sp;) {
for (; *sp == ' ' || *sp == '\t'; sp++) {
- ; // do nothing
- }
+ /* do nothing */
+ ;
+ }
if (!strncmp(sp, "#define", 7)) {
for (p = sp + 7; *p == ' ' || *p == '\t'; p++) {
- ; // do nothing
- }
+ /* do nothing */
+ ;
+ }
if (*p == '\n' || *p == '\r' || *p == '/') {
memset(sp, 0x20, 7);
}
}
for (; *sp && *sp != '\n' && *sp != '\r'; sp++) {
- ; // do nothing
- }
+ /* do nothing */
+ ;
+ }
for (; *sp == '\n' || *sp == '\r'; sp++) {
- ; // do nothing
- }
+ /* do nothing */
+ ;
+ }
}
return patched;
}
-static int
-shadersrc_gles_to_gl(GLsizei count, const char** string, char **s, const GLint* length, GLint *l)
+static int
+shadersrc_gles_to_gl(GLsizei count, const char **string,
+ char **s, const GLint *length, GLint *l)
{
- int i;
-
- for(i = 0; i < count; ++i) {
- GLint len;
- if(length) {
- len = length[i];
- if (len < 0)
- len = string[i] ? strlen(string[i]) : 0;
- } else
- len = string[i] ? strlen(string[i]) : 0;
-
- if(string[i]) {
- s[i] = do_eglShaderPatch(string[i], len, &l[i]);
- if(!s[i]) {
- while(i) {
- free(s[--i]);
- }
-
- free(l);
- free(s);
- return -1;
- }
- } else {
- s[i] = NULL;
- l[i] = 0;
- }
- }
-
- return 0;
+ int i;
+
+ for (i = 0; i < count; ++i) {
+ GLint len;
+ if (length) {
+ len = length[i];
+ if (len < 0) {
+ len = string[i] ? strlen(string[i]) : 0;
+ }
+ } else {
+ len = string[i] ? strlen(string[i]) : 0;
+ }
+
+ if (string[i]) {
+ s[i] = do_eglShaderPatch(string[i], len, &l[i]);
+ if (!s[i]) {
+ while (i) {
+ free(s[--i]);
+ }
+
+ free(l);
+ free(s);
+ return -1;
+ }
+ } else {
+ s[i] = NULL;
+ l[i] = 0;
+ }
+ }
+
+ return 0;
}
#ifdef __APPLE__
*/
static void mac_dump_texture(void)
{
- int w, h;
- unsigned char *buf;
+ int w, h;
+ unsigned char *buf;
- /* only handle target=GL_TEXTURE_2D, level=0, format=GL_RGBA, type=GL_UNSIGNED_BYTE */
- glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &w);
- glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &h);
+ /* only handle target=GL_TEXTURE_2D, level=0,
+ format=GL_RGBA, type=GL_UNSIGNED_BYTE */
+ glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &w);
+ glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &h);
- if ( w == 0 && h == 0 )
- return;
+ if (w == 0 && h == 0) {
+ return;
+ }
- buf = g_malloc( (w*4) * h); /* XXX:need allignment? */
+ buf = g_malloc((w*4) * h); /* XXX:need allignment? */
- glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, buf);
+ glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, buf);
- g_free(buf);
+ g_free(buf);
}
#endif
-static int record_fbconfig_set (ProcessState *process, const GLXFBConfig* fbconfigs, int nconfigs)
+static int record_fbconfig_set(ProcessState *process,
+ const GLXFBConfig *fbconfigs,
+ int nconfigs)
{
- int i;
- int id;
- int previous_entries = 0;
-
- if (!fbconfigs)
- return 0;
-
- /* Check if we already have a similar set in our tables */
- for (i=0; i<process->nfbconfig; i++)
- {
- if (process->fbconfigs_max[i] == nconfigs &&
- !memcmp(fbconfigs, process->fbconfigs[i], sizeof(GLXFBConfig) * nconfigs))
- {
- /* No need to store this set as it's identical to another one */
- // XFree(fbconfigs);
-
- /* Return the identifier of the previously allocated set matching the query */
- id = previous_entries + 1;
- return id;
- }
- else
- previous_entries += process->fbconfigs_max[i];
- }
-
- /* Check if we have room for a new set */
- if (process->nfbconfig >= MAX_FBCONFIG)
- {
- fprintf(stderr, "[%s]:%d Too many FB configs allocated for this process\n", __FUNCTION__, __LINE__);
- // XFree(fbconfigs);
- return 0;
- }
-
- /* Store new set - this block should be released using XFree on process exit */
- process->fbconfigs[process->nfbconfig] = fbconfigs;
- process->fbconfigs_max[process->nfbconfig] = nconfigs;
- process->nfbconfig++;
- process->nfbconfig_total += nconfigs;
-
- id = previous_entries + 1;
- return id;
-}
-
-
-int do_function_call(ProcessState *process, int func_number, unsigned long *args, char *ret_string)
+ int i;
+ int id;
+ int previous_entries = 0;
+
+ if (!fbconfigs) {
+ return 0;
+ }
+
+ /* Check if we already have a similar set in our tables */
+ for (i = 0; i < process->nfbconfig; i++) {
+ if (process->fbconfigs_max[i] == nconfigs &&
+ !memcmp(fbconfigs, process->fbconfigs[i],
+ sizeof(GLXFBConfig) * nconfigs)) {
+ /* No need to store this set as it's identical to another one */
+ /* XFree(fbconfigs); */
+
+ /* Return the identifier of the previously allocated
+ set matching the query */
+ id = previous_entries + 1;
+ return id;
+ } else {
+ previous_entries += process->fbconfigs_max[i];
+ }
+ }
+
+ /* Check if we have room for a new set */
+ if (process->nfbconfig >= MAX_FBCONFIG) {
+ fprintf(stderr,
+ "[%s]:%d Too many FB configs allocated for this process\n",
+ __func__, __LINE__);
+ /* XFree(fbconfigs); */
+ return 0;
+ }
+
+ /* Store new set -
+ this block should be released using XFree on process exit */
+ process->fbconfigs[process->nfbconfig] = fbconfigs;
+ process->fbconfigs_max[process->nfbconfig] = nconfigs;
+ process->nfbconfig++;
+ process->nfbconfig_total += nconfigs;
+
+ id = previous_entries + 1;
+ return id;
+}
+
+
+int do_function_call(ProcessState *process, int func_number,
+ unsigned long *args, char *ret_string)
{
union gl_ret_type ret;
ret.s = NULL;
if (display_function_call) {
- DEBUGF( "[%d]> %s\n", process->p.process_id,
- tab_opengl_calls_name[func_number]);
+ DEBUGF("[%d]> %s\n", process->p.process_id,
+ tab_opengl_calls_name[func_number]);
}
- TRACE( "[%d]> %s\n", process->p.process_id,
- tab_opengl_calls_name[func_number]);
+ TRACE("[%d]> %s\n", process->p.process_id,
+ tab_opengl_calls_name[func_number]);
switch (func_number) {
case -1:
break;
-
case _resize_surface_func:
{
ClientGLXDrawable client_drawable = to_drawable(args[0]);
QGloSurface *qsurface = get_qsurface_from_client_drawable(
- process->current_state, client_drawable);
+ process->current_state,
+ client_drawable);
- // We have to assume the current context here
- // since we assume that a drawable must belong to a specific context
- if (qsurface)
+ /* We have to assume the current context here since we assume that
+ a drawable must belong to a specific context */
+ if (qsurface) {
resize_surface(process, qsurface, (int)args[1], (int)args[2]);
- else
- DEBUGF("%s Failed to find surface for client_drawable %p process %p ->current_state %p ->->current_surface %p\n", "_resize_surface_func", client_drawable, process, process->current_state, process->current_state->current_qsurface);
+ } else {
+ DEBUGF("%s Failed to find surface for client_drawable(%p),"
+ "process(%p),current_state(%p),current_surface(%p)\n",
+ "_resize_surface_func", client_drawable, process,
+ process->current_state,
+ process->current_state->current_qsurface);
+ }
break;
-
}
-
case _render_surface_func:
{
ClientGLXDrawable client_drawable = to_drawable(args[0]);
QGloSurface *qsurface = get_qsurface_from_client_drawable(
- process->current_state, client_drawable);
+ process->current_state,
+ client_drawable);
int bpp = (int)args[1];
int stride = (int)args[2];
- char *render_buffer = (char*)args[3];
-
-// DEBUGF( "win: %08x stride: %d buf: %08x cl_dr: %08x qsurf: %08x\n", args[0], args[1], args[2], client_drawable, qsurface);
+ char *render_buffer = (char *)args[3];
- // We have to assume the current context here
- // since we assume that a drawable must belong to a specific context
- if (qsurface)
+ /* We have to assume the current context here since we assume that
+ a drawable must belong to a specific context */
+ if (qsurface) {
render_surface(qsurface, bpp, stride, render_buffer);
+ }
break;
-
}
-
case glXWaitGL_func:
{
- glFinish(); //glXWaitGL();
+ glFinish(); /* glXWaitGL(); */
ret.i = 0;
break;
}
-
case glXWaitX_func:
{
- // FIXME GW Maybe we should just do this on the server?
- //glXWaitX();
+ /* FIXME GW Maybe we should just do this on the server? */
+ /* glXWaitX(); */
ret.i = 0;
break;
}
-
case glXChooseVisual_func:
{
- ret.i = glXChooseVisualFunc((int *) &args[2]);
+ ret.i = glXChooseVisualFunc((int *)&args[2]);
break;
}
-
case glXQueryExtensionsString_func:
{
- ret.s = supported_glx_extensions();//glXQueryExtensionsString(dpy, 0);
+ /* glXQueryExtensionsString(dpy, 0); */
+ ret.s = supported_glx_extensions();
break;
}
case glXQueryServerString_func:
{
switch (args[2]) {
- case GLX_VENDOR : ret.s = FAKE_GLX_VENDOR; break;
- case GLX_VERSION : ret.s = FAKE_GLX_VERSION_STRING; break;
- case GLX_EXTENSIONS : ret.s = supported_glx_extensions(); break;
- default: ret.s = 0;
+ case GLX_VENDOR:
+ ret.s = FAKE_GLX_VENDOR;
+ break;
+ case GLX_VERSION:
+ ret.s = FAKE_GLX_VERSION_STRING;
+ break;
+ case GLX_EXTENSIONS:
+ ret.s = supported_glx_extensions();
+ break;
+ default:
+ ret.s = 0;
+ break;
}
break;
}
-
case glXGetClientString_func:
{
switch (args[1]) {
- case GLX_VENDOR : ret.s = FAKE_GLX_VENDOR; break;
- case GLX_VERSION : ret.s = FAKE_GLX_VERSION_STRING; break;
- case GLX_EXTENSIONS : ret.s = "GLX_ARB_get_proc_address "; break;
- default: ret.s = 0;
+ case GLX_VENDOR:
+ ret.s = FAKE_GLX_VENDOR;
+ break;
+ case GLX_VERSION:
+ ret.s = FAKE_GLX_VERSION_STRING;
+ break;
+ case GLX_EXTENSIONS:
+ ret.s = "GLX_ARB_get_proc_address ";
+ break;
+ default:
+ ret.s = 0;
+ break;
}
break;
}
-
case glXGetScreenDriver_func:
{
- // FIXME GW What is this? not documented anywhere!!
- //GET_EXT_PTR(const char *, glXGetScreenDriver, (Display *, int));
- //ret.s = ptr_func_glXGetScreenDriver(dpy, 0);
+ /* FIXME GW What is this? not documented anywhere!! */
+ /*GET_EXT_PTR(const char *, glXGetScreenDriver, (Display *, int));
+ ret.s = ptr_func_glXGetScreenDriver(dpy, 0); */
ret.s = "";
break;
}
-
case glXGetDriverConfig_func:
{
- // FIXME GW What is this? not documented anywhere!!
- //GET_EXT_PTR(const char *, glXGetDriverConfig, (const char *));
- //ret.s = ptr_func_glXGetDriverConfig((const char *) args[0]);
+ /* FIXME GW What is this? not documented anywhere!! */
+ /*GET_EXT_PTR(const char *, glXGetDriverConfig, (const char *));
+ ret.s = ptr_func_glXGetDriverConfig((const char *) args[0]); */
ret.s = "";
break;
}
-
case glXCreateContext_func:
{
int visualid = (int) args[1];
int fake_shareList = (int) args[2];
- if (display_function_call)
- DEBUGF( "visualid=%d, fake_shareList=%d\n", visualid,
- fake_shareList);
+ if (display_function_call) {
+ DEBUGF("visualid=%d, fake_shareList=%d\n", visualid,
+ fake_shareList);
+ }
- GLState *shareListState = get_glstate_for_fake_ctxt(process, fake_shareList);
+ GLState *shareListState = get_glstate_for_fake_ctxt(process,
+ fake_shareList);
ret.i = 0;
- // Work out format flags from visual id
+ /* Work out format flags from visual id */
int formatFlags = GLO_FF_DEFAULT;
- if (visualid>=0 && visualid<DIM(FBCONFIGS))
+ if (visualid >= 0 && visualid < DIM(FBCONFIGS)) {
formatFlags = FBCONFIGS[visualid].formatFlags;
+ }
GloContext *context = glo_context_create(formatFlags,
- (GloContext*)shareListState ? shareListState->context : 0);
+ (GloContext *)shareListState ?
+ shareListState->context : 0);
if (context) {
- GLState *state = _create_context(process, ++process->next_available_context_number);
+ GLState *state = _create_context(process,
+ ++process->next_available_context_number);
if (state) {
state->context = context;
set_context_sharelist(process, state, fake_shareList);
ret.i = state->fake_ctxt;
} else {
- DEBUGF("Failed to allocate state context for format %08x\n", formatFlags);
+ DEBUGF("Failed to allocate state context"
+ " for format %08x\n", formatFlags);
glo_context_destroy(context);
}
} else {
- DEBUGF("Failed to create context for format %08x\n", formatFlags);
+ DEBUGF("Failed to create context "
+ "for format %08x\n", formatFlags);
}
break;
}
-
case glXCreateNewContext_func:
{
int client_fbconfig = args[1];
ret.i = 0;
- const GLXFBConfig *fbconfig = get_fbconfig(process, client_fbconfig);
+ const GLXFBConfig *fbconfig = get_fbconfig(process,
+ client_fbconfig);
if (fbconfig) {
int fake_shareList = args[3];
- GLState *shareListState = get_glstate_for_fake_ctxt(process, fake_shareList);
-
+ GLState *shareListState = get_glstate_for_fake_ctxt(process,
+ fake_shareList);
+ /* FIXME GW get from fbconfig */
GloContext *context = glo_context_create(fbconfig->formatFlags,
- (GloContext*)shareListState ? shareListState->context : 0); // FIXME GW get from fbconfig
+ (GloContext *)shareListState ?
+ shareListState->context : 0);
if (context) {
- GLState *state = _create_context(process, ++process->next_available_context_number);
+ GLState *state =
+ _create_context(process,
+ ++process->next_available_context_number);
if (state) {
state->context = context;
set_context_sharelist(process, state, fake_shareList);
ret.i = state->fake_ctxt;
} else {
- DEBUGF("Failed to allocate state context for format %08x", fbconfig->formatFlags);
+ DEBUGF("Failed to allocate state context"
+ " for format %08x", fbconfig->formatFlags);
glo_context_destroy(context);
}
} else {
- DEBUGF("Failed to create context for format %08x", fbconfig->formatFlags);
+ DEBUGF("Failed to create context"
+ " for format %08x", fbconfig->formatFlags);
}
}
break;
}
-
case glXCopyContext_func:
{
- DEBUGF( " glXCopyContext not supported (does anything use it?)\n");
+ DEBUGF("glXCopyContext not supported (does anything use it?)\n");
break;
}
-
case glXDestroyContext_func:
{
- int fake_ctxt = (int) args[1];
+ int fake_ctxt = (int)args[1];
- if (display_function_call)
- DEBUGF( "fake_ctxt=%d\n", fake_ctxt);
+ if (display_function_call) {
+ DEBUGF("fake_ctxt=%d\n", fake_ctxt);
+ }
int i;
- for (i = 0; i < process->nb_states; i ++) {
+ for (i = 0; i < process->nb_states; i++) {
if (process->glstates[i]->fake_ctxt == fake_ctxt) {
- /*XXX: DestroyContext should not switch current context, or
- * else guest still try to access it and cause qemu
- * segfalt. But not sure if any corner case, so comment it
- * for now and will remove it completely in future.
- */
- // this was our GLState...
- // process->current_state = &process->default_state;
-
- int fake_shareList =
- process->glstates[i]->fake_shareList;
+ /*XXX: DestroyContext should not switch current context,
+ * or else guest still try to access it
+ * and cause qemu segfalt.
+ * But not sure if any corner case, so comment it
+ * for now and will remove it completely in future.
+ * this was our GLState...
+ * process->current_state = &process->default_state;
+ */
+ int fake_shareList = process->glstates[i]->fake_shareList;
process->glstates[i]->ref--;
if (process->glstates[i]->ref == 0) {
- DEBUGF(
- "destroy_gl_state fake_ctxt = %d\n",
- process->glstates[i]->fake_ctxt);
+ DEBUGF("destroy_gl_state fake_ctxt = %d\n",
+ process->glstates[i]->fake_ctxt);
destroy_gl_state(process->glstates[i]);
g_free(process->glstates[i]);
memmove(&process->glstates[i],
&process->glstates[i + 1],
(process->nb_states - i - 1) *
sizeof(GLState *));
- process->nb_states --;
+ process->nb_states--;
}
if (fake_shareList) {
fake_shareList) {
process->glstates[i]->ref--;
if (process->glstates[i]->ref == 0) {
- DEBUGF(
- "destroy_gl_state fake_sharelist fake_ctxt = %d\n",
- process->glstates[i]->
- fake_ctxt);
- destroy_gl_state(process->
- glstates[i]);
+ DEBUGF("destroy_gl_state fake_sharelist"
+ " fake_ctxt = %d\n",
+ process->glstates[i]->fake_ctxt);
+ destroy_gl_state(process->glstates[i]);
g_free(process->glstates[i]);
memmove(&process->glstates[i],
&process->glstates[i + 1],
(process->nb_states - i - 1) *
sizeof(GLState *));
- process->nb_states --;
+ process->nb_states--;
}
break;
}
}
}
-
break;
}
}
break;
}
-
case glXQueryVersion_func:
{
- int *major = (int *) args[1];
- int *minor = (int *) args[2];
- //ret.i = glXQueryVersion(dpy, (int *) args[1], (int *) args[2]);
- if (major) *major=FAKE_GLX_VERSION_MAJOR;
- if (minor) *minor=FAKE_GLX_VERSION_MINOR;
+ int *major = (int *)args[1];
+ int *minor = (int *)args[2];
+ /* ret.i = glXQueryVersion(dpy, (int *)args[1], (int *)args[2]); */
+ if (major) {
+ *major = FAKE_GLX_VERSION_MAJOR;
+ }
+ if (minor) {
+ *minor = FAKE_GLX_VERSION_MINOR;
+ }
ret.i = True;
break;
}
-
case glGetString_func:
{
switch (args[0]) {
- case GL_VENDOR:
+ case GL_VENDOR:
ret.s = FAKE_GL_VENDOR;
- break;
- case GL_RENDERER:
+ break;
+ case GL_RENDERER:
ret.s = FAKE_GL_RENDERER;
- break;
- case GL_VERSION:
+ break;
+ case GL_VERSION:
ret.s = FAKE_GL_VERSION;
- break;
- case GL_EXTENSIONS:
+ break;
+ case GL_EXTENSIONS:
ret.s = compute_gl_extensions();
- break;
- case GL_SHADING_LANGUAGE_VERSION:
- if(FAKE_GL_MAJOR < 2) {
- ret.s = "";
- break;
+ break;
+ case GL_SHADING_LANGUAGE_VERSION:
+ if (FAKE_GL_MAJOR < 2) {
+ ret.s = "";
+ break;
}
- // Fall through.
- default:
- ret.s = (char *) glGetString(args[0]);
- break;
+ /* Fall through. */
+ default:
+ ret.s = (char *)glGetString(args[0]);
+ break;
}
break;
}
-
case glXMakeCurrent_func:
{
ClientGLXDrawable client_drawable = to_drawable(args[1]);
- int fake_ctxt = (int) args[2];
+ int fake_ctxt = (int)args[2];
GLState *glstate = NULL;
- DEBUGF( "Makecurrent: fake_ctx=%d client_drawable=%08x\n", fake_ctxt, client_drawable);
+ DEBUGF("Makecurrent: fake_ctx=%d client_drawable=%08x\n",
+ fake_ctxt, client_drawable);
if (client_drawable == 0 && fake_ctxt == 0) {
/* Release context */
- if(process->current_state->current_qsurface) {
- if(process->current_state->current_qsurface->type != SURFACE_PIXMAP)
+ if (process->current_state->current_qsurface) {
+ if (process->current_state->current_qsurface->type !=
+ SURFACE_PIXMAP) {
process->current_state->current_qsurface->ref--;
- else
- unbind_qsurface(process->current_state, process->current_state->current_qsurface);
+ } else {
+ unbind_qsurface(process->current_state,
+ process->current_state->current_qsurface);
+ }
}
process->current_state = &process->default_state;
- DEBUGF( " --release\n");
+ DEBUGF(" --release\n");
glo_surface_makecurrent(0);
} else { /* Lookup GLState struct for this context */
glstate = get_glstate_for_fake_ctxt(process, fake_ctxt);
if (!glstate) {
- DEBUGF( " --invalid fake_ctxt (%d)!\n", fake_ctxt);
+ DEBUGF(" --invalid fake_ctxt (%d)!\n", fake_ctxt);
} else {
- if(!set_current_qsurface(glstate, client_drawable) &&
- !link_qsurface(process, glstate, client_drawable) ) {
- // If there is no surface, create one.
- QGloSurface *qsurface = calloc(1, sizeof(QGloSurface));
- qsurface->surface = glo_surface_create(4, 4,
- glstate->context);
- qsurface->client_drawable = client_drawable;
- qsurface->ref = 1;
- qsurface->type = SURFACE_WINDOW;
- qsurface->status = SURFACE_ACTIVE;
-
- bind_qsurface(glstate, qsurface);
- DEBUGF( " --Client drawable not found, create new surface: %p %16lx\n", qsurface, (unsigned long int)client_drawable);
- }
- else {
- DEBUGF( " --Client drawable found, using surface: %p %16lx\n", glstate->current_qsurface, (unsigned long int)client_drawable);
+ if (!set_current_qsurface(glstate, client_drawable) &&
+ !link_qsurface(process, glstate, client_drawable)) {
+ /* If there is no surface, create one. */
+ QGloSurface *qsurface = calloc(1, sizeof(QGloSurface));
+ qsurface->surface = glo_surface_create(4, 4,
+ glstate->context);
+ qsurface->client_drawable = client_drawable;
+ qsurface->ref = 1;
+ qsurface->type = SURFACE_WINDOW;
+ qsurface->status = SURFACE_ACTIVE;
+
+ bind_qsurface(glstate, qsurface);
+ DEBUGF(" --Client drawable not found, "
+ "create new surface: %p %16lx\n",
+ qsurface, (unsigned long int)client_drawable);
+ } else {
+ DEBUGF(" --Client drawable found, using surface: "
+ "%p %16lx\n", glstate->current_qsurface,
+ (unsigned long int)client_drawable);
}
#if 0
/*Test old surface contents */
int reset_texture = 0;
GLState *old_glstate = NULL;
/* Switch from pixmap */
- if (process->current_state->current_qsurface && SURFACE_PIXMAP == process->current_state->current_qsurface->type )
- {
- glo_surface_updatecontents(process->current_state->current_qsurface->surface);
+ if (process->current_state->current_qsurface &&
+ SURFACE_PIXMAP == process->current_state->
+ current_qsurface->type) {
+ glo_surface_updatecontents(
+ process->current_state->
+ current_qsurface->surface);
reset_texture = 1;
old_glstate = process->current_state;
}
- fprintf(stderr, "edwin:MakeCurrent: drawable=0x%x,qsurface=%p.\n", client_drawable, glstate->current_qsurface);
+ fprintf(stderr,
+ "MakeCurrent: drawable=0x%x,qsurface=%p.\n",
+ client_drawable, glstate->current_qsurface);
#endif
/* Switch in pixmap surface */
- if (glstate->current_qsurface && SURFACE_PIXMAP == glstate->current_qsurface->type )
- {
- /* Release it if the surface is used as texture target */
- glo_surface_release_texture(glstate->current_qsurface->surface);
+ if (glstate->current_qsurface && SURFACE_PIXMAP ==
+ glstate->current_qsurface->type) {
+ /* Release it if the surface is used
+ as texture target */
+ glo_surface_release_texture(
+ glstate->current_qsurface->surface);
}
process->current_state = glstate;
- ret.i = glo_surface_makecurrent(glstate->current_qsurface->surface);
-/* if (reset_texture)*/
-/* glo_surface_as_texture(process->current_state->context, old_glstate->current_qsurface->surface);*/
+ ret.i = glo_surface_makecurrent(
+ glstate->current_qsurface->surface);
+/* if (reset_texture) {
+ glo_surface_as_texture(
+ process->current_state->context,
+ old_glstate->current_qsurface->surface);
+ } */
}
}
break;
}
-
case glXSwapBuffers_func:
{
- // Does nothing - window data is copied via render_surface()
+ /* Does nothing - window data is copied via render_surface() */
break;
}
case glXIsDirect_func:
{
- // int fake_ctxt = (int) args[1];
+ /* int fake_ctxt = (int) args[1]; */
- // Does this go direct and skip the X server? We'll just say
- // yes for now.
+ /* Does this go direct and skip the X server? We'll just say
+ yes for now. */
ret.c = True;
-
break;
}
-
case glXGetConfig_func:
{
int visualid = args[1];
- ret.i = glXGetConfigFunc(visualid, args[2], (int *) args[3]);
+ ret.i = glXGetConfigFunc(visualid, args[2], (int *)args[3]);
break;
}
-
case glXGetConfig_extended_func:
{
int visualid = args[1];
int n = args[2];
int i;
- int *attribs = (int *) args[3];
- int *values = (int *) args[4];
- int *res = (int *) args[5];
+ int *attribs = (int *)args[3];
+ int *values = (int *)args[4];
+ int *res = (int *)args[5];
for (i = 0; i < n; i++) {
res[i] = glXGetConfigFunc(visualid, attribs[i], &values[i]);
}
break;
}
-
case glXUseXFont_func:
{
/* implementation is client-side only :-) */
break;
}
-
case glXQueryExtension_func:
{
- int *errorBase = (int *) args[1];
- int *eventBase = (int *) args[2];
- if (errorBase) *errorBase = 0; /* FIXME GW */
- if (eventBase) *eventBase = 0; /* FIXME GW */
+ int *errorBase = (int *)args[1];
+ int *eventBase = (int *)args[2];
+ if (errorBase) {
+ *errorBase = 0; /* FIXME GW */
+ }
+ if (eventBase) {
+ *eventBase = 0; /* FIXME GW */
+ }
ret.i = True;
break;
}
-
case glXChooseFBConfig_func:
{
- /* Retrieve array of FB configs matching our contraints */
- const GLXFBConfig *fbconfigs = glXChooseFBConfigFunc(args[1], (int *) args[2], (int *) args[3]);
-
- /* Record this in our tables and return a client-side identifier for the first entry in the array */
- ret.i = record_fbconfig_set(process, fbconfigs, *(int *) args[3]);
-
- /* Zero indicates failure */
- if (ret.i == 0)
- *(int *) args[3] = 0;
-
- break;
- }
-
+ /* Retrieve array of FB configs matching our contraints */
+ const GLXFBConfig *fbconfigs = glXChooseFBConfigFunc(args[1],
+ (int *)args[2], (int *)args[3]);
+
+ /* Record this in our tables and return a client-side identifier
+ for the first entry in the array */
+ ret.i = record_fbconfig_set(process, fbconfigs, *(int *)args[3]);
+
+ /* Zero indicates failure */
+ if (ret.i == 0) {
+ *(int *)args[3] = 0;
+ }
+ break;
+ }
case glXGetFBConfigs_func:
{
- /* Retrieve array of available FB configs */
- const GLXFBConfig *fbconfigs = glXGetFBConfigsFunc(args[1], (int *) args[2]);
-
- /* Record this in our tables and return a client-side identifier for the first entry in the array */
- ret.i = record_fbconfig_set(process, fbconfigs, *(int *) args[2]);
-
- /* Zero indicates failure */
- if (ret.i == 0)
- *(int *) args[2] = 0;
-
+ /* Retrieve array of available FB configs */
+ const GLXFBConfig *fbconfigs = glXGetFBConfigsFunc(args[1],
+ (int *)args[2]);
+
+ /* Record this in our tables and return a client-side identifier
+ for the first entry in the array */
+ ret.i = record_fbconfig_set(process, fbconfigs, *(int *)args[2]);
+
+ /* Zero indicates failure */
+ if (ret.i == 0) {
+ *(int *)args[2] = 0;
+ }
break;
}
case glXGetFBConfigAttrib_func:
int client_fbconfig = args[1];
ret.i = 0;
- const GLXFBConfig *fbconfig = get_fbconfig(process, client_fbconfig);
+ const GLXFBConfig *fbconfig = get_fbconfig(process,
+ client_fbconfig);
- if (fbconfig)
+ if (fbconfig) {
ret.i =
- glXGetFBConfigAttribFunc(fbconfig, args[2], (int *) args[3]);
+ glXGetFBConfigAttribFunc(fbconfig, args[2],
+ (int *)args[3]);
+ }
break;
}
-
case glXGetFBConfigAttrib_extended_func:
{
int client_fbconfig = args[1];
int n = args[2];
int i;
- int *attribs = (int *) args[3];
- int *values = (int *) args[4];
- int *res = (int *) args[5];
- const GLXFBConfig *fbconfig = get_fbconfig(process, client_fbconfig);
+ int *attribs = (int *)args[3];
+ int *values = (int *)args[4];
+ int *res = (int *)args[5];
+ const GLXFBConfig *fbconfig = get_fbconfig(process,
+ client_fbconfig);
for (i = 0; i < n; i++) {
if (fbconfig) {
res[i] =
- glXGetFBConfigAttribFunc(fbconfig, attribs[i], &values[i]);
+ glXGetFBConfigAttribFunc(fbconfig,
+ attribs[i], &values[i]);
} else {
res[i] = 0;
}
}
case glXQueryContext_func:
{
- DEBUGF( "glXQueryContext not implemented\n");
+ DEBUGF("glXQueryContext not implemented\n");
ret.i = 0;
-#if 0 //GW
+#if 0 /* GW */
GET_EXT_PTR(int, glXQueryContext,
(Display *, GLXContext, int, int *));
int fake_ctxt = (int) args[1];
- if (display_function_call)
- DEBUGF( "fake_ctx=%i\n", fake_ctxt);
+ if (display_function_call) {
+ DEBUGF("fake_ctx=%i\n", fake_ctxt);
+ }
GLXContext ctxt =
get_association_fakecontext_glxcontext(process, fake_ctxt);
if (ctxt == NULL) {
- DEBUGF( "invalid fake_ctxt (%i) !\n", fake_ctxt);
+ DEBUGF("invalid fake_ctxt (%i) !\n", fake_ctxt);
ret.i = 0;
} else {
ret.i =
ptr_func_glXQueryContext(dpy, ctxt, args[2],
- (int *) args[3]);
+ (int *)args[3]);
}
#endif
break;
}
-
case glXQueryDrawable_func:
{
- // TODO GW one of:
- // GLX_WIDTH, GLX_HEIGHT, GLX_PRESERVED_CONTENTS, GLX_LARGEST_PBUFFER, GLX_FBCONFIG_ID
- DEBUGF( "FIXME: glXQueryDrawable not implemented\n");
+ /* TODO GW one of:
+ GLX_WIDTH, GLX_HEIGHT, GLX_PRESERVED_CONTENTS,
+ GLX_LARGEST_PBUFFER, GLX_FBCONFIG_ID */
+ DEBUGF("FIXME: glXQueryDrawable not implemented\n");
ret.i = 0;
-#if 0 //GW
+#if 0 /* GW */
GET_EXT_PTR(void, glXQueryDrawable,
(Display *, GLXDrawable, int, int *));
ClientGLXDrawable client_drawable = to_drawable(args[1]);
get_association_clientdrawable_serverdrawable(
glstate, client_drawable);
- if (display_function_call)
- DEBUGF( "client_drawable=%p\n",
- client_drawable);
+ if (display_function_call) {
+ DEBUGF("client_drawable=%p\n", client_drawable);
+ }
- if (!drawable)
- DEBUGF( "invalid client_drawable (%p) !\n",
- client_drawable);
- else
+ if (!drawable) {
+ DEBUGF("invalid client_drawable (%p) !\n", client_drawable);
+ } else {
ptr_func_glXQueryDrawable(dpy, drawable,
- args[2], (int *) args[3]);
+ args[2], (int *)args[3]);
+ }
#endif
break;
}
int client_fbconfig = args[1];
ret.i = 0;
- const GLXFBConfig *fbconfig = get_fbconfig(process, client_fbconfig);
+ const GLXFBConfig *fbconfig = get_fbconfig(process,
+ client_fbconfig);
if (fbconfig) {
- // we tread visualid as the index into the fbconfigs array
+ /* we tread visualid as the index into the fbconfigs array */
ret.i = &FBCONFIGS[0] - fbconfig;
- if (display_function_call)
- DEBUGF( "visualid = %d\n", ret.i);
+ if (display_function_call) {
+ DEBUGF("visualid = %d\n", ret.i);
+ }
}
break;
}
case glXGetProcAddress_fake_func:
{
-// if (display_function_call)
- //DEBUGF( "glXGetProcAddress %s ", (char *) args[0]);
- // ret.i = glo_getprocaddress((const char *) args[0]) != NULL;
- // DEBUGF( " == %08x\n", ret.i);
+ /* if (display_function_call)
+ DEBUGF( "glXGetProcAddress %s ", (char *) args[0]);
+ ret.i = glo_getprocaddress((const char *) args[0]) != NULL;
+ DEBUGF( " == %08x\n", ret.i); */
ret.i = 0;
break;
}
-
case glXGetProcAddress_global_fake_func:
{
int nbElts = args[0];
- char *huge_buffer = (char *) args[1];
- char *result = (char *) args[2];
+ char *huge_buffer = (char *)args[1];
+ char *result = (char *)args[2];
int i;
for (i = 0; i < nbElts; i++) {
int len = strlen(huge_buffer);
- //DEBUGF( "glXGetProcAddress_global %s ", (char *)huge_buffer);
+ /* DEBUGF("glXGetProcAddress_global %s\n",
+ (char *)huge_buffer); */
result[i] =
- glo_getprocaddress((const char *) huge_buffer) !=
- NULL;
+ glo_getprocaddress((const char *)huge_buffer) != NULL;
huge_buffer += len + 1;
}
break;
int client_fbconfig = args[1];
ret.i = 0;
- const GLXFBConfig *fbconfig = get_fbconfig(process, client_fbconfig);
+ const GLXFBConfig *fbconfig = get_fbconfig(process,
+ client_fbconfig);
if (fbconfig) {
/* Create a light-weight context just for creating surface */
- GloContext *context = __glo_context_create(fbconfig->formatFlags);
+ GloContext *context = __glo_context_create(
+ fbconfig->formatFlags);
if (context) {
/* glXPixmap same as input Pixmap */
ClientGLXDrawable client_drawable = to_drawable(args[2]);
if (qsurface) {
/* get the width and height */
int width, height;
- glo_geometry_get_from_glx((int*)args[3], &width, &height);
+ glo_geometry_get_from_glx((int *)args[3],
+ &width, &height);
- DEBUGF( "glXCreatePixmap: %dX%d.\n", width, height);
- qsurface->surface = glo_surface_create(width, height, context);
+ DEBUGF("glXCreatePixmap: %dX%d.\n", width, height);
+ qsurface->surface = glo_surface_create(width,
+ height, context);
if (qsurface->surface) {
qsurface->client_drawable = client_drawable;
qsurface->type = SURFACE_PIXMAP;
qsurface->status = SURFACE_PENDING;
qsurface_pixmap_ref(qsurface);
- /* Keep this surface, will link it with context in MakeCurrent */
+ /* Keep this surface,
+ will link it with context in MakeCurrent */
keep_qsurface(process, qsurface);
- /* If this pixmap is linked as texture previously */
- if (link_drawable(process, client_drawable))
- glo_surface_as_texture(process->current_state->context,
+ /* If this pixmap is linked
+ as texture previously */
+ if (link_drawable(process, client_drawable)) {
+ glo_surface_as_texture(
+ process->current_state->context,
qsurface->surface, qsurface->type);
+ }
ret.i = (int)client_drawable;
} else {
{
/* glXPixmap same as input Pixmap */
ClientGLXDrawable client_drawable = to_drawable(args[1]);
- QGloSurface *qsurface = find_qsurface_from_client_drawable(process, client_drawable);
+ QGloSurface *qsurface =
+ find_qsurface_from_client_drawable(process,
+ client_drawable);
qsurface_pixmap_unref(qsurface);
break;
}
{
int target = args[0];
ClientGLXDrawable client_drawable = to_drawable(args[1]);
- QGloSurface *qsurface = find_qsurface_from_client_drawable(process, client_drawable);
+ QGloSurface *qsurface =
+ find_qsurface_from_client_drawable(process,
+ client_drawable);
- /* Only support GL_TEXTURE_2D according to spec */
- if ( target == GL_TEXTURE_2D )
+ /* Only support GL_TEXTURE_2D according to spec */
+ if (target == GL_TEXTURE_2D) {
add_pixmap_texture_mapping(process->current_state,
process->current_state->bindTexture2D,
client_drawable);
-
- if ( !qsurface )
- {
- if ( !keep_drawable(process, client_drawable) )
- {
- DEBUGF( "No space to store drawable for ImageTargetTexture. Need call CreatePixmapSurface to free them.\n");
+ }
+
+ if (!qsurface) {
+ if (!keep_drawable(process, client_drawable)) {
+ DEBUGF("No space to store drawable for ImageTargetTexture."
+ " Need call CreatePixmapSurface to free them.\n");
break;
}
+ } else {
+ glo_surface_as_texture(process->current_state->context,
+ qsurface->surface, qsurface->type);
}
- else
- glo_surface_as_texture(process->current_state->context, qsurface->surface, qsurface->type);
-
- break;
- }
- case glXBindTexImageARB_fake_func:
- {
- ClientGLXDrawable client_drawable = to_drawable(args[1]);
- QGloSurface *qsurface = find_qsurface_from_client_drawable(process, client_drawable);
- ret.i = 0;
-
-
- if ( qsurface )
- {
- add_pixmap_texture_mapping(process->current_state,
- process->current_state->bindTexture2D,
- client_drawable);
- glo_surface_as_texture(process->current_state->context, qsurface->surface, qsurface->type);
- ret.i = 1;
- }
- else
- DEBUGF( "Not found pbuffer surface for BindTexImage!\n");
-
- break;
- }
- case glXReleaseTexImageARB_fake_func:
- {
- ClientGLXDrawable client_drawable = to_drawable(args[1]);
- QGloSurface *qsurface = find_qsurface_from_client_drawable(process, client_drawable);
-
- if ( qsurface )
- {
- remove_pixmap_texture_mapping(process->current_state,
- client_drawable);
- glo_surface_release_texture(qsurface->surface);
- }
-
- break;
- }
- case glXCreatePbuffer_func:
- {
- int client_fbconfig = args[1];
-
- ret.i = 0;
- const GLXFBConfig *fbconfig = get_fbconfig(process, client_fbconfig);
- if (fbconfig) {
+ break;
+ }
+ case glXBindTexImageARB_fake_func:
+ {
+ ClientGLXDrawable client_drawable = to_drawable(args[1]);
+ QGloSurface *qsurface =
+ find_qsurface_from_client_drawable(process,
+ client_drawable);
+ ret.i = 0;
+
+ if (qsurface) {
+ add_pixmap_texture_mapping(process->current_state,
+ process->current_state->bindTexture2D,
+ client_drawable);
+ glo_surface_as_texture(process->current_state->context,
+ qsurface->surface, qsurface->type);
+ ret.i = 1;
+ } else {
+ DEBUGF("Not found pbuffer surface for BindTexImage!\n");
+ }
+
+ break;
+ }
+ case glXReleaseTexImageARB_fake_func:
+ {
+ ClientGLXDrawable client_drawable = to_drawable(args[1]);
+ QGloSurface *qsurface =
+ find_qsurface_from_client_drawable(process,
+ client_drawable);
+
+ if (qsurface) {
+ remove_pixmap_texture_mapping(process->current_state,
+ client_drawable);
+ glo_surface_release_texture(qsurface->surface);
+ }
+
+ break;
+ }
+ case glXCreatePbuffer_func:
+ {
+ int client_fbconfig = args[1];
+
+ ret.i = 0;
+ const GLXFBConfig *fbconfig = get_fbconfig(process,
+ client_fbconfig);
+ if (fbconfig) {
/* Create a light-weight context just for creating surface */
- GloContext *context = __glo_context_create(fbconfig->formatFlags);
+ GloContext *context =
+ __glo_context_create(fbconfig->formatFlags);
if (context) {
QGloSurface *qsurface = calloc(1, sizeof(QGloSurface));
if (qsurface) {
/* get the width and height */
int width, height;
- glo_geometry_get_from_glx((int*)args[2], &width, &height);
+ glo_geometry_get_from_glx((int *)args[2],
+ &width, &height);
- DEBUGF( "glXCreatePbuffer: %dX%d.\n", width, height);
- qsurface->surface = glo_surface_create(width, height, context);
+ DEBUGF("glXCreatePbuffer: %dX%d.\n", width, height);
+ qsurface->surface = glo_surface_create(width,
+ height,
+ context);
if (qsurface->surface) {
- /* Use GloSurface handler as no input client_drawable, and
- * keep only low 32bit of handler on x86_64 host. */
- qsurface->client_drawable = (ClientGLXDrawable)(long)qsurface->surface;
+ /* Use GloSurface handler
+ as no input client_drawable,
+ and keep only low 32bit of handler
+ on x86_64 host. */
+ qsurface->client_drawable =
+ (ClientGLXDrawable)(long)qsurface->surface;
qsurface->type = SURFACE_PBUFFER;
qsurface->status = SURFACE_PENDING;
- /* qsurface->ref = 1;*/
+ /* qsurface->ref = 1; */
- /* Keep this surface, will link it with context in MakeCurrent */
+ /* Keep this surface,
+ will link it with context in MakeCurrent */
keep_qsurface(process, qsurface);
ret.i = qsurface->client_drawable;
}
}
}
- break;
- }
- case glXDestroyPbuffer_func:
- {
+ break;
+ }
+ case glXDestroyPbuffer_func:
+ {
ClientGLXDrawable client_drawable = to_drawable(args[1]);
- QGloSurface *qsurface = find_qsurface_from_client_drawable(process, client_drawable);
- if ( qsurface &&
- qsurface != process->current_state->current_qsurface &&
- qsurface->glstate == NULL &&
- qsurface->type == SURFACE_PBUFFER )
- {
+ QGloSurface *qsurface =
+ find_qsurface_from_client_drawable(process,
+ client_drawable);
+ if (qsurface &&
+ qsurface != process->current_state->current_qsurface &&
+ qsurface->glstate == NULL &&
+ qsurface->type == SURFACE_PBUFFER) {
glo_surface_destroy(qsurface->surface);
g_free(qsurface);
}
break;
- }
-
+ }
/* Begin of texture stuff */
case glBindTexture_func:
case glBindTextureEXT_func:
unsigned int client_texture = args[1];
unsigned int server_texture;
- if(((int)client_texture) < 0)
- {
- fprintf(stderr, "glBindTexture got invalid texture ID, do nothing!\n");
- break;
- }
+ if (((int)client_texture) < 0) {
+ fprintf(stderr,
+ "glBindTexture got invalid texture ID, do nothing!\n");
+ break;
+ }
if (client_texture == 0) {
glBindTexture(target, 0);
glBindTexture(target, server_texture);
}
- if ( target == GL_TEXTURE_2D ) {
+ if (target == GL_TEXTURE_2D) {
QGloSurface *qsurface = NULL;
ClientGLXDrawable drawable =
- find_pixmap_texture(process->current_state, client_texture);
+ find_pixmap_texture(process->current_state,
+ client_texture);
- if ( drawable )
- {
- qsurface = find_qsurface_from_client_drawable(process, drawable);
+ if (drawable) {
+ qsurface = find_qsurface_from_client_drawable(process,
+ drawable);
- if ( qsurface )
- {
- glo_surface_as_texture(process->current_state->context, qsurface->surface, qsurface->type);
- /*fprintf(stderr, "edwin:bindtexture: drawable=0x%x,qsurface=%p.\n", drawable, qsurface);*/
+ if (qsurface) {
+ glo_surface_as_texture(process->current_state->context,
+ qsurface->surface,
+ qsurface->type);
+ /* fprintf(stderr,
+ "bindtexture: drawable=0x%x,qsurface=%p.\n",
+ drawable, qsurface);*/
}
}
-
process->current_state->bindTexture2D = client_texture;
}
- break;
+ break;
}
-
case glGenTextures_fake_func:
{
- //GET_EXT_PTR(void, glGenTextures, (GLsizei n, GLuint *textures));
+ /* GET_EXT_PTR(void, glGenTextures,
+ (GLsizei n, GLuint *textures)); */
int i;
int n = args[0];
unsigned int *clientTabTextures = g_malloc(n * sizeof(int));
alloc_range(process->current_state->textureAllocator, n,
clientTabTextures);
- //ptr_func_glGenTextures(n, serverTabTextures);
- glGenTextures(n, serverTabTextures);
+ /* ptr_func_glGenTextures(n, serverTabTextures); */
+ glGenTextures(n, serverTabTextures);
for (i = 0; i < n; i++) {
process->current_state->tabTextures[clientTabTextures[i]] =
serverTabTextures[i];
g_free(serverTabTextures);
break;
}
-
-
case glDeleteTextures_func:
{
- //GET_EXT_PTR(void, glDeleteTextures,
- // (GLsizei n, const GLuint *textures));
+ /* GET_EXT_PTR(void, glDeleteTextures,
+ (GLsizei n, const GLuint *textures)); */
int i;
int n = args[0];
- unsigned int *clientTabTextures = (unsigned int *) args[1];
+ unsigned int *clientTabTextures = (unsigned int *)args[1];
delete_range(process->current_state->textureAllocator, n,
clientTabTextures);
serverTabTextures[i] =
get_server_texture(process, clientTabTextures[i]);
}
- //ptr_func_glDeleteTextures(n, serverTabTextures);
- glDeleteTextures(n, serverTabTextures);
+ /* ptr_func_glDeleteTextures(n, serverTabTextures); */
+ glDeleteTextures(n, serverTabTextures);
for (i = 0; i < n; i++) {
process->current_state->tabTextures[clientTabTextures[i]] = 0;
}
g_free(serverTabTextures);
- for ( i = 0; i < n; i++ )
- {
- del_pixmap_texture_mapping(process->current_state, clientTabTextures[i]);
+ for (i = 0; i < n; i++) {
+ del_pixmap_texture_mapping(process->current_state,
+ clientTabTextures[i]);
}
- break;
+ break;
}
-
case glPrioritizeTextures_func:
{
GET_EXT_PTR(void, glPrioritizeTextures,
int i;
int n = args[0];
- unsigned int *textures = (unsigned int *) args[1];
+ unsigned int *textures = (unsigned int *)args[1];
for (i = 0; i < n; i++) {
textures[i] = get_server_texture(process, textures[i]);
}
ptr_func_glPrioritizeTextures(n, textures,
- (const GLclampf *) args[2]);
+ (const GLclampf *)args[2]);
break;
}
-
case glAreTexturesResident_func:
{
GET_EXT_PTR(void, glAreTexturesResident,
(GLsizei n, const GLuint *textures,
- GLboolean *residences));
+ GLboolean *residences));
int i;
int n = args[0];
- unsigned int *textures = (unsigned int *) args[1];
+ unsigned int *textures = (unsigned int *)args[1];
for (i = 0; i < n; i++) {
textures[i] = get_server_texture(process, textures[i]);
}
ptr_func_glAreTexturesResident(n, textures,
- (GLboolean *) args[2]);
+ (GLboolean *)args[2]);
break;
}
-
case glIsTexture_func:
case glIsTextureEXT_func:
{
- //GET_EXT_PTR(GLboolean, glIsTexture, (GLuint texture));
+ /* GET_EXT_PTR(GLboolean, glIsTexture, (GLuint texture)); */
unsigned int client_texture = args[0];
unsigned int server_texture =
get_server_texture(process, client_texture);
- if (server_texture)
- // ret.c = ptr_func_glIsTexture(server_texture);
- ret.c = glIsTexture(server_texture);
- else
+ if (server_texture) {
+ /* ret.c = ptr_func_glIsTexture(server_texture); */
+ ret.c = glIsTexture(server_texture);
+ } else {
ret.c = 0;
+ }
break;
}
-
case glFramebufferTexture1DEXT_func:
{
GET_EXT_PTR(void, glFramebufferTexture1DEXT,
unsigned int client_texture = args[3];
unsigned int server_texture =
get_server_texture(process, client_texture);
- if (server_texture)
+ if (server_texture) {
ptr_func_glFramebufferTexture1DEXT(args[0], args[1], args[2],
server_texture, args[4]);
+ }
break;
}
-
case glFramebufferTexture2D_func:
- //DEBUGF( "wooooot!\n");
+ /* DEBUGF("wooooot!\n"); */
case glFramebufferTexture2DEXT_func:
{
GET_EXT_PTR(void, glFramebufferTexture2DEXT,
unsigned int client_texture = args[3];
unsigned int server_texture =
get_server_texture(process, client_texture);
- if (server_texture)
+ if (server_texture) {
ptr_func_glFramebufferTexture2DEXT(args[0], args[1], args[2],
server_texture, args[4]);
+ }
break;
}
unsigned int client_texture = args[3];
unsigned int server_texture =
get_server_texture(process, client_texture);
- if (server_texture)
+ if (server_texture) {
ptr_func_glFramebufferTexture3DEXT(args[0], args[1], args[2],
server_texture, args[4],
args[5]);
+ }
break;
}
/* End of texture stuff */
unsigned int client_list = args[0];
unsigned int server_list = get_server_list(process, client_list);
- if (server_list)
+ if (server_list) {
ret.c = glIsList(server_list);
- else
+ } else {
ret.c = 0;
+ }
break;
}
get_server_list(process, first_client);
for (i = 0; i < n; i++) {
if (get_server_list(process, first_client + i) !=
- first_server + i)
+ first_server + i) {
break;
+ }
}
if (i == n) {
glDeleteLists(first_server, n);
first_client, n);
break;
}
-
case glGenLists_fake_func:
{
int i;
}
break;
}
-
case glNewList_func:
{
unsigned int client_list = args[0];
glNewList(server_list, mode);
break;
}
-
case glCallList_func:
{
unsigned int client_list = args[0];
glCallList(server_list);
break;
}
-
case glCallLists_func:
{
int i;
int n = args[0];
int type = args[1];
- const GLvoid *lists = (const GLvoid *) args[2];
+ const GLvoid *lists = (const GLvoid *)args[2];
int *new_lists = g_malloc(sizeof(int) * n);
for (i = 0; i < n; i++) {
g_free(new_lists);
break;
}
-
-
/* End of list stuff */
/* Begin of buffer stuff */
}
break;
}
-
case glGenBuffersARB_fake_func:
{
GET_EXT_PTR(void, glGenBuffersARB, (int, unsigned int *));
g_free(serverTabBuffers);
break;
}
-
-
case glDeleteBuffersARB_func:
{
GET_EXT_PTR(void, glDeleteBuffersARB, (int, int *));
int i;
int n = args[0];
- unsigned int *clientTabBuffers = (unsigned int *) args[1];
+ unsigned int *clientTabBuffers = (unsigned int *)args[1];
delete_range(process->current_state->bufferAllocator, n,
clientTabBuffers);
g_free(serverTabBuffers);
break;
}
-
case glIsBufferARB_func:
{
GET_EXT_PTR(int, glIsBufferARB, (int));
unsigned int client_buffer = args[0];
unsigned int server_buffer =
get_server_buffer(process, client_buffer);
- if (server_buffer)
+ if (server_buffer) {
ret.i = ptr_func_glIsBufferARB(server_buffer);
- else
+ } else {
ret.i = 0;
+ }
break;
}
-
/* End of buffer stuff */
-
case glShaderSourceARB_fake_func:
{
GET_EXT_PTR(void, glShaderSourceARB, (int, int, char **, void *));
int i;
int acc_length = 0;
GLcharARB **tab_prog = g_malloc(size * sizeof(GLcharARB *));
- int *tab_length = (int *) args[3];
+ int *tab_length = (int *)args[3];
for (i = 0; i < size; i++) {
- tab_prog[i] = ((GLcharARB *) args[2]) + acc_length;
+ tab_prog[i] = ((GLcharARB *)args[2]) + acc_length;
acc_length += tab_length[i];
}
ptr_func_glShaderSourceARB(args[0], args[1], tab_prog,
g_free(tab_prog);
break;
}
-
case glShaderSource_fake_func:
- {
- GET_EXT_PTR(void, glShaderSource, (int, int, char **, void *));
- int size = args[1];
- int i;
- int acc_length = 0;
- GLcharARB **tab_prog = g_malloc(size * sizeof(GLcharARB *));
- int *tab_length = (int *) args[3];
-
- char **tab_prog_new;
- GLint *tab_length_new;
+ {
+ GET_EXT_PTR(void, glShaderSource, (int, int, char **, void *));
+ int size = args[1];
+ int i;
+ int acc_length = 0;
+ GLcharARB **tab_prog = g_malloc(size * sizeof(GLcharARB *));
+ int *tab_length = (int *)args[3];
- tab_prog_new = malloc(args[1]* sizeof(char*));
- tab_length_new = malloc(args[1]* sizeof(GLint));
+ char **tab_prog_new;
+ GLint *tab_length_new;
- memset(tab_prog_new, 0, args[1] * sizeof(char*));
- memset(tab_length_new, 0, args[1] * sizeof(GLint));
+ tab_prog_new = malloc(args[1] * sizeof(char *));
+ tab_length_new = malloc(args[1] * sizeof(GLint));
+ memset(tab_prog_new, 0, args[1] * sizeof(char *));
+ memset(tab_length_new, 0, args[1] * sizeof(GLint));
- for (i = 0; i < size; i++) {
- tab_prog[i] = ((GLcharARB *) args[2]) + acc_length;
- acc_length += tab_length[i];
- }
- shadersrc_gles_to_gl(args[1], (const char **)tab_prog, tab_prog_new, tab_length, tab_length_new);
+ for (i = 0; i < size; i++) {
+ tab_prog[i] = ((GLcharARB *) args[2]) + acc_length;
+ acc_length += tab_length[i];
+ }
- if (!tab_prog_new || !tab_length_new)
- break;
+ shadersrc_gles_to_gl(args[1], (const char **)tab_prog,
+ tab_prog_new, tab_length, tab_length_new);
- ptr_func_glShaderSource(args[0], args[1], tab_prog_new, tab_length_new);
+ if (!tab_prog_new || !tab_length_new) {
+ break;
+ }
- for (i = 0; i < args[1]; i++) {
- free(tab_prog_new[i]);
- }
+ ptr_func_glShaderSource(args[0], args[1],
+ tab_prog_new, tab_length_new);
- free(tab_prog_new);
- free(tab_length_new);
+ for (i = 0; i < args[1]; i++) {
+ free(tab_prog_new[i]);
+ }
- free(tab_prog);
+ free(tab_prog_new);
+ free(tab_length_new);
- break;
- }
+ free(tab_prog);
+ break;
+ }
case glVertexPointer_fake_func:
{
int offset = args[0];
g_realloc(process->current_state->vertexPointer,
process->current_state->vertexPointerSize);
memcpy(process->current_state->vertexPointer + offset,
- (void *) args[5], bytes_size);
- /* DEBUGF( "glVertexPointer_fake_func size=%d, type=%d,
+ (void *)args[5], bytes_size);
+ /* DEBUGF("glVertexPointer_fake_func size=%d, type=%d,
* stride=%d, byte_size=%d\n", size, type, stride, bytes_size); */
glVertexPointer(size, type, stride,
process->current_state->vertexPointer);
break;
}
-
case glNormalPointer_fake_func:
{
int offset = args[0];
g_realloc(process->current_state->normalPointer,
process->current_state->normalPointerSize);
memcpy(process->current_state->normalPointer + offset,
- (void *) args[4], bytes_size);
- // DEBUGF( "glNormalPointer_fake_func type=%d, stride=%d,
- // byte_size=%d\n", type, stride, bytes_size);
+ (void *)args[4], bytes_size);
+ /* DEBUGF("glNormalPointer_fake_func type=%d, stride=%d,
+ byte_size=%d\n", type, stride, bytes_size); */
glNormalPointer(type, stride,
process->current_state->normalPointer);
break;
}
-
case glIndexPointer_fake_func:
{
int offset = args[0];
g_realloc(process->current_state->indexPointer,
process->current_state->indexPointerSize);
memcpy(process->current_state->indexPointer + offset,
- (void *) args[4], bytes_size);
- // DEBUGF( "glIndexPointer_fake_func type=%d, stride=%d,
- // byte_size=%d\n", type, stride, bytes_size);
+ (void *)args[4], bytes_size);
+ /* DEBUGF("glIndexPointer_fake_func type=%d, stride=%d,
+ byte_size=%d\n", type, stride, bytes_size); */
glIndexPointer(type, stride,
process->current_state->indexPointer);
break;
}
-
case glEdgeFlagPointer_fake_func:
{
int offset = args[0];
g_realloc(process->current_state->edgeFlagPointer,
process->current_state->edgeFlagPointerSize);
memcpy(process->current_state->edgeFlagPointer + offset,
- (void *) args[3], bytes_size);
- // DEBUGF( "glEdgeFlagPointer_fake_func stride = %d,
- // bytes_size=%d\n", stride, bytes_size);
+ (void *)args[3], bytes_size);
+ /* DEBUGF("glEdgeFlagPointer_fake_func stride=%d, bytes_size=%d\n",
+ stride, bytes_size); */
glEdgeFlagPointer(stride,
process->current_state->edgeFlagPointer);
break;
}
-
case glVertexAttribPointerARB_fake_func:
{
GET_EXT_PTR(void, glVertexAttribPointerARB,
process->current_state->
vertexAttribPointerSize[index]);
memcpy(process->current_state->vertexAttribPointer[index] +
- offset, (void *) args[7], bytes_size);
+ offset, (void *)args[7], bytes_size);
ptr_func_glVertexAttribPointerARB(index, size, type, normalized,
stride,
process->current_state->
vertexAttribPointer[index]);
break;
}
-
case glVertexAttribPointerNV_fake_func:
{
GET_EXT_PTR(void, glVertexAttribPointerNV,
process->current_state->
vertexAttribPointerNVSize[index]);
memcpy(process->current_state->vertexAttribPointerNV[index] +
- offset, (void *) args[6], bytes_size);
+ offset, (void *)args[6], bytes_size);
ptr_func_glVertexAttribPointerNV(index, size, type, stride,
process->current_state->
vertexAttribPointerNV[index]);
break;
}
-
case glColorPointer_fake_func:
{
int offset = args[0];
g_realloc(process->current_state->colorPointer,
process->current_state->colorPointerSize);
memcpy(process->current_state->colorPointer + offset,
- (void *) args[5], bytes_size);
- // DEBUGF( "glColorPointer_fake_func bytes_size = %d\n",
- // bytes_size);
+ (void *)args[5], bytes_size);
+ /* DEBUGF("glColorPointer_fake_func bytes_size = %d\n",
+ bytes_size); */
glColorPointer(size, type, stride,
process->current_state->colorPointer);
break;
}
-
case glSecondaryColorPointer_fake_func:
{
GET_EXT_PTR(void, glSecondaryColorPointer,
g_realloc(process->current_state->secondaryColorPointer,
process->current_state->secondaryColorPointerSize);
memcpy(process->current_state->secondaryColorPointer + offset,
- (void *) args[5], bytes_size);
- // DEBUGF( "glSecondaryColorPointer_fake_func bytes_size
- // = %d\n", bytes_size);
+ (void *)args[5], bytes_size);
+ /* DEBUGF("glSecondaryColorPointer_fake_func bytes_size = %d\n",
+ bytes_size); */
ptr_func_glSecondaryColorPointer(size, type, stride,
process->current_state->
secondaryColorPointer);
break;
}
-
case glPushClientAttrib_func:
{
int mask = args[0];
glPushClientAttrib(mask);
break;
}
-
case glPopClientAttrib_func:
{
if (process->current_state->clientStateSp > 0) {
glPopClientAttrib();
break;
}
-
case glClientActiveTexture_func:
case glClientActiveTextureARB_func:
{
do_glClientActiveTextureARB(activeTexture);
break;
}
-
case glTexCoordPointer_fake_func:
{
int offset = args[0];
g_realloc(process->current_state->texCoordPointer[index],
process->current_state->texCoordPointerSize[index]);
memcpy(process->current_state->texCoordPointer[index] + offset,
- (void *) args[6], bytes_size);
- /* DEBUGF( "glTexCoordPointer_fake_func size=%d, type=%d,
- * stride=%d, byte_size=%d\n", size, type, stride, bytes_size); */
+ (void *)args[6], bytes_size);
+ /* DEBUGF("glTexCoordPointer_fake_func size=%d, type=%d,"
+ " stride=%d, byte_size=%d\n",
+ size, type, stride, bytes_size); */
do_glClientActiveTextureARB(GL_TEXTURE0_ARB + index);
glTexCoordPointer(size, type, stride,
process->current_state->texCoordPointer[index]);
activeTextureIndex);
break;
}
-
case glWeightPointerARB_fake_func:
{
GET_EXT_PTR(void, glWeightPointerARB, (int, int, int, void *));
g_realloc(process->current_state->weightPointer,
process->current_state->weightPointerSize);
memcpy(process->current_state->weightPointer + offset,
- (void *) args[5], bytes_size);
- /* DEBUGF( "glWeightPointerARB_fake_func size=%d,
+ (void *)args[5], bytes_size);
+ /* DEBUGF("glWeightPointerARB_fake_func size=%d,
* type=%d, stride=%d, byte_size=%d\n", size, type, stride,
* bytes_size); */
ptr_func_glWeightPointerARB(size, type, stride,
weightPointer);
break;
}
-
case glMatrixIndexPointerARB_fake_func:
{
GET_EXT_PTR(void, glMatrixIndexPointerARB,
g_realloc(process->current_state->matrixIndexPointer,
process->current_state->matrixIndexPointerSize);
memcpy(process->current_state->matrixIndexPointer + offset,
- (void *) args[5], bytes_size);
- /* DEBUGF( "glMatrixIndexPointerARB_fake_func size=%d,
+ (void *)args[5], bytes_size);
+ /* DEBUGF("glMatrixIndexPointerARB_fake_func size=%d,
* type=%d, stride=%d, byte_size=%d\n", size, type, stride,
* bytes_size); */
ptr_func_glMatrixIndexPointerARB(size, type, stride,
matrixIndexPointer);
break;
}
-
case glFogCoordPointer_fake_func:
{
GET_EXT_PTR(void, glFogCoordPointer, (int, int, void *));
g_realloc(process->current_state->fogCoordPointer,
process->current_state->fogCoordPointerSize);
memcpy(process->current_state->fogCoordPointer + offset,
- (void *) args[4], bytes_size);
- // DEBUGF( "glFogCoordPointer_fake_func type=%d,
- // stride=%d, byte_size=%d\n", type, stride, bytes_size);
+ (void *)args[4], bytes_size);
+ /* DEBUGF("glFogCoordPointer_fake_func type=%d,
+ stride=%d, byte_size=%d\n", type, stride, bytes_size); */
ptr_func_glFogCoordPointer(type, stride,
process->current_state->
fogCoordPointer);
break;
}
-
case glVariantPointerEXT_fake_func:
{
GET_EXT_PTR(void, glVariantPointerEXT, (int, int, int, void *));
g_realloc(process->current_state->variantPointerEXT[id],
process->current_state->variantPointerEXTSize[id]);
memcpy(process->current_state->variantPointerEXT[id] + offset,
- (void *) args[5], bytes_size);
- // DEBUGF( "glVariantPointerEXT_fake_func[%d] type=%d,
- // stride=%d, byte_size=%d\n", id, type, stride, bytes_size);
+ (void *)args[5], bytes_size);
+ /* DEBUGF("glVariantPointerEXT_fake_func[%d] type=%d,
+ stride=%d, byte_size=%d\n", id, type, stride, bytes_size); */
ptr_func_glVariantPointerEXT(id, type, stride,
process->current_state->
variantPointerEXT[id]);
break;
}
-
case glInterleavedArrays_fake_func:
{
GET_EXT_PTR(void, glInterleavedArrays, (int, int, void *));
g_realloc(process->current_state->interleavedArrays,
process->current_state->interleavedArraysSize);
memcpy(process->current_state->interleavedArrays + offset,
- (void *) args[4], bytes_size);
- // DEBUGF( "glInterleavedArrays_fake_func format=%d,
- // stride=%d, byte_size=%d\n", format, stride, bytes_size);
+ (void *)args[4], bytes_size);
+ /* DEBUGF("glInterleavedArrays_fake_func format=%d,
+ stride=%d, byte_size=%d\n", format, stride, bytes_size); */
ptr_func_glInterleavedArrays(format, stride,
process->current_state->
interleavedArrays);
break;
}
-
case glElementPointerATI_fake_func:
{
GET_EXT_PTR(void, glElementPointerATI, (int, void *));
g_realloc(process->current_state->elementPointerATI,
process->current_state->elementPointerATISize);
memcpy(process->current_state->elementPointerATI,
- (void *) args[2], bytes_size);
- // DEBUGF( "glElementPointerATI_fake_func type=%d,
- // byte_size=%d\n", type, bytes_size);
+ (void *)args[2], bytes_size);
+ /* DEBUGF("glElementPointerATI_fake_func type=%d,
+ byte_size=%d\n", type, bytes_size); */
ptr_func_glElementPointerATI(type,
process->current_state->
elementPointerATI);
break;
}
-
case glTexCoordPointer01_fake_func:
{
int size = args[0];
g_realloc(process->current_state->texCoordPointer[0],
bytes_size);
memcpy(process->current_state->texCoordPointer[0],
- (void *) args[4], bytes_size);
- /* DEBUGF( "glTexCoordPointer01_fake_func size=%d,
+ (void *)args[4], bytes_size);
+ /* DEBUGF("glTexCoordPointer01_fake_func size=%d,
* type=%d, stride=%d, byte_size=%d\n", size, type, stride,
* bytes_size); */
do_glClientActiveTextureARB(GL_TEXTURE0_ARB + 0);
activeTextureIndex);
break;
}
-
case glTexCoordPointer012_fake_func:
{
int size = args[0];
g_realloc(process->current_state->texCoordPointer[0],
bytes_size);
memcpy(process->current_state->texCoordPointer[0],
- (void *) args[4], bytes_size);
- /* DEBUGF( "glTexCoordPointer012_fake_func size=%d,
+ (void *)args[4], bytes_size);
+ /* DEBUGF("glTexCoordPointer012_fake_func size=%d,
* type=%d, stride=%d, byte_size=%d\n", size, type, stride,
* bytes_size); */
do_glClientActiveTextureARB(GL_TEXTURE0_ARB + 0);
activeTextureIndex);
break;
}
-
case glVertexAndNormalPointer_fake_func:
{
int vertexPointerSize = args[0];
int normalPointerType = args[3];
int normalPointerStride = args[4];
int bytes_size = args[5];
- void *ptr = (void *) args[6];
+ void *ptr = (void *)args[6];
process->current_state->vertexPointerSize = bytes_size;
process->current_state->vertexPointer =
process->current_state->vertexPointer);
break;
}
-
case glVertexNormalPointerInterlaced_fake_func:
{
int i = 0;
int normalPointerOffset = args[i++];
int normalPointerType = args[i++];
int bytes_size = args[i++];
- void *ptr = (void *) args[i++];
+ void *ptr = (void *)args[i++];
process->current_state->vertexPointerSize =
MAX(process->current_state->vertexPointerSize,
normalPointerOffset);
break;
}
-
case glTuxRacerDrawElements_fake_func:
{
int mode = args[0];
int count = args[1];
int isColorEnabled = args[2];
- void *ptr = (void *) args[3];
+ void *ptr = (void *)args[3];
int stride =
6 * sizeof(float) +
((isColorEnabled) ? 4 * sizeof(unsigned char) : 0);
glVertexPointer(3, GL_FLOAT, stride, ptr);
glNormalPointer(GL_FLOAT, stride, ptr + 3 * sizeof(float));
- if (isColorEnabled)
+ if (isColorEnabled) {
glColorPointer(4, GL_UNSIGNED_BYTE, stride,
ptr + 6 * sizeof(float));
+ }
glDrawArrays(mode, 0, count);
-#ifdef __APPLE__ //only for mac
- {
- int prev_fbo;
- glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &prev_fbo);
- if ( prev_fbo != 0 )
- glFlush();
- }
+#ifdef __APPLE__
+ {
+ int prev_fbo;
+ glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &prev_fbo);
+ if (prev_fbo != 0) {
+ glFlush();
+ }
+ }
#endif
-
break;
}
-
case glVertexNormalColorPointerInterlaced_fake_func:
{
int i = 0;
int colorPointerSize = args[i++];
int colorPointerType = args[i++];
int bytes_size = args[i++];
- void *ptr = (void *) args[i++];
+ void *ptr = (void *)args[i++];
process->current_state->vertexPointerSize =
MAX(process->current_state->vertexPointerSize,
colorPointerOffset);
break;
}
-
case glVertexColorTexCoord0PointerInterlaced_fake_func:
{
int i = 0;
int texCoord0PointerSize = args[i++];
int texCoord0PointerType = args[i++];
int bytes_size = args[i++];
- void *ptr = (void *) args[i++];
+ void *ptr = (void *)args[i++];
process->current_state->vertexPointerSize =
MAX(process->current_state->vertexPointerSize,
activeTextureIndex);
break;
}
-
case glVertexNormalTexCoord0PointerInterlaced_fake_func:
{
int i = 0;
int texCoord0PointerSize = args[i++];
int texCoord0PointerType = args[i++];
int bytes_size = args[i++];
- void *ptr = (void *) args[i++];
+ void *ptr = (void *)args[i++];
process->current_state->vertexPointerSize =
MAX(process->current_state->vertexPointerSize,
activeTextureIndex);
break;
}
-
case glVertexNormalTexCoord01PointerInterlaced_fake_func:
{
int i = 0;
int texCoord1PointerSize = args[i++];
int texCoord1PointerType = args[i++];
int bytes_size = args[i++];
- void *ptr = (void *) args[i++];
+ void *ptr = (void *)args[i++];
process->current_state->vertexPointerSize =
MAX(process->current_state->vertexPointerSize,
activeTextureIndex);
break;
}
-
case glVertexNormalTexCoord012PointerInterlaced_fake_func:
{
int i = 0;
int texCoord2PointerSize = args[i++];
int texCoord2PointerType = args[i++];
int bytes_size = args[i++];
- void *ptr = (void *) args[i++];
+ void *ptr = (void *)args[i++];
process->current_state->vertexPointerSize =
MAX(process->current_state->vertexPointerSize,
activeTextureIndex);
break;
}
-
case glVertexNormalColorTexCoord0PointerInterlaced_fake_func:
{
int i = 0;
int texCoord0PointerSize = args[i++];
int texCoord0PointerType = args[i++];
int bytes_size = args[i++];
- void *ptr = (void *) args[i++];
+ void *ptr = (void *)args[i++];
process->current_state->vertexPointerSize =
MAX(process->current_state->vertexPointerSize,
activeTextureIndex);
break;
}
-
case glVertexNormalColorTexCoord01PointerInterlaced_fake_func:
{
int i = 0;
int texCoord1PointerSize = args[i++];
int texCoord1PointerType = args[i++];
int bytes_size = args[i++];
- void *ptr = (void *) args[i++];
+ void *ptr = (void *)args[i++];
process->current_state->vertexPointerSize =
MAX(process->current_state->vertexPointerSize,
activeTextureIndex);
break;
}
-
case glVertexNormalColorTexCoord012PointerInterlaced_fake_func:
{
int i = 0;
int texCoord2PointerSize = args[i++];
int texCoord2PointerType = args[i++];
int bytes_size = args[i++];
- void *ptr = (void *) args[i++];
+ void *ptr = (void *)args[i++];
process->current_state->vertexPointerSize =
MAX(process->current_state->vertexPointerSize,
activeTextureIndex);
break;
}
-
case _glVertexPointer_buffer_func:
{
- glVertexPointer(args[0], args[1], args[2], (void *) args[3]);
+ glVertexPointer(args[0], args[1], args[2], (void *)args[3]);
break;
}
-
case _glNormalPointer_buffer_func:
{
- glNormalPointer(args[0], args[1], (void *) args[2]);
+ glNormalPointer(args[0], args[1], (void *)args[2]);
break;
}
-
case _glColorPointer_buffer_func:
{
- glColorPointer(args[0], args[1], args[2], (void *) args[3]);
+ glColorPointer(args[0], args[1], args[2], (void *)args[3]);
break;
}
-
case _glSecondaryColorPointer_buffer_func:
{
GET_EXT_PTR(void, glSecondaryColorPointer,
(int, int, int, void *));
ptr_func_glSecondaryColorPointer(args[0], args[1], args[2],
- (void *) args[3]);
+ (void *)args[3]);
break;
}
-
case _glIndexPointer_buffer_func:
{
- glIndexPointer(args[0], args[1], (void *) args[2]);
+ glIndexPointer(args[0], args[1], (void *)args[2]);
break;
}
-
case _glTexCoordPointer_buffer_func:
{
- glTexCoordPointer(args[0], args[1], args[2], (void *) args[3]);
+ glTexCoordPointer(args[0], args[1], args[2], (void *)args[3]);
break;
}
-
case _glEdgeFlagPointer_buffer_func:
{
- glEdgeFlagPointer(args[0], (void *) args[1]);
+ glEdgeFlagPointer(args[0], (void *)args[1]);
break;
}
-
case _glVertexAttribPointerARB_buffer_func:
{
GET_EXT_PTR(void, glVertexAttribPointerARB,
(int, int, int, int, int, void *));
ptr_func_glVertexAttribPointerARB(args[0], args[1], args[2],
args[3], args[4],
- (void *) args[5]);
+ (void *)args[5]);
break;
}
-
case _glWeightPointerARB_buffer_func:
{
GET_EXT_PTR(void, glWeightPointerARB, (int, int, int, void *));
ptr_func_glWeightPointerARB(args[0], args[1], args[2],
- (void *) args[3]);
+ (void *)args[3]);
break;
}
-
case _glMatrixIndexPointerARB_buffer_func:
{
GET_EXT_PTR(void, glMatrixIndexPointerARB,
(int, int, int, void *));
ptr_func_glMatrixIndexPointerARB(args[0], args[1], args[2],
- (void *) args[3]);
+ (void *)args[3]);
break;
}
-
case _glFogCoordPointer_buffer_func:
{
GET_EXT_PTR(void, glFogCoordPointer, (int, int, void *));
- ptr_func_glFogCoordPointer(args[0], args[1], (void *) args[2]);
+ ptr_func_glFogCoordPointer(args[0], args[1], (void *)args[2]);
break;
}
-
case _glVariantPointerEXT_buffer_func:
{
GET_EXT_PTR(void, glVariantPointerEXT, (int, int, int, void *));
ptr_func_glVariantPointerEXT(args[0], args[1], args[2],
- (void *) args[3]);
+ (void *)args[3]);
break;
}
-
case _glDrawElements_buffer_func:
{
- glDrawElements(args[0], args[1], args[2], (void *) args[3]);
-
-#ifdef __APPLE__ //only for mac
- {
- int prev_fbo;
- glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &prev_fbo);
- if ( prev_fbo != 0 )
- glFlush();
- }
+ glDrawElements(args[0], args[1], args[2], (void *)args[3]);
+
+#ifdef __APPLE__
+ {
+ int prev_fbo;
+ glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &prev_fbo);
+ if (prev_fbo != 0) {
+ glFlush();
+ }
+ }
#endif
break;
case _glDrawRangeElements_buffer_func:
{
glDrawRangeElements(args[0], args[1], args[2], args[3], args[4],
- (void *) args[5]);
+ (void *)args[5]);
break;
}
#endif
{
GET_EXT_PTR(void, glMultiDrawElements,
(int, int *, int, void **, int));
- ptr_func_glMultiDrawElements(args[0], (int *) args[1], args[2],
- (void **) args[3], args[4]);
-#ifdef __APPLE__ //only for mac
- {
- int prev_fbo;
- glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &prev_fbo);
- if ( prev_fbo != 0 )
- glFlush();
- }
+ ptr_func_glMultiDrawElements(args[0], (int *)args[1], args[2],
+ (void **)args[3], args[4]);
+#ifdef __APPLE__
+ {
+ int prev_fbo;
+ glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &prev_fbo);
+ if (prev_fbo != 0) {
+ glFlush();
+ }
+ }
#endif
-
- break;
- }
-#ifdef __APPLE__ // only for mac
- case glDrawArrays_func:
- {
- int prev_fbo;
- glDrawArrays(ARG_TO_UNSIGNED_INT(args[0]), ARG_TO_INT(args[1]), ARG_TO_INT(args[2]));
- glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &prev_fbo);
- if ( prev_fbo != 0 )
- glFlush();
- break;
- }
- case glDrawElements_func:
- {
- int prev_fbo;
- glDrawElements(ARG_TO_UNSIGNED_INT(args[0]), ARG_TO_INT(args[1]), ARG_TO_UNSIGNED_INT(args[2]), (const void*)(args[3]));
- glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &prev_fbo);
- if ( prev_fbo != 0 )
- glFlush();
- break;
- }
+ break;
+ }
+#ifdef __APPLE__
+ case glDrawArrays_func:
+ {
+ int prev_fbo;
+ glDrawArrays(ARG_TO_UNSIGNED_INT(args[0]), ARG_TO_INT(args[1]),
+ ARG_TO_INT(args[2]));
+ glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &prev_fbo);
+ if (prev_fbo != 0) {
+ glFlush();
+ }
+ break;
+ }
+ case glDrawElements_func:
+ {
+ int prev_fbo;
+ glDrawElements(ARG_TO_UNSIGNED_INT(args[0]),
+ ARG_TO_INT(args[1]),
+ ARG_TO_UNSIGNED_INT(args[2]),
+ (const void *)(args[3]));
+ glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &prev_fbo);
+ if (prev_fbo != 0) {
+ glFlush();
+ }
+ break;
+ }
#endif
-
case _glGetError_fake_func:
{
break;
}
-
case glGetIntegerv_func:
{
- glGetIntegerv(args[0], (int *) args[1]);
+ glGetIntegerv(args[0], (int *)args[1]);
break;
}
-
case _glReadPixels_pbo_func:
{
glReadPixels(ARG_TO_INT(args[0]), ARG_TO_INT(args[1]),
ARG_TO_INT(args[2]), ARG_TO_INT(args[3]),
ARG_TO_UNSIGNED_INT(args[4]),
- ARG_TO_UNSIGNED_INT(args[5]), (void *) (args[6]));
+ ARG_TO_UNSIGNED_INT(args[5]), (void *)(args[6]));
break;
}
-
case _glDrawPixels_pbo_func:
{
glDrawPixels(ARG_TO_INT(args[0]), ARG_TO_INT(args[1]),
ARG_TO_UNSIGNED_INT(args[2]),
ARG_TO_UNSIGNED_INT(args[3]),
- (const void *) (args[4]));
+ (const void *)(args[4]));
break;
}
-
case _glMapBufferARB_fake_func:
{
GET_EXT_PTR(GLvoid *, glMapBufferARB, (GLenum, GLenum));
GET_EXT_PTR(GLboolean, glUnmapBufferARB, (GLenum));
int target = args[0];
int size = args[1];
- void *dst_ptr = (void *) args[2];
+ void *dst_ptr = (void *)args[2];
void *src_ptr = ptr_func_glMapBufferARB(target, GL_READ_ONLY);
if (src_ptr) {
}
break;
}
-
case fake_gluBuild2DMipmaps_func:
{
GET_GLU_PTR(GLint, gluBuild2DMipmaps,
(GLenum arg_0, GLint arg_1, GLsizei arg_2,
GLsizei arg_3, GLenum arg_4, GLenum arg_5,
const GLvoid *arg_6));
- if (ptr_func_gluBuild2DMipmaps == NULL)
+ if (ptr_func_gluBuild2DMipmaps == NULL) {
ptr_func_gluBuild2DMipmaps = mesa_gluBuild2DMipmaps;
+ }
ptr_func_gluBuild2DMipmaps(ARG_TO_UNSIGNED_INT(args[0]),
ARG_TO_INT(args[1]),
ARG_TO_INT(args[2]),
ARG_TO_INT(args[3]),
ARG_TO_UNSIGNED_INT(args[4]),
ARG_TO_UNSIGNED_INT(args[5]),
- (const void *) (args[6]));
+ (const void *)(args[6]));
break;
}
-
case _glSelectBuffer_fake_func:
{
process->current_state->selectBufferSize = args[0] * 4;
glSelectBuffer(args[0], process->current_state->selectBufferPtr);
break;
}
-
case _glGetSelectBuffer_fake_func:
{
- void *ptr = (void *) args[0];
+ void *ptr = (void *)args[0];
memcpy(ptr, process->current_state->selectBufferPtr,
process->current_state->selectBufferSize);
break;
}
-
case _glFeedbackBuffer_fake_func:
{
process->current_state->feedbackBufferSize = args[0] * 4;
process->current_state->feedbackBufferPtr =
g_realloc(process->current_state->feedbackBufferPtr,
process->current_state->feedbackBufferSize);
- glFeedbackBuffer((GLsizei)args[0], (GLenum) args[1],
+ glFeedbackBuffer((GLsizei)args[0], (GLenum)args[1],
process->current_state->feedbackBufferPtr);
break;
}
-
case _glGetFeedbackBuffer_fake_func:
{
- void *ptr = (void *) args[0];
+ void *ptr = (void *)args[0];
memcpy(ptr, process->current_state->feedbackBufferPtr,
process->current_state->feedbackBufferSize);
break;
}
-
- /*
+ /*
* case glEnableClientState_func: { if (display_function_call)
* DEBUGF( "cap : %s\n", nameArrays[args[0] -
* GL_VERTEX_ARRAY]); glEnableClientState(args[0]); break; }
- *
+ *
* case glDisableClientState_func: { if (display_function_call)
* DEBUGF( "cap : %s\n", nameArrays[args[0] -
* GL_VERTEX_ARRAY]); glDisableClientState(args[0]); break; }
- *
+ *
* case glClientActiveTexture_func: case
* glClientActiveTextureARB_func: { if (display_function_call)
* DEBUGF( "client activeTexture %d\n", args[0] -
* GL_TEXTURE0_ARB); glClientActiveTextureARB(args[0]); break; }
- *
+ *
* case glActiveTextureARB_func: { if (display_function_call)
* DEBUGF( "server activeTexture %d\n", args[0] -
* GL_TEXTURE0_ARB); glActiveTextureARB(args[0]); break; }
- *
+ *
* case glLockArraysEXT_func: break;
- *
+ *
* case glUnlockArraysEXT_func: break;
- *
+ *
* case glArrayElement_func: { glArrayElement(args[0]); break; }
- *
+ *
* case glDrawArrays_func: { glDrawArrays(args[0],args[1],args[2]);
* break; }
- *
+ *
* case glDrawElements_func: {
* glDrawElements(args[0],args[1],args[2],(void*)args[3]); break; }
- *
+ *
* case glDrawRangeElements_func: {
- * glDrawRangeElements(args[0],args[1],args[2],args[3],args[4],(void*)args[5]);
+ * glDrawRangeElements(args[0],args[1],args[2],
+ args[3],args[4],(void *)args[5]);
* break; } */
-
case glGetError_func:
{
ret.i = glGetError();
break;
}
-
case glNewObjectBufferATI_func:
{
GET_EXT_PTR(int, glNewObjectBufferATI, (int, void *, int));
ret.i = ptr_func_glNewObjectBufferATI(args[0],
- (void *) args[1], args[2]);
+ (void *)args[1], args[2]);
break;
}
-
case glClear_func:
glClear((GLbitfield)args[0]);
break;
#if 0
/* HACK workaround for an unexplainable issue */
- if (args[0] & GL_COLOR_BUFFER_BIT)
+ if (args[0] & GL_COLOR_BUFFER_BIT) {
glClear(GL_COLOR_BUFFER_BIT);
- if (args[0] & GL_STENCIL_BUFFER_BIT)
+ }
+ if (args[0] & GL_STENCIL_BUFFER_BIT) {
glClear(GL_STENCIL_BUFFER_BIT);
- if (args[0] & GL_DEPTH_BUFFER_BIT)
+ }
+ if (args[0] & GL_DEPTH_BUFFER_BIT) {
glClear(GL_DEPTH_BUFFER_BIT);
- if (args[0] & GL_ACCUM_BUFFER_BIT)
+ }
+ if (args[0] & GL_ACCUM_BUFFER_BIT) {
glClear(GL_ACCUM_BUFFER_BIT);
+ }
break;
#endif
#ifdef _WIN32
- /* workaround for bug T_SDK-128. If GL_UNPACK_ROW_LENGTH==0, GL driver
- * should calculate it for glTexSubImage2D according to width parameter and
- * GL_UNPACK_ALIGNMENT. But on windows, some vender's driver like nvidia,
- * don't follow it. So we need do it for the driver, and probably remove
- * this hack in future if driver get fixed.
- */
- case glTexSubImage2D_func:
- {
- int origin_row_length, alignment, width;
-
- if (args[6] == GL_ALPHA) {
- width = args[4];
- glGetIntegerv(GL_UNPACK_ALIGNMENT, &alignment);
- glGetIntegerv(GL_UNPACK_ROW_LENGTH, &origin_row_length);
-
- if (width%alignment != 0) {
- width = (width/alignment + 1) * alignment;
- }
-
- glPixelStorei(GL_UNPACK_ROW_LENGTH, width);
- }
-
- glTexSubImage2D(ARG_TO_UNSIGNED_INT(args[0]), ARG_TO_INT(args[1]),
- ARG_TO_INT(args[2]), ARG_TO_INT(args[3]),
- ARG_TO_INT(args[4]), ARG_TO_INT(args[5]),
- ARG_TO_UNSIGNED_INT(args[6]),
- ARG_TO_UNSIGNED_INT(args[7]), (const void*)(args[8]));
-
- if (args[6] == GL_ALPHA)
- glPixelStorei(GL_UNPACK_ROW_LENGTH, origin_row_length);
-
- break;
- }
+ /* workaround for bug T_SDK-128. If GL_UNPACK_ROW_LENGTH==0, GL driver
+ * should calculate it for glTexSubImage2D according to width parameter and
+ * GL_UNPACK_ALIGNMENT. But on windows, some vender's driver like nvidia,
+ * don't follow it. So we need do it for the driver, and probably remove
+ * this hack in future if driver get fixed.
+ */
+ case glTexSubImage2D_func:
+ {
+ int origin_row_length, alignment, width;
+
+ if (args[6] == GL_ALPHA) {
+ width = args[4];
+ glGetIntegerv(GL_UNPACK_ALIGNMENT, &alignment);
+ glGetIntegerv(GL_UNPACK_ROW_LENGTH, &origin_row_length);
+
+ if (width % alignment != 0) {
+ width = (width / alignment + 1) * alignment;
+ }
+
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, width);
+ }
+
+ glTexSubImage2D(ARG_TO_UNSIGNED_INT(args[0]), ARG_TO_INT(args[1]),
+ ARG_TO_INT(args[2]), ARG_TO_INT(args[3]),
+ ARG_TO_INT(args[4]), ARG_TO_INT(args[5]),
+ ARG_TO_UNSIGNED_INT(args[6]),
+ ARG_TO_UNSIGNED_INT(args[7]), (const void *)(args[8]));
+
+ if (args[6] == GL_ALPHA) {
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, origin_row_length);
+ }
+
+ break;
+ }
#endif
#ifdef __APPLE__
- case glTexSubImage2D_func:
- {
-
- glTexSubImage2D(ARG_TO_UNSIGNED_INT(args[0]), ARG_TO_INT(args[1]),
- ARG_TO_INT(args[2]), ARG_TO_INT(args[3]),
- ARG_TO_INT(args[4]), ARG_TO_INT(args[5]),
- ARG_TO_UNSIGNED_INT(args[6]), ARG_TO_UNSIGNED_INT(args[7]),
- (const void*)(args[8]));
-
- if ( ARG_TO_UNSIGNED_INT(args[0]) == GL_TEXTURE_2D &&
- ARG_TO_INT(args[1]) == 0 &&
- ARG_TO_UNSIGNED_INT(args[6]) == GL_RGBA &&
- ARG_TO_UNSIGNED_INT(args[7]) == GL_UNSIGNED_BYTE )
- mac_dump_texture();
- else
- fprintf(stderr, "!!! Probable screen crash, no work around as glTexSubImage2d parameters do not match!\n");
-
- break;
- }
-#endif
+ case glTexSubImage2D_func:
+ {
+
+ glTexSubImage2D(ARG_TO_UNSIGNED_INT(args[0]), ARG_TO_INT(args[1]),
+ ARG_TO_INT(args[2]), ARG_TO_INT(args[3]),
+ ARG_TO_INT(args[4]), ARG_TO_INT(args[5]),
+ ARG_TO_UNSIGNED_INT(args[6]), ARG_TO_UNSIGNED_INT(args[7]),
+ (const void *)(args[8]));
+
+ if (ARG_TO_UNSIGNED_INT(args[0]) == GL_TEXTURE_2D &&
+ ARG_TO_INT(args[1]) == 0 &&
+ ARG_TO_UNSIGNED_INT(args[6]) == GL_RGBA &&
+ ARG_TO_UNSIGNED_INT(args[7]) == GL_UNSIGNED_BYTE) {
+ mac_dump_texture();
+ } else {
+ fprintf(stderr, "!!! Probable screen crash, no work around "
+ "as glTexSubImage2d parameters do not match!\n");
+ }
+ break;
+ }
+#endif
default:
- execute_func(func_number, (void**)args, &ret);
+ execute_func(func_number, (void **)args, &ret);
break;
}
}
default:
- DEBUGF( "unexpected ret type : %d\n", ret_type);
+ DEBUGF("unexpected ret type : %d\n", ret_type);
exit(-1);
break;
}
- if (display_function_call)
- DEBUGF( "[%d]< %s\n", process->p.process_id,
+ if (display_function_call) {
+ DEBUGF("[%d]< %s\n", process->p.process_id,
tab_opengl_calls_name[func_number]);
+ }
return ret.i;
}
/*
* Parse gl.h et glx.h to auto-generate source code
- *
+ *
* Copyright (c) 2006,2007 Even Rouault
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
#include <string.h>
#include <assert.h>
-#define GL_INCLUDE_PATH "../tizen/src/hw/"
+#define GL_INCLUDE_PATH "../tizen/src/hw/"
-int isExtByName(const char* name)
+int isExtByName(const char *name)
{
return (strstr(name, "ARB") != NULL) ||
(strstr(name, "IBM") != NULL) ||
(strstr(name, "SGI") != NULL);
}
-char* get_arg_type(char* s)
+char *get_arg_type(char *s)
{
- while(*s == ' ' || *s == '\t') s++;
- char* n = s;
- char* c = strstr(n, "const");
- if (c)
+ while (*s == ' ' || *s == '\t') {
+ s++;
+ }
+ char *n = s;
+ char *c = strstr(n, "const");
+ if (c) {
n += 6;
-
- char* t = strstr(n, " ");
- if (t)
- {
- if (t[1] == '*')
+ }
+
+ char *t = strstr(n, " ");
+ if (t) {
+ if (t[1] == '*') {
t += 2;
+ }
t[0] = 0;
- char* ori = t;
+ char *ori = t;
t = strstr(t+1, "[");
- if (t)
- {
+ if (t) {
memmove(ori, t, strlen(t));
strstr(ori, "]")[1] = 0;
}
return strdup(s);
}
-typedef struct
-{
- char* type;
- char* name;
+typedef struct {
+ char *type;
+ char *name;
int nargs;
- char** args;
+ char **args;
int ok;
int just_for_server_side;
int has_out_parameters;
int isExt;
} FuncDesc;
-int isExt(FuncDesc* func)
+int isExt(FuncDesc *func)
{
return func->isExt;
}
-char* get_type_string(char* type)
+char *get_type_string(char *type)
{
- if (strstr(type, "[16]"))
- {
- if (strstr(type, "float"))
- return ("TYPE_16FLOAT");
- else if (strstr(type, "double"))
- return ("TYPE_16DOUBLE");
- else
- {
+ if (strstr(type, "[16]")) {
+ if (strstr(type, "float")) {
+ return "TYPE_16FLOAT";
+ } else if (strstr(type, "double")) {
+ return "TYPE_16DOUBLE";
+ } else {
printf("inconnu %s\n", type);
exit(-1);
}
- }
- else if (strstr(type, "[128]") && strstr(type, "GLubyte"))
+ } else if (strstr(type, "[128]") && strstr(type, "GLubyte")) {
return strstr(type, "const") ? "TYPE_128UCHAR" : "TYPE_OUT_128UCHAR";
- else if (strstr(type, "const GLvoid *"))
+ } else if (strstr(type, "const GLvoid *")) {
return "TYPE_ARRAY_VOID";
- else if (strstr(type, "const GLchar *") ||
- strstr(type, "const GLcharARB *"))
+ } else if (strstr(type, "const GLchar *") ||
+ strstr(type, "const GLcharARB *")) {
return "TYPE_NULL_TERMINATED_STRING";
- else if (strstr(type, "const GLbyte *"))
+ } else if (strstr(type, "const GLbyte *")) {
return "TYPE_ARRAY_SIGNED_CHAR";
- else if (strstr(type, "const GLubyte *"))
+ } else if (strstr(type, "const GLubyte *")) {
return "TYPE_ARRAY_UNSIGNED_CHAR";
- else if (strstr(type, "const GLshort *"))
+ } else if (strstr(type, "const GLshort *")) {
return "TYPE_ARRAY_SHORT";
- else if (strstr(type, "const GLushort *") ||
- strstr(type, "const GLhalfNV *"))
+ } else if (strstr(type, "const GLushort *") ||
+ strstr(type, "const GLhalfNV *")) {
return "TYPE_ARRAY_UNSIGNED_SHORT";
- else if (strstr(type, "const GLint *"))
+ } else if (strstr(type, "const GLint *")) {
return "TYPE_ARRAY_INT";
- else if (strstr(type, "const GLuint *") ||
- strstr(type, "const GLenum *"))
+ } else if (strstr(type, "const GLuint *") ||
+ strstr(type, "const GLenum *")) {
return "TYPE_ARRAY_UNSIGNED_INT";
- else if (strstr(type, "const GLfloat *") ||
- strstr(type, "const GLclampf *"))
+ } else if (strstr(type, "const GLfloat *") ||
+ strstr(type, "const GLclampf *")) {
return "TYPE_ARRAY_FLOAT";
- else if (strstr(type, "const GLdouble *"))
+ } else if (strstr(type, "const GLdouble *")) {
return "TYPE_ARRAY_DOUBLE";
- else if (strstr(type, "GLvoid *"))
+ } else if (strstr(type, "GLvoid *")) {
return "TYPE_OUT_ARRAY_VOID";
- else if (strstr(type, "GLboolean *") ||
- strstr(type, "GLubyte *"))
+ } else if (strstr(type, "GLboolean *") ||
+ strstr(type, "GLubyte *")) {
return "TYPE_OUT_ARRAY_UNSIGNED_CHAR";
- else if (strstr(type, "GLcharARB *") ||
- strstr(type, "GLchar *"))
+ } else if (strstr(type, "GLcharARB *") ||
+ strstr(type, "GLchar *")) {
return "TYPE_OUT_ARRAY_CHAR";
- else if (strstr(type, "GLshort *"))
+ } else if (strstr(type, "GLshort *")) {
return "TYPE_OUT_ARRAY_SHORT";
- else if (strstr(type, "GLushort *"))
+ } else if (strstr(type, "GLushort *")) {
return "TYPE_OUT_ARRAY_UNSIGNED_SHORT";
- else if (strstr(type, "GLint *")||
- strstr(type, "GLsizei *"))
+ } else if (strstr(type, "GLint *") ||
+ strstr(type, "GLsizei *")) {
return "TYPE_OUT_ARRAY_INT";
- else if (strstr(type, "GLuint *") ||
+ } else if (strstr(type, "GLuint *") ||
strstr(type, "GLenum *") ||
- strstr(type, "GLhandleARB *"))
+ strstr(type, "GLhandleARB *")) {
return "TYPE_OUT_ARRAY_UNSIGNED_INT";
- else if (strstr(type, "GLfloat *"))
+ } else if (strstr(type, "GLfloat *")) {
return "TYPE_OUT_ARRAY_FLOAT";
- else if (strstr(type, "GLdouble *"))
+ } else if (strstr(type, "GLdouble *")) {
return "TYPE_OUT_ARRAY_DOUBLE";
- else if (strcmp(type, "void") == 0)
- return("TYPE_NONE");
- else if (strcmp(type, "GLbyte") == 0)
- return("TYPE_CHAR");
- else if (strcmp(type, "GLubyte") == 0 ||
- strcmp(type, "GLboolean") == 0)
- return("TYPE_UNSIGNED_CHAR");
- else if (strcmp(type, "GLshort") == 0)
- return("TYPE_SHORT");
- else if (strcmp(type, "GLushort") == 0 ||
- strcmp(type, "GLhalfNV") == 0)
- return("TYPE_UNSIGNED_SHORT");
- else if (strcmp(type, "GLint") == 0 ||
+ } else if (strcmp(type, "void") == 0) {
+ return "TYPE_NONE";
+ } else if (strcmp(type, "GLbyte") == 0) {
+ return "TYPE_CHAR";
+ } else if (strcmp(type, "GLubyte") == 0 ||
+ strcmp(type, "GLboolean") == 0) {
+ return "TYPE_UNSIGNED_CHAR";
+ } else if (strcmp(type, "GLshort") == 0) {
+ return "TYPE_SHORT";
+ } else if (strcmp(type, "GLushort") == 0 ||
+ strcmp(type, "GLhalfNV") == 0) {
+ return "TYPE_UNSIGNED_SHORT";
+ } else if (strcmp(type, "GLint") == 0 ||
strcmp(type, "GLsizei") == 0 ||
strcmp(type, "GLintptr") == 0 ||
strcmp(type, "GLsizeiptr") == 0 ||
strcmp(type, "GLintptrARB") == 0 ||
- strcmp(type, "GLsizeiptrARB") == 0)
- return("TYPE_INT");
- else if (strcmp(type, "GLenum") == 0 ||
+ strcmp(type, "GLsizeiptrARB") == 0) {
+ return "TYPE_INT";
+ } else if (strcmp(type, "GLenum") == 0 ||
strcmp(type, "GLuint") == 0 ||
strcmp(type, "GLhandleARB") == 0 ||
- strcmp(type, "GLbitfield") == 0)
- return("TYPE_UNSIGNED_INT");
- else if (strcmp(type, "GLfloat") == 0 ||
- strcmp(type, "GLclampf") == 0)
- return("TYPE_FLOAT");
- else if (strcmp(type, "GLdouble") == 0 ||
- strcmp(type, "GLclampd") == 0)
- return("TYPE_DOUBLE");
- else
- {
+ strcmp(type, "GLbitfield") == 0) {
+ return "TYPE_UNSIGNED_INT";
+ } else if (strcmp(type, "GLfloat") == 0 ||
+ strcmp(type, "GLclampf") == 0) {
+ return "TYPE_FLOAT";
+ } else if (strcmp(type, "GLdouble") == 0 ||
+ strcmp(type, "GLclampd") == 0) {
+ return "TYPE_DOUBLE";
+ } else {
printf("inconnu %s\n", type);
exit(-1);
}
}
-typedef struct
-{
- char* letter;
- char* signature_type_name;
- char* gl_c_type_name;
- char* c_type_name;
+typedef struct {
+ char *letter;
+ char *signature_type_name;
+ char *gl_c_type_name;
+ char *c_type_name;
} ForIsKnownArgVector;
#define N_ELEMENTS(x) (sizeof(x)/sizeof(x[0]))
#define N_FIELDS_IN_ARG_VECTOR 4
-typedef struct
-{
- char* func_name;
- char* signature_type_name;
+typedef struct {
+ char *func_name;
+ char *signature_type_name;
} KnownLastArgFunc;
-static KnownLastArgFunc knownLastArgFuncs[] =
-{
+static KnownLastArgFunc knownLastArgFuncs[] = {
{"glFogCoordfv", "TYPE_1FLOAT"},
{"glFogCoorddv", "TYPE_1DOUBLE"},
{"glFogCoordfvEXT", "TYPE_1FLOAT"},
{"glFogCoorddvEXT", "TYPE_1DOUBLE"},
{"glFogCoordhvNV", "TYPE_1USHORT"},
-
+
{"glGetFenceivNV", "TYPE_OUT_1INT"},
{"glGetTexLevelParameteriv", "TYPE_OUT_1INT" },
};
-int is_known_arg_vector(FuncDesc* desc, char** p_signature_type_name, char** p_c_type_name)
+int is_known_arg_vector(FuncDesc *desc,
+ char **p_signature_type_name,
+ char **p_c_type_name)
{
- static ForIsKnownArgVector my_tab[] =
- {
+ static ForIsKnownArgVector my_tab[] = {
{ "b", "CHAR", "GLbyte", "signed char" },
{ "Boolean", "CHAR", "GLboolean", "unsigned char" },
{ "s", "SHORT", "GLshort", "short" },
{ "Nub", "CHAR", "GLubyte", "unsigned char" },
{ "Nus", "SHORT", "GLushort", "unsigned short" },
{ "Nui", "INT", "GLuint", "unsigned int" },
-
+
{ "f", "FLOAT", "GLfloat", "float" },
{ "Float", "FLOAT", "GLfloat", "float" },
{ "d", "DOUBLE", "GLdouble", "double" },
};
-
- if (desc->nargs == 0)
+
+ if (desc->nargs == 0) {
return 0;
-
+ }
+
int i , j;
-
+
if (strstr(desc->name, "glVertexAttribs") ||
strstr(desc->name, "glProgramParameters") ||
strstr(desc->name, "glProgramEnvParameters") ||
strstr(desc->name, "glProgramLocalParameters") ||
- (strstr(desc->name, "glUniform") && (strstr(desc->name, "iv") || strstr(desc->name, "fv"))))
+ (strstr(desc->name, "glUniform") && (strstr(desc->name, "iv") ||
+ strstr(desc->name, "fv")))) {
return 0;
-
+ }
+
static char signatures[N_ELEMENTS(my_tab)][N_FIELDS_IN_ARG_VECTOR][20] = {0};
char signature[10];
-
- for(i=0;i<N_ELEMENTS(knownLastArgFuncs);i++)
- {
- if (strcmp(desc->name, knownLastArgFuncs[i].func_name) == 0)
- {
- if (p_signature_type_name)
- {
+
+ for (i = 0; i < N_ELEMENTS(knownLastArgFuncs); i++) {
+ if (strcmp(desc->name, knownLastArgFuncs[i].func_name) == 0) {
+ if (p_signature_type_name) {
*p_signature_type_name = knownLastArgFuncs[i].signature_type_name;
}
- if (p_c_type_name)
- {
- if (strstr(knownLastArgFuncs[i].signature_type_name, "FLOAT"))
+ if (p_c_type_name) {
+ if (strstr(knownLastArgFuncs[i].signature_type_name, "FLOAT")) {
*p_c_type_name = "float";
- else if (strstr(knownLastArgFuncs[i].signature_type_name, "DOUBLE"))
+ } else if (strstr(knownLastArgFuncs[i].signature_type_name, "DOUBLE")) {
*p_c_type_name = "double";
- else if (strstr(knownLastArgFuncs[i].signature_type_name, "UINT"))
+ } else if (strstr(knownLastArgFuncs[i].signature_type_name, "UINT")) {
*p_c_type_name = "unsigned int";
- else if (strstr(knownLastArgFuncs[i].signature_type_name, "INT"))
+ } else if (strstr(knownLastArgFuncs[i].signature_type_name, "INT")) {
*p_c_type_name = "int";
- else if (strstr(knownLastArgFuncs[i].signature_type_name, "USHORT"))
+ } else if (strstr(knownLastArgFuncs[i].signature_type_name, "USHORT")) {
*p_c_type_name = "unsigned short";
- else if (strstr(knownLastArgFuncs[i].signature_type_name, "SHORT"))
+ } else if (strstr(knownLastArgFuncs[i].signature_type_name, "SHORT")) {
*p_c_type_name = "short";
- else if (strstr(knownLastArgFuncs[i].signature_type_name, "UCHAR"))
+ } else if (strstr(knownLastArgFuncs[i].signature_type_name, "UCHAR")) {
*p_c_type_name = "unsigned char";
- else if (strstr(knownLastArgFuncs[i].signature_type_name, "CHAR"))
+ } else if (strstr(knownLastArgFuncs[i].signature_type_name, "CHAR")) {
*p_c_type_name = "char";
- else
+ } else {
assert(0);
+ }
}
return 1;
}
}
-
- for(i=0;i<N_ELEMENTS(my_tab);i++)
- {
- for(j=1;j<=N_FIELDS_IN_ARG_VECTOR;j++)
- {
- if (strstr(desc->name, "glIndex") && strstr(desc->name, "v"))
+
+ for (i = 0; i < N_ELEMENTS(my_tab); i++) {
+ for (j = 1; j <= N_FIELDS_IN_ARG_VECTOR; j++) {
+ if (strstr(desc->name, "glIndex") && strstr(desc->name, "v")) {
sprintf(signature, "%sv", my_tab[i].letter);
- else
+ } else {
sprintf(signature, "%d%sv", j, my_tab[i].letter);
+ }
if (strstr(desc->name, signature) &&
strstr(desc->args[desc->nargs - 1], my_tab[i].gl_c_type_name) &&
- strstr(desc->args[desc->nargs - 1], "*"))
- {
- if (p_signature_type_name)
- {
- if (signatures[i][j-1][0] == 0)
- sprintf(signatures[i][j-1], "TYPE_%d%s", j, my_tab[i].signature_type_name);
+ strstr(desc->args[desc->nargs - 1], "*")) {
+ if (p_signature_type_name) {
+ if (signatures[i][j-1][0] == 0) {
+ sprintf(signatures[i][j-1], "TYPE_%d%s",
+ j, my_tab[i].signature_type_name);
+ }
*p_signature_type_name = signatures[i][j-1];
}
- if (p_c_type_name) *p_c_type_name = my_tab[i].c_type_name;
+ if (p_c_type_name) {
+ *p_c_type_name = my_tab[i].c_type_name;
+ }
return 1;
}
}
return 0;
}
-static void print_server_side_argument(FILE* server_stub, int j, char* glType)
+static void print_server_side_argument(FILE *server_stub, int j, char *glType)
{
- const char* symbolic_type = get_type_string(glType);
- if (strcmp(symbolic_type, "TYPE_CHAR") == 0)
+ const char *symbolic_type = get_type_string(glType);
+ if (strcmp(symbolic_type, "TYPE_CHAR") == 0) {
fprintf(server_stub, "ARG_TO_CHAR(args[%d])", j);
- else if (strcmp(symbolic_type, "TYPE_UNSIGNED_CHAR") == 0)
+ } else if (strcmp(symbolic_type, "TYPE_UNSIGNED_CHAR") == 0) {
fprintf(server_stub, "ARG_TO_UNSIGNED_CHAR(args[%d])", j);
- else if (strcmp(symbolic_type, "TYPE_SHORT") == 0)
+ } else if (strcmp(symbolic_type, "TYPE_SHORT") == 0) {
fprintf(server_stub, "ARG_TO_SHORT(args[%d])", j);
- else if (strcmp(symbolic_type, "TYPE_UNSIGNED_SHORT") == 0)
+ } else if (strcmp(symbolic_type, "TYPE_UNSIGNED_SHORT") == 0) {
fprintf(server_stub, "ARG_TO_UNSIGNED_SHORT(args[%d])", j);
- else if (strcmp(symbolic_type, "TYPE_INT") == 0)
+ } else if (strcmp(symbolic_type, "TYPE_INT") == 0) {
fprintf(server_stub, "ARG_TO_INT(args[%d])", j);
- else if (strcmp(symbolic_type, "TYPE_UNSIGNED_INT") == 0)
+ } else if (strcmp(symbolic_type, "TYPE_UNSIGNED_INT") == 0) {
fprintf(server_stub, "ARG_TO_UNSIGNED_INT(args[%d])", j);
- else if (strcmp(symbolic_type, "TYPE_FLOAT") == 0)
+ } else if (strcmp(symbolic_type, "TYPE_FLOAT") == 0) {
fprintf(server_stub, "ARG_TO_FLOAT(args[%d])", j);
- else if (strcmp(symbolic_type, "TYPE_16FLOAT") == 0)
+ } else if (strcmp(symbolic_type, "TYPE_16FLOAT") == 0) {
fprintf(server_stub, "(const float*)(args[%d])", j);
- else if (strcmp(symbolic_type, "TYPE_DOUBLE") == 0)
+ } else if (strcmp(symbolic_type, "TYPE_DOUBLE") == 0) {
fprintf(server_stub, "ARG_TO_DOUBLE(args[%d])", j);
- else if ( strcmp(symbolic_type, "TYPE_16DOUBLE") == 0)
+ } else if (strcmp(symbolic_type, "TYPE_16DOUBLE") == 0) {
fprintf(server_stub, "(const double*)(args[%d])", j);
- else if ( strcmp(symbolic_type, "TYPE_OUT_128UCHAR") == 0)
+ } else if (strcmp(symbolic_type, "TYPE_OUT_128UCHAR") == 0) {
fprintf(server_stub, "(unsigned char*)(args[%d])", j);
- else if ( strcmp(symbolic_type, "TYPE_128UCHAR") == 0)
+ } else if (strcmp(symbolic_type, "TYPE_128UCHAR") == 0) {
fprintf(server_stub, "(const unsigned char*)(args[%d])", j);
- else if ( strcmp(symbolic_type, "TYPE_NULL_TERMINATED_STRING") == 0)
+ } else if (strcmp(symbolic_type, "TYPE_NULL_TERMINATED_STRING") == 0) {
fprintf(server_stub, "(const char*)(args[%d])", j);
- else if ( strcmp(symbolic_type, "TYPE_ARRAY_SHORT") == 0)
+ } else if (strcmp(symbolic_type, "TYPE_ARRAY_SHORT") == 0) {
fprintf(server_stub, "(const short*)(args[%d])", j);
- else if ( strcmp(symbolic_type, "TYPE_ARRAY_UNSIGNED_SHORT") == 0)
+ } else if (strcmp(symbolic_type, "TYPE_ARRAY_UNSIGNED_SHORT") == 0) {
fprintf(server_stub, "(const unsigned short*)(args[%d])", j);
- else if ( strcmp(symbolic_type, "TYPE_ARRAY_INT") == 0)
+ } else if (strcmp(symbolic_type, "TYPE_ARRAY_INT") == 0) {
fprintf(server_stub, "(const int*)(args[%d])", j);
- else if ( strcmp(symbolic_type, "TYPE_ARRAY_UNSIGNED_INT") == 0)
+ } else if (strcmp(symbolic_type, "TYPE_ARRAY_UNSIGNED_INT") == 0) {
fprintf(server_stub, "(const unsigned int*)(args[%d])", j);
- else if ( strcmp(symbolic_type, "TYPE_ARRAY_FLOAT") == 0)
+ } else if (strcmp(symbolic_type, "TYPE_ARRAY_FLOAT") == 0) {
fprintf(server_stub, "(const float*)(args[%d])", j);
- else if ( strcmp(symbolic_type, "TYPE_ARRAY_DOUBLE") == 0)
+ } else if (strcmp(symbolic_type, "TYPE_ARRAY_DOUBLE") == 0) {
fprintf(server_stub, "(const double*)(args[%d])", j);
- else if ( strcmp(symbolic_type, "TYPE_ARRAY_CHAR") == 0)
+ } else if (strcmp(symbolic_type, "TYPE_ARRAY_CHAR") == 0) {
fprintf(server_stub, "(const char*)(args[%d])", j);
- else if ( strcmp(symbolic_type, "TYPE_ARRAY_SIGNED_CHAR") == 0)
+ } else if (strcmp(symbolic_type, "TYPE_ARRAY_SIGNED_CHAR") == 0) {
fprintf(server_stub, "(const signed char*)(args[%d])", j);
- else if ( strcmp(symbolic_type, "TYPE_ARRAY_VOID") == 0)
+ } else if (strcmp(symbolic_type, "TYPE_ARRAY_VOID") == 0) {
fprintf(server_stub, "(const void*)(args[%d])", j);
- else if ( strcmp(symbolic_type, "TYPE_ARRAY_UNSIGNED_CHAR") == 0)
+ } else if (strcmp(symbolic_type, "TYPE_ARRAY_UNSIGNED_CHAR") == 0) {
fprintf(server_stub, "(const unsigned char*)(args[%d])", j);
- else if ( strcmp(symbolic_type, "TYPE_OUT_ARRAY_SHORT") == 0)
+ } else if (strcmp(symbolic_type, "TYPE_OUT_ARRAY_SHORT") == 0) {
fprintf(server_stub, "(short*)(args[%d])", j);
- else if ( strcmp(symbolic_type, "TYPE_OUT_ARRAY_UNSIGNED_SHORT") == 0)
+ } else if (strcmp(symbolic_type, "TYPE_OUT_ARRAY_UNSIGNED_SHORT") == 0) {
fprintf(server_stub, "(unsigned short*)(args[%d])", j);
- else if ( strcmp(symbolic_type, "TYPE_OUT_ARRAY_INT") == 0)
+ } else if (strcmp(symbolic_type, "TYPE_OUT_ARRAY_INT") == 0) {
fprintf(server_stub, "(int*)(args[%d])", j);
- else if ( strcmp(symbolic_type, "TYPE_OUT_ARRAY_UNSIGNED_INT") == 0)
+ } else if (strcmp(symbolic_type, "TYPE_OUT_ARRAY_UNSIGNED_INT") == 0) {
fprintf(server_stub, "(unsigned int*)(args[%d])", j);
- else if ( strcmp(symbolic_type, "TYPE_OUT_ARRAY_FLOAT") == 0)
+ } else if (strcmp(symbolic_type, "TYPE_OUT_ARRAY_FLOAT") == 0) {
fprintf(server_stub, "(float*)(args[%d])", j);
- else if ( strcmp(symbolic_type, "TYPE_OUT_ARRAY_DOUBLE") == 0)
+ } else if (strcmp(symbolic_type, "TYPE_OUT_ARRAY_DOUBLE") == 0) {
fprintf(server_stub, "(double*)(args[%d])", j);
- else if ( strcmp(symbolic_type, "TYPE_OUT_ARRAY_VOID") == 0)
+ } else if (strcmp(symbolic_type, "TYPE_OUT_ARRAY_VOID") == 0) {
fprintf(server_stub, "(void*)(args[%d])", j);
- else if ( strcmp(symbolic_type, "TYPE_OUT_ARRAY_CHAR") == 0)
+ } else if (strcmp(symbolic_type, "TYPE_OUT_ARRAY_CHAR") == 0) {
fprintf(server_stub, "(char*)(args[%d])", j);
- else if ( strcmp(symbolic_type, "TYPE_OUT_ARRAY_UNSIGNED_CHAR") == 0)
+ } else if (strcmp(symbolic_type, "TYPE_OUT_ARRAY_UNSIGNED_CHAR") == 0) {
fprintf(server_stub, "(unsigned char*)(args[%d])", j);
-
- else
- {
+ } else {
fprintf(stderr, "Unknown : %s\n", symbolic_type);
assert(0);
}
}
-static const char* func_dealt_by_hand[500] = { NULL };
+static const char *func_dealt_by_hand[500] = { NULL };
-static const char* ignore_func[] =
-{
+static const char *ignore_func[] = {
"glGetPointerv",
"glRectdv",
"glRectfv",
"glLoadTransposeMatrixdARB",
"glMultTransposeMatrixfARB",
"glMultTransposeMatrixdARB",
-
+
"glPixelDataRangeNV",
"glFlushPixelDataRangeNV",
"glVertexArrayRangeNV",
"glFlushVertexArrayRangeNV",
"glVertexWeightfEXT",
-
+
"glGetBufferPointerv",
"glGetBufferPointervARB",
"glGetVertexAttribPointerv",
void get_func_dealt_by_hand()
{
- FILE* f = fopen(GL_INCLUDE_PATH"gl_func_perso.h", "r");
+ FILE *f = fopen(GL_INCLUDE_PATH"gl_func_perso.h", "r");
char buffer[256];
int i = 0;
- char* c;
- while(fgets(buffer, 256, f))
- {
- if (strstr(buffer, "MAGIC_MACRO("))
- {
- func_dealt_by_hand[i] = strdup(strstr(buffer, "MAGIC_MACRO(") + strlen("MAGIC_MACRO("));
- * strstr(func_dealt_by_hand[i], ")") = 0;
+ char *c;
+ while (fgets(buffer, 256, f)) {
+ if (strstr(buffer, "MAGIC_MACRO(")) {
+ func_dealt_by_hand[i] = strdup(strstr(buffer, "MAGIC_MACRO(") +
+ strlen("MAGIC_MACRO("));
+ *strstr(func_dealt_by_hand[i], ")") = 0;
c = strstr(func_dealt_by_hand[i], "_");
- if (c && c != func_dealt_by_hand[i]) *c = 0;
- i ++;
+ if (c && c != func_dealt_by_hand[i]) {
+ *c = 0;
+ }
+ i++;
}
}
fclose(f);
-
+
int j = 0;
- while(ignore_func[j])
- {
+ while (ignore_func[j]) {
func_dealt_by_hand[i] = ignore_func[j];
i++;
j++;
}
}
-static const char* just_for_server_side_list[] =
-{
+static const char *just_for_server_side_list[] = {
"glEnableClientState",
"glDisableClientState",
"glPushClientAttrib",
"glFogi",
"glClipPlane",
"glGetClipPlane",
-
+
/* begin of openquartz optimization */
#if 1
"glMatrixMode",
"glTranslatef",
#endif
/* end of openquartz optimization */
-
+
"glGetError",
"glActiveTextureARB",
-
+
"glViewport",
"glScissor",
-
+
"glBindBufferARB",
"glDeleteBuffersARB",
"glGenBuffersARB",
"glBufferSubData",
"glGetBufferSubData",
"glGetBufferParameteriv",
-
+
"glPushAttrib",
"glPopAttrib",
"glEnable",
"glDrawPixels",
"glSelectBuffer",
"glFeedbackBuffer",
-
+
"glTexImage1D",
"glTexImage2D",
"glTexImage3D",
"glTexSubImage1D",
"glTexSubImage2D",
"glTexSubImage3D",
-
+
"glTexImage3DEXT",
"glTexSubImage1DEXT",
"glTexSubImage2DEXT",
"glTexSubImage3DEXT",
-
+
"glGetCompressedTexImage",
"glCompressedTexImage1D",
"glCompressedTexImage2D",
"glCompressedTexSubImage1D",
"glCompressedTexSubImage2D",
"glCompressedTexSubImage3D",
-
+
"glGetCompressedTexImageARB",
"glCompressedTexImage1DARB",
"glCompressedTexImage2DARB",
"glCompressedTexSubImage1DARB",
"glCompressedTexSubImage2DARB",
"glCompressedTexSubImage3DARB",
-
+
"glCallLists",
"glNewList",
"glDeleteLists",
"glGenLists",
-
+
"glGenTextures",
"glDeleteTextures",
"glDeleteTexturesEXT",
"glGetIntegerv",
"glGetFloatv",
"glGetDoublev",
-
+
"glGetPixelMapfv",
"glGetPixelMapuiv",
"glGetPixelMapusv",
"glGetActiveAttrib",
"glGetAttribLocationARB",
"glGetAttribLocation",
-
+
"glNewObjectBufferATI",
"glUpdateObjectBufferATI",
-
+
"glSetLocalConstantEXT",
"glSetInvariantEXT",
"glVariantbvEXT",
"glGetLocalConstantBooleanvEXT",
"glGetLocalConstantIntegervEXT",
"glGetLocalConstantFloatvEXT",
-
+
"glMatrixIndexubvARB",
"glMatrixIndexusvARB",
"glMatrixIndexuivARB",
-
+
"glColorTable",
"glColorSubTable",
"glGetColorTable",
"glGetSeparableFilterEXT",
"glGetHistogramEXT",
"glGetMinmaxEXT",
-
+
"glGetTexParameterfv",
-
+
"glGetVertexAttribivARB",
"glGetVertexAttribfvARB",
"glGetVertexAttribdvARB",
"glGetVertexAttribiv",
"glGetVertexAttribfv",
"glGetVertexAttribdv",
-
+
"glGetDetailTexFuncSGIS",
"glGetSharpenTexFuncSGIS",
-
+
"fake_gluBuild2DMipmaps",
-
+
"glRenderMode",
-
+
"glEnableVariantClientStateEXT",
"glDisableVariantClientStateEXT",
-
+
"glGetActiveVaryingNV",
-
+
NULL,
};
-static int just_for_server_side_func(char* funcname)
+static int just_for_server_side_func(char *funcname)
{
int i;
- for(i=0;just_for_server_side_list[i];i++)
- {
- if (strcmp(just_for_server_side_list[i], funcname) == 0)
+ for (i = 0; just_for_server_side_list[i]; i++) {
+ if (strcmp(just_for_server_side_list[i], funcname) == 0) {
return 1;
+ }
}
return 0;
}
-int parse(FILE* f, FuncDesc* funcDesc, int funcDescCount, int ignoreEXT)
+int parse(FILE *f, FuncDesc *funcDesc, int funcDescCount, int ignoreEXT)
{
char buffer[256];
- while(fgets(buffer, 256, f))
- {
+ while (fgets(buffer, 256, f)) {
- if (strncmp(buffer, "GLAPI", 5) == 0 && strstr(buffer, "APIENTRY") && strstr(buffer, "("))
- {
+ if (strncmp(buffer, "GLAPI", 5) == 0 &&
+ strstr(buffer, "APIENTRY") &&
+ strstr(buffer, "(")) {
int i = 0;
int skip = 0;
- if (func_dealt_by_hand[0] == 0)
- {
+ if (func_dealt_by_hand[0] == 0) {
get_func_dealt_by_hand();
}
- while (func_dealt_by_hand[i])
- {
- if (strstr(buffer, func_dealt_by_hand[i]))
- {
+ while (func_dealt_by_hand[i]) {
+ if (strstr(buffer, func_dealt_by_hand[i])) {
skip = 1;
break;
}
i++;
}
- if (skip)
+ if (skip) {
continue;
-
- char** args = malloc(15 * sizeof(char*));
+ }
+
+ char **args = malloc(15 * sizeof(char *));
int narg = 0;
- char* type = buffer + 6;
- char* n = strstr(type, "GLAPIENTRY") ? strstr(type, "GLAPIENTRY") : strstr(type, "APIENTRY");
+ char *type = buffer + 6;
+ char *n = strstr(type, "GLAPIENTRY") ?
+ strstr(type, "GLAPIENTRY") : strstr(type, "APIENTRY");
int skip_length = strstr(type, "GLAPIENTRY") ? 11 : 9;
n[-1] = 0;
type = strdup(type);
n += skip_length;
- char* fonc = n;
+ char *fonc = n;
n = strstr(n, "(");
- if (n[-1] == ' ') n[-1] = 0;
+ if (n[-1] == ' ') {
+ n[-1] = 0;
+ }
n[0] = 0;
fonc = strdup(fonc);
- /*if (strstr(fonc, "glLockArraysEXT") || strstr(fonc, "glUnlockArraysEXT"))
- {
- }
- else*/
-
-
- if (ignoreEXT == 1 && isExtByName(fonc))
- {
+ /*if (strstr(fonc, "glLockArraysEXT") ||
+ strstr(fonc, "glUnlockArraysEXT")) {
+ } else*/
+
+ if (ignoreEXT == 1 && isExtByName(fonc)) {
free(type);
free(fonc);
continue;
}
n++;
- while(1)
- {
- char* virg = strstr(n, ",");
- if (virg)
- {
+ while (1) {
+ char *virg = strstr(n, ",");
+ if (virg) {
args[narg] = n;
virg[0] = 0;
args[narg] = get_arg_type(args[narg]);
narg++;
n = virg+1;
- }
- else
+ } else {
break;
+ }
}
- while (strstr(n, ")") == 0)
- {
+ while (strstr(n, ")") == 0) {
fgets(buffer, 256, f);
n = buffer;
- while(1)
- {
- char* virg = strstr(n, ",");
- if (virg)
- {
+ while (1) {
+ char *virg = strstr(n, ",");
+ if (virg) {
args[narg] = n;
virg[0] = 0;
args[narg] = get_arg_type(args[narg]);
narg++;
n = virg+1;
- }
- else
+ } else {
break;
+ }
}
}
- char* par = strstr(n, ")");
+ char *par = strstr(n, ")");
args[narg] = n;
par[0] = 0;
args[narg] = get_arg_type(args[narg]);
narg++;
-
-
+
+
/*printf("%s %s (", type, fonc);
- for(i=0;i<narg;i++)
- {
+ for (i = 0; i < narg; i++) {
printf("%s,", args[i]);
}
printf(")\n");*/
-
- for(i=0;i<funcDescCount;i++)
- {
- if (strcmp(funcDesc[i].name, fonc) == 0)
- {
- if (ignoreEXT == 0)
+
+ for (i = 0; i < funcDescCount; i++) {
+ if (strcmp(funcDesc[i].name, fonc) == 0) {
+ if (ignoreEXT == 0) {
funcDesc[i].isExt = 1;
+ }
break;
}
}
- if (i == funcDescCount)
- {
+ if (i == funcDescCount) {
funcDesc[funcDescCount].type = type;
funcDesc[funcDescCount].name = fonc;
funcDesc[funcDescCount].nargs = narg;
funcDesc[funcDescCount].args = args;
funcDesc[funcDescCount].isExt = ignoreEXT == 0;
funcDescCount++;
- }
- else
- {
+ } else {
free(fonc);
free(args);
free(type);
}
/*
- for(i=0;i<narg;i++)
- {
+ for (i = 0; i < narg; i++) {
free(args[i]);
}
free(fonc);
return funcDescCount;
}
-typedef struct
-{
- char* str;
+typedef struct {
+ char *str;
int i;
} StringIntStruct;
-StringIntStruct argDependingOnPreviousArgTab[] =
-{
+StringIntStruct argDependingOnPreviousArgTab[] = {
{ "glLoadProgramNV", 3},
{ "ProgramNamedParameter", 2},
{ "glDeleteBuffers", 1},
{ "glPrioritizeTextures", 1} ,
{ "glPrioritizeTextures", 2} ,
{ "glProgramStringARB", 3} ,
-
+
{ "glVertexAttribs", 2},
-
+
{ "glUniformMatrix", 3 },
-
+
{ "glGetVertexAttribfv", 2},
{ "glGetVertexAttribiv", 2},
{ "glGetVertexAttribdv", 2},
{ "glGetVertexAttribIivEXT", 2},
{ "glGetVertexAttribIuivEXT", 2},
-
+
{ "glPointParameterfv", 1},
{ "glPointParameteriv", 1},
-
+
{ "glWeightbvARB", 1},
{ "glWeightsvARB", 1},
{ "glWeightivARB", 1},
{ "glGetTexGendv", 2},
{ "glGetTexGenfv", 2},
{ "glGetTexGeniv", 2},
-
+
{ "glLightfv", 2},
{ "glLightiv", 2},
{ "glGetLightfv", 2},
{ "glFragmentLightivSGIX", 2},
{ "glGetFragmentLightfvSGIX", 2},
{ "glGetFragmentLightivSGIX", 2},
-
-
+
+
{ "glLightModelfv", 1},
{ "glLightModeliv", 1},
{ "glFragmentLightModelfvSGIX", 1},
{ "glFragmentLightModelivSGIX", 1},
-
+
{ "glMaterialfv", 2},
{ "glMaterialiv", 2},
{ "glGetMaterialfv", 2},
{ "glTexParameteriv", 2},
{ "glGetTexParameterfv", 2},
{ "glGetTexParameteriv", 2},
-
+
{ "glTexParameterIivEXT", 2},
{ "glTexParameterIuivEXT", 2},
{ "glGetTexParameterIivEXT", 2},
{ "glPixelMapfv", 2},
{ "glPixelMapuiv", 2},
{ "glPixelMapusv", 2},
-
+
{ "glDetailTexFuncSGIS", 2 },
{ "glSharpenTexFuncSGIS", 2 },
-
+
{ "glSpriteParameterfvSGIX", 1 },
{ "glSpriteParameterivSGIX", 1 },
-
+
{ "ConvolutionParameter", 2},
-
+
{ "glProgramBufferParametersfvNV", 4},
{ "glProgramBufferParametersIivNV", 4},
{ "glProgramBufferParametersIuivNV", 4},
-
+
{ "glTransformFeedbackAttribsNV", 1},
{ "glTransformFeedbackVaryingsNV", 2},
};
-int is_arg_of_length_depending_on_previous_args(FuncDesc* funcDesc, int j)
+int is_arg_of_length_depending_on_previous_args(FuncDesc *funcDesc, int j)
{
int i;
- if (strstr(funcDesc->args[j], "*") == NULL)
+ if (strstr(funcDesc->args[j], "*") == NULL) {
return 0;
- for(i=0;i< N_ELEMENTS(argDependingOnPreviousArgTab); i++)
- {
- if (strstr(funcDesc->name, argDependingOnPreviousArgTab[i].str) && j == argDependingOnPreviousArgTab[i].i)
+ }
+ for (i = 0; i < N_ELEMENTS(argDependingOnPreviousArgTab); i++) {
+ if (strstr(funcDesc->name, argDependingOnPreviousArgTab[i].str) &&
+ j == argDependingOnPreviousArgTab[i].i) {
return 1;
+ }
}
return 0;
}
-static void fprintf_prototype_args(FILE* f, FuncDesc* funcDesc)
+static void fprintf_prototype_args(FILE *f, FuncDesc *funcDesc)
{
int j;
- for(j=0;j<funcDesc->nargs;j++)
- {
- if (j != 0) fprintf(f,", ");
- if (strstr(funcDesc->args[j], "[16]"))
- {
- if (strstr(funcDesc->args[j], "float"))
- {
+ for (j = 0; j < funcDesc->nargs; j++) {
+ if (j != 0) {
+ fprintf(f, ", ");
+ }
+ if (strstr(funcDesc->args[j], "[16]")) {
+ if (strstr(funcDesc->args[j], "float")) {
fprintf(f, "const GLfloat arg_%d[16]", j);
- }
- else if (strstr(funcDesc->args[j], "double"))
- {
+ } else if (strstr(funcDesc->args[j], "double")) {
fprintf(f, "const GLdouble arg_%d[16]", j);
- }
- else
- {
+ } else {
exit(-1);
}
- }
- else if (strstr(funcDesc->args[j], "[128]") && strstr(funcDesc->args[j], "GLubyte"))
- fprintf(f, (strstr(funcDesc->args[j], "const")) ? "const GLubyte* arg_%d" : "GLubyte* arg_%d", j);
- else
+ } else if (strstr(funcDesc->args[j], "[128]") &&
+ strstr(funcDesc->args[j], "GLubyte")) {
+ fprintf(f, (strstr(funcDesc->args[j], "const")) ?
+ "const GLubyte* arg_%d" : "GLubyte* arg_%d", j);
+ } else {
fprintf(f, "%s arg_%d", funcDesc->args[j], j);
+ }
+ }
+ if (j == 0) {
+ fprintf(f, "void");
}
- if (j == 0)
- fprintf(f, "void");
}
-int main(int argc, char* argv[])
+int main(int argc, char *argv[])
{
FuncDesc funcDesc[3000];
int funcDescCount = 0;
- FILE* f;
+ FILE *f;
- printf("***** path : %s\n", GL_INCLUDE_PATH"mesa_gl.h");
+ printf("***** path : %s\n", GL_INCLUDE_PATH"mesa_gl.h");
f = fopen(GL_INCLUDE_PATH"mesa_gl.h", "r");
assert(f);
- /*if (!f)
- f = fopen("/usr/include/GL/gl.h", "r");*/
+ /*if (!f) {
+ f = fopen("/usr/include/GL/gl.h", "r");
+ }*/
funcDescCount = parse(f, funcDesc, 0, 1);
fclose(f);
-
+
f = fopen(GL_INCLUDE_PATH"mesa_glext.h", "r");
assert(f);
- /*if (!f)
- f = fopen("/usr/include/GL/glext.h", "r");*/
+ /*if (!f) {
+ f = fopen("/usr/include/GL/glext.h", "r");
+ }*/
funcDescCount = parse(f, funcDesc, funcDescCount, 0);
fclose(f);
- FILE* header = fopen("gl_func.h", "w");
- FILE* client_stub = fopen("client_stub.c", "w");
- FILE* server_stub = fopen("server_stub.c", "w");
+ FILE *header = fopen("gl_func.h", "w");
+ FILE *client_stub = fopen("client_stub.c", "w");
+ FILE *server_stub = fopen("server_stub.c", "w");
- fprintf(header, "/* This is a generated file by parse_gl_h.c - DO NOT EDIT ! */\n\n");
+ fprintf(header,
+ "/* This is a generated file by parse_gl_h.c - DO NOT EDIT ! */\n\n");
fprintf(header, "union gl_ret_type {\n"
"const char *s;\n"
"int i;\n"
fprintf(header, "enum {\n"
"#include \"gl_func_perso.h\"\n");
- fprintf(client_stub, "/* This is a generated file by parse_gl_h.c - DO NOT EDIT ! */\n\n");
+ fprintf(client_stub,
+ "/* This is a generated file by parse_gl_h.c - DO NOT EDIT ! */\n\n");
- fprintf(server_stub, "/* This is a generated file by parse_gl_h.c - DO NOT EDIT ! */\n\n");
+ fprintf(server_stub,
+ "/* This is a generated file by parse_gl_h.c - DO NOT EDIT ! */\n\n");
int i;
- for(i=0;i<funcDescCount;i++)
- {
+ for (i = 0; i < funcDescCount; i++) {
funcDesc[i].ok = 0;
- char* name = funcDesc[i].name;
- char* type = funcDesc[i].type;
+ char *name = funcDesc[i].name;
+ char *type = funcDesc[i].type;
if ((strcmp(type, "void") == 0 || strcmp(type, "GLboolean") == 0 ||
strcmp(type, "GLuint") == 0 || strcmp(type, "GLint") == 0 ||
strcmp(type, "GLenum") == 0) || strcmp(type, "GLhandleARB") == 0 ||
- strcmp(type, "GLhalf") == 0 || strcmp(type, "GLhalfNV") == 0)
- {
+ strcmp(type, "GLhalf") == 0 || strcmp(type, "GLhalfNV") == 0) {
int pointer_of_unknown_size = 0;
int j;
-
- if (funcDesc[i].nargs == 1 && strcmp(funcDesc[i].args[0], "void") == 0)
- {
+
+ if (funcDesc[i].nargs == 1 && strcmp(funcDesc[i].args[0], "void") == 0) {
funcDesc[i].nargs = 0;
}
- for(j=0;j<funcDesc[i].nargs-1;j++)
- {
- if (!is_arg_of_length_depending_on_previous_args(&funcDesc[i], j) &&
+ for (j = 0; j < funcDesc[i].nargs-1; j++) {
+ if (!is_arg_of_length_depending_on_previous_args(
+ &funcDesc[i], j) &&
strstr(funcDesc[i].args[j], "const GLchar") == NULL &&
- strstr(funcDesc[i].args[j], "[16]") == NULL)
- {
+ strstr(funcDesc[i].args[j], "[16]") == NULL) {
pointer_of_unknown_size |= strstr(funcDesc[i].args[j], "*") != NULL;
pointer_of_unknown_size |= strstr(funcDesc[i].args[j], "[") != NULL;
}
}
- if (pointer_of_unknown_size == 0)
- {
- char* signature_type_name;
- if (is_known_arg_vector(&funcDesc[i], &signature_type_name, NULL))
- {
- if (strstr(signature_type_name, "TYPE_OUT"))
+ if (pointer_of_unknown_size == 0) {
+ char *signature_type_name;
+ if (is_known_arg_vector(&funcDesc[i], &signature_type_name, NULL)) {
+ if (strstr(signature_type_name, "TYPE_OUT")) {
funcDesc[i].has_out_parameters = 1;
- }
- else
- {
- if (funcDesc[i].nargs-1 >= 0)
- {
+ }
+ } else {
+ if (funcDesc[i].nargs-1 >= 0) {
j = funcDesc[i].nargs-1;
if (!is_arg_of_length_depending_on_previous_args(&funcDesc[i], j) &&
strstr(funcDesc[i].args[j], "const GLchar") == NULL &&
- strstr(funcDesc[i].args[j], "[16]") == NULL)
- {
- pointer_of_unknown_size |= strstr(funcDesc[i].args[j], "*") != NULL;
- pointer_of_unknown_size |= strstr(funcDesc[i].args[j], "[") != NULL;
+ strstr(funcDesc[i].args[j], "[16]") == NULL) {
+ pointer_of_unknown_size |=
+ strstr(funcDesc[i].args[j], "*") != NULL;
+ pointer_of_unknown_size |=
+ strstr(funcDesc[i].args[j], "[") != NULL;
}
}
}
}
- if (pointer_of_unknown_size && funcDesc[i].nargs == 1)
- {
- if (strstr(funcDesc[i].name, "Matrixf") || strstr(funcDesc[i].name, "Matrixd"))
- {
+ if (pointer_of_unknown_size && funcDesc[i].nargs == 1) {
+ if (strstr(funcDesc[i].name, "Matrixf") ||
+ strstr(funcDesc[i].name, "Matrixd")) {
free(funcDesc[i].args[0]);
- if (strstr(funcDesc[i].name, "Matrixf"))
+ if (strstr(funcDesc[i].name, "Matrixf")) {
funcDesc[i].args[0] = strdup("GLfloat m[16]");
- else
+ } else {
funcDesc[i].args[0] = strdup("GLdouble m[16]");
+ }
pointer_of_unknown_size = 0;
- }
- else if (strcmp(funcDesc[i].name, "glPolygonStipple") == 0)
- {
+ } else if (strcmp(funcDesc[i].name, "glPolygonStipple") == 0) {
free(funcDesc[i].args[0]);
funcDesc[i].args[0] = strdup("const GLubyte mask[128]");
pointer_of_unknown_size = 0;
- }
- else if (strcmp(funcDesc[i].name, "glGetPolygonStipple") == 0)
- {
+ } else if (strcmp(funcDesc[i].name, "glGetPolygonStipple") == 0) {
free(funcDesc[i].args[0]);
funcDesc[i].args[0] = strdup("GLubyte mask[128]");
funcDesc[i].has_out_parameters = 1;
pointer_of_unknown_size = 0;
}
}
- if (just_for_server_side_func(name) || pointer_of_unknown_size == 0)
- {
+ if (just_for_server_side_func(name) || pointer_of_unknown_size == 0) {
fprintf(header, " %s_func,\n", funcDesc[i].name);
funcDesc[i].ok = 1;
- if (just_for_server_side_func(name))
+ if (just_for_server_side_func(name)) {
funcDesc[i].just_for_server_side = 1;
- for(j=0;j<funcDesc[i].nargs;j++)
- {
- if (strstr(get_type_string(funcDesc[i].args[j]), "OUT"))
+ }
+ for (j = 0; j < funcDesc[i].nargs; j++) {
+ if (strstr(get_type_string(funcDesc[i].args[j]), "OUT")) {
funcDesc[i].has_out_parameters = 1;
+ }
}
- }
- else
- {
- fprintf(stderr, "not handled either manually or automatically : %s\n", funcDesc[i].name);
+ } else {
+ fprintf(stderr, "not handled either manually or automatically : %s\n",
+ funcDesc[i].name);
}
}
}
-
+
fprintf(header, " GL_N_CALLS\n};\n");
- fprintf(server_stub, "static void execute_func(int func_number, void **args, union gl_ret_type *pret)\n");
+ fprintf(server_stub, "static void execute_func(int func_number, void **args,"
+ " union gl_ret_type *pret)\n");
fprintf(server_stub, "{\n");
fprintf(server_stub, " switch(func_number)\n");
fprintf(server_stub, " {\n");
-
-
- for(i=0;i<funcDescCount;i++)
- {
- if (funcDesc[i].ok)
- {
+
+
+ for (i = 0; i < funcDescCount; i++) {
+ if (funcDesc[i].ok) {
fprintf(header, "static const int %s_signature[] = { %s, %d, ",
funcDesc[i].name,
get_type_string(funcDesc[i].type),
funcDesc[i].has_out_parameters);
fprintf(header, "%d", funcDesc[i].nargs);
int j;
- char* signature_type_name;
- int n_args_to_check = is_known_arg_vector(&funcDesc[i], &signature_type_name, NULL) ? funcDesc[i].nargs - 1 : funcDesc[i].nargs;
-
- for(j=0;j<n_args_to_check;j++)
- {
- if (is_arg_of_length_depending_on_previous_args(&funcDesc[i], j))
- {
- fprintf(header, ", %s_OF_LENGTH_DEPENDING_ON_PREVIOUS_ARGS", get_type_string(funcDesc[i].args[j]));
- }
- else
+ char *signature_type_name;
+ int n_args_to_check =
+ is_known_arg_vector(&funcDesc[i], &signature_type_name, NULL) ?
+ funcDesc[i].nargs - 1 : funcDesc[i].nargs;
+
+ for (j = 0; j < n_args_to_check; j++) {
+ if (is_arg_of_length_depending_on_previous_args(&funcDesc[i], j)) {
+ fprintf(header, ", %s_OF_LENGTH_DEPENDING_ON_PREVIOUS_ARGS",
+ get_type_string(funcDesc[i].args[j]));
+ } else {
fprintf(header, ", %s", get_type_string(funcDesc[i].args[j]));
+ }
}
-
- if (is_known_arg_vector(&funcDesc[i], &signature_type_name, NULL))
- {
+
+ if (is_known_arg_vector(&funcDesc[i], &signature_type_name, NULL)) {
fprintf(header, ", %s", signature_type_name);
}
fprintf(header, "};\n");
-
-
- if (funcDesc[i].just_for_server_side == 0)
- {
- if (isExt(&funcDesc[i]))
- fprintf(client_stub, "GLAPI %s APIENTRY EXT_FUNC(%s) (", funcDesc[i].type, funcDesc[i].name);
- else
- fprintf(client_stub, "GLAPI %s APIENTRY %s(", funcDesc[i].type, funcDesc[i].name);
+
+
+ if (funcDesc[i].just_for_server_side == 0) {
+ if (isExt(&funcDesc[i])) {
+ fprintf(client_stub, "GLAPI %s APIENTRY EXT_FUNC(%s) (",
+ funcDesc[i].type, funcDesc[i].name);
+ } else {
+ fprintf(client_stub, "GLAPI %s APIENTRY %s(",
+ funcDesc[i].type, funcDesc[i].name);
+ }
fprintf_prototype_args(client_stub, &funcDesc[i]);
fprintf(client_stub, ")\n");
fprintf(client_stub, "{\n");
- if (strcmp(funcDesc[i].type, "void") != 0)
- {
+ if (strcmp(funcDesc[i].type, "void") != 0) {
fprintf(client_stub, " %s ret;\n", funcDesc[i].type);
- if (isExt(&funcDesc[i]))
- fprintf(client_stub, " CHECK_PROC_WITH_RET(%s);\n", funcDesc[i].name);
- }
- else
- {
- if (isExt(&funcDesc[i]))
+ if (isExt(&funcDesc[i])) {
+ fprintf(client_stub, " CHECK_PROC_WITH_RET(%s);\n",
+ funcDesc[i].name);
+ }
+ } else {
+ if (isExt(&funcDesc[i])) {
fprintf(client_stub, " CHECK_PROC(%s);\n", funcDesc[i].name);
+ }
}
-
+
/*
fprintf(client_stub, " do_opengl_call(%s_func, %s",
- funcDesc[i].name, (strcmp(funcDesc[i].type, "void") == 0) ? "NULL" : "&ret");
- for(j=0;j<funcDesc[i].nargs;j++)
- {
+ funcDesc[i].name,
+ (strcmp(funcDesc[i].type, "void") == 0) ? "NULL" : "&ret");
+ for (j = 0; j < funcDesc[i].nargs; j++) {
fprintf(client_stub, ", arg_%d", j);
}
fprintf(client_stub, ");\n");
*/
-
- if (funcDesc[i].nargs)
- {
+
+ if (funcDesc[i].nargs) {
fprintf(client_stub, " long args[] = { ");
- for(j=0;j<funcDesc[i].nargs;j++)
- {
- if (j > 0) fprintf(client_stub, ", ");
- if (strstr(funcDesc[i].args[j], "*"))
- {
- fprintf(client_stub, "POINTER_TO_ARG(arg_%d)", j);
+ for (j = 0; j < funcDesc[i].nargs; j++) {
+ if (j > 0) {
+ fprintf(client_stub, ", ");
}
- else
- {
- const char* symbolic_type = get_type_string(funcDesc[i].args[j]);
- if (strcmp(symbolic_type, "TYPE_CHAR") == 0)
+ if (strstr(funcDesc[i].args[j], "*")) {
+ fprintf(client_stub, "POINTER_TO_ARG(arg_%d)", j);
+ } else {
+ const char *symbolic_type = get_type_string(funcDesc[i].args[j]);
+ if (strcmp(symbolic_type, "TYPE_CHAR") == 0) {
fprintf(client_stub, "CHAR_TO_ARG");
- else if (strcmp(symbolic_type, "TYPE_UNSIGNED_CHAR") == 0)
+ } else if (strcmp(symbolic_type, "TYPE_UNSIGNED_CHAR") == 0) {
fprintf(client_stub, "UNSIGNED_CHAR_TO_ARG");
- else if (strcmp(symbolic_type, "TYPE_SHORT") == 0)
+ } else if (strcmp(symbolic_type, "TYPE_SHORT") == 0) {
fprintf(client_stub, "SHORT_TO_ARG");
- else if (strcmp(symbolic_type, "TYPE_UNSIGNED_SHORT") == 0)
+ } else if (strcmp(symbolic_type, "TYPE_UNSIGNED_SHORT") == 0) {
fprintf(client_stub, "UNSIGNED_SHORT_TO_ARG");
- else if (strcmp(symbolic_type, "TYPE_INT") == 0)
+ } else if (strcmp(symbolic_type, "TYPE_INT") == 0) {
fprintf(client_stub, "INT_TO_ARG");
- else if (strcmp(symbolic_type, "TYPE_UNSIGNED_INT") == 0)
+ } else if (strcmp(symbolic_type, "TYPE_UNSIGNED_INT") == 0) {
fprintf(client_stub, "UNSIGNED_INT_TO_ARG");
- else if (strcmp(symbolic_type, "TYPE_FLOAT") == 0)
+ } else if (strcmp(symbolic_type, "TYPE_FLOAT") == 0) {
fprintf(client_stub, "FLOAT_TO_ARG");
- else if (strcmp(symbolic_type, "TYPE_16FLOAT") == 0)
+ } else if (strcmp(symbolic_type, "TYPE_16FLOAT") == 0) {
fprintf(client_stub, "POINTER_TO_ARG");
- else if (strcmp(symbolic_type, "TYPE_DOUBLE") == 0)
+ } else if (strcmp(symbolic_type, "TYPE_DOUBLE") == 0) {
fprintf(client_stub, "DOUBLE_TO_ARG");
- else if ( strcmp(symbolic_type, "TYPE_16DOUBLE") == 0)
+ } else if (strcmp(symbolic_type, "TYPE_16DOUBLE") == 0) {
fprintf(client_stub, "POINTER_TO_ARG");
- else if ( strcmp(symbolic_type, "TYPE_128UCHAR") == 0 || strcmp(symbolic_type, "TYPE_OUT_128UCHAR") == 0)
+ } else if (strcmp(symbolic_type, "TYPE_128UCHAR") == 0 ||
+ strcmp(symbolic_type, "TYPE_OUT_128UCHAR") == 0) {
fprintf(client_stub, "POINTER_TO_ARG");
- else
- {
+ } else {
fprintf(stderr, "Unknown : %s\n", symbolic_type);
assert(0);
}
}
fprintf(client_stub, "};\n");
}
-
+
fprintf(client_stub, " do_opengl_call(%s_func, %s, %s, NULL);\n",
- funcDesc[i].name, (strcmp(funcDesc[i].type, "void") == 0) ? "NULL" : "&ret",
+ funcDesc[i].name,
+ (strcmp(funcDesc[i].type, "void") == 0) ? "NULL" : "&ret",
(funcDesc[i].nargs) ? "args" : "NULL");
-
- if (strcmp(funcDesc[i].type, "void") != 0)
- {
+
+ if (strcmp(funcDesc[i].type, "void") != 0) {
fprintf(client_stub, " return ret;\n");
}
fprintf(client_stub, "}\n\n");
}
-
+
fprintf(server_stub, " case %s_func:\n", funcDesc[i].name);
fprintf(server_stub, " {\n");
-
- if (isExt(&funcDesc[i]))
- {
- fprintf(server_stub, " GET_EXT_PTR(%s, %s, (", funcDesc[i].type, funcDesc[i].name);
+
+ if (isExt(&funcDesc[i])) {
+ fprintf(server_stub, " GET_EXT_PTR(%s, %s, (",
+ funcDesc[i].type, funcDesc[i].name);
fprintf_prototype_args(server_stub, &funcDesc[i]);
fprintf(server_stub, "));\n");
}
-
+
fprintf(server_stub, " ");
-
- if (strcmp(funcDesc[i].type, "void") == 0)
+
+ if (strcmp(funcDesc[i].type, "void") == 0) {
;
- else if (strcmp(get_type_string(funcDesc[i].type), "TYPE_INT") == 0 ||
- strcmp(get_type_string(funcDesc[i].type), "TYPE_UNSIGNED_INT") == 0)
+ } else if (strcmp(get_type_string(funcDesc[i].type), "TYPE_INT") == 0 ||
+ strcmp(get_type_string(funcDesc[i].type),
+ "TYPE_UNSIGNED_INT") == 0) {
fprintf(server_stub, "pret->i = ");
- else if (strcmp(get_type_string(funcDesc[i].type), "TYPE_CHAR") == 0 ||
- strcmp(get_type_string(funcDesc[i].type), "TYPE_UNSIGNED_CHAR") == 0)
+ } else if (strcmp(get_type_string(funcDesc[i].type), "TYPE_CHAR") == 0 ||
+ strcmp(get_type_string(funcDesc[i].type),
+ "TYPE_UNSIGNED_CHAR") == 0) {
fprintf(server_stub, "pret->c = ");
- else
- {
- fprintf(stderr, "unknown ret type = %s\n", get_type_string(funcDesc[i].type));
+ } else {
+ fprintf(stderr, "unknown ret type = %s\n",
+ get_type_string(funcDesc[i].type));
exit(-1);
}
- /*if (strstr(funcDesc[i].name, "EXT"))
- {
- char* dup = strdup(funcDesc[i].name);
+ /* if (strstr(funcDesc[i].name, "EXT")) {
+ char *dup = strdup(funcDesc[i].name);
*strstr(dup, "EXT") = 0;
fprintf(server_stub, "%s(", dup);
free(dup);
- }
- else*/
- {
- if (isExt(&funcDesc[i]))
+ } else */
+ {
+ if (isExt(&funcDesc[i])) {
fprintf(server_stub, "ptr_func_%s(", funcDesc[i].name);
- else
+ } else {
fprintf(server_stub, "%s(", funcDesc[i].name);
+ }
}
- char* c_type_name;
- if (is_known_arg_vector(&funcDesc[i], NULL, &c_type_name))
- {
- for(j=0;j<funcDesc[i].nargs - 1;j++)
- {
- if (j != 0) fprintf(server_stub,", ");
+ char *c_type_name;
+ if (is_known_arg_vector(&funcDesc[i], NULL, &c_type_name)) {
+ for (j = 0; j < funcDesc[i].nargs - 1; j++) {
+ if (j != 0) {
+ fprintf(server_stub, ", ");
+ }
print_server_side_argument(server_stub, j, funcDesc[i].args[j]);
}
- if (j != 0) fprintf(server_stub,", ");
- if (strstr(funcDesc[i].args[funcDesc[i].nargs - 1], "const"))
+ if (j != 0) {
+ fprintf(server_stub, ", ");
+ }
+ if (strstr(funcDesc[i].args[funcDesc[i].nargs - 1], "const")) {
fprintf(server_stub, "(const %s*)args[%d]", c_type_name, j);
- else
+ } else {
fprintf(server_stub, "(%s*)args[%d]", c_type_name, j);
- }
- else
- {
- for(j=0;j<funcDesc[i].nargs;j++)
- {
- if (j != 0) fprintf(server_stub,", ");
+ }
+ } else {
+ for (j = 0; j < funcDesc[i].nargs; j++) {
+ if (j != 0) {
+ fprintf(server_stub, ", ");
+ }
print_server_side_argument(server_stub, j, funcDesc[i].args[j]);
}
}
fprintf(server_stub, ");\n");
-
+
fprintf(server_stub, " break;\n");
fprintf(server_stub, " }\n");
}
}
-
+
fprintf(server_stub, " default:\n");
fprintf(server_stub, " DEBUGF(\"unknown=%%d\", func_number);\n");
fprintf(server_stub, " break;\n");
fprintf(header, "static const int* tab_opengl_calls[GL_N_CALLS] =\n");
fprintf(header, "{\n");
fprintf(header, "#include \"gl_func_perso.h\"\n");
- for(i=0;i<funcDescCount;i++)
- {
- if (funcDesc[i].ok)
- {
+ for (i = 0; i < funcDescCount; i++) {
+ if (funcDesc[i].ok) {
fprintf(header, " %s_signature,\n", funcDesc[i].name);
}
}
fprintf(header, "static const char* tab_opengl_calls_name[GL_N_CALLS] =\n");
fprintf(header, "{\n");
fprintf(header, "#include \"gl_func_perso.h\"\n");
- for(i=0;i<funcDescCount;i++)
- {
- if (funcDesc[i].ok)
- {
+ for (i = 0; i < funcDescCount; i++) {
+ if (funcDesc[i].ok) {
fprintf(header, " \"%s\",\n", funcDesc[i].name);
}
}
fprintf(header, "};\n\n");
-
+
fclose(header);
fclose(server_stub);
fclose(client_stub);