45e9809aff7304721fddb95654901b32195c9c7avboxsync/*
45e9809aff7304721fddb95654901b32195c9c7avboxsync * Mesa 3-D graphics library
45e9809aff7304721fddb95654901b32195c9c7avboxsync * Version: 7.1
45e9809aff7304721fddb95654901b32195c9c7avboxsync *
45e9809aff7304721fddb95654901b32195c9c7avboxsync * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
45e9809aff7304721fddb95654901b32195c9c7avboxsync *
45e9809aff7304721fddb95654901b32195c9c7avboxsync * Permission is hereby granted, free of charge, to any person obtaining a
45e9809aff7304721fddb95654901b32195c9c7avboxsync * copy of this software and associated documentation files (the "Software"),
45e9809aff7304721fddb95654901b32195c9c7avboxsync * to deal in the Software without restriction, including without limitation
45e9809aff7304721fddb95654901b32195c9c7avboxsync * the rights to use, copy, modify, merge, publish, distribute, sublicense,
45e9809aff7304721fddb95654901b32195c9c7avboxsync * and/or sell copies of the Software, and to permit persons to whom the
45e9809aff7304721fddb95654901b32195c9c7avboxsync * Software is furnished to do so, subject to the following conditions:
45e9809aff7304721fddb95654901b32195c9c7avboxsync *
45e9809aff7304721fddb95654901b32195c9c7avboxsync * The above copyright notice and this permission notice shall be included
45e9809aff7304721fddb95654901b32195c9c7avboxsync * in all copies or substantial portions of the Software.
45e9809aff7304721fddb95654901b32195c9c7avboxsync *
45e9809aff7304721fddb95654901b32195c9c7avboxsync * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
45e9809aff7304721fddb95654901b32195c9c7avboxsync * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
45e9809aff7304721fddb95654901b32195c9c7avboxsync * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
45e9809aff7304721fddb95654901b32195c9c7avboxsync * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
45e9809aff7304721fddb95654901b32195c9c7avboxsync * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
45e9809aff7304721fddb95654901b32195c9c7avboxsync * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
45e9809aff7304721fddb95654901b32195c9c7avboxsync */
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync/**
45e9809aff7304721fddb95654901b32195c9c7avboxsync * \mainpage Mesa GL API Module
45e9809aff7304721fddb95654901b32195c9c7avboxsync *
45e9809aff7304721fddb95654901b32195c9c7avboxsync * \section GLAPIIntroduction Introduction
45e9809aff7304721fddb95654901b32195c9c7avboxsync *
45e9809aff7304721fddb95654901b32195c9c7avboxsync * The Mesa GL API module is responsible for dispatching all the
45e9809aff7304721fddb95654901b32195c9c7avboxsync * gl*() functions. All GL functions are dispatched by jumping through
45e9809aff7304721fddb95654901b32195c9c7avboxsync * the current dispatch table (basically a struct full of function
45e9809aff7304721fddb95654901b32195c9c7avboxsync * pointers.)
45e9809aff7304721fddb95654901b32195c9c7avboxsync *
45e9809aff7304721fddb95654901b32195c9c7avboxsync * A per-thread current dispatch table and per-thread current context
45e9809aff7304721fddb95654901b32195c9c7avboxsync * pointer are managed by this module too.
45e9809aff7304721fddb95654901b32195c9c7avboxsync *
45e9809aff7304721fddb95654901b32195c9c7avboxsync * This module is intended to be non-Mesa-specific so it can be used
45e9809aff7304721fddb95654901b32195c9c7avboxsync * with the X/DRI libGL also.
45e9809aff7304721fddb95654901b32195c9c7avboxsync */
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#ifndef _GLAPI_H
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define _GLAPI_H
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define GL_GLEXT_PROTOTYPES
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#include "GL/gl.h"
45e9809aff7304721fddb95654901b32195c9c7avboxsync#include "GL/glext.h"
45e9809aff7304721fddb95654901b32195c9c7avboxsync#include "glthread.h"
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsyncstruct _glapi_table;
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsynctypedef void (*_glapi_proc)(void); /* generic function pointer */
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsynctypedef void (*_glapi_warning_func)(void *ctx, const char *str, ...);
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#if defined(USE_MGL_NAMESPACE)
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define _glapi_set_dispatch _mglapi_set_dispatch
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define _glapi_get_dispatch _mglapi_get_dispatch
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define _glapi_set_context _mglapi_set_context
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define _glapi_get_context _mglapi_get_context
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define _glapi_Context _mglapi_Context
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define _glapi_Dispatch _mglapi_Dispatch
45e9809aff7304721fddb95654901b32195c9c7avboxsync#endif
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync/*
45e9809aff7304721fddb95654901b32195c9c7avboxsync * Number of extension functions which we can dynamically add at runtime.
45e9809aff7304721fddb95654901b32195c9c7avboxsync */
45e9809aff7304721fddb95654901b32195c9c7avboxsync#define MAX_EXTENSION_FUNCS 300
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync/**
45e9809aff7304721fddb95654901b32195c9c7avboxsync ** Define the GET_CURRENT_CONTEXT() macro.
45e9809aff7304721fddb95654901b32195c9c7avboxsync ** \param C local variable which will hold the current context.
45e9809aff7304721fddb95654901b32195c9c7avboxsync **/
45e9809aff7304721fddb95654901b32195c9c7avboxsync#if defined (GLX_USE_TLS)
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsyncconst extern void *_glapi_Context;
45e9809aff7304721fddb95654901b32195c9c7avboxsyncconst extern struct _glapi_table *_glapi_Dispatch;
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsyncextern __thread void * _glapi_tls_Context
45e9809aff7304721fddb95654901b32195c9c7avboxsync __attribute__((tls_model("initial-exec")));
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync# define GET_CURRENT_CONTEXT(C) GLcontext *C = (GLcontext *) _glapi_tls_Context
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#else
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsyncextern void *_glapi_Context;
45e9809aff7304721fddb95654901b32195c9c7avboxsyncextern struct _glapi_table *_glapi_Dispatch;
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync# ifdef THREADS
45e9809aff7304721fddb95654901b32195c9c7avboxsync# define GET_CURRENT_CONTEXT(C) GLcontext *C = (GLcontext *) (_glapi_Context ? _glapi_Context : _glapi_get_context())
45e9809aff7304721fddb95654901b32195c9c7avboxsync# else
45e9809aff7304721fddb95654901b32195c9c7avboxsync# define GET_CURRENT_CONTEXT(C) GLcontext *C = (GLcontext *) _glapi_Context
45e9809aff7304721fddb95654901b32195c9c7avboxsync# endif
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#endif /* defined (GLX_USE_TLS) */
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync/**
45e9809aff7304721fddb95654901b32195c9c7avboxsync ** GL API public functions
45e9809aff7304721fddb95654901b32195c9c7avboxsync **/
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsyncextern void
45e9809aff7304721fddb95654901b32195c9c7avboxsync_glapi_noop_enable_warnings(GLboolean enable);
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsyncextern void
45e9809aff7304721fddb95654901b32195c9c7avboxsync_glapi_set_warning_func(_glapi_warning_func func);
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsyncextern void
45e9809aff7304721fddb95654901b32195c9c7avboxsync_glapi_check_multithread(void);
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsyncextern void
45e9809aff7304721fddb95654901b32195c9c7avboxsync_glapi_set_context(void *context);
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsyncextern void *
45e9809aff7304721fddb95654901b32195c9c7avboxsync_glapi_get_context(void);
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsyncextern void
45e9809aff7304721fddb95654901b32195c9c7avboxsync_glapi_set_dispatch(struct _glapi_table *dispatch);
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsyncextern struct _glapi_table *
45e9809aff7304721fddb95654901b32195c9c7avboxsync_glapi_get_dispatch(void);
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsyncextern int
45e9809aff7304721fddb95654901b32195c9c7avboxsync_glapi_begin_dispatch_override(struct _glapi_table *override);
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsyncextern void
45e9809aff7304721fddb95654901b32195c9c7avboxsync_glapi_end_dispatch_override(int layer);
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsyncstruct _glapi_table *
45e9809aff7304721fddb95654901b32195c9c7avboxsync_glapi_get_override_dispatch(int layer);
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsyncextern GLuint
45e9809aff7304721fddb95654901b32195c9c7avboxsync_glapi_get_dispatch_table_size(void);
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsyncextern void
45e9809aff7304721fddb95654901b32195c9c7avboxsync_glapi_check_table(const struct _glapi_table *table);
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsyncextern int
45e9809aff7304721fddb95654901b32195c9c7avboxsync_glapi_add_dispatch( const char * const * function_names,
45e9809aff7304721fddb95654901b32195c9c7avboxsync const char * parameter_signature );
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsyncextern GLint
45e9809aff7304721fddb95654901b32195c9c7avboxsync_glapi_get_proc_offset(const char *funcName);
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsyncextern _glapi_proc
45e9809aff7304721fddb95654901b32195c9c7avboxsync_glapi_get_proc_address(const char *funcName);
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsyncextern const char *
45e9809aff7304721fddb95654901b32195c9c7avboxsync_glapi_get_proc_name(GLuint offset);
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync
45e9809aff7304721fddb95654901b32195c9c7avboxsync#endif