| TerraLib 4.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Examples

- File List
- File Members

E:/Projetos_Primeiro_Semestre_2012/TerraView/terralib/src/terralib/drivers/GL/glcore.h
Go to the documentation of this file.

    00001 /* $XFree86: xc/lib/GL/include/GL/internal/glcore.h,v 1.7 2001/03/25 05:32:00 tsi Exp $ */
    00002 #ifndef __gl_core_h_
    00003 #define __gl_core_h_
    00004
    00005 /*
    00006 ** License Applicability. Except to the extent portions of this file are
    00007 ** made subject to an alternative license as permitted in the SGI Free
    00008 ** Software License B, Version 1.1 (the "License"), the contents of this
    00009 ** file are subject only to the provisions of the License. You may not use
    00010 ** this file except in compliance with the License. You may obtain a copy
    00011 ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
    00012 ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
    00013 **
    00014 ** http://oss.sgi.com/projects/FreeB
    00015 **
    00016 ** Note that, as provided in the License, the Software is distributed on an
    00017 ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
    00018 ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
    00019 ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
    00020 ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
    00021 **
    00022 ** Original Code. The Original Code is: OpenGL Sample Implementation,
    00023 ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
    00024 ** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
    00025 ** Copyright in any portions created by third parties is as indicated
    00026 ** elsewhere herein. All Rights Reserved.
    00027 **
    00028 ** Additional Notice Provisions: The application programming interfaces
    00029 ** established by SGI in conjunction with the Original Code are The
    00030 ** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
    00031 ** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
    00032 ** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
    00033 ** Window System(R) (Version 1.3), released October 19, 1998. This software
    00034 ** was created using the OpenGL(R) version 1.2.1 Sample Implementation
    00035 ** published by SGI, but has not been independently verified as being
    00036 ** compliant with the OpenGL(R) version 1.2.1 Specification.
    00037 **
    00038 */
    00039
    00040 #ifndef XFree86LOADER
    00041 #include <sys/types.h>
    00042 #endif
    00043
    00044 #ifdef CAPI
    00045 #undef CAPI
    00046 #endif
    00047 #define CAPI
    00048
    00049 #define GL_CORE_SGI  1
    00050 #define GL_CORE_MESA 2
    00051 #define GL_CORE_APPLE 4
    00052 #define GL_CORE_WINDOWS 8
    00053
    00054 typedef struct __GLcontextRec __GLcontext;
    00055 typedef struct __GLinterfaceRec __GLinterface;
    00056
    00057 /*
    00058 ** This file defines the interface between the GL core and the surrounding
    00059 ** "operating system" that supports it (currently the GLX or WGL extensions).
    00060 **
    00061 ** Members (data and function pointers) are documented as imported or
    00062 ** exported according to how they are used by the core rendering functions.
    00063 ** Imported members are initialized by the "operating system" and used by
    00064 ** the core functions.  Exported members are initialized by the core functions
    00065 ** and used by the "operating system".
    00066 */
    00067
    00068 /*
    00069 ** Mode and limit information for a context.  This information is
    00070 ** kept around in the context so that values can be used during
    00071 ** command execution, and for returning information about the
    00072 ** context to the application.
    00073 */
    00074 typedef struct __GLcontextModesRec {
    00075     struct __GLcontextModesRec * next;
    00076
    00077     GLboolean rgbMode;
    00078     GLboolean floatMode;
    00079     GLboolean colorIndexMode;
    00080     GLuint doubleBufferMode;
    00081     GLuint stereoMode;
    00082
    00083     GLboolean haveAccumBuffer;
    00084     GLboolean haveDepthBuffer;
    00085     GLboolean haveStencilBuffer;
    00086
    00087     GLint redBits, greenBits, blueBits, alphaBits;     /* bits per comp */
    00088     GLuint redMask, greenMask, blueMask, alphaMask;
    00089     GLint rgbBits;               /* total bits for rgb */
    00090     GLint indexBits;             /* total bits for colorindex */
    00091
    00092     GLint accumRedBits, accumGreenBits, accumBlueBits, accumAlphaBits;
    00093     GLint depthBits;
    00094     GLint stencilBits;
    00095
    00096     GLint numAuxBuffers;
    00097
    00098     GLint level;
    00099
    00100     GLint pixmapMode;
    00101
    00102     /* GLX */
    00103     GLint visualID;
    00104     GLint visualType;
    00108     /* EXT_visual_rating / GLX 1.2 */
    00109     GLint visualRating;
    00110
    00111     /* EXT_visual_info / GLX 1.2 */
    00112     GLint transparentPixel;
    00113                                             /*    colors are floats scaled to ints */
    00114     GLint transparentRed, transparentGreen, transparentBlue, transparentAlpha;
    00115     GLint transparentIndex;
    00116
    00117     /* ARB_multisample / SGIS_multisample */
    00118     GLint sampleBuffers;
    00119     GLint samples;
    00120
    00121     /* SGIX_fbconfig / GLX 1.3 */
    00122     GLint drawableType;
    00123     GLint renderType;
    00124     GLint xRenderable;
    00125     GLint fbconfigID;
    00126
    00127     /* SGIX_pbuffer / GLX 1.3 */
    00128     GLint maxPbufferWidth;
    00129     GLint maxPbufferHeight;
    00130     GLint maxPbufferPixels;
    00131     GLint optimalPbufferWidth;   /* Only for SGIX_pbuffer. */
    00132     GLint optimalPbufferHeight;  /* Only for SGIX_pbuffer. */
    00133
    00134     /* SGIX_visual_select_group */
    00135     GLint visualSelectGroup;
    00136
    00137     /* OML_swap_method */
    00138     GLint swapMethod;
    00139
    00140     GLint screen;
    00141 } __GLcontextModes;
    00142
    00143 /* Several fields of __GLcontextModes can take these as values.  Since
    00144  * GLX header files may not be available everywhere they need to be used,
    00145  * redefine them here.
    00146  */
    00147 #define GLX_NONE                           0x8000
    00148 #define GLX_SLOW_CONFIG                    0x8001
    00149 #define GLX_TRUE_COLOR                     0x8002
    00150 #define GLX_DIRECT_COLOR                   0x8003
    00151 #define GLX_PSEUDO_COLOR                   0x8004
    00152 #define GLX_STATIC_COLOR                   0x8005
    00153 #define GLX_GRAY_SCALE                     0x8006
    00154 #define GLX_STATIC_GRAY                    0x8007
    00155 #define GLX_TRANSPARENT_RGB                0x8008
    00156 #define GLX_TRANSPARENT_INDEX              0x8009
    00157 #define GLX_NON_CONFORMANT_CONFIG          0x800D
    00158 #define GLX_SWAP_EXCHANGE_OML              0x8061
    00159 #define GLX_SWAP_COPY_OML                  0x8062
    00160 #define GLX_SWAP_UNDEFINED_OML             0x8063
    00161
    00162 #define GLX_DONT_CARE                      0xFFFFFFFF
    00163
    00164 #define GLX_RGBA_BIT                       0x00000001
    00165 #define GLX_COLOR_INDEX_BIT                0x00000002
    00166 #define GLX_WINDOW_BIT                     0x00000001
    00167 #define GLX_PIXMAP_BIT                     0x00000002
    00168 #define GLX_PBUFFER_BIT                    0x00000004
    00169
    00170 /************************************************************************/
    00171
    00172 /*
    00173 ** Structure used for allocating and freeing drawable private memory.
    00174 ** (like software buffers, for example).
    00175 **
    00176 ** The memory allocation routines are provided by the surrounding
    00177 ** "operating system" code, and they are to be used for allocating
    00178 ** software buffers and things which are associated with the drawable,
    00179 ** and used by any context which draws to that drawable.  There are
    00180 ** separate memory allocation functions for drawables and contexts
    00181 ** since drawables and contexts can be created and destroyed independently
    00182 ** of one another, and the "operating system" may want to use separate
    00183 ** allocation arenas for each.
    00184 **
    00185 ** The freePrivate function is filled in by the core routines when they
    00186 ** allocates software buffers, and stick them in "private".  The freePrivate
    00187 ** function will destroy anything allocated to this drawable (to be called
    00188 ** when the drawable is destroyed).
    00189 */
    00190 typedef struct __GLdrawableRegionRec __GLdrawableRegion;
    00191 typedef struct __GLdrawableBufferRec __GLdrawableBuffer;
    00192 typedef struct __GLdrawablePrivateRec __GLdrawablePrivate;
    00193
    00194 typedef struct __GLregionRectRec {
    00195     /* lower left (inside the rectangle) */
    00196     GLint x0, y0;
    00197     /* upper right (outside the rectangle) */
    00198     GLint x1, y1;
    00199 } __GLregionRect;
    00200
    00201 struct __GLdrawableRegionRec {
    00202     GLint numRects;
    00203     __GLregionRect *rects;
    00204     __GLregionRect boundingRect;
    00205 };
    00206
    00207 /************************************************************************/
    00208
    00209 /* masks for the buffers */
    00210 #define __GL_FRONT_BUFFER_MASK              0x00000001
    00211 #define    __GL_FRONT_LEFT_BUFFER_MASK      0x00000001
    00212 #define    __GL_FRONT_RIGHT_BUFFER_MASK     0x00000002
    00213 #define    __GL_BACK_BUFFER_MASK            0x00000004
    00214 #define __GL_BACK_LEFT_BUFFER_MASK          0x00000004
    00215 #define __GL_BACK_RIGHT_BUFFER_MASK         0x00000008
    00216 #define    __GL_ACCUM_BUFFER_MASK                      0x00000010
    00217 #define    __GL_DEPTH_BUFFER_MASK                      0x00000020
    00218 #define    __GL_STENCIL_BUFFER_MASK         0x00000040
    00219 #define    __GL_AUX_BUFFER_MASK(i)                     (0x0000080 << (i))
    00220
    00221 #define __GL_ALL_BUFFER_MASK                0xffffffff
    00222
    00223 /* what Resize routines return if resize resorted to fallback case */
    00224 #define __GL_BUFFER_FALLBACK     0x10
    00225
    00226 typedef void (*__GLbufFallbackInitFn)(__GLdrawableBuffer *buf,
    00227                                                   __GLdrawablePrivate *glPriv, GLint bits);
    00228 typedef void (*__GLbufMainInitFn)(__GLdrawableBuffer *buf,
    00229                                               __GLdrawablePrivate *glPriv, GLint bits,
    00230                                               __GLbufFallbackInitFn back);
    00231
    00232 /*
    00233 ** A drawable buffer
    00234 **
    00235 ** This data structure describes the context side of a drawable.
    00236 **
    00237 ** According to the spec there could be multiple contexts bound to the same
    00238 ** drawable at the same time (from different threads).  In order to avoid
    00239 ** multiple-access conflicts, locks are used to serialize access.  When a
    00240 ** thread needs to access (read or write) a member of the drawable, it takes
    00241 ** a lock first.  Some of the entries in the drawable are treated "mostly
    00242 ** constant", so we take the freedom of allowing access to them without
    00243 ** taking a lock (for optimization reasons).
    00244 **
    00245 ** For more details regarding locking, see buffers.h in the GL core
    00246 */
    00247 struct __GLdrawableBufferRec {
    00248     /*
    00249     ** Buffer dimensions
    00250     */
    00251     GLint width, height, depth;
    00252
    00253     /*
    00254     ** Framebuffer base address
    00255     */
    00256     void *base;
    00257
    00258     /*
    00259     ** Framebuffer size (in bytes)
    00260     */
    00261     GLuint size;
    00262
    00263     /*
    00264     ** Size (in bytes) of each element in the framebuffer
    00265     */
    00266     GLuint elementSize;
    00267     GLuint elementSizeLog2;
    00268
    00269     /*
    00270     ** Element skip from one scanline to the next.
    00271     ** If the buffer is part of another buffer (for example, fullscreen
    00272     ** front buffer), outerWidth is the width of that buffer.
    00273     */
    00274     GLint outerWidth;
    00275
    00276     /*
    00277     ** outerWidth * elementSize
    00278     */
    00279     GLint byteWidth;
    00280
    00281     /*
    00282     ** Allocation/deallocation is done based on this handle.  A handle
    00283     ** is conceptually different from the framebuffer 'base'.
    00284     */
    00285     void *handle;
    00286
    00287     /* imported */
    00288     GLboolean (*resize)(__GLdrawableBuffer *buf,
    00289                                  GLint x, GLint y, GLuint width, GLuint height,
    00290                                  __GLdrawablePrivate *glPriv, GLuint bufferMask);
    00291     void (*lock)(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv);
    00292     void (*unlock)(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv);
    00293     void (*fill)(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv,
    00294                       GLuint val, GLint x, GLint y, GLint w, GLint h);
    00295     void (*free)(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv);
    00296
    00297     /* exported */
    00298     void (*freePrivate)(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv);
    00299 #ifdef __cplusplus
    00300     void *privatePtr;
    00301 #else
    00302     void *private;
    00303 #endif
    00304
    00305     /* private */
    00306     void *other;      /* implementation private data */
    00307     __GLbufMainInitFn mainInit;
    00308     __GLbufFallbackInitFn fallbackInit;
    00309 };
    00310
    00311 /*
    00312 ** The context side of the drawable private
    00313 */
    00314 struct __GLdrawablePrivateRec {
    00315     /*
    00316     ** Drawable Modes
    00317     */
    00318     __GLcontextModes *modes;
    00319
    00320     /*
    00321     ** Drawable size
    00322     */
    00323     GLuint width, height;
    00324
    00325     /*
    00326     ** Origin in screen coordinates of the drawable
    00327     */
    00328     GLint xOrigin, yOrigin;
    00329 #ifdef __GL_ALIGNED_BUFFERS
    00330     /*
    00331     ** Drawable offset from screen origin
    00332     */
    00333     GLint xOffset, yOffset;
    00334
    00335     /*
    00336     ** Alignment restriction
    00337     */
    00338     GLint xAlignment, yAlignment;
    00339 #endif
    00340     /*
    00341     ** Should we invert the y axis?
    00342     */
    00343     GLint yInverted;
    00344
    00345     /*
    00346     ** Mask specifying which buffers are renderable by the hw
    00347     */
    00348     GLuint accelBufferMask;
    00349
    00350     /*
    00351     ** the buffers themselves
    00352     */
    00353     __GLdrawableBuffer frontBuffer;
    00354     __GLdrawableBuffer backBuffer;
    00355     __GLdrawableBuffer accumBuffer;
    00356     __GLdrawableBuffer depthBuffer;
    00357     __GLdrawableBuffer stencilBuffer;
    00358 #if defined(__GL_NUMBER_OF_AUX_BUFFERS) && (__GL_NUMBER_OF_AUX_BUFFERS > 0)
    00359     __GLdrawableBuffer *auxBuffer;
    00360 #endif
    00361
    00362     __GLdrawableRegion ownershipRegion;
    00363
    00364     /*
    00365     ** Lock for the drawable private structure
    00366     */
    00367     void *lock;
    00368 #ifdef DEBUG
    00369     /* lock debugging info */
    00370     int lockRefCount;
    00371     int lockLine[10];
    00372     char *lockFile[10];
    00373 #endif
    00374
    00375     /* imported */
    00376     void *(*malloc)(size_t size);
    00377     void *(*calloc)(size_t numElem, size_t elemSize);
    00378     void *(*realloc)(void *oldAddr, size_t newSize);
    00379     void (*free)(void *addr);
    00380
    00381     GLboolean (*addSwapRect)(__GLdrawablePrivate *glPriv,
    00382                                       GLint x, GLint y, GLsizei width, GLsizei height);
    00383     void (*setClipRect)(__GLdrawablePrivate *glPriv,
    00384                                  GLint x, GLint y, GLsizei width, GLsizei height);
    00385     void (*updateClipRegion)(__GLdrawablePrivate *glPriv);
    00386     GLboolean (*resize)(__GLdrawablePrivate *glPriv);
    00387     void (*getDrawableSize)(__GLdrawablePrivate *glPriv,
    00388                                      GLint *x, GLint *y, GLuint *width, GLuint *height);
    00389
    00390     void (*lockDP)(__GLdrawablePrivate *glPriv, __GLcontext *gc);
    00391     void (*unlockDP)(__GLdrawablePrivate *glPriv);
    00392
    00393     /* exported */
    00394 #ifdef __cplusplus
    00395     void *privatePtr;
    00396 #else
    00397     void *private;
    00398 #endif
    00399     void (*freePrivate)(__GLdrawablePrivate *);
    00400
    00401     /* client data */
    00402     void *other;
    00403 };
    00404
    00405 /*
    00406 ** Macros to lock/unlock the drawable private
    00407 */
    00408 #if defined(DEBUG)
    00409 #define __GL_LOCK_DP(glPriv,gc) \
    00410     (*(glPriv)->lockDP)(glPriv,gc); \
    00411     (glPriv)->lockLine[(glPriv)->lockRefCount] = __LINE__; \
    00412     (glPriv)->lockFile[(glPriv)->lockRefCount] = __FILE__; \
    00413     (glPriv)->lockRefCount++
    00414 #define __GL_UNLOCK_DP(glPriv) \
    00415     (glPriv)->lockRefCount--; \
    00416     (glPriv)->lockLine[(glPriv)->lockRefCount] = 0; \
    00417     (glPriv)->lockFile[(glPriv)->lockRefCount] = NULL; \
    00418     (*(glPriv)->unlockDP)(glPriv)
    00419 #else /* DEBUG */
    00420 #define __GL_LOCK_DP(glPriv,gc)             (*(glPriv)->lockDP)(glPriv,gc)
    00421 #define    __GL_UNLOCK_DP(glPriv)                      (*(glPriv)->unlockDP)(glPriv)
    00422 #endif /* DEBUG */
    00423
    00424
    00425 /*
    00426 ** Procedures which are imported by the GL from the surrounding
    00427 ** "operating system".  Math functions are not considered part of the
    00428 ** "operating system".
    00429 */
    00430 typedef struct __GLimportsRec {
    00431     /* Memory management */
    00432     void * (*malloc)(__GLcontext *gc, size_t size);
    00433     void *(*calloc)(__GLcontext *gc, size_t numElem, size_t elemSize);
    00434     void *(*realloc)(__GLcontext *gc, void *oldAddr, size_t newSize);
    00435     void (*free)(__GLcontext *gc, void *addr);
    00436
    00437     /* Error handling */
    00438     void (*warning)(__GLcontext *gc, char *fmt);
    00439     void (*fatal)(__GLcontext *gc, char *fmt);
    00440
    00441     /* other system calls */
    00442     char *(CAPI *getenv)(__GLcontext *gc, const char *var);
    00443     int (CAPI *atoi)(__GLcontext *gc, const char *str);
    00444     int (CAPI *sprintf)(__GLcontext *gc, char *str, const char *fmt, ...);
    00445     void *(CAPI *fopen)(__GLcontext *gc, const char *path, const char *mode);
    00446     int (CAPI *fclose)(__GLcontext *gc, void *stream);
    00447     int (CAPI *fprintf)(__GLcontext *gc, void *stream, const char *fmt, ...);
    00448
    00449     /* Drawing surface management */
    00450     __GLdrawablePrivate *(*getDrawablePrivate)(__GLcontext *gc);
    00451     __GLdrawablePrivate *(*getReadablePrivate)(__GLcontext *gc);
    00452
    00453     /* Operating system dependent data goes here */
    00454     void *other;
    00455 } __GLimports;
    00456
    00457 /************************************************************************/
    00458
    00459 /*
    00460 ** Procedures which are exported by the GL to the surrounding "operating
    00461 ** system" so that it can manage multiple GL context's.
    00462 */
    00463 typedef struct __GLexportsRec {
    00464     /* Context management (return GL_FALSE on failure) */
    00465     GLboolean (*destroyContext)(__GLcontext *gc);
    00466     GLboolean (*loseCurrent)(__GLcontext *gc);
    00467     /* oldglPriv isn't used anymore, kept for backwards compatibility */
    00468     GLboolean (*makeCurrent)(__GLcontext *gc);
    00469     GLboolean (*shareContext)(__GLcontext *gc, __GLcontext *gcShare);
    00470     GLboolean (*copyContext)(__GLcontext *dst, const __GLcontext *src, GLuint mask);
    00471     GLboolean (*forceCurrent)(__GLcontext *gc);
    00472
    00473     /* Drawing surface notification callbacks */
    00474     GLboolean (*notifyResize)(__GLcontext *gc);
    00475     void (*notifyDestroy)(__GLcontext *gc);
    00476     void (*notifySwapBuffers)(__GLcontext *gc);
    00477
    00478     /* Dispatch table override control for external agents like libGLS */
    00479     struct __GLdispatchStateRec* (*dispatchExec)(__GLcontext *gc);
    00480     void (*beginDispatchOverride)(__GLcontext *gc);
    00481     void (*endDispatchOverride)(__GLcontext *gc);
    00482 } __GLexports;
    00483
    00484 /************************************************************************/
    00485
    00486 /*
    00487 ** This must be the first member of a __GLcontext structure.  This is the
    00488 ** only part of a context that is exposed to the outside world; everything
    00489 ** else is opaque.
    00490 */
    00491 struct __GLinterfaceRec {
    00492     __GLimports imports;
    00493     __GLexports exports;
    00494 };
    00495
    00496 extern __GLcontext *__glCoreCreateContext(__GLimports *, __GLcontextModes *);
    00497 extern void __glCoreNopDispatch(void);
    00498
    00499 #endif /* __gl_core_h_ */

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines