ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

macros.h
Go to the documentation of this file.
00001 
00006 /*
00007  * Mesa 3-D graphics library
00008  * Version:  6.5.2
00009  *
00010  * Copyright (C) 1999-2006  Brian Paul   All Rights Reserved.
00011  *
00012  * Permission is hereby granted, free of charge, to any person obtaining a
00013  * copy of this software and associated documentation files (the "Software"),
00014  * to deal in the Software without restriction, including without limitation
00015  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
00016  * and/or sell copies of the Software, and to permit persons to whom the
00017  * Software is furnished to do so, subject to the following conditions:
00018  *
00019  * The above copyright notice and this permission notice shall be included
00020  * in all copies or substantial portions of the Software.
00021  *
00022  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00023  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00024  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
00025  * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
00026  * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
00027  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00028  */
00029 
00030 
00031 #ifndef MACROS_H
00032 #define MACROS_H
00033 
00034 #include "imports.h"
00035 
00036 
00041 
00043 extern GLfloat _mesa_ubyte_to_float_color_tab[256];
00044 #define UBYTE_TO_FLOAT(u) _mesa_ubyte_to_float_color_tab[(unsigned int)(u)]
00045 
00047 #define FLOAT_TO_UBYTE(X)   ((GLubyte) (GLint) ((X) * 255.0F))
00048 
00049 
00051 #define BYTE_TO_FLOAT(B)    ((2.0F * (B) + 1.0F) * (1.0F/255.0F))
00052 
00054 #define FLOAT_TO_BYTE(X)    ( (((GLint) (255.0F * (X))) - 1) / 2 )
00055 
00056 
00058 #define USHORT_TO_FLOAT(S)  ((GLfloat) (S) * (1.0F / 65535.0F))
00059 
00061 #define SHORT_TO_FLOAT(S)   ((2.0F * (S) + 1.0F) * (1.0F/65535.0F))
00062 
00064 #define FLOAT_TO_SHORT(X)   ( (((GLint) (65535.0F * (X))) - 1) / 2 )
00065 
00066 
00068 #define UINT_TO_FLOAT(U)    ((GLfloat) (U) * (1.0F / 4294967295.0F))
00069 
00071 #define FLOAT_TO_UINT(X)    ((GLuint) ((X) * 4294967295.0))
00072 
00073 
00075 #define INT_TO_FLOAT(I)     ((2.0F * (I) + 1.0F) * (1.0F/4294967294.0F))
00076 
00078 /* causes overflow:
00079 #define FLOAT_TO_INT(X)     ( (((GLint) (4294967294.0F * (X))) - 1) / 2 )
00080 */
00081 /* a close approximation: */
00082 #define FLOAT_TO_INT(X)     ( (GLint) (2147483647.0 * (X)) )
00083 
00084 
00085 #define BYTE_TO_UBYTE(b)   ((GLubyte) ((b) < 0 ? 0 : (GLubyte) (b)))
00086 #define SHORT_TO_UBYTE(s)  ((GLubyte) ((s) < 0 ? 0 : (GLubyte) ((s) >> 7)))
00087 #define USHORT_TO_UBYTE(s) ((GLubyte) ((s) >> 8))
00088 #define INT_TO_UBYTE(i)    ((GLubyte) ((i) < 0 ? 0 : (GLubyte) ((i) >> 23)))
00089 #define UINT_TO_UBYTE(i)   ((GLubyte) ((i) >> 24))
00090 
00091 
00092 #define BYTE_TO_USHORT(b)  ((b) < 0 ? 0 : ((GLushort) (((b) * 65535) / 255)))
00093 #define UBYTE_TO_USHORT(b) (((GLushort) (b) << 8) | (GLushort) (b))
00094 #define SHORT_TO_USHORT(s) ((s) < 0 ? 0 : ((GLushort) (((s) * 65535 / 32767))))
00095 #define INT_TO_USHORT(i)   ((i) < 0 ? 0 : ((GLushort) ((i) >> 15)))
00096 #define UINT_TO_USHORT(i)  ((i) < 0 ? 0 : ((GLushort) ((i) >> 16)))
00097 #define UNCLAMPED_FLOAT_TO_USHORT(us, f)  \
00098         us = ( (GLushort) IROUND( CLAMP((f), 0.0, 1.0) * 65535.0F) )
00099 #define CLAMPED_FLOAT_TO_USHORT(us, f)  \
00100         us = ( (GLushort) IROUND( (f) * 65535.0F) )
00101 
00106 #define STRIDE_F(p, i)  (p = (GLfloat *)((GLubyte *)p + i))
00107 
00108 #define STRIDE_UI(p, i)  (p = (GLuint *)((GLubyte *)p + i))
00109 
00110 #define STRIDE_4UB(p, i)  (p = (GLubyte (*)[4])((GLubyte *)p + i))
00111 
00112 #define STRIDE_4F(p, i)  (p = (GLfloat (*)[4])((GLubyte *)p + i))
00113 
00114 #define STRIDE_4CHAN(p, i)  (p = (GLchan (*)[4])((GLubyte *)p + i))
00115 
00116 #define STRIDE_CHAN(p, i)  (p = (GLchan *)((GLubyte *)p + i))
00117 
00118 #define STRIDE_T(p, t, i)  (p = (t)((GLubyte *)p + i))
00119 
00120 
00121 /**********************************************************************/
00124 
00126 #define ZERO_4V( DST )  (DST)[0] = (DST)[1] = (DST)[2] = (DST)[3] = 0
00127 
00129 #define TEST_EQ_4V(a,b)  ((a)[0] == (b)[0] &&   \
00130               (a)[1] == (b)[1] &&   \
00131               (a)[2] == (b)[2] &&   \
00132               (a)[3] == (b)[3])
00133 
00135 #if defined(__i386__)
00136 #define TEST_EQ_4UBV(DST, SRC) *((GLuint*)(DST)) == *((GLuint*)(SRC))
00137 #else
00138 #define TEST_EQ_4UBV(DST, SRC) TEST_EQ_4V(DST, SRC)
00139 #endif
00140 
00142 #define COPY_4V( DST, SRC )         \
00143 do {                                \
00144    (DST)[0] = (SRC)[0];             \
00145    (DST)[1] = (SRC)[1];             \
00146    (DST)[2] = (SRC)[2];             \
00147    (DST)[3] = (SRC)[3];             \
00148 } while (0)
00149 
00151 #define COPY_4V_CAST( DST, SRC, CAST )  \
00152 do {                                    \
00153    (DST)[0] = (CAST)(SRC)[0];           \
00154    (DST)[1] = (CAST)(SRC)[1];           \
00155    (DST)[2] = (CAST)(SRC)[2];           \
00156    (DST)[3] = (CAST)(SRC)[3];           \
00157 } while (0)
00158 
00160 #if defined(__i386__)
00161 #define COPY_4UBV(DST, SRC)                 \
00162 do {                                        \
00163    *((GLuint*)(DST)) = *((GLuint*)(SRC));   \
00164 } while (0)
00165 #else
00166 /* The GLuint cast might fail if DST or SRC are not dword-aligned (RISC) */
00167 #define COPY_4UBV(DST, SRC)         \
00168 do {                                \
00169    (DST)[0] = (SRC)[0];             \
00170    (DST)[1] = (SRC)[1];             \
00171    (DST)[2] = (SRC)[2];             \
00172    (DST)[3] = (SRC)[3];             \
00173 } while (0)
00174 #endif
00175 
00180 #define COPY_4FV( DST, SRC )                  \
00181 do {                                          \
00182    const GLuint *_s = (const GLuint *) (SRC); \
00183    GLuint *_d = (GLuint *) (DST);             \
00184    _d[0] = _s[0];                             \
00185    _d[1] = _s[1];                             \
00186    _d[2] = _s[2];                             \
00187    _d[3] = _s[3];                             \
00188 } while (0)
00189 
00191 #define COPY_SZ_4V(DST, SZ, SRC)  \
00192 do {                              \
00193    switch (SZ) {                  \
00194    case 4: (DST)[3] = (SRC)[3];   \
00195    case 3: (DST)[2] = (SRC)[2];   \
00196    case 2: (DST)[1] = (SRC)[1];   \
00197    case 1: (DST)[0] = (SRC)[0];   \
00198    }                              \
00199 } while(0)
00200 
00203 #define COPY_CLEAN_4V(DST, SZ, SRC)  \
00204 do {                                 \
00205       ASSIGN_4V( DST, 0, 0, 0, 1 );  \
00206       COPY_SZ_4V( DST, SZ, SRC );    \
00207 } while (0)
00208 
00210 #define SUB_4V( DST, SRCA, SRCB )           \
00211 do {                                        \
00212       (DST)[0] = (SRCA)[0] - (SRCB)[0];     \
00213       (DST)[1] = (SRCA)[1] - (SRCB)[1];     \
00214       (DST)[2] = (SRCA)[2] - (SRCB)[2];     \
00215       (DST)[3] = (SRCA)[3] - (SRCB)[3];     \
00216 } while (0)
00217 
00219 #define ADD_4V( DST, SRCA, SRCB )           \
00220 do {                                        \
00221       (DST)[0] = (SRCA)[0] + (SRCB)[0];     \
00222       (DST)[1] = (SRCA)[1] + (SRCB)[1];     \
00223       (DST)[2] = (SRCA)[2] + (SRCB)[2];     \
00224       (DST)[3] = (SRCA)[3] + (SRCB)[3];     \
00225 } while (0)
00226 
00228 #define SCALE_4V( DST, SRCA, SRCB )         \
00229 do {                                        \
00230       (DST)[0] = (SRCA)[0] * (SRCB)[0];     \
00231       (DST)[1] = (SRCA)[1] * (SRCB)[1];     \
00232       (DST)[2] = (SRCA)[2] * (SRCB)[2];     \
00233       (DST)[3] = (SRCA)[3] * (SRCB)[3];     \
00234 } while (0)
00235 
00237 #define ACC_4V( DST, SRC )          \
00238 do {                                \
00239       (DST)[0] += (SRC)[0];         \
00240       (DST)[1] += (SRC)[1];         \
00241       (DST)[2] += (SRC)[2];         \
00242       (DST)[3] += (SRC)[3];         \
00243 } while (0)
00244 
00246 #define ACC_SCALE_4V( DST, SRCA, SRCB )     \
00247 do {                                        \
00248       (DST)[0] += (SRCA)[0] * (SRCB)[0];    \
00249       (DST)[1] += (SRCA)[1] * (SRCB)[1];    \
00250       (DST)[2] += (SRCA)[2] * (SRCB)[2];    \
00251       (DST)[3] += (SRCA)[3] * (SRCB)[3];    \
00252 } while (0)
00253 
00255 #define ACC_SCALE_SCALAR_4V( DST, S, SRCB ) \
00256 do {                                        \
00257       (DST)[0] += S * (SRCB)[0];            \
00258       (DST)[1] += S * (SRCB)[1];            \
00259       (DST)[2] += S * (SRCB)[2];            \
00260       (DST)[3] += S * (SRCB)[3];            \
00261 } while (0)
00262 
00264 #define SCALE_SCALAR_4V( DST, S, SRCB ) \
00265 do {                                    \
00266       (DST)[0] = S * (SRCB)[0];         \
00267       (DST)[1] = S * (SRCB)[1];         \
00268       (DST)[2] = S * (SRCB)[2];         \
00269       (DST)[3] = S * (SRCB)[3];         \
00270 } while (0)
00271 
00273 #define SELF_SCALE_SCALAR_4V( DST, S ) \
00274 do {                                   \
00275       (DST)[0] *= S;                   \
00276       (DST)[1] *= S;                   \
00277       (DST)[2] *= S;                   \
00278       (DST)[3] *= S;                   \
00279 } while (0)
00280 
00282 #define ASSIGN_4V( V, V0, V1, V2, V3 )  \
00283 do {                                    \
00284     V[0] = V0;                          \
00285     V[1] = V1;                          \
00286     V[2] = V2;                          \
00287     V[3] = V3;                          \
00288 } while(0)
00289 
00293 /**********************************************************************/
00296 
00298 #define ZERO_3V( DST )  (DST)[0] = (DST)[1] = (DST)[2] = 0
00299 
00301 #define TEST_EQ_3V(a,b)  \
00302    ((a)[0] == (b)[0] &&  \
00303     (a)[1] == (b)[1] &&  \
00304     (a)[2] == (b)[2])
00305 
00307 #define COPY_3V( DST, SRC )         \
00308 do {                                \
00309    (DST)[0] = (SRC)[0];             \
00310    (DST)[1] = (SRC)[1];             \
00311    (DST)[2] = (SRC)[2];             \
00312 } while (0)
00313 
00315 #define COPY_3V_CAST( DST, SRC, CAST )  \
00316 do {                                    \
00317    (DST)[0] = (CAST)(SRC)[0];           \
00318    (DST)[1] = (CAST)(SRC)[1];           \
00319    (DST)[2] = (CAST)(SRC)[2];           \
00320 } while (0)
00321 
00323 #define COPY_3FV( DST, SRC )        \
00324 do {                                \
00325    const GLfloat *_tmp = (SRC);     \
00326    (DST)[0] = _tmp[0];              \
00327    (DST)[1] = _tmp[1];              \
00328    (DST)[2] = _tmp[2];              \
00329 } while (0)
00330 
00332 #define SUB_3V( DST, SRCA, SRCB )        \
00333 do {                                     \
00334       (DST)[0] = (SRCA)[0] - (SRCB)[0];  \
00335       (DST)[1] = (SRCA)[1] - (SRCB)[1];  \
00336       (DST)[2] = (SRCA)[2] - (SRCB)[2];  \
00337 } while (0)
00338 
00340 #define ADD_3V( DST, SRCA, SRCB )       \
00341 do {                                    \
00342       (DST)[0] = (SRCA)[0] + (SRCB)[0]; \
00343       (DST)[1] = (SRCA)[1] + (SRCB)[1]; \
00344       (DST)[2] = (SRCA)[2] + (SRCB)[2]; \
00345 } while (0)
00346 
00348 #define SCALE_3V( DST, SRCA, SRCB )     \
00349 do {                                    \
00350       (DST)[0] = (SRCA)[0] * (SRCB)[0]; \
00351       (DST)[1] = (SRCA)[1] * (SRCB)[1]; \
00352       (DST)[2] = (SRCA)[2] * (SRCB)[2]; \
00353 } while (0)
00354 
00356 #define SELF_SCALE_3V( DST, SRC )   \
00357 do {                                \
00358       (DST)[0] *= (SRC)[0];         \
00359       (DST)[1] *= (SRC)[1];         \
00360       (DST)[2] *= (SRC)[2];         \
00361 } while (0)
00362 
00364 #define ACC_3V( DST, SRC )          \
00365 do {                                \
00366       (DST)[0] += (SRC)[0];         \
00367       (DST)[1] += (SRC)[1];         \
00368       (DST)[2] += (SRC)[2];         \
00369 } while (0)
00370 
00372 #define ACC_SCALE_3V( DST, SRCA, SRCB )     \
00373 do {                                        \
00374       (DST)[0] += (SRCA)[0] * (SRCB)[0];    \
00375       (DST)[1] += (SRCA)[1] * (SRCB)[1];    \
00376       (DST)[2] += (SRCA)[2] * (SRCB)[2];    \
00377 } while (0)
00378 
00380 #define SCALE_SCALAR_3V( DST, S, SRCB ) \
00381 do {                                    \
00382       (DST)[0] = S * (SRCB)[0];         \
00383       (DST)[1] = S * (SRCB)[1];         \
00384       (DST)[2] = S * (SRCB)[2];         \
00385 } while (0)
00386 
00388 #define ACC_SCALE_SCALAR_3V( DST, S, SRCB ) \
00389 do {                                        \
00390       (DST)[0] += S * (SRCB)[0];            \
00391       (DST)[1] += S * (SRCB)[1];            \
00392       (DST)[2] += S * (SRCB)[2];            \
00393 } while (0)
00394 
00396 #define SELF_SCALE_SCALAR_3V( DST, S ) \
00397 do {                                   \
00398       (DST)[0] *= S;                   \
00399       (DST)[1] *= S;                   \
00400       (DST)[2] *= S;                   \
00401 } while (0)
00402 
00404 #define ACC_SCALAR_3V( DST, S )     \
00405 do {                                \
00406       (DST)[0] += S;                \
00407       (DST)[1] += S;                \
00408       (DST)[2] += S;                \
00409 } while (0)
00410 
00412 #define ASSIGN_3V( V, V0, V1, V2 )  \
00413 do {                                \
00414     V[0] = V0;                      \
00415     V[1] = V1;                      \
00416     V[2] = V2;                      \
00417 } while(0)
00418 
00422 /**********************************************************************/
00425 
00427 #define ZERO_2V( DST )  (DST)[0] = (DST)[1] = 0
00428 
00430 #define COPY_2V( DST, SRC )         \
00431 do {                        \
00432    (DST)[0] = (SRC)[0];             \
00433    (DST)[1] = (SRC)[1];             \
00434 } while (0)
00435 
00437 #define COPY_2V_CAST( DST, SRC, CAST )      \
00438 do {                        \
00439    (DST)[0] = (CAST)(SRC)[0];           \
00440    (DST)[1] = (CAST)(SRC)[1];           \
00441 } while (0)
00442 
00444 #define COPY_2FV( DST, SRC )            \
00445 do {                        \
00446    const GLfloat *_tmp = (SRC);         \
00447    (DST)[0] = _tmp[0];              \
00448    (DST)[1] = _tmp[1];              \
00449 } while (0)
00450 
00452 #define SUB_2V( DST, SRCA, SRCB )       \
00453 do {                        \
00454       (DST)[0] = (SRCA)[0] - (SRCB)[0];     \
00455       (DST)[1] = (SRCA)[1] - (SRCB)[1];     \
00456 } while (0)
00457 
00459 #define ADD_2V( DST, SRCA, SRCB )       \
00460 do {                        \
00461       (DST)[0] = (SRCA)[0] + (SRCB)[0];     \
00462       (DST)[1] = (SRCA)[1] + (SRCB)[1];     \
00463 } while (0)
00464 
00466 #define SCALE_2V( DST, SRCA, SRCB )     \
00467 do {                        \
00468       (DST)[0] = (SRCA)[0] * (SRCB)[0];     \
00469       (DST)[1] = (SRCA)[1] * (SRCB)[1];     \
00470 } while (0)
00471 
00473 #define ACC_2V( DST, SRC )          \
00474 do {                        \
00475       (DST)[0] += (SRC)[0];         \
00476       (DST)[1] += (SRC)[1];         \
00477 } while (0)
00478 
00480 #define ACC_SCALE_2V( DST, SRCA, SRCB )     \
00481 do {                        \
00482       (DST)[0] += (SRCA)[0] * (SRCB)[0];    \
00483       (DST)[1] += (SRCA)[1] * (SRCB)[1];    \
00484 } while (0)
00485 
00487 #define SCALE_SCALAR_2V( DST, S, SRCB )     \
00488 do {                        \
00489       (DST)[0] = S * (SRCB)[0];         \
00490       (DST)[1] = S * (SRCB)[1];         \
00491 } while (0)
00492 
00494 #define ACC_SCALE_SCALAR_2V( DST, S, SRCB ) \
00495 do {                        \
00496       (DST)[0] += S * (SRCB)[0];        \
00497       (DST)[1] += S * (SRCB)[1];        \
00498 } while (0)
00499 
00501 #define SELF_SCALE_SCALAR_2V( DST, S )      \
00502 do {                        \
00503       (DST)[0] *= S;                \
00504       (DST)[1] *= S;                \
00505 } while (0)
00506 
00508 #define ACC_SCALAR_2V( DST, S )         \
00509 do {                        \
00510       (DST)[0] += S;                \
00511       (DST)[1] += S;                \
00512 } while (0)
00513 
00515 #define ASSIGN_2V( V, V0, V1 )  \
00516 do {                \
00517     V[0] = V0;          \
00518     V[1] = V1;          \
00519 } while(0)
00520 
00526 
00533 #define LINTERP(T, OUT, IN) ((OUT) + (T) * ((IN) - (OUT)))
00534 
00535 /* Can do better with integer math
00536  */
00537 #define INTERP_UB( t, dstub, outub, inub )  \
00538 do {                        \
00539    GLfloat inf = UBYTE_TO_FLOAT( inub );    \
00540    GLfloat outf = UBYTE_TO_FLOAT( outub );  \
00541    GLfloat dstf = LINTERP( t, outf, inf );  \
00542    UNCLAMPED_FLOAT_TO_UBYTE( dstub, dstf ); \
00543 } while (0)
00544 
00545 #define INTERP_CHAN( t, dstc, outc, inc )   \
00546 do {                        \
00547    GLfloat inf = CHAN_TO_FLOAT( inc );      \
00548    GLfloat outf = CHAN_TO_FLOAT( outc );    \
00549    GLfloat dstf = LINTERP( t, outf, inf );  \
00550    UNCLAMPED_FLOAT_TO_CHAN( dstc, dstf );   \
00551 } while (0)
00552 
00553 #define INTERP_UI( t, dstui, outui, inui )  \
00554    dstui = (GLuint) (GLint) LINTERP( (t), (GLfloat) (outui), (GLfloat) (inui) )
00555 
00556 #define INTERP_F( t, dstf, outf, inf )      \
00557    dstf = LINTERP( t, outf, inf )
00558 
00559 #define INTERP_4F( t, dst, out, in )        \
00560 do {                        \
00561    dst[0] = LINTERP( (t), (out)[0], (in)[0] );  \
00562    dst[1] = LINTERP( (t), (out)[1], (in)[1] );  \
00563    dst[2] = LINTERP( (t), (out)[2], (in)[2] );  \
00564    dst[3] = LINTERP( (t), (out)[3], (in)[3] );  \
00565 } while (0)
00566 
00567 #define INTERP_3F( t, dst, out, in )        \
00568 do {                        \
00569    dst[0] = LINTERP( (t), (out)[0], (in)[0] );  \
00570    dst[1] = LINTERP( (t), (out)[1], (in)[1] );  \
00571    dst[2] = LINTERP( (t), (out)[2], (in)[2] );  \
00572 } while (0)
00573 
00574 #define INTERP_4CHAN( t, dst, out, in )         \
00575 do {                            \
00576    INTERP_CHAN( (t), (dst)[0], (out)[0], (in)[0] ); \
00577    INTERP_CHAN( (t), (dst)[1], (out)[1], (in)[1] ); \
00578    INTERP_CHAN( (t), (dst)[2], (out)[2], (in)[2] ); \
00579    INTERP_CHAN( (t), (dst)[3], (out)[3], (in)[3] ); \
00580 } while (0)
00581 
00582 #define INTERP_3CHAN( t, dst, out, in )         \
00583 do {                            \
00584    INTERP_CHAN( (t), (dst)[0], (out)[0], (in)[0] ); \
00585    INTERP_CHAN( (t), (dst)[1], (out)[1], (in)[1] ); \
00586    INTERP_CHAN( (t), (dst)[2], (out)[2], (in)[2] ); \
00587 } while (0)
00588 
00589 #define INTERP_SZ( t, vec, to, out, in, sz )                \
00590 do {                                    \
00591    switch (sz) {                            \
00592    case 4: vec[to][3] = LINTERP( (t), (vec)[out][3], (vec)[in][3] );    \
00593    case 3: vec[to][2] = LINTERP( (t), (vec)[out][2], (vec)[in][2] );    \
00594    case 2: vec[to][1] = LINTERP( (t), (vec)[out][1], (vec)[in][1] );    \
00595    case 1: vec[to][0] = LINTERP( (t), (vec)[out][0], (vec)[in][0] );    \
00596    }                                    \
00597 } while(0)
00598 
00604 #define CLAMP( X, MIN, MAX )  ( (X)<(MIN) ? (MIN) : ((X)>(MAX) ? (MAX) : (X)) )
00605 
00607 #define CLAMP_SELF(x, mn, mx)  \
00608    ( (x)<(mn) ? ((x) = (mn)) : ((x)>(mx) ? ((x)=(mx)) : (x)) )
00609 
00610 
00611 
00613 #define MIN2( A, B )   ( (A)<(B) ? (A) : (B) )
00614 
00616 #define MAX2( A, B )   ( (A)>(B) ? (A) : (B) )
00617 
00619 #define DOT2( a, b )  ( (a)[0]*(b)[0] + (a)[1]*(b)[1] )
00620 
00622 #define DOT3( a, b )  ( (a)[0]*(b)[0] + (a)[1]*(b)[1] + (a)[2]*(b)[2] )
00623 
00625 #define DOT4( a, b )  ( (a)[0]*(b)[0] + (a)[1]*(b)[1] + \
00626             (a)[2]*(b)[2] + (a)[3]*(b)[3] )
00627 
00629 #define DOT4V(v,a,b,c,d) (v[0]*(a) + v[1]*(b) + v[2]*(c) + v[3]*(d))
00630 
00631 
00633 #define CROSS3(n, u, v)             \
00634 do {                        \
00635    (n)[0] = (u)[1]*(v)[2] - (u)[2]*(v)[1];  \
00636    (n)[1] = (u)[2]*(v)[0] - (u)[0]*(v)[2];  \
00637    (n)[2] = (u)[0]*(v)[1] - (u)[1]*(v)[0];  \
00638 } while (0)
00639 
00640 
00641 /* Normalize a 3-element vector to unit length. */
00642 #define NORMALIZE_3FV( V )          \
00643 do {                        \
00644    GLfloat len = (GLfloat) LEN_SQUARED_3FV(V);  \
00645    if (len) {                   \
00646       len = INV_SQRTF(len);         \
00647       (V)[0] = (GLfloat) ((V)[0] * len);    \
00648       (V)[1] = (GLfloat) ((V)[1] * len);    \
00649       (V)[2] = (GLfloat) ((V)[2] * len);    \
00650    }                        \
00651 } while(0)
00652 
00653 #define LEN_3FV( V ) (SQRTF((V)[0]*(V)[0]+(V)[1]*(V)[1]+(V)[2]*(V)[2]))
00654 #define LEN_2FV( V ) (SQRTF((V)[0]*(V)[0]+(V)[1]*(V)[1]))
00655 
00656 #define LEN_SQUARED_3FV( V ) ((V)[0]*(V)[0]+(V)[1]*(V)[1]+(V)[2]*(V)[2])
00657 #define LEN_SQUARED_2FV( V ) ((V)[0]*(V)[0]+(V)[1]*(V)[1])
00658 
00659 
00661 #define ENUM_TO_INT(E)     ((GLint)(E))
00662 #define ENUM_TO_FLOAT(E)   ((GLfloat)(GLint)(E))
00663 #define ENUM_TO_DOUBLE(E)  ((GLdouble)(GLint)(E))
00664 #define ENUM_TO_BOOLEAN(E) ((E) ? GL_TRUE : GL_FALSE)
00665 
00666 
00667 #endif

Generated on Sun May 27 2012 04:20:21 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.