diff options
-rw-r--r-- | src/mesa/main/context.c | 52 | ||||
-rw-r--r-- | src/mesa/main/context.h | 15 | ||||
-rw-r--r-- | src/mesa/main/mtypes.h | 9 |
3 files changed, 65 insertions, 11 deletions
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 1707e229c91..87e5a88fad2 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -791,6 +791,7 @@ alloc_dispatch_table(void) * for debug flags. * * \param ctx the context to initialize + * \param api the GL API type to create the context for * \param visual describes the visual attributes for this context * \param share_list points to context to share textures, display lists, * etc with, or NULL @@ -799,11 +800,12 @@ alloc_dispatch_table(void) * \param driverContext pointer to driver-specific context data */ GLboolean -_mesa_initialize_context(GLcontext *ctx, - const GLvisual *visual, - GLcontext *share_list, - const struct dd_function_table *driverFunctions, - void *driverContext) +_mesa_initialize_context_for_api(GLcontext *ctx, + gl_api api, + const GLvisual *visual, + GLcontext *share_list, + const struct dd_function_table *driverFunctions, + void *driverContext) { struct gl_shared_state *shared; @@ -814,6 +816,7 @@ _mesa_initialize_context(GLcontext *ctx, /* misc one-time initializations */ one_time_init(ctx); + ctx->API = api; ctx->Visual = *visual; ctx->DrawBuffer = NULL; ctx->ReadBuffer = NULL; @@ -892,6 +895,20 @@ _mesa_initialize_context(GLcontext *ctx, return GL_TRUE; } +GLboolean +_mesa_initialize_context(GLcontext *ctx, + const GLvisual *visual, + GLcontext *share_list, + const struct dd_function_table *driverFunctions, + void *driverContext) +{ + return _mesa_initialize_context_for_api(ctx, + API_OPENGL, + visual, + share_list, + driverFunctions, + driverContext); +} /** * Allocate and initialize a GLcontext structure. @@ -899,6 +916,7 @@ _mesa_initialize_context(GLcontext *ctx, * we need to at least call driverFunctions->NewTextureObject to initialize * the rendering context. * + * \param api the GL API type to create the context for * \param visual a GLvisual pointer (we copy the struct contents) * \param share_list another context to share display lists with or NULL * \param driverFunctions points to the dd_function_table into which the @@ -908,10 +926,11 @@ _mesa_initialize_context(GLcontext *ctx, * \return pointer to a new __GLcontextRec or NULL if error. */ GLcontext * -_mesa_create_context(const GLvisual *visual, - GLcontext *share_list, - const struct dd_function_table *driverFunctions, - void *driverContext) +_mesa_create_context_for_api(gl_api api, + const GLvisual *visual, + GLcontext *share_list, + const struct dd_function_table *driverFunctions, + void *driverContext) { GLcontext *ctx; @@ -922,8 +941,8 @@ _mesa_create_context(const GLvisual *visual, if (!ctx) return NULL; - if (_mesa_initialize_context(ctx, visual, share_list, - driverFunctions, driverContext)) { + if (_mesa_initialize_context_for_api(ctx, api, visual, share_list, + driverFunctions, driverContext)) { return ctx; } else { @@ -932,6 +951,17 @@ _mesa_create_context(const GLvisual *visual, } } +GLcontext * +_mesa_create_context(const GLvisual *visual, + GLcontext *share_list, + const struct dd_function_table *driverFunctions, + void *driverContext) +{ + return _mesa_create_context_for_api(API_OPENGL, visual, + share_list, + driverFunctions, + driverContext); +} /** * Free the data associated with the given context. diff --git a/src/mesa/main/context.h b/src/mesa/main/context.h index 09bf1777dab..e9405c8bc27 100644 --- a/src/mesa/main/context.h +++ b/src/mesa/main/context.h @@ -112,6 +112,21 @@ _mesa_initialize_context( GLcontext *ctx, const struct dd_function_table *driverFunctions, void *driverContext ); +extern GLcontext * +_mesa_create_context_for_api(gl_api api, + const GLvisual *visual, + GLcontext *share_list, + const struct dd_function_table *driverFunctions, + void *driverContext); + +extern GLboolean +_mesa_initialize_context_for_api(GLcontext *ctx, + gl_api api, + const GLvisual *visual, + GLcontext *share_list, + const struct dd_function_table *driverFunctions, + void *driverContext); + extern void _mesa_initialize_context_extra(GLcontext *ctx); diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 349d5f51e66..e5e099acc3c 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -2869,6 +2869,14 @@ struct gl_dlist_state } Current; }; +/** + * Enum for the OpenGL APIs we know about and may support. + */ +typedef enum { + API_OPENGL, + API_OPENGLES, + API_OPENGLES2, +} gl_api; /** * Mesa rendering context. @@ -2887,6 +2895,7 @@ struct __GLcontextRec /** \name API function pointer tables */ /*@{*/ + gl_api API; struct _glapi_table *Save; /**< Display list save functions */ struct _glapi_table *Exec; /**< Execute functions */ struct _glapi_table *CurrentDispatch; /**< == Save or Exec !! */ |