1706f2543Smrg/* 2706f2543Smrg * Mesa 3-D graphics library 3706f2543Smrg * Version: 7.1 4706f2543Smrg * 5706f2543Smrg * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. 6706f2543Smrg * 7706f2543Smrg * Permission is hereby granted, free of charge, to any person obtaining a 8706f2543Smrg * copy of this software and associated documentation files (the "Software"), 9706f2543Smrg * to deal in the Software without restriction, including without limitation 10706f2543Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11706f2543Smrg * and/or sell copies of the Software, and to permit persons to whom the 12706f2543Smrg * Software is furnished to do so, subject to the following conditions: 13706f2543Smrg * 14706f2543Smrg * The above copyright notice and this permission notice shall be included 15706f2543Smrg * in all copies or substantial portions of the Software. 16706f2543Smrg * 17706f2543Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18706f2543Smrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19706f2543Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20706f2543Smrg * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 21706f2543Smrg * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22706f2543Smrg * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23706f2543Smrg */ 24706f2543Smrg 25706f2543Smrg 26706f2543Smrg/** 27706f2543Smrg * \mainpage Mesa GL API Module 28706f2543Smrg * 29706f2543Smrg * \section GLAPIIntroduction Introduction 30706f2543Smrg * 31706f2543Smrg * The Mesa GL API module is responsible for dispatching all the 32706f2543Smrg * gl*() functions. All GL functions are dispatched by jumping through 33706f2543Smrg * the current dispatch table (basically a struct full of function 34706f2543Smrg * pointers.) 35706f2543Smrg * 36706f2543Smrg * A per-thread current dispatch table and per-thread current context 37706f2543Smrg * pointer are managed by this module too. 38706f2543Smrg * 39706f2543Smrg * This module is intended to be non-Mesa-specific so it can be used 40706f2543Smrg * with the X/DRI libGL also. 41706f2543Smrg */ 42706f2543Smrg 43706f2543Smrg 44706f2543Smrg#ifndef _GLAPI_H 45706f2543Smrg#define _GLAPI_H 46706f2543Smrg 47706f2543Smrg#define GL_GLEXT_PROTOTYPES 48706f2543Smrg 49706f2543Smrg#include "GL/gl.h" 50706f2543Smrg#include "GL/glext.h" 51706f2543Smrg#include "glthread.h" 52706f2543Smrg 53706f2543Smrg 54706f2543Smrgstruct _glapi_table; 55706f2543Smrg 56706f2543Smrgtypedef void (*_glapi_proc)(void); /* generic function pointer */ 57706f2543Smrg 58706f2543Smrgtypedef void (*_glapi_warning_func)(void *ctx, const char *str, ...); 59706f2543Smrg 60706f2543Smrg 61706f2543Smrg#if defined(USE_MGL_NAMESPACE) 62706f2543Smrg#define _glapi_set_dispatch _mglapi_set_dispatch 63706f2543Smrg#define _glapi_get_dispatch _mglapi_get_dispatch 64706f2543Smrg#define _glapi_set_context _mglapi_set_context 65706f2543Smrg#define _glapi_get_context _mglapi_get_context 66706f2543Smrg#define _glapi_Context _mglapi_Context 67706f2543Smrg#define _glapi_Dispatch _mglapi_Dispatch 68706f2543Smrg#endif 69706f2543Smrg 70706f2543Smrg 71706f2543Smrg/* 72706f2543Smrg * Number of extension functions which we can dynamically add at runtime. 73706f2543Smrg */ 74706f2543Smrg#define MAX_EXTENSION_FUNCS 300 75706f2543Smrg 76706f2543Smrg 77706f2543Smrg/** 78706f2543Smrg ** Define the GET_CURRENT_CONTEXT() macro. 79706f2543Smrg ** \param C local variable which will hold the current context. 80706f2543Smrg **/ 81706f2543Smrg#if defined (GLX_USE_TLS) 82706f2543Smrg 83706f2543Smrgconst extern void *_glapi_Context; 84706f2543Smrgconst extern struct _glapi_table *_glapi_Dispatch; 85706f2543Smrg 86706f2543Smrgextern TLS void * _glapi_tls_Context 87706f2543Smrg __attribute__((tls_model("initial-exec"))); 88706f2543Smrg 89706f2543Smrg# define GET_CURRENT_CONTEXT(C) GLcontext *C = (GLcontext *) _glapi_tls_Context 90706f2543Smrg 91706f2543Smrg#else 92706f2543Smrg 93706f2543Smrgextern void *_glapi_Context; 94706f2543Smrgextern struct _glapi_table *_glapi_Dispatch; 95706f2543Smrg 96706f2543Smrg# ifdef THREADS 97706f2543Smrg# define GET_CURRENT_CONTEXT(C) GLcontext *C = (GLcontext *) (_glapi_Context ? _glapi_Context : _glapi_get_context()) 98706f2543Smrg# else 99706f2543Smrg# define GET_CURRENT_CONTEXT(C) GLcontext *C = (GLcontext *) _glapi_Context 100706f2543Smrg# endif 101706f2543Smrg 102706f2543Smrg#endif /* defined (GLX_USE_TLS) */ 103706f2543Smrg 104706f2543Smrg 105706f2543Smrg/** 106706f2543Smrg ** GL API public functions 107706f2543Smrg **/ 108706f2543Smrg 109706f2543Smrgextern void 110706f2543Smrg_glapi_check_multithread(void); 111706f2543Smrg 112706f2543Smrgextern void 113706f2543Smrg_glapi_set_context(void *context); 114706f2543Smrg 115706f2543Smrgextern void * 116706f2543Smrg_glapi_get_context(void); 117706f2543Smrg 118706f2543Smrgextern void 119706f2543Smrg_glapi_set_dispatch(struct _glapi_table *dispatch); 120706f2543Smrg 121706f2543Smrgextern struct _glapi_table * 122706f2543Smrg_glapi_get_dispatch(void); 123706f2543Smrg 124706f2543Smrgextern int 125706f2543Smrg_glapi_begin_dispatch_override(struct _glapi_table *override); 126706f2543Smrg 127706f2543Smrgextern void 128706f2543Smrg_glapi_end_dispatch_override(int layer); 129706f2543Smrg 130706f2543Smrgstruct _glapi_table * 131706f2543Smrg_glapi_get_override_dispatch(int layer); 132706f2543Smrg 133706f2543Smrgextern GLuint 134706f2543Smrg_glapi_get_dispatch_table_size(void); 135706f2543Smrg 136706f2543Smrgextern int 137706f2543Smrg_glapi_add_dispatch( const char * const * function_names, 138706f2543Smrg const char * parameter_signature ); 139706f2543Smrg 140706f2543Smrgextern _glapi_proc 141706f2543Smrg_glapi_get_proc_address(const char *funcName); 142706f2543Smrg 143706f2543Smrgextern struct _glapi_table * 144706f2543Smrg_glapi_create_table_from_handle(void *handle, const char *symbol_prefix); 145706f2543Smrg 146706f2543Smrg#endif 147