00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048 #include <AR/gsub_lite.h>
00049
00050 #include <stdio.h>
00051 #include <string.h>
00052 #ifndef __APPLE__
00053 # include <GL/glu.h>
00054 # ifdef GL_VERSION_1_2
00055 # include <GL/glext.h>
00056 # endif
00057 #else
00058 # include <OpenGL/glu.h>
00059 # include <OpenGL/glext.h>
00060 #endif
00061
00062
00063
00064
00065 #ifdef _MSC_VER
00066 # pragma warning (disable:4068) // Disable MSVC warnings about unknown pragmas.
00067 #endif
00068
00069
00070
00071
00072
00073 #ifndef GL_VERSION_1_2
00074 # if GL_EXT_bgra
00075 # define GL_BGR GL_BGR_EXT
00076 # define GL_BGRA GL_BGRA_EXT
00077 # else
00078 # define GL_BGR 0x80E0
00079 # define GL_BGRA 0x80E1
00080 # endif
00081 # ifndef GL_APPLE_packed_pixels
00082 # define GL_UNSIGNED_INT_8_8_8_8 0x8035
00083 # define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367
00084 # endif
00085 # if GL_SGIS_texture_edge_clamp
00086 # define GL_CLAMP_TO_EDGE GL_CLAMP_TO_EDGE_SGIS
00087 # else
00088 # define GL_CLAMP_TO_EDGE 0x812F
00089 # endif
00090 #endif
00091
00092
00093 #ifndef GL_APPLE_ycbcr_422
00094 # define GL_YCBCR_422_APPLE 0x85B9
00095 # define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA
00096 # define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB
00097 #endif
00098 #ifndef GL_EXT_abgr
00099 # define GL_ABGR_EXT 0x8000
00100 #endif
00101 #if GL_NV_texture_rectangle
00102 # define GL_TEXTURE_RECTANGLE GL_TEXTURE_RECTANGLE_NV
00103 # define GL_PROXY_TEXTURE_RECTANGLE GL_PROXY_TEXTURE_RECTANGLE_NV
00104 # define GL_MAX_RECTANGLE_TEXTURE_SIZE GL_MAX_RECTANGLE_TEXTURE_SIZE_NV
00105 #elif GL_EXT_texture_rectangle
00106 # define GL_TEXTURE_RECTANGLE GL_TEXTURE_RECTANGLE_EXT
00107 # define GL_PROXY_TEXTURE_RECTANGLE GL_PROXY_TEXTURE_RECTANGLE_EXT
00108 # define GL_MAX_RECTANGLE_TEXTURE_SIZE GL_MAX_RECTANGLE_TEXTURE_SIZE_EXT
00109 #else
00110 # define GL_TEXTURE_RECTANGLE 0x84F5
00111 # define GL_PROXY_TEXTURE_RECTANGLE 0x84F7
00112 # define GL_MAX_RECTANGLE_TEXTURE_SIZE 0x84F8
00113 #endif
00114 #ifndef GL_MESA_ycbcr_texture
00115 # define GL_YCBCR_MESA 0x8757
00116 # define GL_UNSIGNED_SHORT_8_8_MESA 0x85BA
00117 # define GL_UNSIGNED_SHORT_8_8_REV_MESA 0x85BB
00118 #endif
00119
00120
00121
00122 struct _ARGL_CONTEXT_SETTINGS {
00123 int texturePow2CapabilitiesChecked;
00124 GLuint texturePow2;
00125 GLuint listPow2;
00126 int initedPow2;
00127 int textureRectangleCapabilitiesChecked;
00128 GLuint textureRectangle;
00129 GLuint listRectangle;
00130 int initedRectangle;
00131 int initPlease;
00132 int asInited_texmapScaleFactor;
00133 float asInited_zoom;
00134 int asInited_xsize;
00135 int asInited_ysize;
00136 GLsizei texturePow2SizeX;
00137 GLsizei texturePow2SizeY;
00138 GLenum texturePow2WrapMode;
00139 int disableDistortionCompensation;
00140 GLenum pixIntFormat;
00141 GLenum pixFormat;
00142 GLenum pixType;
00143 GLenum pixSize;
00144 int arglDrawMode;
00145 int arglTexmapMode;
00146 int arglTexRectangle;
00147 };
00148 typedef struct _ARGL_CONTEXT_SETTINGS ARGL_CONTEXT_SETTINGS;
00149
00150
00151
00152
00153
00154
00155 #ifdef __APPLE__
00156 # ifdef APPLE_TEXTURE_FAST_TRANSFER
00157 int arglAppleClientStorage = TRUE;
00158 int arglAppleTextureRange = TRUE;
00159 # else
00160 int arglAppleClientStorage = FALSE;
00161 int arglAppleTextureRange = FALSE;
00162 # endif // APPLE_TEXTURE_FAST_TRANSFER
00163 #endif // __APPLE__
00164
00165
00166
00167
00168
00169
00170 #pragma mark -
00171
00172
00173
00174
00175
00176
00177
00178 GLboolean arglGluCheckExtension(const GLubyte* extName, const GLubyte *extString)
00179 {
00180 const GLubyte *start;
00181 GLubyte *where, *terminator;
00182
00183
00184 where = (GLubyte *)strchr((const char *)extName, ' ');
00185 if (where || *extName == '\0')
00186 return GL_FALSE;
00187
00188
00189 start = extString;
00190 for (;;) {
00191 where = (GLubyte *) strstr((const char *)start, (const char *)extName);
00192 if (!where)
00193 break;
00194 terminator = where + strlen((const char *)extName);
00195 if (where == start || *(where - 1) == ' ')
00196 if (*terminator == ' ' || *terminator == '\0')
00197 return GL_TRUE;
00198 start = terminator;
00199 }
00200 return GL_FALSE;
00201 }
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213 static int arglGLCapabilityCheck(const unsigned short minVersion, const unsigned char *extension)
00214 {
00215 const GLubyte * strRenderer;
00216 const GLubyte * strVersion;
00217 const GLubyte * strVendor;
00218 const GLubyte * strExtensions;
00219 short j, shiftVal;
00220 unsigned short version = 0;
00221
00222 strRenderer = glGetString(GL_RENDERER);
00223 strVendor = glGetString(GL_VENDOR);
00224 strVersion = glGetString(GL_VERSION);
00225 j = 0;
00226 shiftVal = 8;
00227
00228 while (((strVersion[j] <= '9') && (strVersion[j] >= '0')) || (strVersion[j] == '.')) {
00229 if ((strVersion[j] <= '9') && (strVersion[j] >= '0')) {
00230 version += (strVersion[j] - '0') << shiftVal;
00231 shiftVal -= 4;
00232 }
00233 j++;
00234 }
00235 strExtensions = glGetString(GL_EXTENSIONS);
00236
00237 if (0 < minVersion && version >= minVersion) return (TRUE);
00238 if (extension && arglGluCheckExtension(extension, strExtensions)) return (TRUE);
00239 return (FALSE);
00240 }
00241
00242 static int arglDispImageTexPow2CapabilitiesCheck(const ARParam *cparam, ARGL_CONTEXT_SETTINGS_REF contextSettings)
00243 {
00244 GLint format;
00245 GLint texture1SizeMax;
00246
00247 glGetIntegerv(GL_MAX_TEXTURE_SIZE, &texture1SizeMax);
00248 if (cparam->xsize > texture1SizeMax || cparam->ysize > texture1SizeMax) {
00249 return (FALSE);
00250 }
00251
00252
00253 contextSettings->texturePow2SizeX = contextSettings->texturePow2SizeY = 1;
00254 while (contextSettings->texturePow2SizeX < cparam->xsize) {
00255 contextSettings->texturePow2SizeX *= 2;
00256 if (contextSettings->texturePow2SizeX > texture1SizeMax) {
00257 return (FALSE);
00258 }
00259 }
00260 while (contextSettings->texturePow2SizeY < cparam->ysize) {
00261 contextSettings->texturePow2SizeY *= 2;
00262 if (contextSettings->texturePow2SizeY > texture1SizeMax) {
00263 return (FALSE);
00264 }
00265 }
00266
00267
00268 glTexImage2D(GL_PROXY_TEXTURE_2D, 0, contextSettings->pixIntFormat, contextSettings->texturePow2SizeX, contextSettings->texturePow2SizeY, 0, contextSettings->pixFormat, contextSettings->pixType, NULL);
00269 glGetTexLevelParameteriv(GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_INTERNAL_FORMAT, &format);
00270 if (!format) {
00271 return (FALSE);
00272 }
00273
00274
00275 if (arglGLCapabilityCheck(0x0120, (unsigned char *)"GL_SGIS_texture_edge_clamp")) {
00276 contextSettings->texturePow2WrapMode = GL_CLAMP_TO_EDGE;
00277 } else {
00278 contextSettings->texturePow2WrapMode = GL_REPEAT;
00279 }
00280
00281 return (TRUE);
00282 }
00283
00284 static int arglCleanupTexPow2(ARGL_CONTEXT_SETTINGS_REF contextSettings)
00285 {
00286 if (!contextSettings->initedPow2) return (FALSE);
00287
00288 glDeleteTextures(1, &(contextSettings->texturePow2));
00289 glDeleteLists(contextSettings->listPow2, 1);
00290 contextSettings->texturePow2CapabilitiesChecked = FALSE;
00291 contextSettings->initedPow2 = FALSE;
00292 return (TRUE);
00293 }
00294
00295
00296
00297
00298 static void arglDispImageTexPow2(ARUint8 *image, const ARParam *cparam, const float zoom, ARGL_CONTEXT_SETTINGS_REF contextSettings, const int texmapScaleFactor)
00299 {
00300 float tsx, tsy, tex, tey;
00301 float px, py, qx, qy;
00302 double x1, x2, x3, x4, y1, y2, y3, y4;
00303 float xx1, xx2, xx3, xx4, yy1, yy2, yy3, yy4;
00304 int i, j;
00305
00306 if(!contextSettings->initedPow2 || contextSettings->initPlease) {
00307
00308 contextSettings->initPlease = FALSE;
00309
00310 if (contextSettings->initedPow2) arglCleanupTexPow2(contextSettings);
00311
00312
00313
00314
00315 if (!contextSettings->texturePow2CapabilitiesChecked) {
00316 contextSettings->texturePow2CapabilitiesChecked = TRUE;
00317 if (!arglDispImageTexPow2CapabilitiesCheck(cparam, contextSettings)) {
00318 printf("argl error: Your OpenGL implementation and/or hardware's texturing capabilities are insufficient.\n");
00319 return;
00320 }
00321 } else {
00322 return;
00323 }
00324
00325
00326 glGenTextures(1, &(contextSettings->texturePow2));
00327 glBindTexture(GL_TEXTURE_2D, contextSettings->texturePow2);
00328 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
00329 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
00330 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, contextSettings->texturePow2WrapMode);
00331 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, contextSettings->texturePow2WrapMode);
00332
00333 #ifdef APPLE_TEXTURE_FAST_TRANSFER
00334
00335 glTextureRangeAPPLE(GL_TEXTURE_2D, 0, NULL);
00336 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_STORAGE_HINT_APPLE, GL_STORAGE_PRIVATE_APPLE);
00337 glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, FALSE);
00338 #endif // APPLE_TEXTURE_FAST_TRANSFER
00339
00340
00341 if (texmapScaleFactor == 2) {
00342
00343
00344
00345 glPixelStorei(GL_UNPACK_ROW_LENGTH, cparam->xsize*texmapScaleFactor);
00346 }
00347 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
00348 glTexImage2D(GL_TEXTURE_2D, 0, contextSettings->pixIntFormat, contextSettings->texturePow2SizeX, contextSettings->texturePow2SizeY/texmapScaleFactor, 0, contextSettings->pixFormat, contextSettings->pixType, NULL);
00349 if (texmapScaleFactor == 2) {
00350 glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
00351 }
00352
00353
00354 contextSettings->listPow2 = glGenLists(1);
00355 glNewList(contextSettings->listPow2, GL_COMPILE);
00356 glEnable(GL_TEXTURE_2D);
00357 glMatrixMode(GL_TEXTURE);
00358 glLoadIdentity();
00359 glMatrixMode(GL_MODELVIEW);
00360
00361 if (contextSettings->disableDistortionCompensation) {
00362 glBegin(GL_QUADS);
00363 glTexCoord2f(0.0f, (float)cparam->ysize/(float)contextSettings->texturePow2SizeY);
00364 glVertex2f(0.0f, 0.0f);
00365 glTexCoord2f((float)cparam->xsize/(float)contextSettings->texturePow2SizeX, (float)cparam->ysize/(float)contextSettings->texturePow2SizeY);
00366 glVertex2f((float)cparam->xsize * zoom, 0.0f);
00367 glTexCoord2f((float)cparam->xsize/(float)contextSettings->texturePow2SizeX, 0.0f);
00368 glVertex2f((float)cparam->xsize * zoom, (float)cparam->ysize * zoom);
00369 glTexCoord2f(0.0f, 0.0f);
00370 glVertex2f(0.0f, (float)cparam->ysize * zoom);
00371 glEnd();
00372 } else {
00373 qy = 0.0f;
00374 tey = 0.0f;
00375 for(j = 1; j <= 20; j++) {
00376 py = qy;
00377 tsy = tey;
00378 qy = cparam->ysize * j / 20.0f;
00379 tey = qy / contextSettings->texturePow2SizeY;
00380
00381 qx = 0.0f;
00382 tex = 0.0f;
00383 for(i = 1; i <= 20; i++) {
00384 px = qx;
00385 tsx = tex;
00386 qx = cparam->xsize * i / 20.0f;
00387 tex = qx / contextSettings->texturePow2SizeX;
00388
00389 arParamObserv2Ideal(cparam->dist_factor, (double)px, (double)py, &x1, &y1);
00390 arParamObserv2Ideal(cparam->dist_factor, (double)qx, (double)py, &x2, &y2);
00391 arParamObserv2Ideal(cparam->dist_factor, (double)qx, (double)qy, &x3, &y3);
00392 arParamObserv2Ideal(cparam->dist_factor, (double)px, (double)qy, &x4, &y4);
00393
00394 xx1 = (float)x1 * zoom;
00395 yy1 = (cparam->ysize - (float)y1) * zoom;
00396 xx2 = (float)x2 * zoom;
00397 yy2 = (cparam->ysize - (float)y2) * zoom;
00398 xx3 = (float)x3 * zoom;
00399 yy3 = (cparam->ysize - (float)y3) * zoom;
00400 xx4 = (float)x4 * zoom;
00401 yy4 = (cparam->ysize - (float)y4) * zoom;
00402
00403 glBegin(GL_QUADS);
00404 glTexCoord2f(tsx, tsy); glVertex2f(xx1, yy1);
00405 glTexCoord2f(tex, tsy); glVertex2f(xx2, yy2);
00406 glTexCoord2f(tex, tey); glVertex2f(xx3, yy3);
00407 glTexCoord2f(tsx, tey); glVertex2f(xx4, yy4);
00408 glEnd();
00409 }
00410 }
00411 }
00412 glDisable(GL_TEXTURE_2D);
00413 glEndList();
00414
00415 contextSettings->asInited_ysize = cparam->ysize;
00416 contextSettings->asInited_xsize = cparam->xsize;
00417 contextSettings->asInited_zoom = zoom;
00418 contextSettings->asInited_texmapScaleFactor = texmapScaleFactor;
00419 contextSettings->initedPow2 = TRUE;
00420 }
00421
00422 glBindTexture(GL_TEXTURE_2D, contextSettings->texturePow2);
00423 #ifdef APPLE_TEXTURE_FAST_TRANSFER
00424
00425 glTextureRangeAPPLE(GL_TEXTURE_2D, 0, NULL);
00426 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_STORAGE_HINT_APPLE, GL_STORAGE_PRIVATE_APPLE);
00427 glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, FALSE);
00428 #endif // APPLE_TEXTURE_FAST_TRANSFER
00429 if (texmapScaleFactor == 2) {
00430
00431
00432
00433 glPixelStorei(GL_UNPACK_ROW_LENGTH, cparam->xsize*texmapScaleFactor);
00434 }
00435 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
00436 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, cparam->xsize, cparam->ysize/texmapScaleFactor, contextSettings->pixFormat, contextSettings->pixType, image);
00437 glCallList(contextSettings->listPow2);
00438 if (texmapScaleFactor == 2) {
00439 glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
00440 }
00441 glBindTexture(GL_TEXTURE_2D, 0);
00442 }
00443
00444 static int arglDispImageTexRectangleCapabilitiesCheck(const ARParam *cparam, ARGL_CONTEXT_SETTINGS_REF contextSettings)
00445 {
00446 GLint textureRectangleSizeMax;
00447 GLint format;
00448
00449 if (!arglGLCapabilityCheck(0, (unsigned char *)"GL_NV_texture_rectangle")) {
00450 if (!arglGLCapabilityCheck(0, (unsigned char *)"GL_EXT_texture_rectangle")) {
00451 return (FALSE);
00452 }
00453 }
00454 glGetIntegerv(GL_MAX_RECTANGLE_TEXTURE_SIZE, &textureRectangleSizeMax);
00455 if (cparam->xsize > textureRectangleSizeMax || cparam->ysize > textureRectangleSizeMax) {
00456 return (FALSE);
00457 }
00458
00459
00460 glTexImage2D(GL_PROXY_TEXTURE_RECTANGLE, 0, contextSettings->pixIntFormat, cparam->xsize, cparam->ysize, 0, contextSettings->pixFormat, contextSettings->pixType, NULL);
00461 glGetTexLevelParameteriv(GL_PROXY_TEXTURE_RECTANGLE, 0, GL_TEXTURE_INTERNAL_FORMAT, &format);
00462 if (!format) {
00463 return (FALSE);
00464 }
00465
00466 return (TRUE);
00467 }
00468
00469 static int arglCleanupTexRectangle(ARGL_CONTEXT_SETTINGS_REF contextSettings)
00470 {
00471 if (!contextSettings->initedRectangle) return (FALSE);
00472
00473 glDeleteTextures(1, &(contextSettings->textureRectangle));
00474 glDeleteLists(contextSettings->listRectangle, 1);
00475 contextSettings->textureRectangleCapabilitiesChecked = FALSE;
00476 contextSettings->initedRectangle = FALSE;
00477 return (TRUE);
00478 }
00479
00480
00481
00482
00483 static void arglDispImageTexRectangle(ARUint8 *image, const ARParam *cparam, const float zoom, ARGL_CONTEXT_SETTINGS_REF contextSettings, const int texmapScaleFactor)
00484 {
00485 float px, py, py_prev;
00486 double x1, x2, y1, y2;
00487 float xx1, xx2, yy1, yy2;
00488 int i, j;
00489
00490 if(!contextSettings->initedRectangle || contextSettings->initPlease) {
00491
00492 contextSettings->initPlease = FALSE;
00493
00494 if (contextSettings->initedRectangle) arglCleanupTexRectangle(contextSettings);
00495
00496
00497
00498
00499 if (!contextSettings->textureRectangleCapabilitiesChecked) {
00500 contextSettings->textureRectangleCapabilitiesChecked = TRUE;
00501 if (!arglDispImageTexRectangleCapabilitiesCheck(cparam, contextSettings)) {
00502 printf("argl error: Your OpenGL implementation and/or hardware's texturing capabilities are insufficient to support rectangle textures.\n");
00503
00504 contextSettings->arglTexRectangle = FALSE;
00505 arglDispImageTexPow2(image, cparam, zoom, contextSettings, texmapScaleFactor);
00506 return;
00507 }
00508 } else {
00509 return;
00510 }
00511
00512
00513 glGenTextures(1, &(contextSettings->textureRectangle));
00514 glBindTexture(GL_TEXTURE_RECTANGLE, contextSettings->textureRectangle);
00515 glTexParameteri(GL_TEXTURE_RECTANGLE, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
00516 glTexParameteri(GL_TEXTURE_RECTANGLE, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
00517 glTexParameteri(GL_TEXTURE_RECTANGLE, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
00518 glTexParameteri(GL_TEXTURE_RECTANGLE, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
00519
00520 #ifdef APPLE_TEXTURE_FAST_TRANSFER
00521 if (arglAppleTextureRange) {
00522 glTextureRangeAPPLE(GL_TEXTURE_RECTANGLE, cparam->xsize * cparam->ysize * contextSettings->pixSize, image);
00523 glTexParameteri(GL_TEXTURE_RECTANGLE, GL_TEXTURE_STORAGE_HINT_APPLE, GL_STORAGE_SHARED_APPLE);
00524 } else {
00525 glTextureRangeAPPLE(GL_TEXTURE_RECTANGLE, 0, NULL);
00526 glTexParameteri(GL_TEXTURE_RECTANGLE, GL_TEXTURE_STORAGE_HINT_APPLE, GL_STORAGE_PRIVATE_APPLE);
00527 }
00528 glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, arglAppleClientStorage);
00529 #endif // APPLE_TEXTURE_FAST_TRANSFER
00530
00531
00532 if (texmapScaleFactor == 2) {
00533
00534
00535
00536 glPixelStorei(GL_UNPACK_ROW_LENGTH, cparam->xsize*texmapScaleFactor);
00537 }
00538 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
00539 glTexImage2D(GL_TEXTURE_RECTANGLE, 0, contextSettings->pixIntFormat, cparam->xsize, cparam->ysize/texmapScaleFactor, 0, contextSettings->pixFormat, contextSettings->pixType, image);
00540 if (texmapScaleFactor == 2) {
00541 glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
00542 }
00543
00544
00545 contextSettings->listRectangle = glGenLists(1);
00546 glNewList(contextSettings->listRectangle, GL_COMPILE);
00547 glEnable(GL_TEXTURE_RECTANGLE);
00548 glMatrixMode(GL_TEXTURE);
00549 glLoadIdentity();
00550 glMatrixMode(GL_MODELVIEW);
00551
00552 if (contextSettings->disableDistortionCompensation) {
00553 glBegin(GL_QUADS);
00554 glTexCoord2f(0.0f, (float)(cparam->ysize/texmapScaleFactor)); glVertex2f(0.0f, 0.0f);
00555 glTexCoord2f((float)(cparam->xsize), (float)(cparam->ysize/texmapScaleFactor)); glVertex2f(cparam->xsize * zoom, 0.0f);
00556 glTexCoord2f((float)(cparam->xsize), 0.0f); glVertex2f(cparam->xsize * zoom, cparam->ysize * zoom);
00557 glTexCoord2f(0.0f, 0.0f); glVertex2f(0.0f, cparam->ysize * zoom);
00558 glEnd();
00559 } else {
00560 py_prev = 0.0f;
00561 for(j = 1; j <= 20; j++) {
00562 py = py_prev;
00563 py_prev = cparam->ysize * j / 20.0f;
00564
00565 glBegin(GL_QUAD_STRIP);
00566 for(i = 0; i <= 20; i++) {
00567 px = cparam->xsize * i / 20.0f;
00568
00569 arParamObserv2Ideal(cparam->dist_factor, (double)px, (double)py, &x1, &y1);
00570 arParamObserv2Ideal(cparam->dist_factor, (double)px, (double)py_prev, &x2, &y2);
00571
00572 xx1 = (float)x1 * zoom;
00573 yy1 = (cparam->ysize - (float)y1) * zoom;
00574 xx2 = (float)x2 * zoom;
00575 yy2 = (cparam->ysize - (float)y2) * zoom;
00576
00577 glTexCoord2f(px, py/texmapScaleFactor); glVertex2f(xx1, yy1);
00578 glTexCoord2f(px, py_prev/texmapScaleFactor); glVertex2f(xx2, yy2);
00579 }
00580 glEnd();
00581 }
00582 }
00583 glDisable(GL_TEXTURE_RECTANGLE);
00584 glEndList();
00585
00586 contextSettings->asInited_ysize = cparam->ysize;
00587 contextSettings->asInited_xsize = cparam->xsize;
00588 contextSettings->asInited_zoom = zoom;
00589 contextSettings->asInited_texmapScaleFactor = texmapScaleFactor;
00590 contextSettings->initedRectangle = TRUE;
00591 }
00592
00593 glBindTexture(GL_TEXTURE_RECTANGLE, contextSettings->textureRectangle);
00594 #ifdef APPLE_TEXTURE_FAST_TRANSFER
00595 if (arglAppleTextureRange) {
00596 glTextureRangeAPPLE(GL_TEXTURE_RECTANGLE, cparam->xsize * cparam->ysize * contextSettings->pixSize, image);
00597 glTexParameteri(GL_TEXTURE_RECTANGLE, GL_TEXTURE_STORAGE_HINT_APPLE, GL_STORAGE_SHARED_APPLE);
00598 } else {
00599 glTextureRangeAPPLE(GL_TEXTURE_RECTANGLE, 0, NULL);
00600 glTexParameteri(GL_TEXTURE_RECTANGLE, GL_TEXTURE_STORAGE_HINT_APPLE, GL_STORAGE_PRIVATE_APPLE);
00601 }
00602 glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, arglAppleClientStorage);
00603 #endif // APPLE_TEXTURE_FAST_TRANSFER
00604 if (texmapScaleFactor == 2) {
00605 glPixelStorei(GL_UNPACK_ROW_LENGTH, cparam->xsize*texmapScaleFactor);
00606 }
00607 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
00608 glTexSubImage2D(GL_TEXTURE_RECTANGLE, 0, 0, 0, cparam->xsize, cparam->ysize/texmapScaleFactor, contextSettings->pixFormat, contextSettings->pixType, image);
00609 glCallList(contextSettings->listRectangle);
00610 if (texmapScaleFactor == 2) {
00611 glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
00612 }
00613 glBindTexture(GL_TEXTURE_RECTANGLE, 0);
00614 }
00615
00616 #pragma mark -
00617
00618
00619
00620
00621 ARGL_CONTEXT_SETTINGS_REF arglSetupForCurrentContext(void)
00622 {
00623 ARGL_CONTEXT_SETTINGS_REF contextSettings;
00624
00625 contextSettings = (ARGL_CONTEXT_SETTINGS_REF)calloc(1, sizeof(ARGL_CONTEXT_SETTINGS));
00626
00627 if (!arglPixelFormatSet(contextSettings, AR_DEFAULT_PIXEL_FORMAT)) {
00628 printf("Unknown default pixel format defined in config.h.\n");
00629 return (NULL);
00630 }
00631 arglDrawModeSet(contextSettings, AR_DRAW_BY_TEXTURE_MAPPING);
00632 arglTexmapModeSet(contextSettings, AR_DRAW_TEXTURE_FULL_IMAGE);
00633 arglTexRectangleSet(contextSettings, TRUE);
00634
00635 return (contextSettings);
00636 }
00637
00638 void arglCleanup(ARGL_CONTEXT_SETTINGS_REF contextSettings)
00639 {
00640 if (!contextSettings) return;
00641 arglCleanupTexRectangle(contextSettings);
00642 arglCleanupTexPow2(contextSettings);
00643 free(contextSettings);
00644 }
00645
00646
00647
00648
00649 void arglCameraFrustum(const ARParam *cparam, const double focalmin, const double focalmax, GLdouble m_projection[16])
00650 {
00651 double icpara[3][4];
00652 double trans[3][4];
00653 double p[3][3], q[4][4];
00654 int width, height;
00655 int i, j;
00656
00657 width = cparam->xsize;
00658 height = cparam->ysize;
00659
00660 if (arParamDecompMat(cparam->mat, icpara, trans) < 0) {
00661 printf("arglCameraFrustum(): arParamDecompMat() indicated parameter error.\n");
00662 return;
00663 }
00664 for (i = 0; i < 4; i++) {
00665 icpara[1][i] = (height - 1)*(icpara[2][i]) - icpara[1][i];
00666 }
00667
00668 for(i = 0; i < 3; i++) {
00669 for(j = 0; j < 3; j++) {
00670 p[i][j] = icpara[i][j] / icpara[2][2];
00671 }
00672 }
00673 q[0][0] = (2.0 * p[0][0] / (width - 1));
00674 q[0][1] = (2.0 * p[0][1] / (width - 1));
00675 q[0][2] = ((2.0 * p[0][2] / (width - 1)) - 1.0);
00676 q[0][3] = 0.0;
00677
00678 q[1][0] = 0.0;
00679 q[1][1] = (2.0 * p[1][1] / (height - 1));
00680 q[1][2] = ((2.0 * p[1][2] / (height - 1)) - 1.0);
00681 q[1][3] = 0.0;
00682
00683 q[2][0] = 0.0;
00684 q[2][1] = 0.0;
00685 q[2][2] = (focalmax + focalmin)/(focalmax - focalmin);
00686 q[2][3] = -2.0 * focalmax * focalmin / (focalmax - focalmin);
00687
00688 q[3][0] = 0.0;
00689 q[3][1] = 0.0;
00690 q[3][2] = 1.0;
00691 q[3][3] = 0.0;
00692
00693 for (i = 0; i < 4; i++) {
00694
00695 for (j = 0; j < 3; j++) {
00696 m_projection[i + j*4] = q[i][0] * trans[0][j] +
00697 q[i][1] * trans[1][j] +
00698 q[i][2] * trans[2][j];
00699 }
00700
00701 m_projection[i + 3*4] = q[i][0] * trans[0][3] +
00702 q[i][1] * trans[1][3] +
00703 q[i][2] * trans[2][3] +
00704 q[i][3];
00705 }
00706 }
00707
00708 void arglCameraFrustumRH(const ARParam *cparam, const double focalmin, const double focalmax, GLdouble m_projection[16])
00709 {
00710 double icpara[3][4];
00711 double trans[3][4];
00712 double p[3][3], q[4][4];
00713 int width, height;
00714 int i, j;
00715
00716 width = cparam->xsize;
00717 height = cparam->ysize;
00718
00719 if (arParamDecompMat(cparam->mat, icpara, trans) < 0) {
00720 printf("arglCameraFrustum(): arParamDecompMat() indicated parameter error.\n");
00721 return;
00722 }
00723 for (i = 0; i < 4; i++) {
00724 icpara[1][i] = (height - 1)*(icpara[2][i]) - icpara[1][i];
00725 }
00726
00727 for(i = 0; i < 3; i++) {
00728 for(j = 0; j < 3; j++) {
00729 p[i][j] = icpara[i][j] / icpara[2][2];
00730 }
00731 }
00732 q[0][0] = (2.0 * p[0][0] / (width - 1));
00733 q[0][1] = (2.0 * p[0][1] / (width - 1));
00734 q[0][2] = -((2.0 * p[0][2] / (width - 1)) - 1.0);
00735 q[0][3] = 0.0;
00736
00737 q[1][0] = 0.0;
00738 q[1][1] = -(2.0 * p[1][1] / (height - 1));
00739 q[1][2] = -((2.0 * p[1][2] / (height - 1)) - 1.0);
00740 q[1][3] = 0.0;
00741
00742 q[2][0] = 0.0;
00743 q[2][1] = 0.0;
00744 q[2][2] = (focalmax + focalmin)/(focalmin - focalmax);
00745 q[2][3] = 2.0 * focalmax * focalmin / (focalmin - focalmax);
00746
00747 q[3][0] = 0.0;
00748 q[3][1] = 0.0;
00749 q[3][2] = -1.0;
00750 q[3][3] = 0.0;
00751
00752 for (i = 0; i < 4; i++) {
00753
00754 for (j = 0; j < 3; j++) {
00755 m_projection[i + j*4] = q[i][0] * trans[0][j] +
00756 q[i][1] * trans[1][j] +
00757 q[i][2] * trans[2][j];
00758 }
00759
00760 m_projection[i + 3*4] = q[i][0] * trans[0][3] +
00761 q[i][1] * trans[1][3] +
00762 q[i][2] * trans[2][3] +
00763 q[i][3];
00764 }
00765 }
00766
00767 void arglCameraView(const double para[3][4], GLdouble m_modelview[16], const double scale)
00768 {
00769 m_modelview[0 + 0*4] = para[0][0];
00770 m_modelview[0 + 1*4] = para[0][1];
00771 m_modelview[0 + 2*4] = para[0][2];
00772 m_modelview[0 + 3*4] = para[0][3];
00773 m_modelview[1 + 0*4] = para[1][0];
00774 m_modelview[1 + 1*4] = para[1][1];
00775 m_modelview[1 + 2*4] = para[1][2];
00776 m_modelview[1 + 3*4] = para[1][3];
00777 m_modelview[2 + 0*4] = para[2][0];
00778 m_modelview[2 + 1*4] = para[2][1];
00779 m_modelview[2 + 2*4] = para[2][2];
00780 m_modelview[2 + 3*4] = para[2][3];
00781 m_modelview[3 + 0*4] = 0.0;
00782 m_modelview[3 + 1*4] = 0.0;
00783 m_modelview[3 + 2*4] = 0.0;
00784 m_modelview[3 + 3*4] = 1.0;
00785 if (scale != 0.0) {
00786 m_modelview[12] *= scale;
00787 m_modelview[13] *= scale;
00788 m_modelview[14] *= scale;
00789 }
00790 }
00791
00792 void arglCameraViewRH(const double para[3][4], GLdouble m_modelview[16], const double scale)
00793 {
00794 m_modelview[0 + 0*4] = para[0][0];
00795 m_modelview[0 + 1*4] = para[0][1];
00796 m_modelview[0 + 2*4] = para[0][2];
00797 m_modelview[0 + 3*4] = para[0][3];
00798 m_modelview[1 + 0*4] = -para[1][0];
00799 m_modelview[1 + 1*4] = -para[1][1];
00800 m_modelview[1 + 2*4] = -para[1][2];
00801 m_modelview[1 + 3*4] = -para[1][3];
00802 m_modelview[2 + 0*4] = -para[2][0];
00803 m_modelview[2 + 1*4] = -para[2][1];
00804 m_modelview[2 + 2*4] = -para[2][2];
00805 m_modelview[2 + 3*4] = -para[2][3];
00806 m_modelview[3 + 0*4] = 0.0;
00807 m_modelview[3 + 1*4] = 0.0;
00808 m_modelview[3 + 2*4] = 0.0;
00809 m_modelview[3 + 3*4] = 1.0;
00810 if (scale != 0.0) {
00811 m_modelview[12] *= scale;
00812 m_modelview[13] *= scale;
00813 m_modelview[14] *= scale;
00814 }
00815 }
00816
00817 void arglDispImage(ARUint8 *image, const ARParam *cparam, const double zoom, ARGL_CONTEXT_SETTINGS_REF contextSettings)
00818 {
00819 GLint texEnvModeSave;
00820 GLboolean lightingSave;
00821 GLboolean depthTestSave;
00822 #ifdef ARGL_DEBUG
00823 GLenum err;
00824 const GLubyte *errs;
00825 #endif // ARGL_DEBUG
00826
00827 if (!image) return;
00828
00829
00830 glGetTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, &texEnvModeSave);
00831 if (texEnvModeSave != GL_REPLACE) glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
00832 lightingSave = glIsEnabled(GL_LIGHTING);
00833 if (lightingSave == GL_TRUE) glDisable(GL_LIGHTING);
00834 depthTestSave = glIsEnabled(GL_DEPTH_TEST);
00835 if (depthTestSave == GL_TRUE) glDisable(GL_DEPTH_TEST);
00836 glMatrixMode(GL_PROJECTION);
00837 glPushMatrix();
00838 glLoadIdentity();
00839 gluOrtho2D(0, cparam->xsize, 0, cparam->ysize);
00840 glMatrixMode(GL_MODELVIEW);
00841 glPushMatrix();
00842 glLoadIdentity();
00843
00844 if (arDebug) {
00845 if (arImage) {
00846 if (arImageProcMode == AR_IMAGE_PROC_IN_HALF) {
00847 ARParam cparamScaled = *cparam;
00848 cparamScaled.xsize /= 2;
00849 cparamScaled.ysize /= 2;
00850 arglDispImageStateful(arImage, &cparamScaled, zoom * 2.0, contextSettings);
00851 } else {
00852 arglDispImageStateful(arImage, cparam, zoom, contextSettings);
00853 }
00854 }
00855 } else {
00856 arglDispImageStateful(image, cparam, zoom, contextSettings);
00857 }
00858
00859
00860 glMatrixMode(GL_PROJECTION);
00861 glPopMatrix();
00862 glMatrixMode(GL_MODELVIEW);
00863 glPopMatrix();
00864 if (depthTestSave == GL_TRUE) glEnable(GL_DEPTH_TEST);
00865 if (lightingSave == GL_TRUE) glEnable(GL_LIGHTING);
00866 if (texEnvModeSave != GL_REPLACE) glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, texEnvModeSave);
00867
00868 #ifdef ARGL_DEBUG
00869
00870 while ((err = glGetError()) != GL_NO_ERROR) {
00871 errs = gluErrorString(err);
00872 fprintf(stderr, "GL error: %s (%i)\n", errs, (int)err);
00873 }
00874 #endif // ARGL_DEBUG
00875
00876 }
00877
00878 void arglDispImageStateful(ARUint8 *image, const ARParam *cparam, const double zoom, ARGL_CONTEXT_SETTINGS_REF contextSettings)
00879 {
00880 float zoomf;
00881 int texmapScaleFactor, params[4];
00882
00883 zoomf = (float)zoom;
00884 texmapScaleFactor = contextSettings->arglTexmapMode + 1;
00885 if (contextSettings->arglDrawMode == AR_DRAW_BY_GL_DRAW_PIXELS) {
00886 glDisable(GL_TEXTURE_2D);
00887 glGetIntegerv(GL_VIEWPORT, (GLint *)params);
00888 glPixelZoom(zoomf * ((float)(params[2]) / (float)(cparam->xsize)),
00889 -zoomf * ((float)(params[3]) / (float)(cparam->ysize)));
00890 glRasterPos2f(0.0f, (float)(cparam->ysize));
00891 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
00892 glDrawPixels(cparam->xsize, cparam->ysize, contextSettings->pixFormat, contextSettings->pixType, image);
00893 } else {
00894
00895
00896 if ((texmapScaleFactor != contextSettings->asInited_texmapScaleFactor) ||
00897 (zoomf != contextSettings->asInited_zoom) ||
00898 (cparam->xsize != contextSettings->asInited_xsize) ||
00899 (cparam->ysize != contextSettings->asInited_ysize)) {
00900 contextSettings->initPlease = TRUE;
00901 }
00902
00903 if (contextSettings->arglTexRectangle) {
00904 arglDispImageTexRectangle(image, cparam, zoomf, contextSettings, texmapScaleFactor);
00905 } else {
00906 arglDispImageTexPow2(image, cparam, zoomf, contextSettings, texmapScaleFactor);
00907 }
00908 }
00909 }
00910
00911 int arglDistortionCompensationSet(ARGL_CONTEXT_SETTINGS_REF contextSettings, int enable)
00912 {
00913 if (!contextSettings) return (FALSE);
00914 contextSettings->disableDistortionCompensation = !enable;
00915 contextSettings->initPlease = TRUE;
00916 return (TRUE);
00917 }
00918
00919 int arglDistortionCompensationGet(ARGL_CONTEXT_SETTINGS_REF contextSettings, int *enable)
00920 {
00921 if (!contextSettings) return (FALSE);
00922 *enable = !contextSettings->disableDistortionCompensation;
00923 return (TRUE);
00924 }
00925
00926 int arglPixelFormatSet(ARGL_CONTEXT_SETTINGS_REF contextSettings, AR_PIXEL_FORMAT format)
00927 {
00928 if (!contextSettings) return (FALSE);
00929 switch (format) {
00930 case AR_PIXEL_FORMAT_RGBA:
00931 contextSettings->pixIntFormat = GL_RGBA;
00932 contextSettings->pixFormat = GL_RGBA;
00933 contextSettings->pixType = GL_UNSIGNED_BYTE;
00934 contextSettings->pixSize = 4;
00935 break;
00936 case AR_PIXEL_FORMAT_ABGR:
00937 if (arglGLCapabilityCheck(0, (unsigned char *)"GL_EXT_abgr")) {
00938 contextSettings->pixIntFormat = GL_RGBA;
00939 contextSettings->pixFormat = GL_ABGR_EXT;
00940 contextSettings->pixType = GL_UNSIGNED_BYTE;
00941 contextSettings->pixSize = 4;
00942 } else {
00943 return (FALSE);
00944 }
00945 break;
00946 case AR_PIXEL_FORMAT_BGRA:
00947 if (arglGLCapabilityCheck(0x0120, (unsigned char *)"GL_EXT_bgra")) {
00948 contextSettings->pixIntFormat = GL_RGBA;
00949 contextSettings->pixFormat = GL_BGRA;
00950 contextSettings->pixType = GL_UNSIGNED_BYTE;
00951 contextSettings->pixSize = 4;
00952 } else {
00953 return (FALSE);
00954 }
00955 break;
00956 case AR_PIXEL_FORMAT_ARGB:
00957 if (arglGLCapabilityCheck(0x0120, (unsigned char *)"GL_EXT_bgra")
00958 && arglGLCapabilityCheck(0x0120, (unsigned char *)"GL_APPLE_packed_pixels")) {
00959 contextSettings->pixIntFormat = GL_RGBA;
00960 contextSettings->pixFormat = GL_BGRA;
00961 #ifdef AR_BIG_ENDIAN
00962 contextSettings->pixType = GL_UNSIGNED_INT_8_8_8_8_REV;
00963 #else
00964 contextSettings->pixType = GL_UNSIGNED_INT_8_8_8_8;
00965 #endif
00966 contextSettings->pixSize = 4;
00967 } else {
00968 return (FALSE);
00969 }
00970 break;
00971 case AR_PIXEL_FORMAT_RGB:
00972 contextSettings->pixIntFormat = GL_RGB;
00973 contextSettings->pixFormat = GL_RGB;
00974 contextSettings->pixType = GL_UNSIGNED_BYTE;
00975 contextSettings->pixSize = 3;
00976 break;
00977 case AR_PIXEL_FORMAT_BGR:
00978 if (arglGLCapabilityCheck(0x0120, (unsigned char *)"GL_EXT_bgra")) {
00979 contextSettings->pixIntFormat = GL_RGB;
00980 contextSettings->pixFormat = GL_BGR;
00981 contextSettings->pixType = GL_UNSIGNED_BYTE;
00982 contextSettings->pixSize = 3;
00983 } else {
00984 return (FALSE);
00985 }
00986 break;
00987 case AR_PIXEL_FORMAT_MONO:
00988 contextSettings->pixIntFormat = GL_LUMINANCE;
00989 contextSettings->pixFormat = GL_LUMINANCE;
00990 contextSettings->pixType = GL_UNSIGNED_BYTE;
00991 contextSettings->pixSize = 1;
00992 break;
00993 case AR_PIXEL_FORMAT_2vuy:
00994 if (arglGLCapabilityCheck(0, (unsigned char *)"GL_APPLE_ycbcr_422")) {
00995 contextSettings->pixIntFormat = GL_RGB;
00996 contextSettings->pixFormat = GL_YCBCR_422_APPLE;
00997 #ifdef AR_BIG_ENDIAN
00998 contextSettings->pixType = GL_UNSIGNED_SHORT_8_8_REV_APPLE;
00999 #else
01000 contextSettings->pixType = GL_UNSIGNED_SHORT_8_8_APPLE;
01001 #endif
01002 } else if (arglGLCapabilityCheck(0, (unsigned char *)"GL_MESA_ycbcr_texture")) {
01003 contextSettings->pixIntFormat = GL_YCBCR_MESA;
01004 contextSettings->pixFormat = GL_YCBCR_MESA;
01005 #ifdef AR_BIG_ENDIAN
01006 contextSettings->pixType = GL_UNSIGNED_SHORT_8_8_REV_MESA;
01007 #else
01008 contextSettings->pixType = GL_UNSIGNED_SHORT_8_8_MESA;
01009 #endif
01010 } else {
01011 return (FALSE);
01012 }
01013 contextSettings->pixSize = 2;
01014 break;
01015 case AR_PIXEL_FORMAT_yuvs:
01016 if (arglGLCapabilityCheck(0, (unsigned char *)"GL_APPLE_ycbcr_422")) {
01017 contextSettings->pixIntFormat = GL_RGB;
01018 contextSettings->pixFormat = GL_YCBCR_422_APPLE;
01019 #ifdef AR_BIG_ENDIAN
01020 contextSettings->pixType = GL_UNSIGNED_SHORT_8_8_APPLE;
01021 #else
01022 contextSettings->pixType = GL_UNSIGNED_SHORT_8_8_REV_APPLE;
01023 #endif
01024 } else if (arglGLCapabilityCheck(0, (unsigned char *)"GL_MESA_ycbcr_texture")) {
01025 contextSettings->pixIntFormat = GL_YCBCR_MESA;
01026 contextSettings->pixFormat = GL_YCBCR_MESA;
01027 #ifdef AR_BIG_ENDIAN
01028 contextSettings->pixType = GL_UNSIGNED_SHORT_8_8_MESA;
01029 #else
01030 contextSettings->pixType = GL_UNSIGNED_SHORT_8_8_REV_MESA;
01031 #endif
01032 } else {
01033 return (FALSE);
01034 }
01035 contextSettings->pixSize = 2;
01036 break;
01037 default:
01038 return (FALSE);
01039 break;
01040 }
01041 contextSettings->initPlease = TRUE;
01042 return (TRUE);
01043 }
01044
01045 int arglPixelFormatGet(ARGL_CONTEXT_SETTINGS_REF contextSettings, AR_PIXEL_FORMAT *format, int *size)
01046 {
01047 if (!contextSettings) return (FALSE);
01048 switch (contextSettings->pixFormat) {
01049 case GL_RGBA:
01050 *format = AR_PIXEL_FORMAT_RGBA;
01051 *size = 4;
01052 break;
01053 case GL_ABGR_EXT:
01054 *format = AR_PIXEL_FORMAT_ABGR;
01055 *size = 4;
01056 break;
01057 case GL_BGRA:
01058 if (contextSettings->pixType == GL_UNSIGNED_BYTE) *format = AR_PIXEL_FORMAT_BGRA;
01059 #ifdef AR_BIG_ENDIAN
01060 else if (contextSettings->pixType == GL_UNSIGNED_INT_8_8_8_8_REV) *format = AR_PIXEL_FORMAT_ARGB;
01061 #else
01062 else if (contextSettings->pixType == GL_UNSIGNED_INT_8_8_8_8) *format = AR_PIXEL_FORMAT_ARGB;
01063 #endif
01064 else return (FALSE);
01065 *size = 4;
01066 break;
01067 case GL_RGB:
01068 *format = AR_PIXEL_FORMAT_RGB;
01069 *size = 3;
01070 break;
01071 case GL_BGR:
01072 *format = AR_PIXEL_FORMAT_BGR;
01073 *size = 3;
01074 break;
01075 case GL_YCBCR_422_APPLE:
01076 case GL_YCBCR_MESA:
01077 #ifdef AR_BIG_ENDIAN
01078 if (contextSettings->pixType == GL_UNSIGNED_SHORT_8_8_REV_APPLE) *format = AR_PIXEL_FORMAT_2vuy;
01079 else if (contextSettings->pixType == GL_UNSIGNED_SHORT_8_8_APPLE) *format = AR_PIXEL_FORMAT_yuvs;
01080 #else
01081 if (contextSettings->pixType == GL_UNSIGNED_SHORT_8_8_APPLE) *format = AR_PIXEL_FORMAT_2vuy;
01082 else if (contextSettings->pixType == GL_UNSIGNED_SHORT_8_8_REV_APPLE) *format = AR_PIXEL_FORMAT_yuvs;
01083 #endif
01084 else return (FALSE);
01085 *size = 2;
01086 break;
01087 case GL_LUMINANCE:
01088 *format = AR_PIXEL_FORMAT_MONO;
01089 *size = 1;
01090 break;
01091 default:
01092 return (FALSE);
01093 break;
01094 }
01095 return (TRUE);
01096 }
01097
01098 void arglDrawModeSet(ARGL_CONTEXT_SETTINGS_REF contextSettings, const int mode)
01099 {
01100 if (!contextSettings || mode < 0 || mode > 1) return;
01101 contextSettings->arglDrawMode = mode;
01102 }
01103
01104 int arglDrawModeGet(ARGL_CONTEXT_SETTINGS_REF contextSettings)
01105 {
01106 if (!contextSettings) return (-1);
01107 return (contextSettings->arglDrawMode);
01108 }
01109
01110 void arglTexmapModeSet(ARGL_CONTEXT_SETTINGS_REF contextSettings, const int mode)
01111 {
01112 if (!contextSettings || mode < 0 || mode > 1) return;
01113 contextSettings->arglTexmapMode = mode;
01114 }
01115
01116 int arglTexmapModeGet(ARGL_CONTEXT_SETTINGS_REF contextSettings)
01117 {
01118 if (!contextSettings) return (-1);
01119 return (contextSettings->arglTexmapMode);
01120 }
01121
01122 void arglTexRectangleSet(ARGL_CONTEXT_SETTINGS_REF contextSettings, const int state)
01123 {
01124 if (!contextSettings) return;
01125 contextSettings->arglTexRectangle = state;
01126 }
01127
01128 int arglTexRectangleGet(ARGL_CONTEXT_SETTINGS_REF contextSettings)
01129 {
01130 if (!contextSettings) return (-1);
01131 return (contextSettings->arglTexRectangle);
01132 }
01133