glapi.h revision af69d88d
13464ebd5Sriastradh/* 23464ebd5Sriastradh * Mesa 3-D graphics library 33464ebd5Sriastradh * 43464ebd5Sriastradh * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. 53464ebd5Sriastradh * 63464ebd5Sriastradh * Permission is hereby granted, free of charge, to any person obtaining a 73464ebd5Sriastradh * copy of this software and associated documentation files (the "Software"), 83464ebd5Sriastradh * to deal in the Software without restriction, including without limitation 93464ebd5Sriastradh * the rights to use, copy, modify, merge, publish, distribute, sublicense, 103464ebd5Sriastradh * and/or sell copies of the Software, and to permit persons to whom the 113464ebd5Sriastradh * Software is furnished to do so, subject to the following conditions: 123464ebd5Sriastradh * 133464ebd5Sriastradh * The above copyright notice and this permission notice shall be included 143464ebd5Sriastradh * in all copies or substantial portions of the Software. 153464ebd5Sriastradh * 163464ebd5Sriastradh * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 173464ebd5Sriastradh * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 183464ebd5Sriastradh * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19af69d88dSmrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20af69d88dSmrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21af69d88dSmrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22af69d88dSmrg * OTHER DEALINGS IN THE SOFTWARE. 233464ebd5Sriastradh */ 243464ebd5Sriastradh 253464ebd5Sriastradh 263464ebd5Sriastradh/** 273464ebd5Sriastradh * \mainpage Mesa GL API Module 283464ebd5Sriastradh * 293464ebd5Sriastradh * \section GLAPIIntroduction Introduction 303464ebd5Sriastradh * 313464ebd5Sriastradh * The Mesa GL API module is responsible for dispatching all the 323464ebd5Sriastradh * gl*() functions. All GL functions are dispatched by jumping through 333464ebd5Sriastradh * the current dispatch table (basically a struct full of function 343464ebd5Sriastradh * pointers.) 353464ebd5Sriastradh * 363464ebd5Sriastradh * A per-thread current dispatch table and per-thread current context 373464ebd5Sriastradh * pointer are managed by this module too. 383464ebd5Sriastradh * 393464ebd5Sriastradh * This module is intended to be non-Mesa-specific so it can be used 403464ebd5Sriastradh * with the X/DRI libGL also. 413464ebd5Sriastradh */ 423464ebd5Sriastradh 433464ebd5Sriastradh 443464ebd5Sriastradh#ifndef _GLAPI_H 453464ebd5Sriastradh#define _GLAPI_H 463464ebd5Sriastradh 47af69d88dSmrg#include "u_thread.h" 48af69d88dSmrg 49af69d88dSmrg 50af69d88dSmrg#ifdef __cplusplus 51af69d88dSmrgextern "C" { 52af69d88dSmrg#endif 53af69d88dSmrg 543464ebd5Sriastradh 553464ebd5Sriastradh#ifdef _GLAPI_NO_EXPORTS 563464ebd5Sriastradh# define _GLAPI_EXPORT 573464ebd5Sriastradh#else /* _GLAPI_NO_EXPORTS */ 583464ebd5Sriastradh# ifdef _WIN32 593464ebd5Sriastradh# ifdef _GLAPI_DLL_EXPORTS 603464ebd5Sriastradh# define _GLAPI_EXPORT __declspec(dllexport) 613464ebd5Sriastradh# else 623464ebd5Sriastradh# define _GLAPI_EXPORT __declspec(dllimport) 633464ebd5Sriastradh# endif 643464ebd5Sriastradh# elif defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) 653464ebd5Sriastradh# define _GLAPI_EXPORT __attribute__((visibility("default"))) 663464ebd5Sriastradh# else 673464ebd5Sriastradh# define _GLAPI_EXPORT 683464ebd5Sriastradh# endif 693464ebd5Sriastradh#endif /* _GLAPI_NO_EXPORTS */ 703464ebd5Sriastradh 713464ebd5Sriastradh 723464ebd5Sriastradh/* Is this needed? It is incomplete anyway. */ 733464ebd5Sriastradh#ifdef USE_MGL_NAMESPACE 743464ebd5Sriastradh#define _glapi_set_dispatch _mglapi_set_dispatch 753464ebd5Sriastradh#define _glapi_get_dispatch _mglapi_get_dispatch 763464ebd5Sriastradh#define _glapi_set_context _mglapi_set_context 773464ebd5Sriastradh#define _glapi_get_context _mglapi_get_context 783464ebd5Sriastradh#define _glapi_Dispatch _mglapi_Dispatch 793464ebd5Sriastradh#define _glapi_Context _mglapi_Context 803464ebd5Sriastradh#endif 813464ebd5Sriastradh 823464ebd5Sriastradhtypedef void (*_glapi_proc)(void); 833464ebd5Sriastradhstruct _glapi_table; 843464ebd5Sriastradh 853464ebd5Sriastradh 863464ebd5Sriastradh#if defined (GLX_USE_TLS) 873464ebd5Sriastradh 883464ebd5Sriastradh_GLAPI_EXPORT extern __thread struct _glapi_table * _glapi_tls_Dispatch 893464ebd5Sriastradh __attribute__((tls_model("initial-exec"))); 903464ebd5Sriastradh 913464ebd5Sriastradh_GLAPI_EXPORT extern __thread void * _glapi_tls_Context 923464ebd5Sriastradh __attribute__((tls_model("initial-exec"))); 933464ebd5Sriastradh 943464ebd5Sriastradh_GLAPI_EXPORT extern const struct _glapi_table *_glapi_Dispatch; 953464ebd5Sriastradh_GLAPI_EXPORT extern const void *_glapi_Context; 963464ebd5Sriastradh 973464ebd5Sriastradh# define GET_DISPATCH() _glapi_tls_Dispatch 983464ebd5Sriastradh# define GET_CURRENT_CONTEXT(C) struct gl_context *C = (struct gl_context *) _glapi_tls_Context 993464ebd5Sriastradh 1003464ebd5Sriastradh#else 1013464ebd5Sriastradh 1023464ebd5Sriastradh_GLAPI_EXPORT extern struct _glapi_table *_glapi_Dispatch; 1033464ebd5Sriastradh_GLAPI_EXPORT extern void *_glapi_Context; 1043464ebd5Sriastradh 1053464ebd5Sriastradh# ifdef THREADS 1063464ebd5Sriastradh 1073464ebd5Sriastradh# define GET_DISPATCH() \ 1083464ebd5Sriastradh (likely(_glapi_Dispatch) ? _glapi_Dispatch : _glapi_get_dispatch()) 1093464ebd5Sriastradh 1103464ebd5Sriastradh# define GET_CURRENT_CONTEXT(C) struct gl_context *C = (struct gl_context *) \ 1113464ebd5Sriastradh (likely(_glapi_Context) ? _glapi_Context : _glapi_get_context()) 1123464ebd5Sriastradh 1133464ebd5Sriastradh# else 1143464ebd5Sriastradh 1153464ebd5Sriastradh# define GET_DISPATCH() _glapi_Dispatch 1163464ebd5Sriastradh# define GET_CURRENT_CONTEXT(C) struct gl_context *C = (struct gl_context *) _glapi_Context 1173464ebd5Sriastradh 1183464ebd5Sriastradh# endif 1193464ebd5Sriastradh 1203464ebd5Sriastradh#endif /* defined (GLX_USE_TLS) */ 1213464ebd5Sriastradh 1223464ebd5Sriastradh 1233464ebd5Sriastradhvoid 1243464ebd5Sriastradh_glapi_destroy_multithread(void); 1253464ebd5Sriastradh 1263464ebd5Sriastradh 1273464ebd5Sriastradh_GLAPI_EXPORT void 1283464ebd5Sriastradh_glapi_check_multithread(void); 1293464ebd5Sriastradh 1303464ebd5Sriastradh 1313464ebd5Sriastradh_GLAPI_EXPORT void 1323464ebd5Sriastradh_glapi_set_context(void *context); 1333464ebd5Sriastradh 1343464ebd5Sriastradh 1353464ebd5Sriastradh_GLAPI_EXPORT void * 1363464ebd5Sriastradh_glapi_get_context(void); 1373464ebd5Sriastradh 1383464ebd5Sriastradh 1393464ebd5Sriastradh_GLAPI_EXPORT void 1403464ebd5Sriastradh_glapi_set_dispatch(struct _glapi_table *dispatch); 1413464ebd5Sriastradh 1423464ebd5Sriastradh 1433464ebd5Sriastradh_GLAPI_EXPORT struct _glapi_table * 1443464ebd5Sriastradh_glapi_get_dispatch(void); 1453464ebd5Sriastradh 1463464ebd5Sriastradh 1473464ebd5Sriastradh_GLAPI_EXPORT unsigned int 1483464ebd5Sriastradh_glapi_get_dispatch_table_size(void); 1493464ebd5Sriastradh 1503464ebd5Sriastradh 1513464ebd5Sriastradh_GLAPI_EXPORT int 1523464ebd5Sriastradh_glapi_add_dispatch( const char * const * function_names, 1533464ebd5Sriastradh const char * parameter_signature ); 1543464ebd5Sriastradh 1553464ebd5Sriastradh_GLAPI_EXPORT int 1563464ebd5Sriastradh_glapi_get_proc_offset(const char *funcName); 1573464ebd5Sriastradh 1583464ebd5Sriastradh 1593464ebd5Sriastradh_GLAPI_EXPORT _glapi_proc 1603464ebd5Sriastradh_glapi_get_proc_address(const char *funcName); 1613464ebd5Sriastradh 1623464ebd5Sriastradh 1633464ebd5Sriastradh_GLAPI_EXPORT const char * 1643464ebd5Sriastradh_glapi_get_proc_name(unsigned int offset); 1653464ebd5Sriastradh 1663464ebd5Sriastradh 1673464ebd5Sriastradh_GLAPI_EXPORT struct _glapi_table * 1683464ebd5Sriastradh_glapi_create_table_from_handle(void *handle, const char *symbol_prefix); 1693464ebd5Sriastradh 1703464ebd5Sriastradh 171af69d88dSmrg/** Deprecated function */ 1723464ebd5Sriastradh_GLAPI_EXPORT unsigned long 1733464ebd5Sriastradh_glthread_GetID(void); 1743464ebd5Sriastradh 1753464ebd5Sriastradh 1763464ebd5Sriastradh/* 1773464ebd5Sriastradh * These stubs are kept so that the old DRI drivers still load. 1783464ebd5Sriastradh */ 1793464ebd5Sriastradh_GLAPI_EXPORT void 1803464ebd5Sriastradh_glapi_noop_enable_warnings(unsigned char enable); 1813464ebd5Sriastradh 1823464ebd5Sriastradh 1833464ebd5Sriastradh_GLAPI_EXPORT void 1843464ebd5Sriastradh_glapi_set_warning_func(_glapi_proc func); 1853464ebd5Sriastradh 1863464ebd5Sriastradh 187af69d88dSmrg#ifdef __cplusplus 188af69d88dSmrg} 189af69d88dSmrg#endif 190af69d88dSmrg 1913464ebd5Sriastradh#endif /* _GLAPI_H */ 192