summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKristian Høgsberg <[email protected]>2010-04-22 09:25:51 -0400
committerKristian Høgsberg <[email protected]>2010-04-22 09:25:51 -0400
commit2ab18d63cb71d988265eeab431e4363081978144 (patch)
tree20a7af40ac207b3e9189a34a04e9f5534f33db19 /src
parentbd91f665a7c12f114619a4f6f1e00059e4f4cb5e (diff)
mesa: Track the OpenGL API we're implementing in the context
This introduces a new way to create or initialize a context: _mesa_create_context_for_api and _mesa_initialize_context_for_api which in addition to the current arguments take an api enum to indicate which OpenGL API the context should implement. At this point the API field in GLcontext isn't used anywhere, but later commits will key certain functionality off of it. The _mesa_create_context and _mesa_initialize_context functions are kept in place as wrappers around the *_for_api versions, passing in API_OPENGL to get the same behavior as before.
Diffstat (limited to 'src')
-rw-r--r--src/mesa/main/context.c52
-rw-r--r--src/mesa/main/context.h15
-rw-r--r--src/mesa/main/mtypes.h9
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 !! */