This was originally in glapi.c but refactored out.
#include <stdlib.h>
#include <string.h>
#include "main/glheader.h"
#include "main/compiler.h"
#include "glapi.h"
#include "glapioffsets.h"
#include "glapitable.h"
#include "glprocs.h"
Data Structures | |
struct | _glapi_function |
Track information about a function added to the GL API. More... | |
Defines | |
#define | NEED_FUNCTION_POINTER |
Functions | |
static void | fill_in_entrypoint_offset (_glapi_proc entrypoint, GLuint offset) |
This function inserts a new dispatch offset into the assembly language stub that was generated with the preceeding function. | |
static char * | str_dup (const char *str) |
strdup() is actually not a standard ANSI C or POSIX routine. | |
static const glprocs_table_t * | find_entry (const char *n) |
Search the table of static entrypoint functions for the named function and return the corresponding glprocs_table_t entry. | |
static GLint | get_static_proc_offset (const char *funcName) |
Return dispatch table offset of the named static (built-in) function. | |
static _glapi_proc | get_static_proc_address (const char *funcName) |
Return dispatch function address for the named static (built-in) function. | |
static const char * | get_static_proc_name (GLuint offset) |
Return the name of the function at the given offset in the dispatch table. | |
static _glapi_proc | generate_entrypoint (GLuint functionOffset) |
Generate a dispatch function (entrypoint) which jumps through the given slot number (offset) in the current dispatch table. | |
static struct _glapi_function * | add_function_name (const char *funcName) |
Generate new entrypoint. | |
PUBLIC int | _glapi_add_dispatch (const char *const *function_names, const char *parameter_signature) |
Fill-in the dispatch stub for the named function. | |
PUBLIC GLint | _glapi_get_proc_offset (const char *funcName) |
Return offset of entrypoint for named function within dispatch table. | |
_glapi_proc | _glapi_get_proc_address (const char *funcName) |
Return pointer to the named function. | |
const char * | _glapi_get_proc_name (GLuint offset) |
Return the name of the function at the given dispatch offset. | |
Variables | |
static struct _glapi_function | ExtEntryTable [MAX_EXTENSION_FUNCS] |
static GLuint | NumExtEntryPoints = 0 |
#define NEED_FUNCTION_POINTER |
PUBLIC int _glapi_add_dispatch | ( | const char *const * | function_names, | |
const char * | parameter_signature | |||
) |
Fill-in the dispatch stub for the named function.
This function is intended to be called by a hardware driver. When called, a dispatch stub may be created created for the function. A pointer to this dispatch function will be returned by glXGetProcAddress.
function_names | Array of pointers to function names that should share a common dispatch offset. | |
parameter_signature | String representing the types of the parameters passed to the named function. Parameter types are converted to characters using the following rules:
|
dispatch_table
[offset
]. Return -1 if error/problem.glPointParameterfSGIS
, glPointParameterfEXT
, glPointParameterfARB
, and glPointParameterf
), so this should not be too painful of a limitation.parameter_signature
should be allowed to be NULL
. It doesn't seem like much of a hardship for drivers to have to pass in an empty string.parameter_signature
with the parameter signature of a static function. In order to do that, we need to find a way to get the parameter signature of a static function. _glapi_proc _glapi_get_proc_address | ( | const char * | funcName | ) |
Return pointer to the named function.
If the function name isn't found in the name of static functions, try generating a new API entrypoint on the fly with assembly language.
const char* _glapi_get_proc_name | ( | GLuint | offset | ) |
Return the name of the function at the given dispatch offset.
This is only intended for debugging.
PUBLIC GLint _glapi_get_proc_offset | ( | const char * | funcName | ) |
Return offset of entrypoint for named function within dispatch table.
static struct _glapi_function* add_function_name | ( | const char * | funcName | ) | [static, read] |
Generate new entrypoint.
Use a temporary dispatch offset of ~0 (i.e. -1). Later, when the driver calls _glapi_add_dispatch
we'll put in the proper offset. If that never happens, and the user calls this function, he'll segfault. That's what you get when you try calling a GL function that doesn't really exist.
funcName | Name of the function to create an entry-point for. |
static void fill_in_entrypoint_offset | ( | _glapi_proc | entrypoint, | |
GLuint | offset | |||
) | [static] |
This function inserts a new dispatch offset into the assembly language stub that was generated with the preceeding function.
static const glprocs_table_t* find_entry | ( | const char * | n | ) | [static] |
Search the table of static entrypoint functions for the named function and return the corresponding glprocs_table_t entry.
static _glapi_proc generate_entrypoint | ( | GLuint | functionOffset | ) | [static] |
Generate a dispatch function (entrypoint) which jumps through the given slot number (offset) in the current dispatch table.
We need assembly language in order to accomplish this.
static _glapi_proc get_static_proc_address | ( | const char * | funcName | ) | [static] |
Return dispatch function address for the named static (built-in) function.
Return NULL if function not found.
static const char* get_static_proc_name | ( | GLuint | offset | ) | [static] |
Return the name of the function at the given offset in the dispatch table.
For debugging only.
static GLint get_static_proc_offset | ( | const char * | funcName | ) | [static] |
Return dispatch table offset of the named static (built-in) function.
Return -1 if function not found.
static char* str_dup | ( | const char * | str | ) | [static] |
strdup() is actually not a standard ANSI C or POSIX routine.
Irix will not define it if ANSI mode is in effect.
struct _glapi_function ExtEntryTable[MAX_EXTENSION_FUNCS] [static] |
GLuint NumExtEntryPoints = 0 [static] |