core  array_cache  math  swrast  swrast_setup  tnl  tnl_dd 
Main Page   Data Structures   File List   Data Fields   Globals   Related Pages  

context.h File Reference

Mesa context/visual/framebuffer management functions. More...

#include "glapi.h"
#include "imports.h"
#include "mtypes.h"

Macros for contexts/flushing.

#define FLUSH_VERTICES(ctx, newstate)
 Flush vertices. More...

#define FLUSH_CURRENT(ctx, newstate)
 Flush current state. More...

#define ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, retval)
 Macro to assert that the API call was made outside the glBegin()/glEnd() pair, with return value. More...

#define ASSERT_OUTSIDE_BEGIN_END(ctx)
 Macro to assert that the API call was made outside the glBegin()/glEnd() pair. More...

#define ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx)
 Macro to assert that the API call was made outside the glBegin()/glEnd() pair and flush the vertices. More...

#define ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, retval)
 Macro to assert that the API call was made outside the glBegin()/glEnd() pair and flush the vertices, with return value. More...


Create/destroy a GLvisual.

GLvisual_mesa_create_visual (GLboolean rgbFlag, GLboolean dbFlag, GLboolean stereoFlag, GLint redBits, GLint greenBits, GLint blueBits, GLint alphaBits, GLint indexBits, GLint depthBits, GLint stencilBits, GLint accumRedBits, GLint accumGreenBits, GLint accumBlueBits, GLint accumAlphaBits, GLint numSamples)
 Allocates a GLvisual structure and initializes it via _mesa_initialize_visual(). More...

GLboolean _mesa_initialize_visual (GLvisual *v, GLboolean rgbFlag, GLboolean dbFlag, GLboolean stereoFlag, GLint redBits, GLint greenBits, GLint blueBits, GLint alphaBits, GLint indexBits, GLint depthBits, GLint stencilBits, GLint accumRedBits, GLint accumGreenBits, GLint accumBlueBits, GLint accumAlphaBits, GLint numSamples)
 Makes some sanity checks and fills in the fields of the GLvisual structure with the given parameters. More...

void _mesa_destroy_visual (GLvisual *vis)
 Destroy a visual and free its memory. More...


Create/destroy a GLframebuffer.

GLframebuffer_mesa_create_framebuffer (const GLvisual *visual, GLboolean softwareDepth, GLboolean softwareStencil, GLboolean softwareAccum, GLboolean softwareAlpha)
 Allocate a GLframebuffer structure and initializes it via _mesa_initialize_framebuffer(). More...

void _mesa_initialize_framebuffer (GLframebuffer *fb, const GLvisual *visual, GLboolean softwareDepth, GLboolean softwareStencil, GLboolean softwareAccum, GLboolean softwareAlpha)
 Makes some sanity checks and fills in the fields of the GLframebuffer structure with the given parameters. More...

void _mesa_free_framebuffer_data (GLframebuffer *buffer)
 Free the data hanging off of buffer, but not buffer itself. More...

void _mesa_destroy_framebuffer (GLframebuffer *buffer)
 Free a framebuffer struct and its buffers. More...


Create/destroy a GLcontext.

GLcontext_mesa_create_context (const GLvisual *visual, GLcontext *share_list, const struct dd_function_table *driverFunctions, void *driverContext)
 Allocate and initialize a GLcontext structure. More...

GLboolean _mesa_initialize_context (GLcontext *ctx, const GLvisual *visual, GLcontext *share_list, const struct dd_function_table *driverFunctions, void *driverContext)
 Initialize a GLcontext struct (rendering context). More...

void _mesa_free_context_data (GLcontext *ctx)
 Free the data associated with the given context. More...

void _mesa_destroy_context (GLcontext *ctx)
 Destroy a GLcontext structure. More...

void _mesa_copy_context (const GLcontext *src, GLcontext *dst, GLuint mask)
 Copy attribute groups from one context to another. More...

void _mesa_make_current (GLcontext *ctx, GLframebuffer *buffer)
 Set the current context, binding the given frame buffer to the context. More...

void _mesa_make_current2 (GLcontext *ctx, GLframebuffer *drawBuffer, GLframebuffer *readBuffer)
 Bind the given context to the given draw-buffer and read-buffer and make it the current context for this thread. More...

GLcontext_mesa_get_current_context (void)
 Get current context for the calling thread. More...


OpenGL SI-style export functions.

GLboolean _mesa_destroyContext (__GLcontext *gc)
 Destroy context callback. More...

GLboolean _mesa_loseCurrent (__GLcontext *gc)
 Unbind context callback. More...

GLboolean _mesa_makeCurrent (__GLcontext *gc)
 Bind context callback. More...

GLboolean _mesa_shareContext (__GLcontext *gc, __GLcontext *gcShare)
 Share context callback. More...

GLboolean _mesa_copyContext (__GLcontext *dst, const __GLcontext *src, GLuint mask)
 Copy context callback. More...

GLboolean _mesa_forceCurrent (__GLcontext *gc)
 No-op. More...

GLboolean _mesa_notifyResize (__GLcontext *gc)
 Windows/buffer resizing notification callback. More...

void _mesa_notifyDestroy (__GLcontext *gc)
 Window/buffer destruction notification callback. More...

void _mesa_notifySwapBuffers (__GLcontext *gc)
 Swap buffers notification callback. More...

__GLdispatchStateRec * _mesa_dispatchExec (__GLcontext *gc)
 No-op. More...

void _mesa_beginDispatchOverride (__GLcontext *gc)
 No-op. More...

void _mesa_endDispatchOverride (__GLcontext *gc)
 No-op. More...


Miscellaneous

void _mesa_record_error (GLcontext *ctx, GLenum error)
 Record an error. More...

void GLAPIENTRY _mesa_Finish (void)
 Execute glFinish(). More...

void GLAPIENTRY _mesa_Flush (void)
 Execute glFlush(). More...


Defines

#define GET_CURRENT_CONTEXT(C)   GLcontext *C = (GLcontext *) _glapi_Context
 Macro for declaration and fetching the current context. More...


Functions

_glapi_table * _mesa_get_dispatch (GLcontext *ctx)
 Get context's current API dispatch table. More...


Detailed Description

Mesa context/visual/framebuffer management functions.

There are three Mesa data types which are meant to be used by device drivers:

These types should be encapsulated by corresponding device driver data types. See xmesa.h and xmesaP.h for an example.

In OOP terms, GLcontext, GLvisual, and GLframebuffer are base classes which the device driver must derive from.

The following functions create and destroy these data types.


Define Documentation

#define ASSERT_OUTSIDE_BEGIN_END ctx   
 

Value:

do {                                                                    \
   if (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) {    \
      _mesa_error( ctx, GL_INVALID_OPERATION, "begin/end" );            \
      return;                                                           \
   }                                                                    \
} while (0)
Macro to assert that the API call was made outside the glBegin()/glEnd() pair.

Parameters:
ctx  GL context.

#define ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH ctx   
 

Value:

do {                                                                    \
   ASSERT_OUTSIDE_BEGIN_END(ctx);                                       \
   FLUSH_VERTICES(ctx, 0);                                              \
} while (0)
Macro to assert that the API call was made outside the glBegin()/glEnd() pair and flush the vertices.

Parameters:
ctx  GL context.

#define ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH_WITH_RETVAL ctx,
retval   
 

Value:

do {                                                                    \
   ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, retval);                   \
   FLUSH_VERTICES(ctx, 0);                                              \
} while (0)
Macro to assert that the API call was made outside the glBegin()/glEnd() pair and flush the vertices, with return value.

Parameters:
ctx  GL context.
retval  value to return value in case the assertion fails.

#define ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL ctx,
retval   
 

Value:

do {                                                                    \
   if (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) {    \
      _mesa_error( ctx, GL_INVALID_OPERATION, "begin/end" );            \
      return retval;                                                    \
   }                                                                    \
} while (0)
Macro to assert that the API call was made outside the glBegin()/glEnd() pair, with return value.

Parameters:
ctx  GL context.
retval  value to return value in case the assertion fails.

#define FLUSH_CURRENT ctx,
newstate   
 

Value:

do {                                                            \
   if (MESA_VERBOSE & VERBOSE_STATE)                            \
      _mesa_debug(ctx, "FLUSH_CURRENT in %s\n", MESA_FUNCTION); \
   if (ctx->Driver.NeedFlush & FLUSH_UPDATE_CURRENT)            \
      ctx->Driver.FlushVertices(ctx, FLUSH_UPDATE_CURRENT);     \
   ctx->NewState |= newstate;                                   \
} while (0)
Flush current state.

Parameters:
ctx  GL context.
newstate  new state.
Checks if dd_function_table::NeedFlush is marked to flush current state, and calls dd_function_table::FlushVertices if so. Marks __GLcontextRec::NewState with newstate.

#define FLUSH_VERTICES ctx,
newstate   
 

Value:

do {                                                            \
   if (MESA_VERBOSE & VERBOSE_STATE)                            \
      _mesa_debug(ctx, "FLUSH_VERTICES in %s\n", MESA_FUNCTION);\
   if (ctx->Driver.NeedFlush & FLUSH_STORED_VERTICES)           \
      ctx->Driver.FlushVertices(ctx, FLUSH_STORED_VERTICES);    \
   ctx->NewState |= newstate;                                   \
} while (0)
Flush vertices.

Parameters:
ctx  GL context.
newstate  new state.
Checks if dd_function_table::NeedFlush is marked to flush stored vertices, and calls dd_function_table::FlushVertices if so. Marks __GLcontextRec::NewState with newstate.

#define GET_CURRENT_CONTEXT      GLcontext *C = (GLcontext *) _glapi_Context
 

Macro for declaration and fetching the current context.

Parameters:
C  local variable which will hold the current context.
It should be used in the variable declaration area of a function:
 ...
 {
   GET_CURRENT_CONTEXT(ctx);
   ...

#define NEED_SECONDARY_COLOR CTX   
 

Value:

(((CTX)->Light.Enabled &&                                               \
     (CTX)->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR)     \
    || (CTX)->Fog.ColorSumEnabled                                       \
    || ((CTX)->VertexProgram._Enabled &&                                \
        ((CTX)->VertexProgram.Current->InputsRead & VERT_BIT_COLOR1))   \
    || ((CTX)->FragmentProgram._Enabled &&                              \
        ((CTX)->FragmentProgram.Current->InputsRead & FRAG_BIT_COL1))   \
   )
Is the secondary color needed?

#define NEED_TWO_SIDED_LIGHTING CTX       (ctx->Light.Enabled && ctx->Light.Model.TwoSide)
 

Is two-sided lighting in effect?


Function Documentation

void _mesa_beginDispatchOverride __GLcontext *    gc
 

No-op.

void _mesa_copy_context const GLcontext   src,
GLcontext   dst,
GLuint    mask
 

Copy attribute groups from one context to another.

Parameters:
src  source context
dst  destination context
mask  bitwise OR of GL_*_BIT flags
According to the bits specified in mask, copies the corresponding attributes from src into \dst. For many of the attributes a simple memcpy is not enough due to the existence of internal pointers in their data structures.

GLboolean _mesa_copyContext __GLcontext *    dst,
const __GLcontext *    src,
GLuint    mask
 

Copy context callback.

GLcontext* _mesa_create_context const GLvisual   visual,
GLcontext   share_list,
const struct dd_function_table   driverFunctions,
void   driverContext
 

Allocate and initialize a GLcontext structure.

Note that the driver needs to pass in its dd_function_table here since we need to at least call driverFunctions->NewTextureObject to initialize the rendering context.

Parameters:
visual  a GLvisual pointer (we copy the struct contents)
share_list  another context to share display lists with or NULL
driverFunctions  points to the dd_function_table into which the driver has plugged in all its special functions.
driverCtx  points to the device driver's private context state
Returns:
pointer to a new __GLcontextRec or NULL if error.

GLframebuffer* _mesa_create_framebuffer const GLvisual   visual,
GLboolean    softwareDepth,
GLboolean    softwareStencil,
GLboolean    softwareAccum,
GLboolean    softwareAlpha
 

Allocate a GLframebuffer structure and initializes it via _mesa_initialize_framebuffer().

A GLframebuffer is a structure which encapsulates the depth, stencil and accum buffers and related parameters.

Parameters:
visual  a GLvisual pointer (we copy the struct contents)
softwareDepth  create/use a software depth buffer?
softwareStencil  create/use a software stencil buffer?
softwareAccum  create/use a software accum buffer?
softwareAlpha  create/use a software alpha buffer?
Returns:
pointer to new GLframebuffer struct or NULL if error.
Note:
Need to add softwareAuxBuffers parameter.

GLvisual* _mesa_create_visual GLboolean    rgbFlag,
GLboolean    dbFlag,
GLboolean    stereoFlag,
GLint    redBits,
GLint    greenBits,
GLint    blueBits,
GLint    alphaBits,
GLint    indexBits,
GLint    depthBits,
GLint    stencilBits,
GLint    accumRedBits,
GLint    accumGreenBits,
GLint    accumBlueBits,
GLint    accumAlphaBits,
GLint    numSamples
 

Allocates a GLvisual structure and initializes it via _mesa_initialize_visual().

Parameters:
rgbFlag  GL_TRUE for RGB(A) mode, GL_FALSE for Color Index mode.
dbFlag  double buffering
stereoFlag  stereo buffer
depthBits  requested bits per depth buffer value. Any value in [0, 32] is acceptable but the actual depth type will be GLushort or GLuint as needed.
stencilBits  requested minimum bits per stencil buffer value
accumRedBits, accumGreenBits, accumBlueBits, accumAlphaBits  number of bits per color component in accum buffer.
indexBits  number of bits per pixel if rgbFlag is GL_FALSE
redBits  number of bits per color component in frame buffer for RGB(A) mode. We always use 8 in core Mesa though.
greenBits  same as above.
blueBits  same as above.
alphaBits  same as above.
numSamples  not really used.
Returns:
pointer to new GLvisual or NULL if requested parameters can't be met.
Note:
Need to add params for level and numAuxBuffers (at least)

void _mesa_destroy_context GLcontext   ctx
 

Destroy a GLcontext structure.

Parameters:
ctx  GL context.
Calls _mesa_free_context_data() and frees the GLcontext structure itself.

void _mesa_destroy_framebuffer GLframebuffer   buffer
 

Free a framebuffer struct and its buffers.

Calls _mesa_free_framebuffer_data() and frees the structure.

void _mesa_destroy_visual GLvisual   vis
 

Destroy a visual and free its memory.

Parameters:
vis  visual.
Frees the visual structure.

GLboolean _mesa_destroyContext __GLcontext *    gc
 

Destroy context callback.

Parameters:
gc  context.
Returns:
GL_TRUE on success, or GL_FALSE on failure.
Called by window system/device driver (via __GLexports::destroyCurrent) when the rendering context is to be destroyed.

Frees the context data and the context structure.

struct __GLdispatchStateRec* _mesa_dispatchExec __GLcontext *    gc
 

No-op.

void _mesa_endDispatchOverride __GLcontext *    gc
 

No-op.

void GLAPIENTRY _mesa_Finish void   
 

Execute glFinish().

Calls the ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH macro and the dd_function_table::Finish driver callback, if not NULL.

void GLAPIENTRY _mesa_Flush void   
 

Execute glFlush().

Calls the ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH macro and the dd_function_table::Flush driver callback, if not NULL.

GLboolean _mesa_forceCurrent __GLcontext *    gc
 

No-op.

void _mesa_free_context_data GLcontext   ctx
 

Free the data associated with the given context.

But doesn't free the GLcontext struct itself.

See also:
_mesa_initialize_context() and init_attrib_groups().

void _mesa_free_framebuffer_data GLframebuffer   buffer
 

Free the data hanging off of buffer, but not buffer itself.

Parameters:
buffer  framebuffer.
Frees all the buffers associated with the structure.

GLcontext* _mesa_get_current_context void   
 

Get current context for the calling thread.

Returns:
pointer to the current GL context.
Calls _glapi_get_context(). This isn't the fastest way to get the current context. If you need speed, see the GET_CURRENT_CONTEXT macro in context.h.

struct _glapi_table* _mesa_get_dispatch GLcontext   ctx
 

Get context's current API dispatch table.

It'll either be the immediate-mode execute dispatcher or the display list compile dispatcher.

Parameters:
ctx  GL context.
Returns:
pointer to dispatch_table.
Simply returns __GLcontextRec::CurrentDispatch.

GLboolean _mesa_initialize_context GLcontext   ctx,
const GLvisual   visual,
GLcontext   share_list,
const struct dd_function_table   driverFunctions,
void   driverContext
 

Initialize a GLcontext struct (rendering context).

This includes allocating all the other structs and arrays which hang off of the context by pointers. Note that the driver needs to pass in its dd_function_table here since we need to at least call driverFunctions->NewTextureObject to create the default texture objects.

Called by _mesa_create_context().

Performs the imports and exports callback tables initialization, and miscellaneous one-time initializations. If no shared context is supplied one is allocated, and increase its reference count. Setups the GL API dispatch tables. Initialize the TNL module. Sets the maximum Z buffer depth. Finally queries the MESA_DEBUG and MESA_VERBOSE environment variables for debug flags.

Parameters:
ctx  the context to initialize
visual  describes the visual attributes for this context
share_list  points to context to share textures, display lists, etc with, or NULL
driverFunctions  table of device driver functions for this context to use
driverContext  pointer to driver-specific context data

void _mesa_initialize_framebuffer GLframebuffer   fb,
const GLvisual   visual,
GLboolean    softwareDepth,
GLboolean    softwareStencil,
GLboolean    softwareAccum,
GLboolean    softwareAlpha
 

Makes some sanity checks and fills in the fields of the GLframebuffer structure with the given parameters.

See also:
_mesa_create_framebuffer() above for the parameter description.

GLboolean _mesa_initialize_visual GLvisual   v,
GLboolean    rgbFlag,
GLboolean    dbFlag,
GLboolean    stereoFlag,
GLint    redBits,
GLint    greenBits,
GLint    blueBits,
GLint    alphaBits,
GLint    indexBits,
GLint    depthBits,
GLint    stencilBits,
GLint    accumRedBits,
GLint    accumGreenBits,
GLint    accumBlueBits,
GLint    accumAlphaBits,
GLint    numSamples
 

Makes some sanity checks and fills in the fields of the GLvisual structure with the given parameters.

Returns:
GL_TRUE on success, or GL_FALSE on failure.
See also:
_mesa_create_visual() above for the parameter description.
Note:
Need to add params for level and numAuxBuffers (at least)

GLboolean _mesa_loseCurrent __GLcontext *    gc
 

Unbind context callback.

Parameters:
gc  context.
Returns:
GL_TRUE on success, or GL_FALSE on failure.
Called by window system/device driver (via __GLexports::loseCurrent) when the rendering context is made non-current.

No-op

void _mesa_make_current GLcontext   ctx,
GLframebuffer   buffer
 

Set the current context, binding the given frame buffer to the context.

Parameters:
newCtx  new GL context.
buffer  framebuffer.
Calls _mesa_make_current2() with buffer as read and write framebuffer.

void _mesa_make_current2 GLcontext   ctx,
GLframebuffer   drawBuffer,
GLframebuffer   readBuffer
 

Bind the given context to the given draw-buffer and read-buffer and make it the current context for this thread.

Parameters:
newCtx  new GL context. If NULL then there will be no current GL context.
drawBuffer  draw framebuffer.
readBuffer  read framebuffer.
Check that the context's and framebuffer's visuals are compatible, returning immediately otherwise. Sets the glapi current context via _glapi_set_context(). If newCtx is not NULL, associates drawBuffer and readBuffer with it and calls dd_function_table::ResizeBuffers if the buffers size has changed. Calls dd_function_table::MakeCurrent callback if defined.

When a context is bound by the first time and the MESA_INFO environment variable is set it calls print_info() as an aid for remote user troubleshooting.

GLboolean _mesa_makeCurrent __GLcontext *    gc
 

Bind context callback.

Parameters:
gc  context.
Returns:
GL_TRUE on success, or GL_FALSE on failure.
Called by window system/device driver (via __GLexports::makeCurrent) when the rendering context is made current.

No-op

void _mesa_notifyDestroy __GLcontext *    gc
 

Window/buffer destruction notification callback.

Parameters:
gc  GL context.
Called when the context's window/buffer is going to be destroyed.

No-op

GLboolean _mesa_notifyResize __GLcontext *    gc
 

Windows/buffer resizing notification callback.

Parameters:
gc  GL context.
Returns:
GL_TRUE on success, or GL_FALSE on failure.

void _mesa_notifySwapBuffers __GLcontext *    gc
 

Swap buffers notification callback.

Parameters:
gc  GL context.
Called by window system just before swapping buffers. We have to finish any pending rendering.

void _mesa_record_error GLcontext   ctx,
GLenum    error
 

Record an error.

Parameters:
ctx  GL context.
error  error code.
Records the given error code and call the driver's dd_function_table::Error function if defined.

See also:
This is called via _mesa_error().

GLboolean _mesa_shareContext __GLcontext *    gc,
__GLcontext *    gcShare
 

Share context callback.

Parameters:
gc  context.
gcShare  shared context.
Returns:
GL_TRUE on success, or GL_FALSE on failure.
Called by window system/device driver (via __GLexports::shareContext)

Update the shared context reference count, gl_shared_state::RefCount.


Generated on Sun May 16 15:55:11 2004 for Mesa Core by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001