}
-struct st_context *st_create_context(struct pipe_context *pipe,
+struct st_context *st_create_context(gl_api api, struct pipe_context *pipe,
const __GLcontextModes *visual,
struct st_context *share)
{
memset(&funcs, 0, sizeof(funcs));
st_init_driver_functions(&funcs);
-#if FEATURE_GL
- ctx = _mesa_create_context_for_api(API_OPENGL,
- visual, shareCtx, &funcs, NULL);
-#elif FEATURE_ES1
- ctx = _mesa_create_context_for_api(API_OPENGLES,
- visual, shareCtx, &funcs, NULL);
-#elif FEATURE_ES2
- ctx = _mesa_create_context_for_api(API_OPENGLES2,
- visual, shareCtx, &funcs, NULL);
-#endif
+ ctx = _mesa_create_context_for_api(api, visual, shareCtx, &funcs, NULL);
/* XXX: need a capability bit in gallium to query if the pipe
* driver prefers DP4 or MUL/MAD for vertex transformation.
#include "st_context.h"
#include "st_format.h"
#include "st_cb_fbo.h"
+#include "st_cb_flush.h"
#include "st_manager.h"
-/* these functions are defined in st_context.c */
-struct st_context *
-st_create_context(struct pipe_context *pipe,
- const __GLcontextModes *visual,
- struct st_context *share);
-void st_destroy_context(struct st_context *st);
-void st_flush(struct st_context *st, uint pipeFlushFlags,
- struct pipe_fence_handle **fence);
-
/**
* Cast wrapper to convert a GLframebuffer to an st_framebuffer.
* Return NULL if the GLframebuffer is a user-created framebuffer.
}
static struct st_context_iface *
-st_api_create_context(struct st_api *stapi, struct st_manager *smapi,
- const struct st_visual *visual,
- struct st_context_iface *shared_stctxi)
+create_context(gl_api api, struct st_manager *smapi,
+ const struct st_visual *visual,
+ struct st_context_iface *shared_stctxi)
{
struct st_context *shared_ctx = (struct st_context *) shared_stctxi;
struct st_context *st;
return NULL;
st_visual_to_context_mode(visual, &mode);
- st = st_create_context(pipe, &mode, shared_ctx);
+ st = st_create_context(api, pipe, &mode, shared_ctx);
if (!st) {
pipe->destroy(pipe);
return NULL;
return &st->iface;
}
+static struct st_context_iface *
+st_api_create_context(struct st_api *stapi, struct st_manager *smapi,
+ const struct st_visual *visual,
+ struct st_context_iface *shared_stctxi)
+{
+ return create_context(API_OPENGL, smapi, visual, shared_stctxi);
+}
+
+static struct st_context_iface *
+st_api_create_context_es1(struct st_api *stapi, struct st_manager *smapi,
+ const struct st_visual *visual,
+ struct st_context_iface *shared_stctxi)
+{
+ return create_context(API_OPENGLES, smapi, visual, shared_stctxi);
+}
+
+static struct st_context_iface *
+st_api_create_context_es2(struct st_api *stapi, struct st_manager *smapi,
+ const struct st_visual *visual,
+ struct st_context_iface *shared_stctxi)
+{
+ return create_context(API_OPENGLES2, smapi, visual, shared_stctxi);
+}
+
static boolean
st_api_make_current(struct st_api *stapi, struct st_context_iface *stctxi,
struct st_framebuffer_iface *stdrawi,
return TRUE;
}
-struct st_api st_gl_api = {
+static const struct st_api st_gl_api = {
st_api_destroy,
st_api_get_proc_address,
st_api_create_context,
st_api_get_current,
};
-/**
- * Return the st_api for this state tracker. This might either be GL, GLES1,
- * GLES2 that mostly depends on the build and link options. But these
- * functions remain the same either way.
- */
+static const struct st_api st_gl_api_es1 = {
+ st_api_destroy,
+ st_api_get_proc_address,
+ st_api_create_context_es1,
+ st_api_make_current,
+ st_api_get_current,
+};
+
+static const struct st_api st_gl_api_es2 = {
+ st_api_destroy,
+ st_api_get_proc_address,
+ st_api_create_context_es2,
+ st_api_make_current,
+ st_api_get_current,
+};
+
struct st_api *
st_gl_api_create(void)
{
- return &st_gl_api;
+ (void) st_gl_api;
+ (void) st_gl_api_es1;
+ (void) st_gl_api_es2;
+
+#if FEATURE_GL
+ return (struct st_api *) &st_gl_api;
+#else
+ return NULL;
+#endif
+}
+
+struct st_api *
+st_gl_api_create_es1(void)
+{
+#if FEATURE_ES1
+ return (struct st_api *) &st_gl_api_es1;
+#else
+ return NULL;
+#endif
+}
+
+struct st_api *
+st_gl_api_create_es2(void)
+{
+#if FEATURE_ES2
+ return (struct st_api *) &st_gl_api_es2;
+#else
+ return NULL;
+#endif
}