00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef __RE_Types__
00019 #define __RE_Types__
00020
00021 #include "RE_API.h"
00022 #include "RE_Platform.h"
00023
00024
00025 #ifdef MBSD
00026 # define RE_OGL_SINGLE_CONTEXT 0
00027 #elif defined(CELLBE)
00028 # define RE_OGL_SINGLE_CONTEXT 1
00029 #elif defined(LINUX)
00030 # define RE_OGL_SINGLE_CONTEXT 0
00031 #else
00032 # define RE_OGL_SINGLE_CONTEXT 0
00033 #endif
00034
00035
00036
00037 #ifdef WIN32
00038 typedef void *RE_IDType;
00039 #elif defined(MBSD_COCOA)
00040 #include <UT/UT_MBSDUtil.h>
00041 typedef UT_ObjCRef RE_IDType;
00042 #elif defined(CELLBE)
00043 typedef void * RE_IDType;
00044 #else
00045 typedef unsigned long RE_IDType;
00046 #endif
00047
00048 enum RE_WindowVisibility
00049 {
00050 RE_WINDOW_VISIBLE,
00051 RE_WINDOW_OFFSCREEN
00052 };
00053
00054
00055
00056 enum RE_WindowType
00057 {
00058 RE_WINDOW_MAIN,
00059 RE_WINDOW_NORMAL,
00060 RE_WINDOW_DIALOG,
00061
00062 RE_WINDOW_UTILITY,
00063
00064 RE_WINDOW_SPLASH,
00065 RE_WINDOW_TRANSIENT,
00066
00067
00068 RE_WINDOW_CHILD,
00069
00070 RE_WINDOW_MENU,
00071 RE_WINDOW_HELPTIP,
00072 RE_WINDOW_INVALID_TYPE
00073 };
00074
00075
00076
00077 enum RE_GPUType
00078 {
00079 RE_GPU_UINT1,
00080 RE_GPU_UINT4,
00081 RE_GPU_UINT8,
00082 RE_GPU_UINT16,
00083 RE_GPU_UINT32,
00084
00085 RE_GPU_INT8,
00086 RE_GPU_INT16,
00087 RE_GPU_INT32,
00088
00089 RE_GPU_FLOAT16,
00090 RE_GPU_FLOAT24,
00091 RE_GPU_FLOAT32,
00092
00093
00094 RE_GPU_MATRIX2,
00095 RE_GPU_MATRIX3,
00096 RE_GPU_MATRIX4
00097 };
00098
00099
00100 #define RE_NUM_WINDOW_TYPES RE_WINDOW_INVALID_TYPE
00101
00102 #include <UT/UT_Color.h>
00103 #include <UT/UT_Matrix4.h>
00104
00105 #if defined(WIN32) || defined(MBSD_COCOA)
00106 typedef void * Display;
00107 #elif defined(CELLBE)
00108 #include </usr/local/sony-cell-sdk/target/ppu/include/GL/egl.h>
00109 typedef EGLDisplay Display;
00110 #endif
00111
00112 #define RE_DEFAULT_DPI 85.0
00113
00114 #define X_ICON_WIDTH 85 // Icon size under Motif.
00115 #define X_ICON_HEIGHT 66
00116
00117 #define RE_MAXGLVTX 65535 // No max in open GL?
00118
00119 #define MAX_DISPLAY_MODES 5
00120
00121 #define MED_RES 90
00122
00123 #define MM_TO_INCHES(mm) ((mm) / 25.4)
00124
00125 #define GL_DRAW_NORMAL 0
00126 #define GL_DRAW_POPUP 1
00127 #define GL_DRAW_OVERLAY 2
00128 #define GL_DRAW_UNDERLAY 3
00129 #define GL_DRAW_CURSOR 4
00130
00131 typedef float RE_CMMatrix[16];
00132
00133
00134 enum RE_RenderBuf
00135 {
00136 RE_FRONT = 1,
00137 RE_BACK = 2
00138
00139
00140 };
00141
00142 enum RE_MatrixMode
00143 {
00144 RE_MATRIX_SINGLE,
00145 RE_MATRIX_VIEWING,
00146 RE_MATRIX_PROJECTION,
00147 RE_MATRIX_TEXTURE
00148 };
00149
00150 enum RE_FillPattern
00151 {
00152 RE_NO_PATTERN,
00153 RE_QUARTER_TONE,
00154 RE_HALF_TONE,
00155 RE_3QUARTER_TONE,
00156 RE_QUARTER_HASH,
00157 RE_QUARTER_FORE_HASH,
00158 RE_QUARTER_BACK_HASH
00159 };
00160
00161 enum RE_LineStyle
00162 {
00163 RE_LINE_SOLID = 0,
00164 RE_LINE_DASH_LONG = 1,
00165 RE_LINE_DASH_SHORT = 2,
00166 RE_LINE_DOTTED = 3
00167 };
00168
00169 enum RE_InterpMode
00170 {
00171 RE_INTERP_FLAT,
00172 RE_INTERP_GOURAUD,
00173 RE_INTERP_PHONG
00174 };
00175
00176 enum RE_SmoothMode
00177 {
00178 RE_SMOOTH_OFF = 0,
00179 RE_SMOOTH_ON = 1
00180 };
00181
00182 enum RE_LightIndex
00183 {
00184 RE_LIGHT0 = 0,
00185 RE_LIGHT1 = 1,
00186 RE_LIGHT2 = 2,
00187 RE_LIGHT3 = 3,
00188 RE_LIGHT4 = 4,
00189 RE_LIGHT5 = 5,
00190 RE_LIGHT6 = 6,
00191 RE_LIGHT7 = 7
00192 };
00193
00194 enum RE_ZFunction
00195 {
00196 RE_ZNEVER,
00197 RE_ZLESS,
00198 RE_ZEQUAL,
00199 RE_ZLEQUAL,
00200 RE_ZGREATER,
00201 RE_ZNOTEQUAL,
00202 RE_ZGEQUAL,
00203 RE_ZALWAYS
00204 };
00205
00206 enum RE_SFunction
00207 {
00208 RE_SNEVER,
00209 RE_SLESS,
00210 RE_SEQUAL,
00211 RE_SLEQUAL,
00212 RE_SGREATER,
00213 RE_SNOTEQUAL,
00214 RE_SGEQUAL,
00215 RE_SALWAYS
00216 };
00217
00218 enum RE_SOperation
00219 {
00220 RE_SKEEP,
00221 RE_SZERO,
00222 RE_SREPLACE,
00223 RE_SINCR,
00224 RE_SDECR,
00225
00226
00227
00228
00229 RE_SINVERT
00230 };
00231
00232 enum RE_BlendSourceFactor
00233 {
00234 RE_SBLEND_ZERO,
00235 RE_SBLEND_DST_COLOR,
00236 RE_SBLEND_ONE_MINUS_DST_COLOR,
00237 RE_SBLEND_SRC_ALPHA,
00238 RE_SBLEND_ONE_MINUS_SRC_ALPHA,
00239 RE_SBLEND_DST_ALPHA,
00240 RE_SBLEND_ONE_MINUS_DST_ALPHA,
00241 RE_SBLEND_SRC_ALPHA_SATURATE,
00242 RE_SBLEND_ONE
00243 };
00244
00245 enum RE_BlendDestFactor
00246 {
00247 RE_DBLEND_ONE,
00248 RE_DBLEND_SRC_COLOR,
00249 RE_DBLEND_ONE_MINUS_SRC_COLOR,
00250 RE_DBLEND_SRC_ALPHA,
00251 RE_DBLEND_ONE_MINUS_SRC_ALPHA,
00252 RE_DBLEND_DST_ALPHA,
00253 RE_DBLEND_ONE_MINUS_DST_ALPHA,
00254 RE_DBLEND_ZERO
00255 };
00256
00257 #define RE_MODE_MULTISAMPLE_MASK 0x60
00258 #define RE_MODE_MULTISAMPLE_SHIFT 5
00259
00260 enum RE_DisplayMode
00261 {
00262
00263 RE_MODE_NONE = 0x000,
00264 RE_MODE_RGB = 0x001,
00265 RE_MODE_DOUBLE = 0x002,
00266 RE_MODE_ZBUFFER = 0x004,
00267 RE_MODE_ALPHA = 0x008,
00268 RE_MODE_STENCIL = 0x010,
00269 RE_MODE_MULTISAMPLE_LOW = 0x020,
00270 RE_MODE_MULTISAMPLE_MED = 0x040,
00271 RE_MODE_MULTISAMPLE_HIGH = 0x060,
00272 RE_MODE_ACCUM = 0x080,
00273 RE_MODE_ACCUM_ALPHA = 0x100,
00274
00275
00276 RE_MODE_RGB_SINGLE = RE_MODE_RGB,
00277 RE_MODE_RGB_DOUBLE = RE_MODE_RGB | RE_MODE_DOUBLE,
00278
00279 RE_MODE_RGBA_SINGLE = RE_MODE_RGB | RE_MODE_ALPHA,
00280 RE_MODE_RGBA_DOUBLE = RE_MODE_RGB | RE_MODE_DOUBLE | RE_MODE_ALPHA,
00281
00282 RE_MODE_RGBZ_SINGLE = RE_MODE_RGB | RE_MODE_ZBUFFER,
00283 RE_MODE_RGBZ_DOUBLE = RE_MODE_RGB | RE_MODE_DOUBLE|RE_MODE_ZBUFFER,
00284
00285 RE_MODE_RGBSZ_SINGLE = RE_MODE_RGBZ_SINGLE | RE_MODE_STENCIL,
00286 RE_MODE_RGBSZ_DOUBLE = RE_MODE_RGBZ_DOUBLE | RE_MODE_STENCIL,
00287
00288 RE_MODE_RGBAZ_SINGLE = RE_MODE_RGB | RE_MODE_ALPHA |RE_MODE_ZBUFFER,
00289 RE_MODE_RGBAZ_DOUBLE = RE_MODE_RGB | RE_MODE_DOUBLE |RE_MODE_ALPHA |
00290 RE_MODE_ZBUFFER,
00291
00292 RE_MODE_RGBS_SINGLE = RE_MODE_RGB | RE_MODE_STENCIL,
00293 RE_MODE_RGBS_DOUBLE = RE_MODE_RGB | RE_MODE_DOUBLE|RE_MODE_STENCIL,
00294
00295 RE_MODE_RGBAS_SINGLE = RE_MODE_RGB | RE_MODE_ALPHA |RE_MODE_STENCIL,
00296 RE_MODE_RGBAS_DOUBLE = RE_MODE_RGB | RE_MODE_DOUBLE |RE_MODE_ALPHA |
00297 RE_MODE_STENCIL,
00298
00299 RE_MODE_RGB_BEST = RE_MODE_RGB_DOUBLE,
00300 RE_MODE_RGBA_BEST = RE_MODE_RGBA_DOUBLE,
00301 RE_MODE_RGBZ_BEST = RE_MODE_RGBZ_DOUBLE,
00302 RE_MODE_RGBAZ_BEST = RE_MODE_RGBAZ_DOUBLE,
00303 RE_MODE_RGBS_BEST = RE_MODE_RGBS_DOUBLE,
00304 RE_MODE_RGBAS_BEST = RE_MODE_RGBAS_DOUBLE
00305 };
00306
00307 enum RE_VisualType
00308 {
00309 RE_NORMAL_VIS,
00310 RE_OVERLAY_VIS,
00311 RE_FULLSCREEN_OVERLAY_VIS
00312 };
00313
00314 enum RE_PolyOffStrategy
00315 {
00316 RE_POLYOFF_GL11,
00317 RE_POLYOFF_GL10_EXT,
00318 RE_POLYOFF_NONE
00319 };
00320
00321 enum RE_DrawPixelsMode
00322 {
00323 RE_PM_ABGR,
00324 RE_PM_RGBA,
00325 RE_PM_RGB
00326 };
00327
00328
00329 enum RE_GraphicsDevice
00330 {
00331 RE_DEVICE_UNKNOWN = 0x0,
00332
00333 RE_DEVICE_ATI = 0x1,
00334 RE_DEVICE_NVIDIA = 0x2,
00335 RE_DEVICE_INTEL = 0x4,
00336 RE_DEVICE_GDI = 0x8,
00337
00338 RE_DEVICE_PRO = 0x100,
00339
00340 RE_DEVICE_ATI_PRO = (RE_DEVICE_PRO|RE_DEVICE_ATI),
00341 RE_DEVICE_NVIDIA_PRO = (RE_DEVICE_PRO|RE_DEVICE_NVIDIA),
00342 RE_DEVICE_INTEL_PRO = (RE_DEVICE_PRO|RE_DEVICE_INTEL)
00343 };
00344
00345 inline bool REisProfessionalDevice(RE_GraphicsDevice dev)
00346 {
00347 return (dev & RE_DEVICE_PRO);
00348 }
00349
00350 inline bool REisConsumerDevice(RE_GraphicsDevice dev)
00351 {
00352 return !(dev & RE_DEVICE_PRO);
00353 }
00354
00355 inline const char *REgetDeviceName(RE_GraphicsDevice dev)
00356 {
00357 switch(dev)
00358 {
00359 case RE_DEVICE_ATI: return "ATI Consumer";
00360 case RE_DEVICE_NVIDIA: return "NVidia Consumer";
00361 case RE_DEVICE_INTEL: return "Intel Consumer";
00362 case RE_DEVICE_GDI: return "GDI Generic";
00363 case RE_DEVICE_ATI_PRO: return "ATI Professional";
00364 case RE_DEVICE_NVIDIA_PRO: return "NVidia Professional";
00365 case RE_DEVICE_INTEL_PRO: return "Intel Professional";
00366 default:
00367 break;
00368 }
00369 return "Unknown";
00370 }
00371
00372
00373
00374 typedef unsigned char RE_State;
00375
00376 class IMG_Raster;
00377 typedef IMG_Raster *(*RE_IconLoader)(int, int);
00378
00379 class PXL_Lookup;
00380
00381 class RE_API RE_RasterOpts
00382 {
00383 public:
00384 RE_RasterOpts() : myZoomX(-1), myZoomY(-1),
00385 myColorScale(1.0f), myColorShift(0.0f),
00386 myColorBlack(0.0f), myColorWhite(1.0f),
00387 myAlphaScale(1.0f), myAlphaShift(0.0f),
00388 myGamma(1.0f), myAspectRatio(1.0f), myVScale(1.0f),
00389 myLUTSize(0), myComponent(-1), myModifyAlpha(false),
00390 myDither(true), myComponentsAsGrey(true),
00391 myLUTObject(0), myTransparent(0), myPremultiplyFlag(0),
00392 myFragment16bit(0)
00393 { myLUT[0] = myLUT[1] = myLUT[2] = myLUT[3] = 0; }
00394
00395 float myZoomX;
00396 float myZoomY;
00397 float myColorScale;
00398 float myColorShift;
00399 float myColorBlack;
00400 float myColorWhite;
00401 float myAlphaScale;
00402 float myAlphaShift;
00403 float myGamma;
00404 float myAspectRatio;
00405 float myVScale;
00406 float *myLUT[4];
00407 int myLUTSize;
00408 int myComponent;
00409 unsigned myModifyAlpha :1,
00410 myDither : 1,
00411 myComponentsAsGrey :1,
00412 myTransparent :1,
00413 myPremultiplyFlag:1,
00414 myFragment16bit : 2;
00415 PXL_Lookup *myLUTObject;
00416 };
00417
00418
00419 class RE_API RE_ColorStack
00420 {
00421 public:
00422 float r, g, b, a;
00423 };
00424
00425 class RE_API RE_StateInfo
00426 {
00427 public:
00428 RE_StateInfo()
00429 {
00430 concave = 0;
00431 backface = 0;
00432 picking = 0;
00433 blending = 0;
00434 reverse_winding = 0;
00435 };
00436 unsigned concave:1,
00437 backface:1,
00438 picking:1,
00439 blending:1,
00440 reverse_winding;
00441 };
00442
00443
00444 class RE_API re_BlendState
00445 {
00446 public:
00447 re_BlendState()
00448 {
00449 myBlend = 0;
00450 mySourceFactor = RE_SBLEND_ONE;
00451 myDestFactor = RE_DBLEND_ZERO;
00452 myZBufferWrite = false;
00453 }
00454
00455 void set(bool blend, RE_BlendSourceFactor s, RE_BlendDestFactor d,
00456 bool zbuf)
00457 { myBlend = blend; mySourceFactor = s; myDestFactor = d;
00458 myZBufferWrite = zbuf; }
00459
00460 void get(bool &blend, RE_BlendSourceFactor &s, RE_BlendDestFactor &d,
00461 bool &zbuf) const
00462 { blend = myBlend; s = mySourceFactor; d = myDestFactor;
00463 zbuf = myZBufferWrite; }
00464
00465 bool myBlend;
00466 RE_BlendSourceFactor mySourceFactor;
00467 RE_BlendDestFactor myDestFactor;
00468 bool myZBufferWrite;
00469 };
00470
00471
00472 class RE_API re_SmoothState : public re_BlendState
00473 {
00474 public:
00475 re_SmoothState()
00476 {
00477 mySmooth = 0;
00478 myAllowSmooth = 0;
00479 }
00480
00481 void set(bool smooth, bool allow, bool blend,
00482 RE_BlendSourceFactor s, RE_BlendDestFactor d, bool zbuf)
00483 { mySmooth = smooth; myAllowSmooth = allow;
00484 re_BlendState::set(blend, s, d, zbuf); }
00485
00486 void get(bool &smooth, bool &allow, bool &blend,
00487 RE_BlendSourceFactor &s, RE_BlendDestFactor &d, bool &zbuf) const
00488 { smooth = mySmooth; allow = myAllowSmooth;
00489 re_BlendState::get(blend, s,d, zbuf); }
00490
00491 bool mySmooth;
00492 bool myAllowSmooth;
00493 };
00494
00495
00496 class RE_API re_StencilState
00497 {
00498 public:
00499 re_StencilState()
00500 {
00501 myEnable = false;
00502 myClearValue = 0;
00503 myWriteMask = 1;
00504 myFunc = RE_SALWAYS;
00505 myRef = 0;
00506 myValueMask = 1;
00507 myFailOperation = RE_SKEEP;
00508 myPassDepthFailOperation = RE_SKEEP;
00509 myPassDepthPassOperation = RE_SKEEP;
00510 }
00511
00512 void set(bool enable,
00513 int clearValue,
00514 int writeMask,
00515 RE_SFunction func,
00516 int ref,
00517 int valueMask,
00518 RE_SOperation failOperation,
00519 RE_SOperation passDepthFailOperation,
00520 RE_SOperation passDepthPassOperation)
00521 {
00522 myEnable = enable;
00523 myClearValue = clearValue;
00524 myWriteMask = writeMask;
00525 myFunc = func;
00526 myRef = ref;
00527 myValueMask = valueMask;
00528 myFailOperation = failOperation;
00529 myPassDepthFailOperation = passDepthFailOperation;
00530 myPassDepthPassOperation = passDepthPassOperation;
00531 }
00532
00533 void get(bool &enable,
00534 int &clearValue,
00535 int &writeMask,
00536 RE_SFunction &func,
00537 int &ref,
00538 int &valueMask,
00539 RE_SOperation &failOperation,
00540 RE_SOperation &passDepthFailOperation,
00541 RE_SOperation &passDepthPassOperation) const
00542 {
00543 enable = myEnable;
00544 clearValue = myClearValue;
00545 writeMask = myWriteMask;
00546 func = myFunc;
00547 ref = myRef;
00548 valueMask = myValueMask;
00549 failOperation = myFailOperation;
00550 passDepthFailOperation = myPassDepthFailOperation;
00551 passDepthPassOperation = myPassDepthPassOperation;
00552 }
00553
00554 bool myEnable;
00555 int myClearValue;
00556 int myWriteMask;
00557 RE_SFunction myFunc;
00558 int myRef;
00559 int myValueMask;
00560 RE_SOperation myFailOperation;
00561 RE_SOperation myPassDepthFailOperation;
00562 RE_SOperation myPassDepthPassOperation;
00563 };
00564
00565 #define CONTEXT_STACK_SIZE 5
00566 #define PATTERN_STACK_SIZE 7
00567 #define RE_COLOR_STACK_SIZE 32
00568 #define PROJECTION_STACK_SIZE 32
00569 #define RE_SMOOTH_STACK_SIZE 16
00570 #define RE_BLEND_STACK_SIZE 16
00571 #define RE_STENCIL_STACK_SIZE 16
00572
00573 #define RE_STACK_DEPTH 256
00574
00575
00576
00577 #if defined(MBSD_COCOA) && RE_OGL_SINGLE_CONTEXT
00578
00579 typedef UT_ObjCRef RE_OGLContext;
00580 #else
00581 typedef void *RE_OGLContext;
00582 #endif
00583
00584 #ifdef WIN32
00585 #include <windows.h>
00586 #include <GL/glu.h>
00587
00588 #ifndef GL_ABGR_EXT
00589 #define GL_ABGR_EXT 0x8000
00590 #endif
00591 #define False 0
00592 #define True 1
00593
00594 typedef unsigned short ColorIndexType;
00595 typedef HGLRC OGLContext;
00596 typedef HWND OGLWindow;
00597 typedef HDC OGLDrawable;
00598
00599 #define NewRE_Server() (new RE_NTServer())
00600 #define NewRE_Cursor(a,b) (new RE_NTCursor(a,b))
00601 #define NewRE_Visual(a,b) (new RE_NTVisual(a,b))
00602
00603 #elif defined(MBSD_COCOA)
00604
00605 #include <OpenGL/glu.h>
00606
00607 #define False 0
00608 #define True 1
00609
00610
00611
00612
00613 typedef unsigned short ColorIndexType;
00614 typedef UT_ObjCRef OGLContext;
00615 typedef UT_ObjCRef OGLWindow;
00616 typedef UT_ObjCRef OGLDrawable;
00617
00618 #define NewRE_Server() (new RE_OSXServer())
00619 #define NewRE_Cursor(a,b) (new RE_OSXCursor(a,b))
00620 #define NewRE_Visual(a,b) (new RE_OSXVisual(a,b))
00621
00622 #elif defined(CELLBE)
00623
00624 #include <GL/gl.h>
00625 #include <GL/egl.h>
00626
00627 #define False 0
00628 #define True 1
00629
00630 typedef EGLContext OGLContext;
00631 typedef EGLSurface OGLWindow;
00632 typedef EGLSurface OGLDrawable;
00633
00634 #define NewRE_Server() (new RE_EGLServer())
00635 #define NewRE_Cursor(a,b) (new RE_EGLCursor(a,b))
00636 #define NewRE_Visual(a,b) (new RE_EGLVisual(a,b))
00637
00638 #else // X11
00639
00640 #include <GL/glu.h>
00641 #include <GL/glx.h>
00642
00643 typedef unsigned short ColorIndexType;
00644 typedef GLXContext OGLContext;
00645 typedef Window OGLWindow;
00646 typedef GLXDrawable OGLDrawable;
00647
00648 #if defined(LINUX) || defined(SOLARIS)
00649 typedef GLXDrawable GLXPbufferSGIX;
00650 #if defined(LINUX) && !defined(GLX_SGIX_fbconfig)
00651
00652 typedef void *GLXFBConfigSGIX;
00653 #endif
00654 #endif
00655
00656 #define NewRE_Server() (new RE_XServer())
00657 #define NewRE_Cursor(a,b) (new RE_XCursor((RE_XServer *)a,b))
00658 #define NewRE_Visual(a,b) (new RE_XVisual((RE_XServer *)a,b))
00659 #endif
00660
00661 #endif